diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2015-09-21 14:45:49 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2015-09-21 14:46:18 -0500 |
commit | 7fc4b62912ca770bf1018fb6deeccc5cf98d9600 (patch) | |
tree | c50fe7e5fd25bda185552f319aea0f74c974c3af /tdeui/tdepassivepopupstack.cpp | |
parent | 9cca766255e3c41c33470bb718e39f408d65367e (diff) | |
download | tdelibs-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
Diffstat (limited to 'tdeui/tdepassivepopupstack.cpp')
-rw-r--r-- | tdeui/tdepassivepopupstack.cpp | 43 |
1 files changed, 31 insertions, 12 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 |