tdeui
tdepassivepopupstack.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "tdepassivepopupstack.h"
00020
00021 TDEPassivePopupStackContainer::TDEPassivePopupStackContainer(TQWidget *parent, const char *name) : TQWidget(parent, name) {
00022 mPopupList.clear();
00023
00024
00025 TQPoint cursorPos = TQCursor::pos();
00026 TQRect r = TDEGlobalSettings::desktopGeometry(cursorPos);
00027 mTopOfStack = r.height();
00028 mRightOfStack = r.width();
00029 }
00030
00031 TDEPassivePopupStackContainer::~TDEPassivePopupStackContainer() {
00032
00033 }
00034
00035 KPassivePopup* TDEPassivePopupStackContainer::displayMessage(TQString title, TQString message, TQString icon, int x, int y, TQString id) {
00036 TQPixmap px;
00037 TDEIconLoader* il = TDEGlobal::iconLoader();
00038 px = il->loadIcon(icon, TDEIcon::NoGroup);
00039
00040 return displayMessage(title, message, px, x, y, id);
00041 }
00042
00043 KPassivePopup* TDEPassivePopupStackContainer::displayMessage(TQString title, TQString message, TQPixmap icon, int x, int y, TQString id) {
00044 KPassivePopup *popup = new KPassivePopup(KPassivePopup::Boxed, this, "");
00045 popup->setAutoDelete(true);
00046 popup->setView(title, message, icon);
00047 popup->setTimeout(-1);
00048 TQPoint leftCorner(x, y);
00049 if (leftCorner.isNull()) {
00050 if (mPopupList.isEmpty()) {
00051
00052 TQPoint cursorPos = TQCursor::pos();
00053 TQRect r = TDEGlobalSettings::desktopGeometry(cursorPos);
00054 mTopOfStack = r.height();
00055 mRightOfStack = r.width();
00056 }
00057 TQSize popupSize = popup->sizeHint();
00058 mTopOfStack = mTopOfStack-popupSize.height();
00059 if (mTopOfStack < 0) mTopOfStack = 0;
00060 leftCorner.setX(mRightOfStack-popupSize.width());
00061 leftCorner.setY(mTopOfStack);
00062 }
00063 connect(popup, SIGNAL(hidden(KPassivePopup*)), this, SLOT(popupClosed(KPassivePopup*)));
00064 connect(popup, SIGNAL(clicked(TQPoint)), this, SLOT(popupClicked(TQPoint)));
00065 connect(popup, SIGNAL(destroyed(TQObject*)), this, SLOT(popupDestroyed(TQObject*)));
00066 mPopupList.append(popup);
00067 mPopupIDMap[popup] = id;
00068 popup->show(leftCorner);
00069
00070 return popup;
00071 }
00072
00073 void TDEPassivePopupStackContainer::processEvents() {
00074 tqApp->processEvents();
00075 }
00076
00077 void TDEPassivePopupStackContainer::popupClosed(KPassivePopup* popup) {
00078
00079 mPopupList.remove(popup);
00080
00081 if (mPopupList.isEmpty()) {
00082
00083 TQPoint cursorPos = TQCursor::pos();
00084 TQRect r = TDEGlobalSettings::desktopGeometry(cursorPos);
00085 mTopOfStack = r.height();
00086 mRightOfStack = r.width();
00087 }
00088 }
00089
00090 void TDEPassivePopupStackContainer::popupClicked(TQPoint point) {
00091 KPassivePopup* popup = dynamic_cast<KPassivePopup*>(const_cast<TQObject*>(TQObject::sender()));
00092 if (popup) {
00093 emit(popupClicked(popup, point, mPopupIDMap[popup]));
00094 }
00095 else {
00096 emit(popupClicked(NULL, point, TQString::null));
00097 }
00098 }
00099
00100 void TDEPassivePopupStackContainer::popupDestroyed(TQObject* object) {
00101 KPassivePopup* popup = static_cast<KPassivePopup*>(const_cast<TQObject*>(object));
00102 if (popup) {
00103 mPopupIDMap.remove(popup);
00104 }
00105 }
00106
00107 #include "tdepassivepopupstack.moc"