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
This commit is contained in:
thunder2 2014-05-10 18:32:48 +00:00
parent 995d63c979
commit cc08fd5a95
11 changed files with 195 additions and 57 deletions

View File

@ -84,6 +84,7 @@
#include "statusbar/discstatus.h"
#include "statusbar/OpModeStatus.h"
#include "statusbar/SoundStatus.h"
#include "statusbar/ToasterDisable.h"
#include <retroshare/rsstatus.h>
#include <retroshare/rsiface.h>
@ -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. */

View File

@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/" >
<qresource prefix="/">
<file>images/add_chat24.png</file>
<file>images/mail-encrypted-full.png</file>
<file>images/decrypt-mail.png</file>
@ -678,8 +678,10 @@
<file>images/circles/circles_64.png</file>
<file>images/newsfeed/news-feed-32.png</file>
<file>images/newsfeed/news-feed-notify-32.png</file>
<file>images/share-icon-16.png</file>
<file>images/share-icon-16.png</file>
<file>help/version.html</file>
<file>images/view-certificate-sign-48.png</file>
<file>images/toasterEnable.png</file>
<file>images/toasterDisable.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -96,6 +96,7 @@ public:
};
/*static*/ NotifyQt *NotifyQt::_instance = NULL;
/*static*/ bool NotifyQt::_disableAllToaster = false;
/*static*/ NotifyQt *NotifyQt::Create ()
{
@ -111,6 +112,20 @@ public:
return _instance;
}
/*static*/ bool NotifyQt::isAllDisable ()
{
return _disableAllToaster;
}
void NotifyQt::SetDisableAll(bool bValue)
{
if (bValue!=_disableAllToaster)
{
_disableAllToaster=bValue;
emit disableAllChanged(bValue);
}
}
NotifyQt::NotifyQt() : cDialog(NULL)
{
runningToasterTimer = new QTimer(this);
@ -141,9 +156,9 @@ void NotifyQt::notifyOwnAvatarChanged()
return ;
}
#ifdef NOTIFY_DEBUG
#ifdef NOTIFY_DEBUG
std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ;
#endif
#endif
emit ownAvatarChanged() ;
}
@ -726,7 +741,7 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/)
/* New Timer Based Update scheme ...
* means correct thread seperation
*
* uses Flags, to detect changes
* uses Flags, to detect changes
*/
void NotifyQt::enable()
@ -778,7 +793,7 @@ void NotifyQt::UpdateGUI()
case RS_POPUP_ENCRYPTED_MSG:
soundManager->play(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;

View File

@ -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 */

View File

@ -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();

View File

@ -19,22 +19,13 @@
<string>News Feed</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="notify_Peers">
@ -174,12 +165,25 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Toasters</string>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButtonDisableAll">
<property name="toolTip">
<string>Disable All Toaster temporaly</string>
</property>
<property name="text">
<string>Disable All Toasters</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Toasters</string>
</property>
<layout class="QVBoxLayout">
<property name="leftMargin">

View File

@ -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 <QHBoxLayout>
#include <QPushButton>
#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);
}

View File

@ -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 <QWidget>
class QPushButton;
class ToasterDisable : public QWidget
{
Q_OBJECT
public:
ToasterDisable(QWidget *parent = 0);
private slots:
void disable(bool isDisable);
private:
QPushButton *imageButton;
};
#endif

View File

@ -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 \