[rkward] rkward/windows: Hide/show status popup with preview

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Jan 14 19:31:28 UTC 2016


Git commit 3dbc2a264eced3e2967f224db7e1d02c3c181387 by Thomas Friedrichsmeier.
Committed on 14/01/2016 at 19:31.
Pushed by tfry into branch 'master'.

Hide/show status popup with preview

M  +15   -1    rkward/windows/rkmdiwindow.cpp
M  +5    -2    rkward/windows/rkmdiwindow.h

http://commits.kde.org/rkward/3dbc2a264eced3e2967f224db7e1d02c3c181387

diff --git a/rkward/windows/rkmdiwindow.cpp b/rkward/windows/rkmdiwindow.cpp
index 17be69c..f287c15 100644
--- a/rkward/windows/rkmdiwindow.cpp
+++ b/rkward/windows/rkmdiwindow.cpp
@@ -327,7 +327,6 @@ void RKMDIWindow::setStatusMessage (const QString& message, RCommand *command) {
 
 	if (!status_popup) {
 		status_popup = new KPassivePopup (this);
-		status_popup->setTimeout (0);
 		disconnect (status_popup, SIGNAL (clicked()), status_popup, SLOT (hide()));   // no auto-hiding, please
 	}
 
@@ -335,8 +334,10 @@ void RKMDIWindow::setStatusMessage (const QString& message, RCommand *command) {
 	if (!message.isEmpty ()) {
 		status_popup->setView (QString (), message);
 		status_popup->show (this->mapToGlobal (QPoint (20, 20)));
+		status_popup->setTimeout (0);
 	} else {
 		status_popup->hide ();
+		status_popup->setTimeout (10);  // this is a lame way to keep track of whether the popup is empty. See showEvent()
 	}
 }
 
@@ -346,6 +347,19 @@ void RKMDIWindow::clearStatusMessage () {
 	setStatusMessage (QString ());
 }
 
+void RKMDIWindow::hideEvent (QHideEvent* ev) {
+	if (status_popup) {
+		status_popup->hide ();
+	}
+	QWidget::hideEvent (ev);
+}
+
+void RKMDIWindow::showEvent (QShowEvent* ev) {
+	if (status_popup && (status_popup->timeout () == 0)) status_popup->show (this->mapToGlobal (QPoint (20, 20)));
+	QWidget::showEvent (ev);
+}
+
+
 void RKMDIWindow::setWindowStyleHint (const QString& hint) {
 	RK_TRACE (APP);
 
diff --git a/rkward/windows/rkmdiwindow.h b/rkward/windows/rkmdiwindow.h
index dfa2d4f..9d0414f 100644
--- a/rkward/windows/rkmdiwindow.h
+++ b/rkward/windows/rkmdiwindow.h
@@ -139,6 +139,11 @@ protected:
 	void enterEvent (QEvent *event);
 /** @see globalContextProperty() */
 	void setGlobalContextProperty (const QString& property, const QString& value) { global_context_properties.insert (property, value); };
+
+	KPassivePopup* status_popup;
+	void hideEvent (QHideEvent *ev);
+	void showEvent (QShowEvent *ev);
+
 friend class RKWorkplace;
 /** type of this window */
 	int type;
@@ -158,8 +163,6 @@ friend class RKToolWindowBar;
 	QString generic_window_name;
 	QString help_url;
 	RKSettings::SettingsPage settings_page;
-
-	KPassivePopup* status_popup;
 };
 
 #endif



More information about the rkward-tracker mailing list