diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 52e15f359..9d88a5b93 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -52,6 +52,10 @@ * #define NOTIFY_DEBUG ****/ +#define TOASTER_MARGIN_X 10 // 10 pixels of x margin +#define TOASTER_MARGIN_Y 10 // 10 pixels of y margin + + class Toaster { public: @@ -584,30 +588,23 @@ void NotifyQt::startWaitingToasters() } 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); + toaster->startPos = QPoint(desktopGeometry.right() - size.width() - TOASTER_MARGIN_X, desktopGeometry.bottom()); + toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - TOASTER_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); +// toaster->startPos = QPoint(desktopGeometry.right() - size.width() - TOASTER_MARGIN_X, desktopGeometry.top() - size.height()); +// toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + TOASTER_MARGIN_Y); /* Initialize widget */ toaster->widget->move(toaster->startPos); - toaster->widget->show(); /* Initialize toaster */ toaster->elapsedTimeToShow = 0; @@ -627,6 +624,9 @@ void NotifyQt::runningTick() { // QMutexLocker lock(&runningToasterMutex); + QDesktopWidget *desktop = QApplication::desktop(); + QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen()); + int interval = runningToasterTimer->interval(); QPoint diff; @@ -634,33 +634,42 @@ void NotifyQt::runningTick() while (it != runningToasterList.end()) { Toaster *toaster = *it; - bool visible = toaster->widget->isVisible(); + bool visible = true; + if (toaster->elapsedTimeToShow) { + /* Toaster is started, check for visible */ + visible = toaster->widget->isVisible(); + } + + QPoint newPos; + enum { NOTHING, SHOW, HIDE } operation = NOTHING; if (visible && toaster->elapsedTimeToShow <= toaster->timeToShow) { /* Toaster is showing */ + if (toaster->elapsedTimeToShow == 0) { + /* Toaster is not visible, show it now */ + operation = SHOW; + } + 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; + newPos = QPoint(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); } else if (visible && toaster->elapsedTimeToLive <= toaster->timeToLive) { /* Toaster is living */ toaster->elapsedTimeToLive += interval; - toaster->widget->move(toaster->endPos + diff); - - diff += toaster->endPos - toaster->startPos; + newPos = toaster->endPos; } 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); + if (toaster->elapsedTimeToHide == toaster->timeToHide) { + /* Toaster is back at the start position, hide it */ + operation = HIDE; + } - diff += newPos - toaster->startPos; + newPos = QPoint(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); } else { /* Toaster is hidden, delete it */ it = runningToasterList.erase(it); @@ -669,6 +678,23 @@ void NotifyQt::runningTick() continue; } + toaster->widget->move(newPos + diff); + diff += newPos - toaster->startPos; + + /* This is only correct when moving the toaster from bottom */ + toaster->widget->setMask(QRegion(0, 0, toaster->widget->width(), qAbs(toaster->startPos.y() - newPos.y()))); + + switch (operation) { + case NOTHING: + break; + case SHOW: + toaster->widget->show(); + break; + case HIDE: + toaster->widget->hide(); + break; + } + ++it; } diff --git a/retroshare-gui/src/gui/toaster/ForumsToaster.cpp b/retroshare-gui/src/gui/toaster/ForumsToaster.cpp deleted file mode 100644 index db406d645..000000000 --- a/retroshare-gui/src/gui/toaster/ForumsToaster.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * RetroShare - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ForumsToaster.h" - -#include "ui_ForumsToaster.h" - -#include "QtToaster.h" - -#include - -ForumsToaster::ForumsToaster() - : QObject(NULL) { - - _ForumsToasterWidget = new QWidget(NULL); - - _ui = new Ui::ForumsToaster(); - _ui->setupUi(_ForumsToasterWidget); - - connect(_ui->messageButton, SIGNAL(clicked()), SLOT(chatButtonSlot())); - - connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close())); - - _toaster = new QtToaster(this, _ForumsToasterWidget, _ui->windowFrame); - _toaster->setTimeOnTop(5000); -} - -ForumsToaster::~ForumsToaster() { - delete _ui; -} - -void ForumsToaster::setMessage(const QString & message) { - _ui->messageLabel->setText(message); -} - -void ForumsToaster::setPixmap(const QPixmap & pixmap) { - _ui->pixmaplabel->setPixmap(pixmap); -} - -void ForumsToaster::show() { - _toaster->show(); -} - -void ForumsToaster::close() { - _toaster->close(); -} - -void ForumsToaster::chatButtonSlot() { - chatButtonClicked(); - close(); -} diff --git a/retroshare-gui/src/gui/toaster/ForumsToaster.h b/retroshare-gui/src/gui/toaster/ForumsToaster.h deleted file mode 100644 index ea5514561..000000000 --- a/retroshare-gui/src/gui/toaster/ForumsToaster.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * RetroShare - * Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef FORUMSTOASTER_H -#define FORUMSTOASTER_H - -#include "IQtToaster.h" - -#include - -class QtToaster; - -class QWidget; -class QString; -class QPixmap; -namespace Ui { class ForumsToaster; } - -/** - * Shows a toaster when friend is Forums . - * - * - */ -class ForumsToaster : public QObject, public IQtToaster { - Q_OBJECT -public: - - ForumsToaster(); - - ~ForumsToaster(); - - void setMessage(const QString & message); - - void setPixmap(const QPixmap & pixmap); - - void show(); - -Q_SIGNALS: - - void chatButtonClicked(); - -private Q_SLOTS: - - void chatButtonSlot(); - - void close(); - -private: - - Ui::ForumsToaster * _ui; - - QWidget * _ForumsToasterWidget; - - QtToaster * _toaster; -}; - -#endif //FORUMSTOASTER_H diff --git a/retroshare-gui/src/gui/toaster/ForumsToaster.ui b/retroshare-gui/src/gui/toaster/ForumsToaster.ui deleted file mode 100644 index 268e17212..000000000 --- a/retroshare-gui/src/gui/toaster/ForumsToaster.ui +++ /dev/null @@ -1,274 +0,0 @@ - - GroupChatToaster - - - - 0 - 0 - 388 - 168 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 18 - 18 - - - - - 18 - 18 - - - - :/images/close-down.png - - - - 16 - 16 - - - - true - - - - - - - Qt::Horizontal - - - - 225 - 22 - - - - - - - - - - 4 - - - 4 - - - 0 - - - 0 - - - - - - 74 - 74 - - - - - 74 - 74 - - - - border-image: url(:/images/avatar_background.png); - - - - - - :/images/konversation128.png - - - true - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 121 - 20 - - - - - - - - - - - color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #49881F, stop: 1 #49881F ); - - - New Forum Message - - - - - - - Qt::Horizontal - - - - 121 - 20 - - - - - - - - - - 6 - - - - - Qt::Horizontal - - - - 81 - 20 - - - - - - - - - - - - - - - Qt::Horizontal - - - - 131 - 20 - - - - - - - - - - Qt::Vertical - - - - 384 - 61 - - - - - - - - - - - messageButton - closeButton - - - - - - diff --git a/retroshare-gui/src/gui/toaster/GroupChatToaster.cpp b/retroshare-gui/src/gui/toaster/GroupChatToaster.cpp deleted file mode 100644 index c53f53001..000000000 --- a/retroshare-gui/src/gui/toaster/GroupChatToaster.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * RetroShare - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "GroupChatToaster.h" - -#include "ui_GroupChatToaster.h" - -#include "QtToaster.h" - -#include - -GroupChatToaster::GroupChatToaster() - : QObject(NULL) { - - _GroupChatToasterWidget = new QWidget(NULL); - - _ui = new Ui::GroupChatToaster(); - _ui->setupUi(_GroupChatToasterWidget); - - connect(_ui->messageButton, SIGNAL(clicked()), SLOT(chatButtonSlot())); - - connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close())); - - _toaster = new QtToaster(this, _GroupChatToasterWidget, _ui->windowFrame); - _toaster->setTimeOnTop(5000); -} - -GroupChatToaster::~GroupChatToaster() { - delete _ui; -} - -void GroupChatToaster::setMessage(const QString & message) { - _ui->messageLabel->setText(message); -} - -void GroupChatToaster::setPixmap(const QPixmap & pixmap) { - _ui->pixmaplabel->setPixmap(pixmap); -} - -void GroupChatToaster::show() { - _toaster->show(); -} - -void GroupChatToaster::close() { - _toaster->close(); -} - -void GroupChatToaster::chatButtonSlot() { - chatButtonClicked(); - close(); -} diff --git a/retroshare-gui/src/gui/toaster/GroupChatToaster.h b/retroshare-gui/src/gui/toaster/GroupChatToaster.h deleted file mode 100644 index c9e7d672f..000000000 --- a/retroshare-gui/src/gui/toaster/GroupChatToaster.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * RetroShare - * Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef GROUPCHATTOASTER_H -#define GROUPCHATTOASTER_H - -#include "IQtToaster.h" - -#include - -class QtToaster; - -class QWidget; -class QString; -class QPixmap; -namespace Ui { class GroupChatToaster; } - -/** - * Shows a toaster when friend is GroupChat . - * - * - */ -class GroupChatToaster : public QObject, public IQtToaster { - Q_OBJECT -public: - - GroupChatToaster(); - - ~GroupChatToaster(); - - void setMessage(const QString & message); - - void setPixmap(const QPixmap & pixmap); - - void show(); - -Q_SIGNALS: - - void chatButtonClicked(); - -private Q_SLOTS: - - void chatButtonSlot(); - - void close(); - -private: - - Ui::GroupChatToaster * _ui; - - QWidget * _GroupChatToasterWidget; - - QtToaster * _toaster; -}; - -#endif //GROUPCHATTOASTER_H diff --git a/retroshare-gui/src/gui/toaster/GroupChatToaster.ui b/retroshare-gui/src/gui/toaster/GroupChatToaster.ui deleted file mode 100644 index 17856b9aa..000000000 --- a/retroshare-gui/src/gui/toaster/GroupChatToaster.ui +++ /dev/null @@ -1,268 +0,0 @@ - - GroupChatToaster - - - - 0 - 0 - 388 - 168 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 18 - 18 - - - - - 18 - 18 - - - - :/images/close-down.png - - - true - - - - - - - Qt::Horizontal - - - - 225 - 22 - - - - - - - - - - 4 - - - 4 - - - 0 - - - 0 - - - - - - 74 - 74 - - - - - 74 - 74 - - - - border-image: url(:/images/avatar_background.png); - - - - - - :/images/user/agt_forum128.png - - - true - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 121 - 20 - - - - - - - - - - - color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #49881F, stop: 1 #49881F ); - - - New GroupChat Message - - - - - - - Qt::Horizontal - - - - 121 - 20 - - - - - - - - - - 6 - - - - - Qt::Horizontal - - - - 81 - 20 - - - - - - - - - - - - - - - Qt::Horizontal - - - - 131 - 20 - - - - - - - - - - Qt::Vertical - - - - 384 - 61 - - - - - - - - - - - messageButton - closeButton - - - - - - diff --git a/retroshare-gui/src/gui/toaster/RetroStyleLabelProxy.h b/retroshare-gui/src/gui/toaster/RetroStyleLabelProxy.h deleted file mode 100644 index 2d02fb41a..000000000 --- a/retroshare-gui/src/gui/toaster/RetroStyleLabelProxy.h +++ /dev/null @@ -1,22 +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