tdepassivepopupstack.cpp
00001 /* This file is part of the TDE libraries 00002 * Copyright (C) 2011 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License version 2 as published by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Library General Public License for more details. 00012 00013 * You should have received a copy of the GNU Library General Public License 00014 * along with this library; see the file COPYING.LIB. If not, write to 00015 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 * Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "tdepassivepopupstack.h" 00020 00021 TDEPassivePopupStackContainer::TDEPassivePopupStackContainer(TQWidget *parent, const char *name) : TQWidget(parent, name) { 00022 mPopupList.clear(); 00023 00024 // Determine bottom of desktop 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 // Determine bottom of desktop 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 // Remove the popup from our list of popups 00079 mPopupList.remove(popup); 00080 00081 if (mPopupList.isEmpty()) { 00082 // Determine bottom of desktop 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"
Trinity API Reference