KDE/kdebase/workspace/krunner/interfaces/default

Aaron J. Seigo aseigo at kde.org
Mon Jul 20 20:39:32 CEST 2009


SVN commit 1000046 by aseigo:

* show the dialog at the 1/3rd pos vertically rather than centered; feels more natural
* preserve the user set location of the window during a session per-screen (would be nice to save and load to keep this between sessions)
* when a screen changes, recalc the location of the window (would be nice to preserve the location if it still fits in the screen, perhaps)
* get rid of tabs while were in here *growl*

if this works for people with multi-screen and other configurations, this should be backported (the would-be-nice-to-haves can appear in 4.4, though; no big rush there imho)

CCMAIL:plasma-devel at kde.org


 M  +38 -8     interface.cpp  
 M  +6 -0      interface.h  


--- trunk/KDE/kdebase/workspace/krunner/interfaces/default/interface.cpp #1000045:1000046
@@ -50,8 +50,6 @@
 #include <Plasma/Theme>
 #include <Plasma/Svg>
 
-#include <kephal/screens.h>
-
 #include "krunnersettings.h"
 #include "interfaces/default/resultscene.h"
 #include "interfaces/default/resultitem.h"
@@ -64,7 +62,8 @@
     : KRunnerDialog(runnerManager, parent),
       m_delayedRun(false),
       m_running(false),
-      m_queryRunning(false)
+      m_queryRunning(false),
+      m_oldScreen(-1)
 {
     m_hideResultsTimer.setSingleShot(true);
     connect(&m_hideResultsTimer, SIGNAL(timeout()), this, SLOT(hideResultsArea()));
@@ -223,6 +222,12 @@
 
     m_defaultSize = size();
 
+    connect(Kephal::Screens::self(), SIGNAL(screenRemoved(int)),
+            this, SLOT(screenRemoved(int)));
+    connect(Kephal::Screens::self(), SIGNAL(screenResized(Kephal::Screen*,QSize,QSize)),
+            this, SLOT(screenChanged(Kephal::Screen*)));
+    connect(Kephal::Screens::self(), SIGNAL(screenMoved(Kephal::Screen*,QPoint,QPoint)),
+            this, SLOT(screenChanged(Kephal::Screen*)));
     centerOnScreen();
     m_resultsContainer->hide();
 
@@ -231,15 +236,14 @@
 
 void Interface::resizeEvent(QResizeEvent *event)
 {
-
     // We set m_defaultSize only when the event is spontaneous, i.e. when the user resizes the window
     // We always update the width, but we update the height only if the resultsContainer is visible.
 
     if (event->spontaneous()) {
         m_defaultSize.setWidth(width());
-	if (m_resultsContainer->isVisible()) {
-	    m_defaultSize.setHeight(height());
-	}
+        if (m_resultsContainer->isVisible()) {
+            m_defaultSize.setHeight(height());
+        }
     }
 
     Plasma::Theme *theme = Plasma::Theme::defaultTheme();
@@ -321,6 +325,19 @@
     }
 }
 
+void Interface::screenRemoved(int screen)
+{
+    m_screenPos.remove(screen);
+}
+
+void Interface::screenChanged(Kephal::Screen* screen)
+{
+    m_screenPos.remove(screen->id());
+    if (m_oldScreen == screen->id()) {
+        m_oldScreen = -1;
+    }
+}
+
 void Interface::centerOnScreen()
 {
     int screen = Kephal::ScreenUtils::primaryScreenId();
@@ -328,11 +345,24 @@
         screen = Kephal::ScreenUtils::screenId(QCursor::pos());
     }
 
+    if (m_oldScreen == screen) {
+        return;
+    }
+
+    m_screenPos[m_oldScreen] = pos();
+    m_oldScreen = screen;
+
+    if (m_screenPos.contains(screen)) {
+        move(m_screenPos[screen]);
+        return;
+    }
+
     QRect r = Kephal::ScreenUtils::screenGeometry(screen);
     int w = m_defaultSize.width();
     int h = m_defaultSize.height();
     move(r.left() + (r.width() / 2) - (w / 2),
-         r.top() + (r.height() / 2) - (h / 2));
+         r.top() + (r.height() / 3));
+    m_screenPos[screen] = pos();
 }
 
 void Interface::setWidgetPalettes()
--- trunk/KDE/kdebase/workspace/krunner/interfaces/default/interface.h #1000045:1000046
@@ -24,6 +24,8 @@
 #include <QMultiMap>
 #include <QTimer>
 
+#include <kephal/screens.h>
+
 // local includes
 #include "krunnerdialog.h"
 
@@ -73,6 +75,8 @@
         void resetInterface();
         void showHelp();
         void ensureVisibility(QGraphicsItem *item);
+        void screenRemoved(int screen);
+        void screenChanged(Kephal::Screen* screen);
 
     private:
         void centerOnScreen();
@@ -99,6 +103,8 @@
         bool m_running;
         bool m_queryRunning;
         QSize m_defaultSize;
+        int m_oldScreen;
+        QHash<int, QPoint> m_screenPos;
 };
 
 #endif


More information about the Plasma-devel mailing list