mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-17 17:43:59 -05:00
Reworked notification code in system tray.
Added a base class and a possibility for the main dialogs and the plugins (derived from MainPage) to provide a notifier. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5381 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
049b4bd577
commit
b21e66241b
30 changed files with 1040 additions and 539 deletions
|
|
@ -27,7 +27,7 @@
|
|||
#include "rsharesettings.h"
|
||||
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
#include "gui/common/UserNotify.h"
|
||||
|
||||
/** Constructor */
|
||||
NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
|
||||
|
|
@ -36,11 +36,30 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
|
|||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.trayNotify_PrivateChat, SIGNAL(toggled(bool)), this, SLOT(privatChatToggled()));
|
||||
connect(ui.trayNotify_Messages, SIGNAL(toggled(bool)), this, SLOT(privatChatToggled()));
|
||||
connect(ui.trayNotify_Channels, SIGNAL(toggled(bool)), this, SLOT(privatChatToggled()));
|
||||
connect(ui.trayNotify_Forums, SIGNAL(toggled(bool)), this, SLOT(privatChatToggled()));
|
||||
connect(ui.trayNotify_Transfer, SIGNAL(toggled(bool)), this, SLOT(privatChatToggled()));
|
||||
/* add user notify */
|
||||
QFont font = ui.notify_Peers->font(); // use font from existing checkbox
|
||||
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
|
||||
QList<UserNotify*>::const_iterator it;
|
||||
int row = 0;
|
||||
for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) {
|
||||
UserNotify *userNotify = *it;
|
||||
|
||||
QString name;
|
||||
if (!userNotify->hasSetting(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
|
||||
enabledCheckBox->setFont(font);
|
||||
ui.notifyLayout->addWidget(enabledCheckBox, row, 0, 0);
|
||||
connect(enabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(notifyToggled()));
|
||||
|
||||
QCheckBox *combinedCheckBox = new QCheckBox(tr("Combined"), this);
|
||||
combinedCheckBox->setFont(font);
|
||||
ui.notifyLayout->addWidget(combinedCheckBox, row++, 1);
|
||||
|
||||
mUserNotifySettingList.push_back(UserNotifySetting(userNotify, enabledCheckBox, combinedCheckBox));
|
||||
}
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
|
@ -59,7 +78,6 @@ NotifyPage::save(QString &/*errmsg*/)
|
|||
/* extract from rsNotify the flags */
|
||||
|
||||
uint notifyflags = 0;
|
||||
uint traynotifyflags = 0;
|
||||
uint newsflags = 0;
|
||||
uint chatflags = 0;
|
||||
uint messageflags = 0;
|
||||
|
|
@ -103,33 +121,16 @@ NotifyPage::save(QString &/*errmsg*/)
|
|||
if (ui.chat_tabbedWindow->isChecked())
|
||||
chatflags |= RS_CHAT_TABBED_WINDOW;
|
||||
|
||||
if (ui.trayNotify_PrivateChat->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_PRIVATECHAT;
|
||||
if (ui.trayNotify_Messages->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_MESSAGES;
|
||||
if (ui.trayNotify_Channels->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_CHANNELS;
|
||||
if (ui.trayNotify_Forums->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_FORUMS;
|
||||
if (ui.trayNotify_Transfer->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_TRANSFERS;
|
||||
|
||||
if (ui.trayNotify_PrivateChatCombined->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_PRIVATECHAT_COMBINED;
|
||||
if (ui.trayNotify_MessagesCombined->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_MESSAGES_COMBINED;
|
||||
if (ui.trayNotify_ChannelsCombined->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_CHANNELS_COMBINED;
|
||||
if (ui.trayNotify_ForumsCombined->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_FORUMS_COMBINED;
|
||||
if (ui.trayNotify_TransferCombined->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_TRANSFERS_COMBINED;
|
||||
|
||||
if (ui.message_ConnectAttempt->isChecked())
|
||||
messageflags |= RS_MESSAGE_CONNECT_ATTEMPT;
|
||||
|
||||
/* save user notify */
|
||||
QList<UserNotifySetting>::iterator notifyIt;
|
||||
for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) {
|
||||
notifyIt->mUserNotify->setNotifyEnabled(notifyIt->mEnabledCheckBox->isChecked(), notifyIt->mCombinedCheckBox->isChecked());
|
||||
}
|
||||
|
||||
Settings->setNotifyFlags(notifyflags);
|
||||
Settings->setTrayNotifyFlags(traynotifyflags);
|
||||
Settings->setNewsFeedFlags(newsflags);
|
||||
Settings->setChatFlags(chatflags);
|
||||
Settings->setMessageFlags(messageflags);
|
||||
|
|
@ -152,13 +153,11 @@ NotifyPage::save(QString &/*errmsg*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void NotifyPage::load()
|
||||
{
|
||||
/* extract from rsNotify the flags */
|
||||
uint notifyflags = Settings->getNotifyFlags();
|
||||
uint traynotifyflags = Settings->getTrayNotifyFlags();
|
||||
uint newsflags = Settings->getNewsFeedFlags();
|
||||
uint chatflags = Settings->getChatFlags();
|
||||
uint messageflags = Settings->getMessageFlags();
|
||||
|
|
@ -189,18 +188,6 @@ void NotifyPage::load()
|
|||
ui.systray_GroupChat->setChecked(Settings->getDisplayTrayGroupChat());
|
||||
ui.systray_ChatLobby->setChecked(Settings->getDisplayTrayChatLobby());
|
||||
|
||||
ui.trayNotify_PrivateChat->setChecked(traynotifyflags & TRAYNOTIFY_PRIVATECHAT);
|
||||
ui.trayNotify_Messages->setChecked(traynotifyflags & TRAYNOTIFY_MESSAGES);
|
||||
ui.trayNotify_Channels->setChecked(traynotifyflags & TRAYNOTIFY_CHANNELS);
|
||||
ui.trayNotify_Forums->setChecked(traynotifyflags & TRAYNOTIFY_FORUMS);
|
||||
ui.trayNotify_Transfer->setChecked(traynotifyflags & TRAYNOTIFY_TRANSFERS);
|
||||
|
||||
ui.trayNotify_PrivateChatCombined->setChecked(traynotifyflags & TRAYNOTIFY_PRIVATECHAT_COMBINED);
|
||||
ui.trayNotify_MessagesCombined->setChecked(traynotifyflags & TRAYNOTIFY_MESSAGES_COMBINED);
|
||||
ui.trayNotify_ChannelsCombined->setChecked(traynotifyflags & TRAYNOTIFY_CHANNELS_COMBINED);
|
||||
ui.trayNotify_ForumsCombined->setChecked(traynotifyflags & TRAYNOTIFY_FORUMS_COMBINED);
|
||||
ui.trayNotify_TransferCombined->setChecked(traynotifyflags & TRAYNOTIFY_TRANSFERS_COMBINED);
|
||||
|
||||
ui.addFeedsAtEnd->setChecked(Settings->getAddFeedsAtEnd());
|
||||
|
||||
RshareSettings::enumToasterPosition toasterPosition = Settings->getToasterPosition();
|
||||
|
|
@ -226,25 +213,25 @@ void NotifyPage::load()
|
|||
ui.spinBoxToasterXMargin->setValue(margin.x());
|
||||
ui.spinBoxToasterYMargin->setValue(margin.y());
|
||||
|
||||
privatChatToggled();
|
||||
/* load user notify */
|
||||
QList<UserNotifySetting>::iterator notifyIt;
|
||||
for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) {
|
||||
notifyIt->mEnabledCheckBox->setChecked(notifyIt->mUserNotify->notifyEnabled());
|
||||
notifyIt->mCombinedCheckBox->setChecked(notifyIt->mUserNotify->notifyCombined());
|
||||
}
|
||||
|
||||
notifyToggled();
|
||||
}
|
||||
|
||||
void NotifyPage::privatChatToggled()
|
||||
void NotifyPage::notifyToggled()
|
||||
{
|
||||
QList<QPair<QCheckBox*, QCheckBox*> > checkboxes;
|
||||
checkboxes << qMakePair(ui.trayNotify_PrivateChat, ui.trayNotify_PrivateChatCombined)
|
||||
<< qMakePair(ui.trayNotify_Messages, ui.trayNotify_MessagesCombined)
|
||||
<< qMakePair(ui.trayNotify_Channels, ui.trayNotify_ChannelsCombined)
|
||||
<< qMakePair(ui.trayNotify_Forums, ui.trayNotify_ForumsCombined)
|
||||
<< qMakePair(ui.trayNotify_Transfer, ui.trayNotify_TransferCombined);
|
||||
|
||||
QList<QPair<QCheckBox*, QCheckBox*> >::iterator checkboxIt;
|
||||
for (checkboxIt = checkboxes.begin(); checkboxIt != checkboxes.end(); checkboxIt++) {
|
||||
if (checkboxIt->first->isChecked()) {
|
||||
checkboxIt->second->setEnabled(true);
|
||||
QList<UserNotifySetting>::iterator notifyIt;
|
||||
for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) {
|
||||
if (notifyIt->mEnabledCheckBox->isChecked()) {
|
||||
notifyIt->mCombinedCheckBox->setEnabled(true);
|
||||
} else {
|
||||
checkboxIt->second->setChecked(false);
|
||||
checkboxIt->second->setEnabled(false);
|
||||
notifyIt->mCombinedCheckBox->setChecked(false);
|
||||
notifyIt->mCombinedCheckBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue