luebking / virtuality

Qt4/Qt5 widget style
GNU General Public License v2.0
20 stars 7 forks source link

No menus in some applications #30

Closed beojan closed 8 years ago

beojan commented 9 years ago

When using Virtuality, menus are hidden by default in some applications, such as KMail and QGis.

In the case of QGis, this means it is impossible to access the menu, as there is no way to reshow it.

EDIT: Small correction that was irritating me. Apologies if this sends out notifications.

luebking commented 9 years ago

Virtuality does not hide menubars (i assume that's what you meant), except for the presence of an XBar server. Given your former question: could experiments in this direction be related?

beojan commented 9 years ago

The missing menus are why I started implementing an XBar plasmoid for Plasma 5. I tried running the deactivate DBus methods manually (from QDBusViewer), and the menus do not reappear.

They are only missing from certain applications, and only with Virtuality (haven't tried Bespin for QGis, so it may have the same problem with Bespin).

luebking commented 9 years ago

If there's no xbar server present, accessing the client xbar methods won't help, since the menubar is not hidden for anything xbar related.

Which version of QGis is that exactly? Have you noticed it in any but the two applications?

beojan commented 9 years ago

hiding then showing the menu while using the Breeze theme seems to have fixed this in KMail, so it seems it is QGis only.

Perhaps a difference between the Qt4 and Qt5 versions?

luebking commented 9 years ago

Ie. it wasn't initially avaialble with breeze either? Did you try to hide/show with virtuality as well?

I assume what happens is that the application wrongly stored the menubar as hidden (for it has a zero height - I do not really hide it as that would break a couple of things) when you were using virtuality or breeze alongside an XBar server - and now doesn't recreate it.

You might want to inspect the QGIs config file (~/.config/somewhere/qgis.conf or similar) for a related key. Might be a base64 encoded binary structure of the window layout.

beojan commented 9 years ago

With virtuality, I had to "hide" (menu was already invisible) then show every time I started KMail.

With QGis, the menubar appears with other styles, then disappears when I use Virtuality (have to restart QGis to change the style), and I tried deleting the config files and starting QGis with a blank configuration.

luebking commented 9 years ago

This rather sounds as if the (two only?) clients would believe an XBar server would be available.

qdbus org.kde.XBar-pidof qgis /XBarClient deactivate

does not work?

beojan commented 9 years ago

No it doesn't.

However, neither does

qdbus org.kde.XBar-23662 /XBarClient org.kde.XBarClient.popup 23662 0 15 15
luebking commented 9 years ago

The menu isn't managed then - no idea why QGis hides the menu. Which version is it exactly (I need to install it and all its odd dependencies via AUR, so I'd like to pick your version ;-)

beojan commented 9 years ago

Default AUR qgis

beojan commented 8 years ago

There seems to have been no updates on this. QGis still has the issue, so is it possible to simply build virtuality without XBar support?

luebking commented 8 years ago

No, but given https://github.com/luebking/virtuality/issues/30#issuecomment-141786728 this isn't the cause anyway.

However, this shall disable it:

diff --git a/polish.cpp b/polish.cpp
index 5975951..71ecc14 100644
--- a/polish.cpp
+++ b/polish.cpp
@@ -842,8 +842,8 @@ Style::polish( QWidget * widget )
             mbar->setAutoFillBackground(true);
         }
 #ifndef QT_NO_DBUS
-        if ( appType != KDevelop ) //&& !(appType == QtDesigner && mbar->inherits("QDesignerMenuBar")) )
-            MacMenu::manage(mbar);
+//         if ( appType != KDevelop ) //&& !(appType == QtDesigner && mbar->inherits("QDesignerMenuBar")) )
+//             MacMenu::manage(mbar);
 #endif
     }
     else if (widget->inherits("KFadeWidgetEffect"))

Sorry, I let this drop off the table (and now, before the pleasure of installing qgis, need to upgrade to libc6 - yeah, but scheduled anyway. So I know what to do tomorrow...)

beojan commented 8 years ago

It looks like this is the cause because the above patch does bring the menubar back in QGis.

luebking commented 8 years ago

Let's see whether we can spare me the gloabal update ;-)

Try this as alternative

diff --git a/macmenu.cpp b/macmenu.cpp
index fd2b90a..038ad7d 100644
--- a/macmenu.cpp
+++ b/macmenu.cpp
@@ -155,7 +155,7 @@ MacMenu::activate(QMenuBar *menu)
     menu->removeEventFilter(this);

     // and WOWWWW - no more per window menubars...
-    menu->setFixedSize(1,0);
+    menu->setFixedSize(1,1);
     //NOTICE i used to set the menu's parent->layout()->setMenuBar(0) to get rid of the free space
     // but this leads to side effects (e.g. kcalc won't come up anymore...)
     // so now the stylehint for the free space below checks the menubar height and returns
