From cc08fd5a955580860fbe1c2807431bcbc80df329 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sat, 10 May 2014 18:32:48 +0000 Subject: [PATCH] Added disable all toaster in status bar (Modified patch from Phenom) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7362 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MainWindow.cpp | 3 + retroshare-gui/src/gui/images.qrc | 6 +- .../src/gui/images/toasterDisable.png | Bin 0 -> 1444 bytes .../src/gui/images/toasterEnable.png | Bin 0 -> 1220 bytes retroshare-gui/src/gui/notifyqt.cpp | 57 ++++++++++------ retroshare-gui/src/gui/notifyqt.h | 4 ++ .../src/gui/settings/NotifyPage.cpp | 4 ++ retroshare-gui/src/gui/settings/NotifyPage.ui | 48 +++++++------- .../src/gui/statusbar/ToasterDisable.cpp | 61 ++++++++++++++++++ .../src/gui/statusbar/ToasterDisable.h | 43 ++++++++++++ retroshare-gui/src/retroshare-gui.pro | 26 ++++---- 11 files changed, 195 insertions(+), 57 deletions(-) create mode 100644 retroshare-gui/src/gui/images/toasterDisable.png create mode 100644 retroshare-gui/src/gui/images/toasterEnable.png create mode 100644 retroshare-gui/src/gui/statusbar/ToasterDisable.cpp create mode 100644 retroshare-gui/src/gui/statusbar/ToasterDisable.h diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 6b094a181..1e4d9321f 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -84,6 +84,7 @@ #include "statusbar/discstatus.h" #include "statusbar/OpModeStatus.h" #include "statusbar/SoundStatus.h" +#include "statusbar/ToasterDisable.h" #include #include @@ -276,6 +277,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) statusBar()->addPermanentWidget(new OpModeStatus()); statusBar()->addPermanentWidget(new SoundStatus()); + + statusBar()->addPermanentWidget(new ToasterDisable()); /** Status Bar end ******/ /* Creates a tray icon with a context menu and adds it to the system's * notification area. */ diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index b2fd8e102..c852170c5 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -1,5 +1,5 @@ - + images/add_chat24.png images/mail-encrypted-full.png images/decrypt-mail.png @@ -678,8 +678,10 @@ images/circles/circles_64.png images/newsfeed/news-feed-32.png images/newsfeed/news-feed-notify-32.png - images/share-icon-16.png + images/share-icon-16.png help/version.html images/view-certificate-sign-48.png + images/toasterEnable.png + images/toasterDisable.png diff --git a/retroshare-gui/src/gui/images/toasterDisable.png b/retroshare-gui/src/gui/images/toasterDisable.png new file mode 100644 index 0000000000000000000000000000000000000000..9e2fda0b1d8e160039dc288196b68b93dee07bf9 GIT binary patch literal 1444 zcmV;V1zY-wP){(f8V#SXPQO%M^NP%VQ{+w^{RIX(N__SxS&n8^%YptF+S z!C8*#G&{9b?nOv!3$UF+1d(n zzUyDt*Kwbw`&coXTQ=7{1X%NFlmtEqE=xl?^oN!et#&Y%MHFV)(A&CjRipf!A>eZO zmH8Pob*;bpE=yOG^F@L}j!;~3Ltov!K;p^Z+_^t5h^ zN1&8-(Un3<3r*Tol%O(ukwkQk-c`w811ov0m|}QGSVFZkiw{5~va- z&%+-}A?zJ&x&L7D{o`lPochO+@#7Ef-M9Ou+qPbMDgsdA(%(alShsRb)15KPCo^*q z!}pM77lfkX``B~qu^PKkUw*^K`=4jl&(KiYG1j)U`R47Z)Xi6EVq5X9-`tTe68xA! zDBT?2xqNvYrKw>|p|B$wj-il%{#-xW;bRQGyOR&kJxzW60oJAuiT*eKbcmVhQTkt? zPd9G+=-DUs0Ek!L2>9TE|IRTCv3~0>JCCfswuE?QjuHu4Ds!EGrl8C zqAH6K19U+qaTWf4i`0M{-{&fpff)(B*U8t23`!P#&A1+tKT!$mIz;d`F0` z?$xz7I;IbqQOxnvXfsoYn1*j_{PQc9K~rLB1w_I`(*>n>&U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h#_c&pfs~MA)ukj z6%3<;>Jd*d7&{6%{mnlHR!7df(`8@5ltU~B@ICM{VEd3?0*wZoydS za$rf&DMT@Q)>?GtIX<%-P i1$Pl}mi0TA1MoKplay(SOUND_MESSAGE_ARRIVED); - if (popupflags & RS_POPUP_MSG) + if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) { toaster = new Toaster(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message")))); } @@ -786,7 +801,7 @@ void NotifyQt::UpdateGUI() case RS_POPUP_MSG: soundManager->play(SOUND_MESSAGE_ARRIVED); - if (popupflags & RS_POPUP_MSG) + if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) { toaster = new Toaster(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); } @@ -794,7 +809,7 @@ void NotifyQt::UpdateGUI() case RS_POPUP_CONNECT: soundManager->play(SOUND_USER_ONLINE); - if (popupflags & RS_POPUP_CONNECT) + if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) { toaster = new Toaster(new OnlineToaster(RsPeerId(id))); } @@ -802,16 +817,16 @@ void NotifyQt::UpdateGUI() case RS_POPUP_DOWNLOAD: soundManager->play(SOUND_DOWNLOAD_COMPLETE); - if (popupflags & RS_POPUP_DOWNLOAD) + if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) { /* id = file hash */ - toaster = new Toaster(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); + toaster = new Toaster(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); } break; case RS_POPUP_CHAT: - if (popupflags & RS_POPUP_CHAT) + if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) { - ChatDialog *chatDialog = ChatDialog::getChat(RsPeerId(id), 0); + ChatDialog *chatDialog = ChatDialog::getChat(RsPeerId(id), 0); ChatWidget *chatWidget; if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { // do not show when active @@ -821,7 +836,7 @@ void NotifyQt::UpdateGUI() } break; case RS_POPUP_GROUPCHAT: - if (popupflags & RS_POPUP_GROUPCHAT) + if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) { MainWindow *mainWindow = MainWindow::getInstance(); if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { @@ -836,9 +851,9 @@ void NotifyQt::UpdateGUI() } break; case RS_POPUP_CHATLOBBY: - if (popupflags & RS_POPUP_CHATLOBBY) + if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) { - ChatDialog *chatDialog = ChatDialog::getChat(RsPeerId(id), 0); + ChatDialog *chatDialog = ChatDialog::getChat(RsPeerId(id), 0); ChatWidget *chatWidget; if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { // do not show when active @@ -853,7 +868,7 @@ void NotifyQt::UpdateGUI() } break; case RS_POPUP_CONNECT_ATTEMPT: - if (popupflags & RS_POPUP_CONNECT_ATTEMPT) + if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) { // id = gpgid // title = ssl name @@ -868,7 +883,7 @@ void NotifyQt::UpdateGUI() toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); /* add toaster to waiting list */ -// QMutexLocker lock(&waitingToasterMutex); + //QMutexLocker lock(&waitingToasterMutex); waitingToasterList.push_back(toaster); } } @@ -967,7 +982,7 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi toaster->margin = margin; /* add toaster to waiting list */ -// QMutexLocker lock(&waitingToasterMutex); + //QMutexLocker lock(&waitingToasterMutex); waitingToasterList.push_back(toaster); } } @@ -992,7 +1007,7 @@ void NotifyQt::notifySettingsChanged() void NotifyQt::startWaitingToasters() { { -// QMutexLocker lock(&waitingToasterMutex); + //QMutexLocker lock(&waitingToasterMutex); if (waitingToasterList.empty()) { /* No toasters are waiting */ @@ -1001,7 +1016,7 @@ void NotifyQt::startWaitingToasters() } { -// QMutexLocker lock(&runningToasterMutex); + //QMutexLocker lock(&runningToasterMutex); if (runningToasterList.size() >= 3) { /* Don't show more than 3 toasters at once */ @@ -1012,7 +1027,7 @@ void NotifyQt::startWaitingToasters() Toaster *toaster = NULL; { -// QMutexLocker lock(&waitingToasterMutex); + //QMutexLocker lock(&waitingToasterMutex); if (waitingToasterList.size()) { /* Take one toaster of the waiting list */ @@ -1022,7 +1037,7 @@ void NotifyQt::startWaitingToasters() } if (toaster) { -// QMutexLocker lock(&runningToasterMutex); + //QMutexLocker lock(&runningToasterMutex); /* Calculate positions */ QSize size = toaster->widget->size(); @@ -1069,7 +1084,7 @@ void NotifyQt::startWaitingToasters() void NotifyQt::runningTick() { -// QMutexLocker lock(&runningToasterMutex); + //QMutexLocker lock(&runningToasterMutex); int interval = runningToasterTimer->interval(); QPoint diff; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 475258d2d..d501a51d6 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -31,6 +31,7 @@ class NotifyQt: public QObject, public NotifyClient public: static NotifyQt *Create (); static NotifyQt *getInstance (); + static bool isAllDisable(); void enable() ; virtual ~NotifyQt() { return; } @@ -130,9 +131,11 @@ class NotifyQt: public QObject, public NotifyClient /* Notify from GUI */ void chatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType); void settingsChanged(); + void disableAllChanged(bool disableAll) const; public slots: void UpdateGUI(); /* called by timer */ + void SetDisableAll(bool bValue); private slots: void runningTick(); @@ -143,6 +146,7 @@ class NotifyQt: public QObject, public NotifyClient NotifyQt(); static NotifyQt *_instance; + static bool _disableAllToaster; /* system notifications */ diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 800ad3946..ecfe3974c 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -41,6 +41,8 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.notifyButton, SIGNAL(clicked()), this, SLOT(testNotify())); connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); + connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); + connect(NotifyQt::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool))); QFont font = ui.notify_Peers->font(); // use font from existing checkbox @@ -239,6 +241,8 @@ void NotifyPage::load() ui.addFeedsAtEnd->setChecked(Settings->getAddFeedsAtEnd()); + ui.pushButtonDisableAll->setChecked(NotifyQt::isAllDisable()); + RshareSettings::enumToasterPosition toasterPosition = Settings->getToasterPosition(); ui.comboBoxToasterPosition->clear(); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui index 2c786ef4a..f83021fc2 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.ui +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -19,22 +19,13 @@ News Feed - - 0 - - - 6 - - - 6 - - - 6 - - - 6 - - + + 0 + + + 6 + + @@ -174,12 +165,25 @@ - - - - - - Toasters + + + + + + Disable All Toaster temporaly + + + Disable All Toasters + + + true + + + + + + + Toasters diff --git a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp new file mode 100644 index 000000000..473b61c7e --- /dev/null +++ b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp @@ -0,0 +1,61 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2012 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 "ToasterDisable.h" +#include "gui/notifyqt.h" + +#define IMAGE_TOASTERDISABLE ":/images/toasterDisable.png" +#define IMAGE_TOASTERENABLE ":/images/toasterEnable.png" + +ToasterDisable::ToasterDisable(QWidget *parent) + : QWidget(parent) +{ + QHBoxLayout *hbox = new QHBoxLayout(this); + hbox->setMargin(0); + hbox->setSpacing(0); + + imageButton = new QPushButton(this); + imageButton->setFlat(true); + imageButton->setCheckable(true); + imageButton->setMaximumSize(24, 24); + imageButton->setFocusPolicy(Qt::ClickFocus); + hbox->addWidget(imageButton); + + setLayout(hbox); + + bool isDisable = NotifyQt::isAllDisable(); + imageButton->setChecked(isDisable); + + connect(NotifyQt::getInstance(), SIGNAL(disableAllChanged(bool)), this, SLOT(disable(bool))); + connect(imageButton, SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); + + disable(isDisable); +} + +void ToasterDisable::disable(bool isDisable) +{ + imageButton->setIcon(QIcon(isDisable ? IMAGE_TOASTERDISABLE : IMAGE_TOASTERENABLE)); + imageButton->setToolTip(isDisable ? tr("All Toasters are disable") : tr("Toasters are enable")); + imageButton->setChecked(isDisable); +} diff --git a/retroshare-gui/src/gui/statusbar/ToasterDisable.h b/retroshare-gui/src/gui/statusbar/ToasterDisable.h new file mode 100644 index 000000000..c504c9868 --- /dev/null +++ b/retroshare-gui/src/gui/statusbar/ToasterDisable.h @@ -0,0 +1,43 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2012 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. + ****************************************************************/ + +#ifndef TOASTERDISABLE_H +#define TOASTERDISABLE_H + +#include + +class QPushButton; + +class ToasterDisable : public QWidget +{ + Q_OBJECT + +public: + ToasterDisable(QWidget *parent = 0); + +private slots: + void disable(bool isDisable); + +private: + QPushButton *imageButton; +}; + +#endif diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 4d86940bf..1829a0452 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -470,12 +470,13 @@ HEADERS += rshare.h \ gui/statusbar/dhtstatus.h \ gui/statusbar/ratesstatus.h \ gui/statusbar/hashingstatus.h \ - gui/statusbar/discstatus.h \ - gui/statusbar/SoundStatus.h \ - gui/statusbar/OpModeStatus.h \ - gui/advsearch/advancedsearchdialog.h \ - gui/advsearch/expressionwidget.h \ - gui/advsearch/guiexprelement.h \ + gui/statusbar/discstatus.h \ + gui/statusbar/SoundStatus.h \ + gui/statusbar/OpModeStatus.h \ + gui/statusbar/ToasterDisable.h \ + gui/advsearch/advancedsearchdialog.h \ + gui/advsearch/expressionwidget.h \ + gui/advsearch/guiexprelement.h \ gui/elastic/graphwidget.h \ gui/elastic/edge.h \ gui/elastic/arrow.h \ @@ -780,12 +781,13 @@ SOURCES += main.cpp \ gui/statusbar/dhtstatus.cpp \ gui/statusbar/ratesstatus.cpp \ gui/statusbar/hashingstatus.cpp \ - gui/statusbar/discstatus.cpp \ - gui/statusbar/SoundStatus.cpp \ - gui/statusbar/OpModeStatus.cpp \ - gui/toaster/MessageToaster.cpp \ - gui/toaster/DownloadToaster.cpp \ - gui/toaster/OnlineToaster.cpp \ + gui/statusbar/discstatus.cpp \ + gui/statusbar/SoundStatus.cpp \ + gui/statusbar/OpModeStatus.cpp \ + gui/statusbar/ToasterDisable.cpp \ + gui/toaster/MessageToaster.cpp \ + gui/toaster/DownloadToaster.cpp \ + gui/toaster/OnlineToaster.cpp \ gui/toaster/ChatToaster.cpp \ gui/toaster/GroupChatToaster.cpp \ gui/toaster/ChatLobbyToaster.cpp \