[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Window modality, (was: Re: KDirWatch bug and the analysis. Help is =?iso-8859-1?Q?welcome!)?=
From:       Thomas_Lübking <thomas.luebking () gmail ! com>
Date:       2013-08-01 15:51:49
Message-ID: 4c0bccf6-cf53-4051-a79a-b69cdedde081 () gmail ! com
[Download RAW message or body]

This is a multipart/mixed message in MIME format.



      *** Please keep me CC, thanks ***


On Donnerstag, 1. August 2013 16:05:01 CEST, Frank Reininghaus wrote:
> Hi,
> 
> 2013/8/1 Thomas Lübking:
> > On Donnerstag, 1. August 2013 13:24:19 CEST, Frank Reininghaus wrote: ...

> http://quickgit.kde.org/?p=kde-baseapps.git&a=commit&h=fff7573ebb910712ad97951bf1762e6a7bb0bdc7
> 

Thanks. Seems mostly crashing, window modality and status message assignment.

> OK, thanks for the hint! Not all modal dialogs come from Dolphin
> itself though (example: KIO's "File exists already" dialog), so one
> would have to make sure that these external dialogs use
> Qt::WindowModal too.
> ...
> Well, if it can be done without regressions (except for the "one
> window crashes all" issue), then I wouldn't mind. It would reduce the
> memory usage and the startup time, after all.

Depends on how "ugly" your willing to let it get. See attached patch.

It "fixes" all modality to be window modal - if you ever need a truely application \
modal dialog etc., you'd have to exlude that (or whitelist widget types to become \
window modal) - eg. by adding a dynamic property or reimplementing its showEvent()

The statusbar assumption (ie. probably some signal/slot binding) should be cleanly \
implementable.

Cheers,
Thomas


["0001-fix-window-modality.patch" (text/x-patch)]

From 33015db960dcf53cd25ee4054d71e36b7a2e2daa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas Lübking?= <thomas.luebking@gmail.com>
Date: Thu, 1 Aug 2013 17:21:33 +0200
Subject: [PATCH] fix window modality

---
 dolphin/src/dolphinmainwindow.cpp | 29 +++++++++++++++++++++++++++++
 dolphin/src/dolphinmainwindow.h   |  6 ++++++
 2 files changed, 35 insertions(+)

diff --git a/dolphin/src/dolphinmainwindow.cpp b/dolphin/src/dolphinmainwindow.cpp
index 9454c8c..11dbff3 100644
--- a/dolphin/src/dolphinmainwindow.cpp
+++ b/dolphin/src/dolphinmainwindow.cpp
@@ -79,6 +79,7 @@
 #include <KUrlComboBox>
 #include <KToolInvocation>

+#include <QChildEvent>
 #include <QDesktopWidget>
 #include <QDBusMessage>
 #include <QKeyEvent>
@@ -630,6 +631,34 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
     KXmlGuiWindow::closeEvent(event);
 }

+bool DolphinMainWindow::eventFilter(QObject *o, QEvent *e)
+{
+    if (e->type() == QEvent::Show) {
+        QWidget *w = qobject_cast<QWidget*>(o);
+        if (w && w->isWindow() && w->isModal()) {
+            w->setWindowModality(Qt::WindowModal);
+        }
+        o->removeEventFilter(this); // hopefully no longer needed
+    }
+    return false;
+}
+
+void DolphinMainWindow::childEvent(QChildEvent* event)
+{
+    if (event->type() == QEvent::ChildAdded && event->child()->isWidgetType()) {
+        QWidget *w = static_cast<QWidget*>(event->child());
+        if (w->isWindow()) {
+            if (w->isModal()) {
+                w->setWindowModality(Qt::WindowModal);
+            } else { // reg. case, esp. for KIO
+                w->removeEventFilter(this); // prevent double installation
+                w->installEventFilter(this); // fix modality on show
+            }
+        }
+    }
+    KXmlGuiWindow::childEvent(event);
+}
+
 void DolphinMainWindow::saveProperties(KConfigGroup& group)
 {
     const int tabCount = m_viewTab.count();
diff --git a/dolphin/src/dolphinmainwindow.h b/dolphin/src/dolphinmainwindow.h
index 7da5801..9f46027 100644
--- a/dolphin/src/dolphinmainwindow.h
+++ b/dolphin/src/dolphinmainwindow.h
@@ -163,6 +163,12 @@ protected:
     /** @see QMainWindow::closeEvent() */
     virtual void closeEvent(QCloseEvent* event);

+    /** @see QWidget::childEvent() */
+    virtual void childEvent(QChildEvent* event);
+
+    /** @see QWidget::eventFilter() */
+    bool eventFilter(QObject *o, QEvent *e);
+
     /** @see KMainWindow::saveProperties() */
     virtual void saveProperties(KConfigGroup& group);

--
1.8.3.1



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic