r14743 by jghali - #8821 : style editor/manger creeps offscreen Replace ScrPaletteBase::show() implementation by a showEvent() implementation. QWidget::show() is an inline method and consequently won't allow our implementation to be called when show() is called by Qt internally

scribus-commit scribus-commit at lists.scribus.net
Tue Feb 16 23:00:38 CET 2010


Revision: 14743
Author: jghali
Date: 2010-02-16T21:57:48.618227Z
Commit message: #8821 : style editor/manger creeps offscreen
Replace ScrPaletteBase::show() implementation by a showEvent() implementation. QWidget::show() is an inline method and consequently won't allow our implementation to be called when show() is called by Qt internally 

Changeset: 
M  /trunk/Scribus/scribus/ui/scrpalettebase.cpp
M  /trunk/Scribus/scribus/ui/scrpalettebase.h

Diffs:
Index: scribus/ui/scrpalettebase.cpp
===================================================================
--- scribus/ui/scrpalettebase.cpp	(revision 14742)
+++ scribus/ui/scrpalettebase.cpp	(revision 14743)
@@ -163,9 +163,12 @@
 	storeSize();
 }
 
-void ScrPaletteBase::show()
+void ScrPaletteBase::showEvent(QShowEvent *showEvent)
 {
-	if (palettePrefs)
+	// According to Qt doc, non-spontaneous show events are sent to widgets
+	// immediately before they are shown. We want to restore geometry for those
+	// events as spontaneous events are delivered after dialog has been shown
+	if (palettePrefs && !showEvent->spontaneous())
 	{
 		QDesktopWidget *d = QApplication::desktop();
 		QSize gStrut = QApplication::globalStrut();
@@ -209,7 +212,7 @@
 		}
 		storeVisibility(true);
 	}
-	QDialog::show();
+	QDialog::showEvent(showEvent);
 }
 
 void ScrPaletteBase::hide()
Index: scribus/ui/scrpalettebase.h
===================================================================
--- scribus/ui/scrpalettebase.h	(revision 14742)
+++ scribus/ui/scrpalettebase.h	(revision 14743)
@@ -30,6 +30,7 @@
 #include <QDialog>
 #include <QHideEvent>
 #include <QKeySequence>
+#include <QShowEvent>
 
 #include "scribusapi.h"
 class PrefsContext;
@@ -43,11 +44,6 @@
 		~ScrPaletteBase() {};
 		/** @brief Sample way to grab keystrokes, simply calls superclass at this point */
 		//virtual void keyPressEvent(QKeyEvent *keyEvent);
-		/** @brief Captures the close event and changes it to hide */
-		virtual void closeEvent(QCloseEvent *closeEvent);
-		/** @brief Stores the geometry of the window when hiding. */
-		void hideEvent(QHideEvent*);
-		virtual void show();
 		virtual void hide();
 		void startup();
 		
@@ -67,6 +63,13 @@
 		void storePosition(int newX, int newY);
 		void storeSize();
 		void storeVisibility(bool);
+
+		/** @brief Restore the geometry of the window when showing it. */
+		virtual void showEvent(QShowEvent *showEvent);
+		/** @brief Captures the close event and changes it to hide */
+		virtual void closeEvent(QCloseEvent *closeEvent);
+		/** @brief Stores the geometry of the window when hiding. */
+		virtual void hideEvent(QHideEvent*);
 		
 		PrefsContext* palettePrefs;
 		QString prefsContextName;




More information about the scribus-commit mailing list