Closed probonopd closed 4 years ago
Ideally we could put a search box right into the menu bar and wire it up so that it works:
Right now, my panda-statusbar fork uses two different QMenu instances: One for the "System" menu (its contents are static and never change) and one for the foremost application's menus (its contents are coming from the application via D-Bus and change frequently).
For testing, I have attached an Action Search to the "System" QMenu in the actionsearch branch. Note that in the "System" menu, there is an item "About This Computer". When you type "about" into the Action Search window, then that command is correctly found.
Issue 1: When I select an item it segfaults though. Why?
Issue 2: Unfortunately I could not get it to work with the application's main menu (Datei, Aktionen, Bearbeiten...) yet. How can it be made work?
Issue 3: I added a "TODO: Action Search" search field to the menu bar itself (with red text). I would like that to become the search box for the Action Search. How can it be made work? In order to be able to enter text there, Qt::WindowDoesNotAcceptFocus
needs to be removed from mainwindow.cpp
. But then, simply clicking into the menu bar makes the application menus disappear, because then the menu rather than the application is the frontmost application. So we would need to keep the previous application's menus there when the user makes the menubar the frontmost window
Issue 4: Why are the colors in the "System" menu wrong?
Issue 5: How can I add the extra "System" menu to the existing m_menuBar
that contains the applications' menus? (https://github.com/pandaos/panda-statusbar/issues/9)
cc @antony-jr (Qt guru), @aoloe (Action Search guru), @rekols (panda-statusbar guru)
I am no Qt guru But anyways I will take a look.
Issue 5: How can I add the extra "System" menu to the existing m_menuBar that contains the applications' menus?
It's definitely possible. But the code base is pretty new for me. And the panel seems to work properly only in pandoOS(or FreeBSD?) so testing time is going to increase. (FYI: I tried to execute the panel in my computer, The panel is rendered weird. Dependency problem or does it execute like this in Linux?)
I will try out FreeBSD and test this in a live boot.
Thanks @antony-jr you can use this Live ISO if you like: https://github.com/helloSystem/ISO/releases/download/continuous-hello/FuryBSD-12.1-HELLO-amd64.iso. It has this it preinstalled. It should also build on Linux but may look broken currently (I am focusing on FreeBSD right now.)
And the panel seems to work properly only in pandoOS(or FreeBSD?) so testing time is going to increase. (FYI: I tried to execute the panel in my computer, The panel is rendered weird. Dependency problem or does it execute like this in Linux?)
It needs https://github.com/helloSystem/QtPlugin and export QT_QPA_PLATFORMTHEME=panda
to work properly.
I see. A virtual machine seems like a good fit than live boot.
EDIT : VM is really a bad idea with this type of OS. Requires at least 4 GB of RAM.
At least in theory it should work with, e.g.,:
sudo pacman -S cmake gcc extra-cmake-modules qt5-base qt5-tools qt5-svg qt5-x11extras kwindowsystem libxtst libxdamage libxcomposite libxrender libxcomposite libxcb xcb-util libdbusmenu-qt5 kdbusaddons libpulse libqtxdg
git clone https://github.com/helloSystem/QtPlugin
mkdir build
cd build
cmake ..
make
sudo make install
cd ../..
git clone https://github.com/helloSystem/Menu
cd Menu
git checkout actionsearch
mkdir build
cd build
cmake ..
make
sudo make install
cd ../..
export QT_QPA_PLATFORMTHEME=panda
# Now launch some Qt application
I will now test whether it works in practice, too. Sorry for the hassle @antony-jr
Actually I got it working somewhat. The theme is broken but it seems to work. But I don't see the action search option.
I had it commented out. Just pushed to the actionsearch
branch. Please checkout that branch and pull again. Then you should see it. Sorry for the hassle
Yes now I can reproduce your bugs.
Issue 1: When I select an item it segfaults though. Why?
@probonopd This line is causing the segfault. I have no idea why.
Also you should just use signals and slots instead of a lambda function. It can reduce code.
Specifically giving the window flag as Qt::Dialog
does this.
I also got the system menu to integrate with the existing menu bar without a new menu bar. But to integrate this you definitely need to cleanup action search stuff to work without the secondary menu bar.
EDIT: To fix the style issue in your menu, you should not have the menu bar as the parent. I guess transparent on QMenu just makes it ugly.
Wow! It is amazing what you got to work in so short a time. Tremendous :+1:
I am no Qt guru
You just proved that you are ;-)
But to integrate this you definitely need to cleanup action search stuff to work without the secondary menu bar.
To clarify, I would like the search to work with the all menus - the System menu and the applciation menus.
Here is a vague explanation on the system menu fix. I have no time to fork this and do a PR so here is a small guide.
src/appmenuwidget.h
//// In the class
private:
QMenu *m_systemMenu; // We store our static QMenu separately.
src/appmenuwidget.cpp
//// Remove all secondary menu bar stuff along with the menu creations.
//// After m_menuBar initialization.
/// ....
m_systemMenu = new QMenu("System");
//// Add all your static actions to the system menu object not the menu bar itself.
//// This is because the menu bar clears it self when a new application menus are
//// fetched.
QAction *aboutAction = m_systemMenu->addAction("About This Computer");
connect(aboutAction, SIGNAL(triggered()), this, SLOT(actionAbout()));
QAction *logoutAction = m_systemMenu->addAction("Log Out");
connect(logoutAction, SIGNAL(triggered()), this, SLOT(actionLogout()));
m_menuBar->addMenu(m_systemMenu);
Now in void AppMenuWidget::updateMenu()
///// This order should not change.
m_menuBar->clear();
m_menuBar->addMenu(m_systemMenu); /// Add whenever the menu updates.
NOTE: Make sure to delete the self managed m_systemMenu
object with deleteLater
, ex: m_systemMenu->deleteLater()
To clarify, I would like the search to work with the all menus - the System menu and the applciation menus.
@probonopd I actually mean that we need to put the action search properly in the main menu bar itself.
Are you really trying to build a new FreeBSD OS based on design aspects of your beloved old macs?
Thanks a ton @antony-jr. Could you do me a big favor and send me (e.g., mail if a PR doesn't work) what you have? I cannot seem to reproduce your fix for the segfault, maybe you have done additional changes.
Are you really trying to build a new FreeBSD OS based on design aspects of your beloved old macs?
You guessed it. https://github.com/helloSystem/hello describes it.
Thanks a ton @antony-jr. Could you do me a big favor and send me (e.g., mail if a PR doesn't work) what you have? I cannot seem to reproduce your fix for the segfault, maybe you have done additional changes.
If you really want that fix, I guess I can make a PR. I got some time left.
It seems that the setParent
was not the one which caused the segfault.
EDIT: Somehow the lambda function is causing the segfault. Specifically using the dialog object inside the lambda function does it. So I think I will use signals and slots.
If you really want that fix, I guess I can make a PR. I got some time left.
This would make me very happy indeed :+1:
The segfaults seems to stem from the ActionSearch's QHash object. Even calling the contains seem to crash the application.
If it helps for debugging, the Scribus AppImages have Action Search too, and there it is not crashing...
@probonopd Actually it was a simple pointer mistake. You created ActionSearch pointer in local context inside the constructor and then used it inside the lambda function, Since it was in local context it did not complain. When the GUI thread calls this lambda function. It does not know the pointer. Also you overwrote the class variable name with the local one in the constructor.
C++ is easy to learn but very hard to master. Changes are ready. I will send a PR soon.
For issue 1: https://github.com/helloSystem/Menu/pull/5
C++ is easy to learn but very hard to master.
Well said @antony-jr.
Actually it was a simple pointer mistake.
I wouldn't call it "simple". Pointers are about the hardest aspect of using Qt for me. Which is why I use PyQt whenever I can get away with it. Need to learn it properly.
For Issue 5, Issue 3, Issue 2: https://github.com/helloSystem/Menu/pull/6
However I did only for you to test out. Not intended for production use since I have no idea what you are aiming for and the code base really needs a cleanup.
EDIT: CC: @probonopd
If a window without global menus is foremost, then the Menu bar, when clicked into, shows menu items of already-gone last application
EDIT: I think this might be a different bug but the same thing happens with the Action Search. The one I'm talking about is with the Action Search.
@probonopd This is a bug introduced by me. Needs some work. The bug is in src/appmenu/dbusmenuimporter*
. The previous version did not have this but it had a major UX flaw. The items inside each menu would not update until the user goes and clicks every menu, So to avoid this I did some workaround in the DBusMenuImporter, Now it does this weird thing. I know how to fix this I will do it when I have time.
Thank you for your great work @antony-jr
Add Action Search from https://github.com/aoloe/scribus-plugin-actionSearch to make the global menu searchable for all applications that can work with the global menu.
Similar to this:
And this:
https://youtu.be/9lGVy6GRbOc?t=140