luebking / qarma

Zenity Clone for Qt5/Qt6
GNU General Public License v2.0
94 stars 18 forks source link

No dialog titles in latest build #39

Open Hitmanfourtyseven opened 3 years ago

Hitmanfourtyseven commented 3 years ago

I recently updated to version 71-1 from the AUR, based on latest git version. The dialog titles in all window types not longer respect the --title option, and just shows "zenity". Thank you image

luebking commented 3 years ago

On what $QT_QPA_PLATFORMTHEME ? Setting the title is abysmally broken in Qt5, I worked around that, that wasn't stable enough so I tried to combat that in https://github.com/luebking/qarma/commit/8c364fc6aa03cfd014d18b3806475f9d7023e136 might might have made it worse on some platform plugins…

Hitmanfourtyseven commented 3 years ago

platformtheme and style_override are set to 'kvantum'. Got it, so it can work around some weird bugs in qt5 but it may or may not work. I want to try it however. Should this patch be included in my case?

Sounds awfully similar to the problems Kvantum has with porting to qt6, it kind of works but with weird instabilities.

luebking commented 3 years ago

You have that patch, you could try to revert it. Alternatively raise the timeout from 10ms to 100ms and/or try

diff --git a/Qarma.cpp b/Qarma.cpp
index ddf8592..14617f3 100644
--- a/Qarma.cpp
+++ b/Qarma.cpp
@@ -271,6 +271,7 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
         QWindow *w = new QWindow;
         w->setVisible(true);
         m_caption = w->title();
+        m_dialog->setWindowTitle(m_caption);
         delete w;
 #endif
         // close on ctrl+return in addition to ctrl+enter

to restore the initial setting (which didn't do anything here and also should™ not be necessary, but would be an easy mitigation to catch more QPAs)

luebking commented 3 years ago

Did you have a chance to test the behavior w/ the patch reverted and/or the alternative patch above?

misaki-web commented 2 years ago

I have the same problem (no title) with all builds (Linux, macOS and Windows) from the latest commit, so builds including the patches 8c364fc and 9170d5c. Here's what I tried:

luebking commented 2 years ago

Can you please try

diff --git a/Qarma.cpp b/Qarma.cpp
index d5c4a6c..4d3406b 100644
--- a/Qarma.cpp
+++ b/Qarma.cpp
@@ -180,7 +180,8 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
 , m_type(Invalid)
 {
     QStringList argList = QCoreApplication::arguments(); // arguments() is slow
-    m_zenity = argList.at(0).endsWith("zenity");
+    const QString binary = argList.at(0);
+    m_zenity = binary.endsWith("zenity");
     // make canonical list
     QStringList args;
     if (argList.at(0).endsWith("-askpass")) {
@@ -301,8 +302,8 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
             m_dialog->resize(sz);
         }
         m_dialog->setWindowModality(m_modal ? Qt::ApplicationModal : Qt::NonModal);
-        if (!m_caption.isNull()) {
-//            QMetaObject::invokeMethod(this, [=]() {m_dialog->setWindowTitle(m_caption);}, Qt::QueuedConnection);
+        if (!(m_caption.isNull() || binary.endsWith(m_caption))) {
+            QMetaObject::invokeMethod(this, [=]() {m_dialog->setWindowTitle(""); m_dialog->setWindowTitle(m_caption);}, Qt::QueuedConnection);
             /*
             Fuck! This! Shit!
             There's somehow a race condition and QWindow happily resets the window
@@ -314,7 +315,7 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
             (likely because Qt queues its title nukation efforts down the road)
             But hey, abstract and wayland and QML… FUCK! THIS! SHIT! *grrrrrrrr*
             */
-            QTimer::singleShot(10, this, [=]() {m_dialog->setWindowTitle(m_caption);});
+//            QTimer::singleShot(1, this, [=]() {m_dialog->setWindowTitle("gnarf"); m_dialog->setWindowTitle(m_caption);});
         }
         if (!m_icon.isNull())
             m_dialog->setWindowIcon(QIcon(m_icon));

I think I figured what's going on…

misaki-web commented 2 years ago

I checked out to the last commit 04875702, then applied your patch and built on Windows. The bug is still there. For example, the default qarma title appears instead of the custom one:

qarma.exe --title="Custom title" --forms --text="Form text" --add-entry="Entry text"                              

qarma-windows-no-title

If I remove the patches 8c364fc and 9170d5c, the title appears:

qarma-windows-title

luebking commented 2 years ago

Try "qarma.exe --title "Custom title"" (w/o the equality) - the title goes in on two different paths because Qt doesn't actually read --title=foo but only --title foo and I had kinda focused on that problem. But I can't rule out that windows behaves differently either.

As an additional problem (on X11), Qt doesn't set the title before the window is mapped, but "while" and that leads to an IPC race condition (the WM picks up the old, bad title but misses the event for the new one because it's happening while the client is being configured) which I must need to address…

luebking commented 2 years ago
diff --git a/Qarma.cpp b/Qarma.cpp
index d5c4a6c..fbf3a36 100644
--- a/Qarma.cpp
+++ b/Qarma.cpp
@@ -180,7 +180,8 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
 , m_type(Invalid)
 {
     QStringList argList = QCoreApplication::arguments(); // arguments() is slow
-    m_zenity = argList.at(0).endsWith("zenity");
+    const QString binary = argList.at(0);
+    m_zenity = binary.endsWith("zenity");
     // make canonical list
     QStringList args;
     if (argList.at(0).endsWith("-askpass")) {
@@ -272,9 +273,12 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
         // for some reason it's not set on the dialog.
         // since it's set on showing the first QWindow, we just create one here and copy the title
         // TODO: remove once this is fixed in Qt5
+        const bool qt5title = m_caption.isNull(); // otherwise we read it in the general options
         QWindow *w = new QWindow;
         w->setVisible(true);
-        m_caption = w->title();
+        if (qt5title)
+            m_caption = w->title();
+        m_dialog->setWindowTitle("");
         m_dialog->setWindowTitle(m_caption);
         delete w;
 #endif
@@ -301,8 +305,8 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
             m_dialog->resize(sz);
         }
         m_dialog->setWindowModality(m_modal ? Qt::ApplicationModal : Qt::NonModal);
-        if (!m_caption.isNull()) {
-//            QMetaObject::invokeMethod(this, [=]() {m_dialog->setWindowTitle(m_caption);}, Qt::QueuedConnection);
+        if (!(m_caption.isNull() || binary.endsWith(m_caption))) {
+//            QMetaObject::invokeMethod(this, [=]() {m_dialog->setWindowTitle(""); m_dialog->setWindowTitle(m_caption);}, Qt::QueuedConnection);
             /*
             Fuck! This! Shit!
             There's somehow a race condition and QWindow happily resets the window
@@ -314,7 +318,7 @@ Qarma::Qarma(int &argc, char **argv) : QApplication(argc, argv)
             (likely because Qt queues its title nukation efforts down the road)
             But hey, abstract and wayland and QML… FUCK! THIS! SHIT! *grrrrrrrr*
             */
-            QTimer::singleShot(10, this, [=]() {m_dialog->setWindowTitle(m_caption);});
+           QTimer::singleShot(10, this, [=]() {m_dialog->setWindowTitle(""); m_dialog->setWindowTitle(m_caption);});
         }
         if (!m_icon.isNull())
             m_dialog->setWindowIcon(QIcon(m_icon));

works "reliable" (timer based…) for me…