@@ -462,9 +462,9 @@ MacMenu::eventFilter(QObject *o, QEvent *ev)
     {
     case QEvent::Resize:
 //         menu->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
-        if (menu->size() != QSize(1,0))
+        if (menu->size() != QSize(1,1))
         {
-            menu->setFixedSize(1,0);
+            menu->setFixedSize(1,1);
             menu->updateGeometry();
         }
         break;
beojan commented 8 years ago

Still no menu.

Also, it appears libc5 is almost 20 years old, so you should probably update to libc6 anyway.

luebking commented 8 years ago

Ok, this is only for inspection. Make it so that you'd expect to see the menubar (show it from another style or whatever) and check the output when running qgis from konsole:

diff --git a/macmenu.cpp b/macmenu.cpp index fd2b90a..555553f 100644 --- a/macmenu.cpp +++ b/macmenu.cpp @@ -94,6 +94,8 @@ MacMenu::manage(QMenuBar *menu) else if (instance->items.contains(menu)) return; // no double adds please!

@@ -257,6 +259,7 @@ MacMenu::deactivate(QMenuBar *menu) { menu->removeEventFilter(this); const bool wasShown = menu->isVisible();

isVisible should say true and wasShown should only occur when you close qgis (and ideally say "true" as well)

beojan commented 8 years ago
Warning: loading of qgis translation failed [/usr/share/qgis/i18n//qgis_en_GB]
Warning: loading of qt translation failed [/usr/share/qt4/translations/qt_en_GB]
Warning: QCss::Parser - Failed to load file  "/style.qss" 

And with Virtuality:

Warning: loading of qgis translation failed [/usr/share/qgis/i18n//qgis_en_GB]
Warning: loading of qt translation failed [/usr/share/qt4/translations/qt_en_GB]
Warning: QCss::Parser - Failed to load file  "/style.qss" 

Somehow, I doubt this will be useful.

luebking commented 8 years ago

I assume you removed the patch that blocks management?

In case it would fail on some other position, while I cannot imagine which query would fail but also cause the menu to end up being hidden

Alternatively, the debug output is redirected or filtered by the client ...

diff --git a/macmenu.cpp b/macmenu.cpp
index fd2b90a..cd53dff 100644
--- a/macmenu.cpp
+++ b/macmenu.cpp
@@ -73,14 +73,16 @@ MacMenu::MacMenu() : QObject()
 void
 MacMenu::manage(QMenuBar *menu)
 {
+    qDebug() << "manage 1" << menu;
     if (!menu) // ..
         return;

+    qDebug() << "manage 2";
     // we only accept menus that are placed on a QMainWindow - for the moment, and probably ever
     QWidget *dad = menu->parentWidget();
     if (!(dad && dad->isWindow() && dad->inherits("QMainWindow") && dad->layout() && dad->layout()->menuBar() == menu))
         return;
-
+    qDebug() << "manage 3";
 //     if ((dad = dad->parentWidget()) && dad->inherits("QMdiSubWindow"))
 //         return;

@@ -94,6 +96,7 @@ MacMenu::manage(QMenuBar *menu)
     else if (instance->items.contains(menu))
         return; // no double adds please!

+    qDebug() << "manage 4";
     if (instance->usingMacMenu)
         instance->activate(menu);
beojan commented 8 years ago

Yep, that's Virtuality with XBar support compiled in (and Breeze for the other screenshot).

On the other hand, I hadn't applied that debug patch, so of course there was no output.

luebking commented 8 years ago

Ah, it ended up as comment - sigh. Sorry. The first debug output is the most relevant. The second was just because the first seemed to have failed.

beojan commented 8 years ago

With XBar support on:

Warning: loading of qgis translation failed [/usr/share/qgis/i18n//qgis_en_GB]
Warning: loading of qt translation failed [/usr/share/qt4/translations/qt_en_GB]
manage 1 QMenuBar(0x11fcb60, name = "menubar") 
manage 2 
manage 3 
manage 4 
Is Visible?  QMenuBar(0x11fcb60, name = "menubar") false 
was shown  QMenuBar(0x11fcb60, name = "menubar") false 
manage 1 QMenuBar(0x11fcb60, name = "menubar") 
manage 2 
manage 3 
manage 4 
Is Visible?  QMenuBar(0x11fcb60, name = "menubar") false 
was shown  QMenuBar(0x11fcb60, name = "menubar") false 
Warning: QCss::Parser - Failed to load file  "/style.qss" 
was shown  QMenuBar(0x11fcb60, name = "menubar") false 
manage 1 QMenuBar(0x11fcb60, name = "menubar") 
manage 2 
manage 3 
manage 4 
Is Visible?  QMenuBar(0x11fcb60, name = "menubar") false 
manage 1 QMenuBar(0x11fcb60, name = "menubar") 
manage 2 
manage 3 
luebking commented 8 years ago

Apparently it's polished three times and never considered visible to begin with ...

Wild shot: it's probably polished before the window is mapped:

diff --git a/macmenu.cpp b/macmenu.cpp
index fd2b90a..5c951e1 100644
--- a/macmenu.cpp
+++ b/macmenu.cpp
@@ -256,7 +256,8 @@ void
 MacMenu::deactivate(QMenuBar *menu)
 {
     menu->removeEventFilter(this);
-    const bool wasShown = menu->isVisible();
+    const QWidget *dad = menu->parentWidget();
+    const bool wasShown = dad ? menu->isVisibleTo(dad) : menu->isVisible();
     menu->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
     if (QWidget *dad = menu->parentWidget())
     if (dad->layout())
beojan commented 8 years ago

That fixes it (although with QWidget* dad instead of const QWidget* dad):

`` Warning: loading of qgis translation failed [/usr/share/qgis/i18n//qgis_en_GB] Warning: loading of qt translation failed [/usr/share/qt4/translations/qt_en_GB] manage 1 QMenuBar(0x13c6390, name = "menubar") manage 2 manage 3 manage 4 Is Visible? QMenuBar(0x13c6390, name = "menubar") false was shown QMenuBar(0x13c6390, name = "menubar") true manage 1 QMenuBar(0x13c6390, name = "menubar") manage 2 manage 3 manage 4 Is Visible? QMenuBar(0x13c6390, name = "menubar") false was shown QMenuBar(0x13c6390, name = "menubar") true Warning: QCss::Parser - Failed to load file "/style.qss" was shown QMenuBar(0x13c6390, name = "menubar") true manage 1 QMenuBar(0x13c6390, name = "menubar") manage 2 manage 3 manage 4 Is Visible? QMenuBar(0x13c6390, name = "menubar") false manage 1 QMenuBar(0x13c6390, name = "menubar") manage 2 manage 3