-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client systray support #565
Conversation
17ae950
to
bdb2b82
Compare
To @gerboland's comments in #564, I wonder if the main event loop I added is indeed unnecessary. My question is if we can use a local |
bdb2b82
to
aabc29b
Compare
src/client/main.cpp
Outdated
@@ -48,7 +48,7 @@ std::string get_server_address() | |||
|
|||
int main(int argc, char* argv[]) | |||
{ | |||
QCoreApplication app(argc, argv); | |||
QApplication app(argc, argv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, can you check if the command line runs when no display server is running (i.e. "DISPLAY=")
QApplication subclasses QGuiApplication, which loads Qt platform backends for various graphical shells. Those are needed for the systray icon ofc, but for a pure command-line util, I'm unsure if it'll run or just bail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't:( Offhand, do you if there is some way to load the platfrom backends after the fact, like when only the systray command runs? I'll do some research, but hoping you have a quick answer:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backends load on Q{Gui,}Application construction.
One workaround might be to read the CLI very early looking for systray:
if (!argv_has_systray())
setenv("QT_QPA_PLATFORM", "minimal");
QApplication app(argc, argv);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That did the trick. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to have a separate command altogether then? Just a separate main instead of the if?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ricab,
I want to use the same binary, ie, multipass
for the cli, systray icon, and the down-the-road full blown gui, so I think the simple if
will do the trick.
a096ae9
to
3617b87
Compare
BTW, the design of this is based closely on https://github.com/CanonicalLtd/multipass-design#status-menu with added changes as I saw necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detail: systray missing autocompletion
OK, so I finally managed to build the snap and launch multipass from it... but crash again :/
|
OK, the issue seems to be a missing "xinerama" library. Here is the output from Qt itself with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Ubuntu:
When there's no instances, there's a stray blank section:
It seems to disappear during the transition when the menu is closed. Maybe it's the separator?
I wouldn't put the instance status verbatim in the menu:
If there's no way to add the status like designed (right-aligned and greyed out), maybe we could add some Unicode trickery. We may need to go platform-dependent on this? Doesn't have to be this PR of course.
|
||
void mcp::open_multipass_shell(const QString& instance_name) | ||
{ | ||
QProcess::startDetached("xterm", {"-e", "multipass", "shell", instance_name}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no way to detect whether the command being run in xterm
failed (in case the shell
command failed for some reason), in which case there's zero feedback… Maybe add || read
to the command being run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I had planned on giving extra feedback when the terminal cannot be started for whatever reason. Ideally, I'd like it to pop up a window with the failure and reason, but for a short term solution, your idea will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid windows whenever possible to keep the experience coherent. Multipass is anchored in command line usage so it shouldn't be surprising that we don't have many dialogs and windows. Those are always focus hogs.
Right, I have plans to fix that. I do think we should be consistent with the output of
Yeah, I'm sure it's the separator and I missed that. Will fix.
I think this is going to be real tricky. I spent some time trying to make it work like the design with no luck. I may end up having to subclass QMenu and try some things in that in forcing Qt to display it how we want to. |
Ack, will add that to the autocompletions.
I think once we switch the snap to use |
|
Would it be better to display something like "No instances" or "No instances defined" or something when there are no instances? When it just has 'About' and 'Quit' there, it kind of looks like it's missing something. |
@townsend2010 there ultimately will be a Launch, won't there? And the whole pet story… |
I'm not under the impression that Launch will be part of the systray drop down menu. I don't see that in the design of the systray icon either. I do think Launch would be part of the main UI though. Regarding the pet story, the only thing we would add is a specific action with a hotkey attached to it for opening the shell. |
@townsend2010 right, but that means there will always be an item above About - and there will never be "No instances" in that sense. |
Some things that I noticed (but could belong in polishing PRs):
|
What desktop environment is this? I don't think we can influence how they deal with this (unless in fact we're deleting the whole menu and recreating it). |
Regarding:
This says:
I noticed it is mentioned here and from some quick googling I got the impression it is relevant for security concerns. |
@Saviq Unity on 16.04 here. Do you see something else? |
@Saviq other similar menus update continuously here (e.g. system monitor) |
Thanks for the feedback. In general, there is much work to be done on this:) But to reply to your feedback:
Yes, there is absolutely no polling or event handling when the menu has been opened. Currently, the only way to refresh the states is to close the menu and then reopen it. Polling will be implemented first and then eventually some event driven model.
Right, this will be fixed. But what you are seeing is the static menu from the last query, ie, the last time you opened the menu, and then once the client receives the list info from the daemon, it clears the menu and then creates a new one based on what it received. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much cleaner, I like this. I've a couple of small comments inline.
Nitpick: there's many files in src/client/cmd that are getting solely formatting changes, making the diff a lot bigger than it needs to be. Has clang-format changed its mind about some things?
Thanks for the review. Glad you like this iteration better. Now that I put in the hard work, I think it's better too:)
Yes, silly |
a59c2a4
to
8d11394
Compare
d7229a6
to
4bfb15f
Compare
ef8afaf
to
5883ff6
Compare
- Use status enum instead of strings for status comparisons. - Remove "Retrieving instances" message which makes "About" happy when there are no instances. - Fix clang copy elision error.
5883ff6
to
c35516f
Compare
"About" issue fixed. New issue: when VM in "Stopped" state, I am shown useless "Open Shell" option. I cannot restart VM from the UI. |
It shouldn't be useless, it should start the instance when invoked.
It would be better to replace with Start, when stopped, indeed. |
Maybe so, but that's not obvious from the UI. |
Regarding Maybe if the instance is |
I like that, it tells you what it will do. |
A bit verbose, but OK… |
I agree, but not sure what else to do since having an active action is not enough to signal to the user they can do something. |
In a well-designed UI, isn't it? ;) |
Not sure what you mean? I thought it was clear that if the But @gerboland disagrees and he's a UI guy, so not sure what else to do except say |
In this case, I think I'd go with I understand it may feel unclear at first, because |
I just went to check the design for this. Why not use "Connect" as described there? |
Because the "Connect" verbiage has been deprecated in favor of "Shell" like in the CLI and the design doc was never updated...at least that is how I took it when we switched the CLI from using |
@townsend2010 Ah ok, fair enough. I have the feeling you had said so already? Sorry if that was the case, I did not memorize that history bit. |
@ricab, I don't think I mentioned that already:) Just getting you up to speed and also leaving it open a bit that "Connect" in the GUI is still what is wanted. Things change and move yet docs aren't updates, so I'm not always sure:) |
5d62e92
to
7ef094d
Compare
CPack doesn't handle hyphens in the target name well
7ef094d
to
ccea4d9
Compare
Overall I'm ok with this, and we can apply any polish in later PRs |
565: Client systray support r=gerboland a=townsend2010 Add a client systray icon and menu. This allows: - Getting a list of all instances and state. - The ability to open a shell to an instance. - Stopping an instance. - Getting version information. - Displaying when an update to Multipass is available. Co-authored-by: Chris Townsend <[email protected]>
Build failed |
Add a client systray icon and menu. This allows: