Closed probonopd closed 3 years ago
That would be a way to do it. But since we are not calling Qt functions directly as far as i read we can just use C++ signals in main like:
//call the update menu function when we get a signal
void SignalHandler(int sig){
std::cout << "Signal called, update the menu";
window->m_mainPanel->m_appMenuWidget->updateMenu();
}
//set up a signal for SIGUSR1
signal(SIGUSR1, SignalHandler);
Wich is a lot simpler than having to set up something to handle a singal then having to emit a Qt signal that eventually does something.
Just tested it, seems to work, if it's still actual feel free to assign it to me. What would be the use-case for this? (for validation and testing)
Thanks @PreyK, a pull requiest would be highly appreciated. :+1: It would allow us to do something more elegant (send SIGUSR1 rather than killing and then restarting the menu), e.g., here:
Test case:
sudo pkg install -y xvier
desktop2app /usr/local/share/applications/xvier.desktop /Applications
(this places a wrapper Xvier.app
into /Applications
and then restarts the menu so that the newly placed application shows up thereStretch goal: Remove the need for SIGUSR1 as well, https://github.com/helloSystem/Menu/issues/15. But even changing from what we have now to using SIGUSR1 would already be a welcome improvement.
@probonopd Sounds great! Just opened a PR for the update on SIGUSR1. Turns out https://github.com/helloSystem/Menu/blob/aaf84275a9eb1c3aed494bc30b8665b2afe9440c/src/appmenuwidget.cpp#L191 Doesn't update the menu so I ended up just reinitializing the system menu widget. New applications on SIGUSR1 now gets populated in the menu bar.
I'll look into https://github.com/helloSystem/Menu/issues/15 next as it should be easier now.
I'll look into #15 next as it should be easier now.
Basically we "just" need to find a way to call window->m_mainPanel->rebuildSystemMenu();
from within
How to do that?
Essentially yes. Since we are Qt widgets (and app menu lives in the main panel) we can just do
qobject_cast<MainPanel*>(parent())->rebuildSystemMenu();
Just opened a PR for this https://github.com/helloSystem/Menu/pull/54 , it now detects new apps automatically https://youtu.be/dcmdzED3mIA I left in SIGUSR1 too, It doesn't needed anymore for this but I guess it's useful for development to have a way to rebuild the menu whenever we want to.
Awesome! Works exactly as intendeed. Thank you so much!
Great! Glad I could help :D
Update the System menu when SIGUSR1 is received. Especially the applications.
How?