Branch: master

8814698e 2015-09-21 14:23:32 Timothy Pearson
Use notifier stack class in tdeui
M src/daemon/daemon.cpp
M src/daemon/daemon.h
diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp
index 1c582ab..957541e 100644
--- a/src/daemon/daemon.cpp
+++ b/src/daemon/daemon.cpp
@@ -35,6 +35,7 @@
 #include <tdeapplication.h>
 #include <kiconloader.h>
 #include <tdeglobalsettings.h>
+#include <tdepassivepopupstack.h>
 
 #include <stdlib.h>
 #include <errno.h>
@@ -43,76 +44,8 @@
 
 #include "daemon.h"
 
-NotifierContainer* GTKNotifierContainer = NULL;
+TDEPassivePopupStackContainer* GTKNotifierContainer = NULL;
 void real_handleGTKMain();
-
-NotifierContainer::NotifierContainer() : TQWidget() {
-	mPopupList.clear();
-
-	// Determine bottom of desktop
-	TQPoint cursorPos = TQCursor::pos();
-	TQRect r = TDEGlobalSettings::desktopGeometry(cursorPos);
-	mTopOfStack = r.height();
-	mRightOfStack = r.width();
-}
-
-NotifierContainer::~NotifierContainer() {
-}
-
-void NotifierContainer::handleGTKMain() {
-	real_handleGTKMain();
-}
-
-void NotifierContainer::displayMessage(TQString title, TQString message, TQString icon, int x, int y) {
-	TQPixmap px;
-	TDEIconLoader* il = TDEGlobal::iconLoader();
-	px = il->loadIcon( icon, TDEIcon::NoGroup );
-// 	if (px.isNull()) {
-// 		px = il->loadIcon( "gnome_apps", TDEIcon::NoGroup );
-// 	}
-
-	KPassivePopup *pop = new KPassivePopup( KPassivePopup::Boxed, this, "" );
-	pop->setAutoDelete( true );
-	pop->setView( title, message, icon );
-	pop->setTimeout( -1 );
-	TQPoint leftCorner( x, y);
-	if (leftCorner.isNull()) {
-		if (mPopupList.isEmpty()) {
-			// Determine bottom of desktop
-			TQPoint cursorPos = TQCursor::pos();
-			TQRect r = TDEGlobalSettings::desktopGeometry(cursorPos);
-			mTopOfStack = r.height();
-			mRightOfStack = r.width();
-		}
-		TQSize popupSize = pop->sizeHint();
-		mTopOfStack = mTopOfStack-popupSize.height();
-		if (mTopOfStack < 0) mTopOfStack = 0;
-		leftCorner.setX(mRightOfStack-popupSize.width());
-		leftCorner.setY(mTopOfStack);
-	}
-	connect(pop, SIGNAL(hidden(KPassivePopup*)), this, SLOT(popupClosed(KPassivePopup*)));
-	mPopupList.append(pop);
-	pop->show(leftCorner);
-
-	processEvents();
-}
-
-void NotifierContainer::processEvents() {
-	tqApp->processEvents();
-}
-
-void NotifierContainer::popupClosed(KPassivePopup* popup) {
-	// Remove the popup from our list of popups
-	mPopupList.remove(popup);
-
-	if (mPopupList.isEmpty()) {
-		// Determine bottom of desktop
-		TQPoint cursorPos = TQCursor::pos();
-		TQRect r = TDEGlobalSettings::desktopGeometry(cursorPos);
-		mTopOfStack = r.height();
-		mRightOfStack = r.width();
-	}
-}
 
 #undef signals
 
@@ -235,6 +168,7 @@
 	TQString messageText = TQString::fromLocal8Bit(body);
 
 	GTKNotifierContainer->displayMessage(messageCaption, messageText, TQString(icon), x, y);
+	GTKNotifierContainer->processEvents();
 
 	return_id = 0;
 
@@ -353,7 +287,7 @@
 	TDECmdLineArgs::init(argc, argv, &aboutData);
 
 	TDEApplication app;
-	NotifierContainer nc;
+	TDEPassivePopupStackContainer nc;
 	app.setMainWidget(&nc);
 	GTKNotifierContainer = &nc;
 	TQTimer *gtkEventProcessor = new TQTimer( &app );
diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h
index 092242d..8931293 100644
--- a/src/daemon/daemon.h
+++ b/src/daemon/daemon.h
@@ -22,31 +22,6 @@
 #ifndef NOTIFY_DAEMON_H
 #define NOTIFY_DAEMON_H
 
-#include <tqwidget.h>
-#include <kpassivepopup.h>
-
-class NotifierContainer : public TQWidget
-{
-	Q_OBJECT
-	
-
-public:
-	NotifierContainer();
-	~NotifierContainer();
-
-	void displayMessage(TQString title, TQString message, TQString icon, int x, int y);
-	void processEvents();
-
-public slots:
-	void handleGTKMain();
-	void popupClosed(KPassivePopup*);
-
-private:
-	TQPtrList<KPassivePopup> mPopupList;
-	long mTopOfStack;
-	long mRightOfStack;
-};
-
 #include <glib.h>
 #include <glib-object.h>