summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-09-21 14:45:49 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-09-21 14:46:18 -0500
commit7fc4b62912ca770bf1018fb6deeccc5cf98d9600 (patch)
treec50fe7e5fd25bda185552f319aea0f74c974c3af
parent9cca766255e3c41c33470bb718e39f408d65367e (diff)
downloadtdelibs-7fc4b62912ca770bf1018fb6deeccc5cf98d9600.tar.gz
tdelibs-7fc4b62912ca770bf1018fb6deeccc5cf98d9600.zip
Extend TDEPassivePopupStackContainer to include an optional user-provided ID per popup
Add display method with icon pixmap as parameter
-rw-r--r--tdeui/tdepassivepopupstack.cpp43
-rw-r--r--tdeui/tdepassivepopupstack.h9
2 files changed, 38 insertions, 14 deletions
diff --git a/tdeui/tdepassivepopupstack.cpp b/tdeui/tdepassivepopupstack.cpp
index 42de3c053..9f116059f 100644
--- a/tdeui/tdepassivepopupstack.cpp
+++ b/tdeui/tdepassivepopupstack.cpp
@@ -32,15 +32,19 @@ TDEPassivePopupStackContainer::~TDEPassivePopupStackContainer() {
//
}
-KPassivePopup* TDEPassivePopupStackContainer::displayMessage(TQString title, TQString message, TQString icon, int x, int y) {
+KPassivePopup* TDEPassivePopupStackContainer::displayMessage(TQString title, TQString message, TQString icon, int x, int y, TQString id) {
TQPixmap px;
TDEIconLoader* il = TDEGlobal::iconLoader();
px = il->loadIcon(icon, TDEIcon::NoGroup);
- KPassivePopup *pop = new KPassivePopup(KPassivePopup::Boxed, this, "");
- pop->setAutoDelete(true);
- pop->setView(title, message, icon);
- pop->setTimeout(-1);
+ return displayMessage(title, message, px, x, y, id);
+}
+
+KPassivePopup* TDEPassivePopupStackContainer::displayMessage(TQString title, TQString message, TQPixmap icon, int x, int y, TQString id) {
+ KPassivePopup *popup = new KPassivePopup(KPassivePopup::Boxed, this, "");
+ popup->setAutoDelete(true);
+ popup->setView(title, message, icon);
+ popup->setTimeout(-1);
TQPoint leftCorner(x, y);
if (leftCorner.isNull()) {
if (mPopupList.isEmpty()) {
@@ -50,18 +54,20 @@ KPassivePopup* TDEPassivePopupStackContainer::displayMessage(TQString title, TQS
mTopOfStack = r.height();
mRightOfStack = r.width();
}
- TQSize popupSize = pop->sizeHint();
+ TQSize popupSize = popup->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*)));
- connect(pop, SIGNAL(clicked(TQPoint)), this, SLOT(popupClicked(TQPoint)));
- mPopupList.append(pop);
- pop->show(leftCorner);
+ connect(popup, SIGNAL(hidden(KPassivePopup*)), this, SLOT(popupClosed(KPassivePopup*)));
+ connect(popup, SIGNAL(clicked(TQPoint)), this, SLOT(popupClicked(TQPoint)));
+ connect(popup, SIGNAL(destroyed(TQObject*)), this, SLOT(popupDestroyed(TQObject*)));
+ mPopupList.append(popup);
+ mPopupIDMap[popup] = id;
+ popup->show(leftCorner);
- return pop;
+ return popup;
}
void TDEPassivePopupStackContainer::processEvents() {
@@ -82,7 +88,20 @@ void TDEPassivePopupStackContainer::popupClosed(KPassivePopup* popup) {
}
void TDEPassivePopupStackContainer::popupClicked(TQPoint point) {
- emit(popupClicked(dynamic_cast<KPassivePopup*>(const_cast<TQObject*>(TQObject::sender())), point));
+ KPassivePopup* popup = dynamic_cast<KPassivePopup*>(const_cast<TQObject*>(TQObject::sender()));
+ if (popup) {
+ emit(popupClicked(popup, point, mPopupIDMap[popup]));
+ }
+ else {
+ emit(popupClicked(NULL, point, TQString::null));
+ }
+}
+
+void TDEPassivePopupStackContainer::popupDestroyed(TQObject* object) {
+ KPassivePopup* popup = static_cast<KPassivePopup*>(const_cast<TQObject*>(object));
+ if (popup) {
+ mPopupIDMap.remove(popup);
+ }
}
#include "tdepassivepopupstack.moc" \ No newline at end of file
diff --git a/tdeui/tdepassivepopupstack.h b/tdeui/tdepassivepopupstack.h
index 0da1c85ea..61ef209e1 100644
--- a/tdeui/tdepassivepopupstack.h
+++ b/tdeui/tdepassivepopupstack.h
@@ -28,6 +28,8 @@
#include "kiconloader.h"
#include "kpassivepopup.h"
+typedef TQMap<KPassivePopup*, TQString> TQStringPopupIDMap;
+
class TDEUI_EXPORT TDEPassivePopupStackContainer : public TQWidget
{
Q_OBJECT
@@ -36,20 +38,23 @@ public:
TDEPassivePopupStackContainer(TQWidget *parent=0, const char *name=0);
~TDEPassivePopupStackContainer();
- KPassivePopup* displayMessage(TQString title, TQString message, TQString icon, int x, int y);
+ KPassivePopup* displayMessage(TQString title, TQString message, TQString icon, int x, int y, TQString id=TQString::null);
+ KPassivePopup* displayMessage(TQString title, TQString message, TQPixmap icon, int x, int y, TQString id=TQString::null);
void processEvents();
signals:
- void popupClicked(KPassivePopup*, TQPoint);
+ void popupClicked(KPassivePopup*, TQPoint, TQString);
private slots:
void popupClosed(KPassivePopup*);
void popupClicked(TQPoint);
+ void popupDestroyed(TQObject* object);
private:
TQPtrList<KPassivePopup> mPopupList;
long mTopOfStack;
long mRightOfStack;
+ TQStringPopupIDMap mPopupIDMap;
};
#endif /* TDEPASSIVEPOPUPSTACK_H */