diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index d801ca0fd..31ae6c83b 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -41,8 +41,8 @@ const uint32_t RS_SYS_WARNING = 0x0002; const uint32_t RS_SYS_INFO = 0x0004; const uint32_t RS_POPUP_MSG = 0x0001; -const uint32_t RS_POPUP_CHAT = 0x0002; -const uint32_t RS_POPUP_CALL = 0x0004; +//const uint32_t RS_POPUP_CHAT = 0x0002; +//const uint32_t RS_POPUP_CALL = 0x0004; const uint32_t RS_POPUP_CONNECT = 0x0008; const uint32_t RS_SYSTRAY_GROUP_MSG = 0x0010; const uint32_t RS_POPUP_DOWNLOAD = 0x0020; diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 56b3cf2c6..9989db5e3 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -273,11 +273,7 @@ HEADERS += rshare.h \ gui/settings/AddFileAssociationDialog.h \ gui/toaster/MessageToaster.h \ gui/toaster/OnlineToaster.h \ - gui/toaster/ChatToaster.h \ gui/toaster/DownloadToaster.h \ - gui/toaster/CallToaster.h \ - gui/toaster/QtToaster.h \ - gui/toaster/IQtToaster.h \ gui/toaster/RetroStyleLabelProxy.h \ gui/common/vmessagebox.h \ gui/common/rwindow.h \ @@ -377,8 +373,6 @@ FORMS += gui/StartDialog.ui \ gui/settings/TransferPage.ui \ gui/settings/SoundPage.ui \ gui/settings/ChatPage.ui \ - gui/toaster/CallToaster.ui \ - gui/toaster/ChatToaster.ui \ gui/toaster/MessageToaster.ui \ gui/toaster/OnlineToaster.ui \ gui/toaster/DownloadToaster.ui \ @@ -515,12 +509,9 @@ SOURCES += main.cpp \ gui/statusbar/dhtstatus.cpp \ gui/statusbar/ratesstatus.cpp \ gui/statusbar/hashingstatus.cpp \ - gui/toaster/ChatToaster.cpp \ gui/toaster/MessageToaster.cpp \ gui/toaster/DownloadToaster.cpp \ - gui/toaster/CallToaster.cpp \ gui/toaster/OnlineToaster.cpp \ - gui/toaster/QtToaster.cpp \ gui/advsearch/advancedsearchdialog.cpp \ gui/advsearch/expressionwidget.cpp \ gui/advsearch/guiexprelement.cpp \ diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index dd41a5791..52e15f359 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -1,5 +1,29 @@ +/**************************************************************** + * This file is distributed under the following license: + * + * Copyright (c) 2010 RetroShare Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + *************************************************************************/ + #include #include +#include +//#include +#include #include "notifyqt.h" #include @@ -10,14 +34,12 @@ #include #endif -#include "gui/RsAutoUpdatePage.h" +#include "RsAutoUpdatePage.h" #ifndef MINIMAL_RSGUI -#include "gui/toaster/OnlineToaster.h" -#include "gui/toaster/MessageToaster.h" -#include "gui/toaster/ChatToaster.h" -#include "gui/toaster/CallToaster.h" -#include "gui/toaster/DownloadToaster.h" +#include "toaster/OnlineToaster.h" +#include "toaster/MessageToaster.h" +#include "toaster/DownloadToaster.h" #endif // MINIMAL_RSGUI #include "gui/settings/rsharesettings.h" @@ -30,6 +52,40 @@ * #define NOTIFY_DEBUG ****/ +class Toaster +{ +public: + Toaster(QWidget *widget) + { + this->widget = widget; + + /* Standard values */ + timeToShow = 500; + timeToLive = 3000; + timeToHide = 500; + + /* Calculated values */ + elapsedTimeToShow = 0; + elapsedTimeToLive = 0; + elapsedTimeToHide = 0; + } + +public: + QWidget *widget; + + /* Standard values */ + int timeToShow; + int timeToLive; + int timeToHide; + + /* Calculated values */ + QPoint startPos; + QPoint endPos; + int elapsedTimeToShow; + int elapsedTimeToLive; + int elapsedTimeToHide; +}; + /*static*/ NotifyQt *NotifyQt::_instance = NULL; /*static*/ NotifyQt *NotifyQt::Create () @@ -46,6 +102,14 @@ return _instance; } +NotifyQt::NotifyQt() : cDialog(NULL) +{ + runningToasterTimer = new QTimer(this); + connect(runningToasterTimer, SIGNAL(timeout()), this, SLOT(runningTick())); + runningToasterTimer->setInterval(10); // tick 100 times a second + runningToasterTimer->setSingleShot(true); +} + void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) { emit errorOccurred(list,type,QString::fromStdString(msg)) ; @@ -373,6 +437,9 @@ void NotifyQt::UpdateGUI() { uint popupflags = Settings->getNotifyFlags(); + /* You can set timeToShow, timeToLive and timeToHide or can leave the standard */ + Toaster *toaster = NULL; + /* id the name */ std::string name; std::string realmsg; @@ -391,59 +458,32 @@ void NotifyQt::UpdateGUI() switch(type) { case RS_POPUP_MSG: - if (popupflags & RS_POPUP_MSG) - { - MessageToaster * msgToaster = new MessageToaster(); - msgToaster->setMessage(QString::fromStdString(msg)); - msgToaster->setName(QString::fromStdString(realmsg)); - msgToaster->setTitle(QString::fromStdString(title)); - msgToaster->displayPopup(); - } + if (popupflags & RS_POPUP_MSG) + { + toaster = new Toaster(new MessageToaster(QString::fromStdString(realmsg), QString::fromStdString(title), QString::fromStdString(msg))); + } break; - case RS_POPUP_CHAT: - if (popupflags & RS_POPUP_CHAT) - { - ChatToaster * chatToaster = new ChatToaster(); - chatToaster->setMessage(QString::fromStdString(realmsg)); - chatToaster->show(); - } - break; - case RS_POPUP_CALL: - if (popupflags & RS_POPUP_CALL) - { - CallToaster * callToaster = new CallToaster(); - callToaster->setMessage(QString::fromStdString(realmsg)); - callToaster->show(); - } - break; - default: case RS_POPUP_CONNECT: - if (popupflags & RS_POPUP_CONNECT) - { - OnlineToaster * onlineToaster = new OnlineToaster(); - onlineToaster->setMessage(QString::fromStdString(realmsg)); - - if(size != 0) + if (popupflags & RS_POPUP_CONNECT) { - // set the image - QPixmap pix ; - pix.loadFromData(data,size,"PNG") ; - onlineToaster->setPixmap(pix); - } - else - { - onlineToaster->setPixmap(QPixmap(":/images/user/personal64.png")); - } + QPixmap avatar; + if(size != 0) + { + // set the image + avatar.loadFromData(data,size,"PNG"); + } + else + { + avatar = QPixmap(":/images/user/personal64.png"); + } - onlineToaster->show(); - onlineToaster->play(); - } + toaster = new Toaster(new OnlineToaster(id, QString::fromStdString(realmsg), avatar)); + } break; case RS_POPUP_DOWNLOAD: if (popupflags & RS_POPUP_DOWNLOAD) { - DownloadToaster *downloadToaster = new DownloadToaster(); - downloadToaster->displayPopup(id, QString::fromUtf8(title.c_str())); + toaster = new Toaster(new DownloadToaster(id, QString::fromUtf8(title.c_str()))); } break; } @@ -451,6 +491,15 @@ void NotifyQt::UpdateGUI() if (data) { delete[] data; } + + if (toaster) { + /* init attributes */ + toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); + + /* add toaster to waiting list */ +// QMutexLocker lock(&waitingToasterMutex); + waitingToasterList.push_back(toaster); + } } if (rsNotify->NotifySysMessage(sysid, type, title, msg)) @@ -476,6 +525,7 @@ void NotifyQt::UpdateGUI() break; } } + if (rsNotify->NotifyLogMessage(sysid, type, title, msg)) { /* make a log message */ @@ -489,6 +539,10 @@ void NotifyQt::UpdateGUI() } } } + + /* Now start the waiting toasters */ + startWaitingToasters(); + #endif // MINIMAL_RSGUI } @@ -496,7 +550,134 @@ void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType { emit chatStyleChanged(styleType); } - + +void NotifyQt::startWaitingToasters() +{ + { +// QMutexLocker lock(&waitingToasterMutex); + + if (waitingToasterList.empty()) { + /* No toasters are waiting */ + return; + } + } + + { +// QMutexLocker lock(&runningToasterMutex); + + if (runningToasterList.size() >= 3) { + /* Don't show more than 3 toasters at once */ + return; + } + } + + Toaster *toaster = NULL; + + { +// QMutexLocker lock(&waitingToasterMutex); + + if (waitingToasterList.size()) { + /* Take one toaster of the waiting list */ + toaster = waitingToasterList.front(); + waitingToasterList.pop_front(); + } + } + + if (toaster) { + /* 10 pixels of x margin */ + static const int MARGIN_X = 10; + /* 10 pixels of y margin */ + static const int MARGIN_Y = 10; + +// QMutexLocker lock(&runningToasterMutex); + + /* Calculate positions */ + QSize size = toaster->widget->size(); + + QDesktopWidget *desktop = QApplication::desktop(); + QRect screenGeometry = desktop->screenGeometry(desktop->primaryScreen()); + QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen()); + + /* From bottom */ + toaster->startPos = QPoint(screenGeometry.right() - size.width() - MARGIN_X, screenGeometry.bottom()); + toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - MARGIN_Y); + /* From top */ +// toaster->startPos = QPoint(screenGeometry.right() - size.width() - MARGIN_X, screenGeometry.top() - size.height()); +// toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + MARGIN_Y); + + /* Initialize widget */ + toaster->widget->move(toaster->startPos); + toaster->widget->show(); + + /* Initialize toaster */ + toaster->elapsedTimeToShow = 0; + toaster->elapsedTimeToLive = 0; + toaster->elapsedTimeToHide = 0; + + /* Add toaster to the running list */ + runningToasterList.push_front(toaster); + if (runningToasterTimer->isActive() == false) { + /* Start the toaster timer */ + runningToasterTimer->start(); + } + } +} + +void NotifyQt::runningTick() +{ +// QMutexLocker lock(&runningToasterMutex); + + int interval = runningToasterTimer->interval(); + QPoint diff; + + QList::iterator it = runningToasterList.begin(); + while (it != runningToasterList.end()) { + Toaster *toaster = *it; + + bool visible = toaster->widget->isVisible(); + + if (visible && toaster->elapsedTimeToShow <= toaster->timeToShow) { + /* Toaster is showing */ + toaster->elapsedTimeToShow += interval; + + QPoint newPos(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * toaster->elapsedTimeToShow / toaster->timeToShow, + toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * toaster->elapsedTimeToShow / toaster->timeToShow); + toaster->widget->move(newPos + diff); + + diff += newPos - toaster->startPos; + } else if (visible && toaster->elapsedTimeToLive <= toaster->timeToLive) { + /* Toaster is living */ + toaster->elapsedTimeToLive += interval; + + toaster->widget->move(toaster->endPos + diff); + + diff += toaster->endPos - toaster->startPos; + } else if (visible && toaster->elapsedTimeToHide <= toaster->timeToHide) { + /* Toaster is hiding */ + toaster->elapsedTimeToHide += interval; + + QPoint newPos(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide, + toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide); + toaster->widget->move(newPos + diff); + + diff += newPos - toaster->startPos; + } else { + /* Toaster is hidden, delete it */ + it = runningToasterList.erase(it); + delete(toaster->widget); + delete(toaster); + continue; + } + + ++it; + } + + if (runningToasterList.size()) { + /* There are more running toasters, start the timer again */ + runningToasterTimer->start(); + } +} + //void NotifyQt::displaySearch() //{ // iface->lockData(); /* Lock Interface */ @@ -579,6 +760,3 @@ void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType // // //} - - - diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 71b2daba3..7794bc087 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -4,9 +4,11 @@ #include #include #include +//#include #include +class QTimer; class NetworkDialog; class PeersDialog; class SharedFilesDialog; @@ -15,6 +17,7 @@ class ChatDialog; class MessagesDialog; class ChannelsDialog; class MessengerWindow; +class Toaster; struct TurtleFileInfo; //class NotifyQt: public NotifyBase, public QObject @@ -95,11 +98,23 @@ class NotifyQt: public QObject, public NotifyBase void UpdateGUI(); /* called by timer */ + private slots: + void runningTick(); + private: - NotifyQt() : cDialog(NULL) { return; } + NotifyQt(); static NotifyQt *_instance; + void startWaitingToasters(); + +// QMutex waitingToasterMutex; // for lock of the waiting toaster list + QList waitingToasterList; + + QTimer *runningToasterTimer; +// QMutex runningToasterMutex; // for lock of the running toaster list + QList runningToasterList; + // void displayNeighbours(); // void displayFriends(); // void displayDirectories(); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 25daddbe7..21c512c84 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -22,16 +22,12 @@ #include #include "NotifyPage.h" -#include -#include #include #include "rsharesettings.h" #include "gui/MainWindow.h" -#include - /** Constructor */ NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags) @@ -76,12 +72,6 @@ NotifyPage::save(QString &errmsg) if (ui.popup_DownloadFinished->isChecked()) notifyflags |= RS_POPUP_DOWNLOAD; - //if (ui.popup_NewChat->isChecked()) - notifyflags |= RS_POPUP_CHAT; - - //if (ui.popup_Call->isChecked()) - // notifyflags |= RS_POPUP_CALL; - if (ui.notify_Peers->isChecked()) newsflags |= RS_FEED_TYPE_PEER; if (ui.notify_Channels->isChecked()) @@ -145,8 +135,6 @@ void NotifyPage::load() ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT); ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG); ui.popup_DownloadFinished->setChecked(notifyflags & RS_POPUP_DOWNLOAD); - //ui.popup_NewChat->setChecked(notifyflags & RS_POPUP_CHAT); - //ui.popup_Call->setChecked(notifyflags & RS_POPUP_CALL); ui.notify_Peers->setChecked(newsflags & RS_FEED_TYPE_PEER); ui.notify_Channels->setChecked(newsflags & RS_FEED_TYPE_CHAN); diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 0d10936c8..05d609021 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -122,8 +122,7 @@ void RshareSettings::initSettings() uint defChat = RS_CHAT_OPEN; // This is not default... RS_CHAT_FOCUS. - uint defNotify = (RS_POPUP_CONNECT | RS_POPUP_MSG | - RS_POPUP_CHAT | RS_POPUP_CALL); + uint defNotify = (RS_POPUP_CONNECT | RS_POPUP_MSG); uint defNewsFeed = (RS_FEED_TYPE_PEER | RS_FEED_TYPE_CHAN | RS_FEED_TYPE_FORUM | RS_FEED_TYPE_BLOG | diff --git a/retroshare-gui/src/gui/toaster/CallToaster.cpp b/retroshare-gui/src/gui/toaster/CallToaster.cpp deleted file mode 100644 index 81357164b..000000000 --- a/retroshare-gui/src/gui/toaster/CallToaster.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2006,2007 crypton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#include "CallToaster.h" - -#include "QtToaster.h" - -#include "ui_CallToaster.h" - -//#include -//#include - -#include - -CallToaster::CallToaster() - : QObject(NULL) { - - _callToasterWidget = new QWidget(NULL); - - _ui = new Ui::CallToaster(); - _ui->setupUi(_callToasterWidget); - - _ui->hangUpButton->setPixmaps(QPixmap(":/images/toaster/hangup.png"), - QPixmap(), - QPixmap(), - QPixmap(":/images/toaster/hangup.png"), - QPixmap(), - QPixmap()); - - _ui->pickUpButton->setPixmaps(QPixmap(":/images/toaster/pickup.png"), - QPixmap(), - QPixmap(), - QPixmap(":/images/toaster/pickup.png"), - QPixmap(), - QPixmap()); - - _ui->pickUpButton->setMinimumSize(QSize(48, 56)); - _ui->pickUpButton->setMaximumSize(QSize(48, 56)); - connect(_ui->pickUpButton, SIGNAL(clicked()), SLOT(pickUpButtonSlot())); - - _ui->hangUpButton->setMinimumSize(QSize(28, 56)); - _ui->hangUpButton->setMaximumSize(QSize(28, 56)); - connect(_ui->hangUpButton, SIGNAL(clicked()), SLOT(hangUpButtonSlot())); - - connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close())); - - _toaster = new QtToaster(this, _callToasterWidget, _ui->windowFrame); - _toaster->setTimeOnTop(10000); -} - -CallToaster::~CallToaster() { - delete(_ui); -} - -void CallToaster::setMessage(const QString & message) { - _ui->messageLabel->setText(message); -} - -void CallToaster::setPixmap(const QPixmap & pixmap) { - _ui->pixmapLabel->setPixmap(pixmap); -} - -void CallToaster::show() { - _toaster->show(); -} - -void CallToaster::close() { - _toaster->close(); -} - -void CallToaster::hangUpButtonSlot() { - hangUpButtonClicked(); - close(); -} - -void CallToaster::pickUpButtonSlot() { - pickUpButtonClicked(); - close(); -} diff --git a/retroshare-gui/src/gui/toaster/CallToaster.h b/retroshare-gui/src/gui/toaster/CallToaster.h deleted file mode 100644 index 2c6061003..000000000 --- a/retroshare-gui/src/gui/toaster/CallToaster.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2006,2007 crypton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#ifndef CALLTOASTER_H -#define CALLTOASTER_H - -#include "IQtToaster.h" - -#include - -class QtToaster; - -class QWidget; -class QString; -class QPixmap; -namespace Ui { class CallToaster; } - -/** - * Shows a toaster when a phone call is incoming. - * - * - */ -class CallToaster : public QObject, public IQtToaster { - Q_OBJECT -public: - - CallToaster(); - - ~CallToaster(); - - void setMessage(const QString & message); - - void setPixmap(const QPixmap & pixmap); - - void show(); - -public Q_SLOTS: - - void close(); - -Q_SIGNALS: - - void hangUpButtonClicked(); - - void pickUpButtonClicked(); - -private Q_SLOTS: - - void hangUpButtonSlot(); - - void pickUpButtonSlot(); - -private: - - Ui::CallToaster * _ui; - - QWidget * _callToasterWidget; - - QtToaster * _toaster; -}; - -#endif //CALLTOASTER_H diff --git a/retroshare-gui/src/gui/toaster/CallToaster.ui b/retroshare-gui/src/gui/toaster/CallToaster.ui deleted file mode 100644 index 1c438d512..000000000 --- a/retroshare-gui/src/gui/toaster/CallToaster.ui +++ /dev/null @@ -1,681 +0,0 @@ - - CallToaster - - - - 0 - 0 - 400 - 300 - - - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - 6 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QFrame::NoFrame - - - :/images/toaster/pickup.png - - - - - - - QFrame::NoFrame - - - :/images/toaster/hangup.png - - - - - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - 0 - 0 - - - - - 18 - 18 - - - - - 18 - 18 - - - - :/images/close-down.png - - - true - - - - - - - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 255 - 255 - 255 - - - - - - - 234 - 229 - 220 - - - - - - - 128 - 128 - 128 - - - - - - - 141 - 139 - 133 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 64 - 64 - 64 - - - - - - - 10 - 36 - 106 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 255 - 255 - 255 - - - - - - - 234 - 229 - 220 - - - - - - - 128 - 128 - 128 - - - - - - - 141 - 139 - 133 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 64 - 64 - 64 - - - - - - - 212 - 208 - 200 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 106 - 104 - 100 - - - - - - - 212 - 208 - 200 - - - - - - - 255 - 255 - 255 - - - - - - - 233 - 231 - 227 - - - - - - - 128 - 128 - 128 - - - - - - - 141 - 139 - 133 - - - - - - - 106 - 104 - 100 - - - - - - - 255 - 255 - 255 - - - - - - - 106 - 104 - 100 - - - - - - - 212 - 208 - 200 - - - - - - - 212 - 208 - 200 - - - - - - - 0 - 0 - 0 - - - - - - - 10 - 36 - 106 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - Message - - - Qt::AlignCenter - - - - - - - - - - - - - RetroStyleLabel - QLabel -
gui/toaster/RetroStyleLabelProxy.h
-
-
- - - - -
diff --git a/retroshare-gui/src/gui/toaster/ChatToaster.cpp b/retroshare-gui/src/gui/toaster/ChatToaster.cpp deleted file mode 100644 index 561c89801..000000000 --- a/retroshare-gui/src/gui/toaster/ChatToaster.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2006,2007 crypton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#include "ChatToaster.h" - -#include "ui_ChatToaster.h" - -#include "QtToaster.h" - - -#include - -ChatToaster::ChatToaster() - : QObject(NULL) { - - _chatToasterWidget = new QWidget(NULL); - - _ui = new Ui::ChatToaster(); - _ui->setupUi(_chatToasterWidget); - - _ui->chatButton->setPixmaps(QPixmap(":/images/toaster/chat.png"), - QPixmap(), - QPixmap(), - QPixmap(":/images/toaster/chat.png"), - QPixmap(), - QPixmap()); - - connect(_ui->chatButton, SIGNAL(clicked()), SLOT(chatButtonSlot())); - - connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close())); - - _toaster = new QtToaster(this, _chatToasterWidget, _ui->windowFrame); - _toaster->setTimeOnTop(5000); -} - -ChatToaster::~ChatToaster() { - delete(_ui); -} - -void ChatToaster::setMessage(const QString & message) { - _ui->messageLabel->setText(message); -} - -void ChatToaster::setPixmap(const QPixmap & pixmap) { - _ui->pixmapLabel->setPixmap(pixmap); -} - -void ChatToaster::show() { - _toaster->show(); -} - -void ChatToaster::close() { - _toaster->close(); -} - -void ChatToaster::chatButtonSlot() { - chatButtonClicked(); - close(); -} diff --git a/retroshare-gui/src/gui/toaster/ChatToaster.h b/retroshare-gui/src/gui/toaster/ChatToaster.h deleted file mode 100644 index 440c5a4b8..000000000 --- a/retroshare-gui/src/gui/toaster/ChatToaster.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2006,2007 crypton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#ifndef CHATTOASTER_H -#define CHATTOASTER_H - -#include "IQtToaster.h" - -#include - -class QtToaster; - -class QWidget; -class QString; -class QPixmap; -namespace Ui { class ChatToaster; } - -/** - * Shows a toaster when a chat is incoming. - * - * - */ -class ChatToaster : public QObject, public IQtToaster { - Q_OBJECT -public: - - ChatToaster(); - - ~ChatToaster(); - - void setMessage(const QString & message); - - void setPixmap(const QPixmap & pixmap); - - void show(); - -public Q_SLOTS: - - void close(); - -Q_SIGNALS: - - void chatButtonClicked(); - -private Q_SLOTS: - - void chatButtonSlot(); - -private: - - Ui::ChatToaster * _ui; - - QWidget * _chatToasterWidget; - - QtToaster * _toaster; -}; - -#endif //CHATTOASTER_H diff --git a/retroshare-gui/src/gui/toaster/ChatToaster.ui b/retroshare-gui/src/gui/toaster/ChatToaster.ui deleted file mode 100644 index 07af2839f..000000000 --- a/retroshare-gui/src/gui/toaster/ChatToaster.ui +++ /dev/null @@ -1,672 +0,0 @@ - - - ChatToaster - - - - 0 - 0 - 400 - 300 - - - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - 6 - - - 0 - - - - - ../images/toaster/chat.png - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - 0 - - - 0 - - - - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 255 - 255 - 255 - - - - - - - 234 - 229 - 220 - - - - - - - 128 - 128 - 128 - - - - - - - 141 - 139 - 133 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 64 - 64 - 64 - - - - - - - 10 - 36 - 106 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 255 - 255 - 255 - - - - - - - 234 - 229 - 220 - - - - - - - 128 - 128 - 128 - - - - - - - 141 - 139 - 133 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 212 - 208 - 200 - - - - - - - 64 - 64 - 64 - - - - - - - 212 - 208 - 200 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 106 - 104 - 100 - - - - - - - 212 - 208 - 200 - - - - - - - 255 - 255 - 255 - - - - - - - 233 - 231 - 227 - - - - - - - 128 - 128 - 128 - - - - - - - 141 - 139 - 133 - - - - - - - 106 - 104 - 100 - - - - - - - 255 - 255 - 255 - - - - - - - 106 - 104 - 100 - - - - - - - 212 - 208 - 200 - - - - - - - 212 - 208 - 200 - - - - - - - 0 - 0 - 0 - - - - - - - 10 - 36 - 106 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - Message - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 18 - 18 - - - - - 18 - 18 - - - - - :/images/close-down.png:/images/close-down.png - - - true - - - - - - - Qt::Horizontal - - - - 225 - 22 - - - - - - - - - - - - - - RetroStyleLabel - QLabel -
gui/toaster/RetroStyleLabelProxy.h
-
-
- - chatButton - closeButton - - - - - -
diff --git a/retroshare-gui/src/gui/toaster/DownloadToaster.cpp b/retroshare-gui/src/gui/toaster/DownloadToaster.cpp index a4f81aab2..805e76cdf 100644 --- a/retroshare-gui/src/gui/toaster/DownloadToaster.cpp +++ b/retroshare-gui/src/gui/toaster/DownloadToaster.cpp @@ -20,110 +20,47 @@ * *************************************************************************/ -#include -#include #include #include #include +#include #include "DownloadToaster.h" #include -DownloadToaster::DownloadToaster(QWidget * parent, Qt::WFlags flags) - : QWidget(parent, flags) +DownloadToaster::DownloadToaster(const std::string &hash, const QString &name) : QWidget(NULL) { - setupUi(this); + ui.setupUi(this); - /* set window flags */ - QWidget::setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); + fileHash = hash; - /* init the timer */ - displayTimer = new QTimer(this); - connect(displayTimer, SIGNAL(timeout()), this, SLOT(displayTimerOnTimer())); + /* connect buttons */ + connect(ui.spbClose, SIGNAL(clicked()), this, SLOT(hide())); + connect(ui.startButton, SIGNAL(clicked()), this, SLOT(play())); - /* connect buttons */ - connect(spbClose, SIGNAL(clicked()), this, SLOT(closeClicked())); - connect(startButton, SIGNAL(clicked()), this, SLOT(play())); - - /* init state */ - displayState = dsInactive; -} - -DownloadToaster::~DownloadToaster() -{ - delete displayTimer; -} - -void DownloadToaster::displayTimerOnTimer() -{ - if (!isVisible()) return; - - QDesktopWidget *desktop = QApplication::desktop(); - QRect availableGeometry = desktop->availableGeometry(this); - - // display popup animation - if (displayState == dsShowing) - if (pos().x() > availableGeometry.width() - size().width())// - 15) - move(pos().x() - 2, pos().y()); - else - { - displayState = dsWaiting; - displayTimer->start(5000); - } - // hide popup animation - else if (displayState == dsHiding) - if (pos().x() < availableGeometry.width()) - move(pos().x() + 2, pos().y()); - else - { - displayState = dsWaiting; - displayTimer->stop(); - hide(); - } - else if (displayState == dsWaiting) - { - displayState = dsHiding; - displayTimer->start(2); - } -} - -void DownloadToaster::displayPopup(const std::string &hash, const QString &name) -{ - fileHash = hash; - labelTitle->setText(name); - - QDesktopWidget *desktop = QApplication::desktop(); - QRect availableGeometry = desktop->availableGeometry(this); - move(desktop->width(), availableGeometry.height() - size().height()); - show(); - - displayState = dsShowing; - displayTimer->start(2); -} - -void DownloadToaster::closeClicked() -{ - displayState = dsHiding; - displayTimer->start(2); + /* set informations */ + ui.labelTitle->setText(name); } void DownloadToaster::play() { - /* look up path */ - FileInfo fi; - if (!rsFiles->FileDetails(fileHash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY, fi)) { - return; - } + /* look up path */ + FileInfo fi; + if (!rsFiles->FileDetails(fileHash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY, fi)) { + return; + } - std::string filename = fi.path + "/" + fi.fname; + std::string filename = fi.path + "/" + fi.fname; - /* open file with a suitable application */ - QFileInfo qinfo; - qinfo.setFile(filename.c_str()); - if (qinfo.exists()) { - QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath())); - }else{ - QMessageBox::information(this, "RetroShare", tr("File %1 does not exist at location.").arg(fi.path.c_str())); - } + /* open file with a suitable application */ + QFileInfo qinfo; + qinfo.setFile(filename.c_str()); + if (qinfo.exists()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath())); + }else{ +// QMessageBox::information(this, "RetroShare", tr("File %1 does not exist at location.").arg(fi.path.c_str())); + } + + hide(); } diff --git a/retroshare-gui/src/gui/toaster/DownloadToaster.h b/retroshare-gui/src/gui/toaster/DownloadToaster.h index 05e46dd11..6c1005474 100644 --- a/retroshare-gui/src/gui/toaster/DownloadToaster.h +++ b/retroshare-gui/src/gui/toaster/DownloadToaster.h @@ -23,28 +23,23 @@ #ifndef DOWNLOADTOASTER_H #define DOWNLOADTOASTER_H -#include "MessageToaster.h" // for DisplayState - #include "ui_DownloadToaster.h" -class DownloadToaster : public QWidget, public Ui::DownloadToaster +class DownloadToaster : public QWidget { -Q_OBJECT + Q_OBJECT public: - DownloadToaster(QWidget *parent = 0, Qt::WFlags f = 0); - ~DownloadToaster(); - void displayPopup(const std::string &hash, const QString &name); + DownloadToaster(const std::string &hash, const QString &name); private slots: - void displayTimerOnTimer(); - void closeClicked(); - void play(); + void play(); private: - QTimer *displayTimer; - std::string fileHash; - DisplayState displayState; + std::string fileHash; + + /** Qt Designer generated object */ + Ui::DownloadToaster ui; }; #endif diff --git a/retroshare-gui/src/gui/toaster/IQtToaster.h b/retroshare-gui/src/gui/toaster/IQtToaster.h deleted file mode 100644 index 7125b011a..000000000 --- a/retroshare-gui/src/gui/toaster/IQtToaster.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2006,2007 crypton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#ifndef IQTTOASTER_H -#define IQTTOASTER_H - -#include - -class QString; -class QPixmap; - -/** - * Shows a toaster when a phone call or a chat is incoming. - * - * A toaster is a small window in the lower right of the desktop. - * - * - */ -class IQtToaster : Interface { -public: - - /** - * Sets the toaster window message. - * - * @param message toaster message - */ - virtual void setMessage(const QString & message) = 0; - - /** - * Sets the toaster window picture. - * - * @param pixmap toaster picture - */ - virtual void setPixmap(const QPixmap & pixmap) = 0; - - /** - * Shows the toaster window. - */ - virtual void show() = 0; - - /** - * Closes the toaster window. - */ - virtual void close() = 0; -}; - -#endif //IQTTOASTER_H diff --git a/retroshare-gui/src/gui/toaster/MessageToaster.cpp b/retroshare-gui/src/gui/toaster/MessageToaster.cpp index ca0de2bef..ac64e5c36 100644 --- a/retroshare-gui/src/gui/toaster/MessageToaster.cpp +++ b/retroshare-gui/src/gui/toaster/MessageToaster.cpp @@ -17,111 +17,29 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include - #include "MessageToaster.h" #include "../MainWindow.h" -MessageToaster::MessageToaster( QWidget * parent, Qt::WFlags f) - : QWidget(parent, f) +MessageToaster::MessageToaster(const QString &name, const QString &title, const QString &message) : QWidget(NULL) { - setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); - setAttribute ( Qt::WA_DeleteOnClose, true ); + /* connect buttons */ + connect(ui.closebtn, SIGNAL(clicked()), this, SLOT(hide())); + connect(ui.openmessagebtn, SIGNAL(clicked()), this, SLOT(openmessageClicked())); + connect(ui.openmessagetoolButton, SIGNAL(clicked()), this, SLOT(openmessageClicked())); - // set window flags - QWidget::setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - // init the timer - displayTimer = new QTimer(this); - connect(displayTimer, SIGNAL(timeout()), this, SLOT(displayTimerOnTimer())); - // connect buttons - connect(closebtn, SIGNAL(clicked()), this, SLOT(closeClicked())); - connect(openmessagebtn, SIGNAL(clicked()), this, SLOT(openmessageClicked())); - connect(openmessagetoolButton, SIGNAL(clicked()), this, SLOT(openmessageClicked())); - - // init state - displayState = dsInactive; -} - -MessageToaster::~MessageToaster() -{ - delete displayTimer; -} - -void MessageToaster::displayTimerOnTimer() -{ - if (!isVisible()) { - close(); - return; - } - - QDesktopWidget *desktop = QApplication::desktop(); - QRect availableGeometry = desktop->availableGeometry(this); - - // display popup animation - if (displayState == dsShowing) - if (pos().x() > availableGeometry.width() - size().width())// - 15) - move(pos().x() - 2, pos().y()); - else - { - displayState = dsWaiting; - displayTimer->start(5000); - } - // hide popup animation - else if (displayState == dsHiding) - if (pos().x() < availableGeometry.width()) - move(pos().x() + 2, pos().y()); - else - { - displayState = dsWaiting; - displayTimer->stop(); - hide(); - close(); - } - else if (displayState == dsWaiting) - { - displayState = dsHiding; - displayTimer->start(2); - } -} - -void MessageToaster::displayPopup() -{ - QDesktopWidget *desktop = QApplication::desktop(); - QRect availableGeometry = desktop->availableGeometry(this); - move(desktop->width(), availableGeometry.height() - size().height()); - this->show(); - - displayState = dsShowing; - displayTimer->start(2); -} - -void MessageToaster::closeClicked() -{ - displayState = dsHiding; - displayTimer->start(2); + /* set informations */ + ui.subjectline->setText(tr("Sub:") + " " + title); + ui.subjectline->setToolTip(title); + ui.contentBrowser->setText(message); + ui.contentBrowser->setToolTip(message); + ui.namelabel->setText(name); } void MessageToaster::openmessageClicked() { - MainWindow::showWindow (MainWindow::Messages); -} - -void MessageToaster::setTitle(const QString & title) -{ - subjectline->setText("Sub: " + title); - subjectline->setToolTip(title); -} - - -void MessageToaster::setMessage(const QString & message) -{ - contentBrowser->setText(message); - contentBrowser->setToolTip(message); -} - -void MessageToaster::setName(const QString & name) -{ - namelabel->setText(name); + MainWindow::showWindow(MainWindow::Messages); + hide(); } diff --git a/retroshare-gui/src/gui/toaster/MessageToaster.h b/retroshare-gui/src/gui/toaster/MessageToaster.h index 34c0b0ffc..05eb108d9 100644 --- a/retroshare-gui/src/gui/toaster/MessageToaster.h +++ b/retroshare-gui/src/gui/toaster/MessageToaster.h @@ -28,29 +28,19 @@ #include "ui_MessageToaster.h" -enum DisplayState {dsInactive, dsShowing, dsWaiting, dsHiding}; - -class MessageToaster : public QWidget, public Ui::MessageToaster +class MessageToaster : public QWidget { -Q_OBJECT - - public: - MessageToaster( QWidget * parent = 0, Qt::WFlags f = 0 ); - ~MessageToaster(); - - void displayPopup(); - void setTitle(const QString &title); - void setMessage(const QString & message); - void setName(const QString & name); + Q_OBJECT - - private slots: - void displayTimerOnTimer(); - void closeClicked(); - void openmessageClicked(); - - private: - QTimer *displayTimer; - DisplayState displayState; +public: + MessageToaster(const QString &name, const QString &title, const QString &message); + +private slots: + void openmessageClicked(); + +private: + /** Qt Designer generated object */ + Ui::MessageToaster ui; }; + #endif diff --git a/retroshare-gui/src/gui/toaster/OnlineToaster.cpp b/retroshare-gui/src/gui/toaster/OnlineToaster.cpp index 014529bea..5213fe304 100644 --- a/retroshare-gui/src/gui/toaster/OnlineToaster.cpp +++ b/retroshare-gui/src/gui/toaster/OnlineToaster.cpp @@ -17,66 +17,52 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "OnlineToaster.h" - -#include "ui_OnlineToaster.h" - -#include "QtToaster.h" #include "gui/settings/rsharesettings.h" +#include "gui/chat/PopupChatDialog.h" +#include "util/WidgetBackgroundImage.h" -#include +OnlineToaster::OnlineToaster(const std::string &peerId, const QString &name, const QPixmap &avatar) : QWidget(NULL) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); -OnlineToaster::OnlineToaster() - : QObject(NULL) { + this->peerId = peerId; - _onlineToasterWidget = new QWidget(NULL); + /* connect buttons */ + connect(ui.messageButton, SIGNAL(clicked()), SLOT(chatButtonSlot())); + connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide())); - _ui = new Ui::OnlineToaster(); - _ui->setupUi(_onlineToasterWidget); + /* set informations */ + ui.messageLabel->setText(name); + ui.pixmaplabel->setPixmap(avatar); - connect(_ui->messageButton, SIGNAL(clicked()), SLOT(chatButtonSlot())); + WidgetBackgroundImage::setBackgroundImage(ui.windowFrame, ":images/toaster/toaster-backrs4.png", WidgetBackgroundImage::AdjustSize); + resize(184, 128); - connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close())); - - _toaster = new QtToaster(this, _onlineToasterWidget, _ui->windowFrame); - _toaster->setTimeOnTop(5000); + play(); } -OnlineToaster::~OnlineToaster() { - delete _ui; +void OnlineToaster::chatButtonSlot() +{ + PopupChatDialog::chatFriend(peerId); + hide(); } -void OnlineToaster::setMessage(const QString & message) { - _ui->messageLabel->setText(message); -} +void OnlineToaster::play() +{ + Settings->beginGroup("Sound"); + Settings->beginGroup("SoundFilePath"); + QString OnlineSound = Settings->value("User_go_Online","").toString(); + Settings->endGroup(); + Settings->beginGroup("Enable"); + bool flag = Settings->value("User_go_Online",false).toBool(); + Settings->endGroup(); + Settings->endGroup(); -void OnlineToaster::setPixmap(const QPixmap & pixmap) { - _ui->pixmaplabel->setPixmap(pixmap); -} - -void OnlineToaster::show() { - _toaster->show(); -} - -void OnlineToaster::close() { - _toaster->close(); -} - -void OnlineToaster::chatButtonSlot() { - chatButtonClicked(); - close(); -} - -void OnlineToaster::play(){ - Settings->beginGroup("Sound"); - Settings->beginGroup("SoundFilePath"); - QString OnlineSound = Settings->value("User_go_Online","").toString(); - Settings->endGroup(); - Settings->beginGroup("Enable"); - bool flag = Settings->value("User_go_Online",false).toBool(); - Settings->endGroup(); - Settings->endGroup(); - if(!OnlineSound.isEmpty()&&flag) - if(QSound::isAvailable()) - QSound::play(OnlineSound); + if(!OnlineSound.isEmpty()&&flag) + if(QSound::isAvailable()) + QSound::play(OnlineSound); } diff --git a/retroshare-gui/src/gui/toaster/OnlineToaster.h b/retroshare-gui/src/gui/toaster/OnlineToaster.h index 6b7c77c2b..1a4515a7a 100644 --- a/retroshare-gui/src/gui/toaster/OnlineToaster.h +++ b/retroshare-gui/src/gui/toaster/OnlineToaster.h @@ -20,54 +20,30 @@ #ifndef ONLINETOASTER_H #define ONLINETOASTER_H -#include "IQtToaster.h" - -#include -#include - -class QtToaster; - -class QWidget; -class QString; -class QPixmap; -namespace Ui { class OnlineToaster; } +#include "ui_OnlineToaster.h" /** * Shows a toaster when friend is Online . * * */ -class OnlineToaster : public QObject, public IQtToaster { +class OnlineToaster : public QWidget +{ Q_OBJECT + public: + OnlineToaster(const std::string &peerId, const QString &name, const QPixmap &avatar); - OnlineToaster(); - - ~OnlineToaster(); - - void setMessage(const QString & message); - - void setPixmap(const QPixmap & pixmap); - - void show(); - void play(); - -Q_SIGNALS: - - void chatButtonClicked(); - -private Q_SLOTS: - +private slots: void chatButtonSlot(); - void close(); - private: - Ui::OnlineToaster * _ui; + void play(); - QWidget * _onlineToasterWidget; + std::string peerId; - QtToaster * _toaster; + /** Qt Designer generated object */ + Ui::OnlineToaster ui; }; #endif //MESSAGETOASTER_H diff --git a/retroshare-gui/src/gui/toaster/QtToaster.cpp b/retroshare-gui/src/gui/toaster/QtToaster.cpp deleted file mode 100644 index c0ed0f4a8..000000000 --- a/retroshare-gui/src/gui/toaster/QtToaster.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2006,2007 crypton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#include "QtToaster.h" - - -#include - -#include - -static const unsigned TIME_TO_SHOW = 20; - -QtToaster::QtToaster(QObject *master, QWidget * toaster, QFrame * toasterWindowFrame) - : QObject(toaster) { - - _timer = NULL; - _show = true; - - _toaster = toaster; - _toaster->setParent(_toaster->parentWidget(), Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - - _toaster->setWindowFlags(_toaster->windowFlags() | Qt::ToolTip); - _toaster->setAttribute ( Qt::WA_DeleteOnClose, true ); - - _master = master; - if (toasterWindowFrame) { - WidgetBackgroundImage::setBackgroundImage(toasterWindowFrame, ":images/toaster/toaster-backrs4.png", WidgetBackgroundImage::AdjustSize); - } - - _toaster->resize(184, 128); -} - -QtToaster::~QtToaster() -{ - if (_master) { - delete (_master); - } -} - -void QtToaster::setTimeOnTop(unsigned time) { - _timeOnTop = time; -} - -void QtToaster::close() { - if (_timer) { - _timer->stop(); - } - _toaster->close(); - - delete (this); -} - -void QtToaster::show() { - //10 pixels of margin -#if !defined(OS_WINDOWS) - static const int MARGIN_X = 30; -#else - static const int MARGIN_X = 10; -#endif - - QDesktopWidget * desktop = QApplication::desktop(); - QRect screenGeometry = desktop->screenGeometry(desktop->primaryScreen()); - - _toaster->move(screenGeometry.right() - _toaster->size().width() - MARGIN_X, screenGeometry.bottom()); - - _toaster->show(); - - _timer = new QTimer(this); - connect(_timer, SIGNAL(timeout()), SLOT(changeToasterPosition())); - _timer->start(TIME_TO_SHOW); -} - -void QtToaster::changeToasterPosition() { - QDesktopWidget * desktop = QApplication::desktop(); - QPoint p = _toaster->pos(); - - //Toaster is showing slowly - if (_show) { - _toaster->move(p.x(), p.y() - 3); - - QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen()); - - if (p.y() < (desktopGeometry.bottom() - _toaster->size().height() - 5)) { - //Toaster should be hidden now - _show = false; - _timer->stop(); - //Waits 5 seconds with the toaster on top - _timer->start(_timeOnTop); - } - } - - //Toaster is hiding slowly - else { - _toaster->move(p.x(), p.y() + 3); - - QRect screenGeometry = desktop->screenGeometry(desktop->primaryScreen()); - - _timer->stop(); - _timer->start(TIME_TO_SHOW); - - if (p.y() > (screenGeometry.bottom())) { - //Closes the toaster -> hide it completely - close(); - } - } -} diff --git a/retroshare-gui/src/gui/toaster/QtToaster.h b/retroshare-gui/src/gui/toaster/QtToaster.h deleted file mode 100644 index ac1987c62..000000000 --- a/retroshare-gui/src/gui/toaster/QtToaster.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2006,2007 crypton - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -#ifndef QTTOASTER_H -#define QTTOASTER_H - -#include - -class QWidget; -class QTimer; -class QFrame; - -/** - * This class codes the algorithm that show/hide the toaster. - * - * This class helps factorizing the code between QtCallToaster and QtChatToaster. - * - * - */ -class QtToaster : public QObject { - Q_OBJECT -public: - - QtToaster(QObject *master, QWidget * toaster, QFrame * toasterWindowFrame); - ~QtToaster(); - - /** - * Sets the time with the toaster on top. - * - * @param time time toaster on top in milliseconds - */ - void setTimeOnTop(unsigned time); - - void show(); - - void close(); - -private Q_SLOTS: - - void changeToasterPosition(); - -private: - - QWidget * _toaster; - - QObject *_master; - - QTimer * _timer; - - bool _show; - - unsigned _timeOnTop; -}; - -#endif //QTTOASTER_H