2009-07-23 13:11:51 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 - 2009 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
|
2009-08-19 18:15:16 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2009-07-23 13:11:51 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <rshare.h>
|
|
|
|
#include "NotifyPage.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsnotify.h>
|
2010-05-11 16:02:52 -04:00
|
|
|
#include "rsharesettings.h"
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
#include "gui/MainWindow.h"
|
|
|
|
|
2009-07-23 13:11:51 -04:00
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
|
2009-08-19 18:15:16 -04:00
|
|
|
: ConfigPage(parent, flags)
|
2009-07-23 13:11:51 -04:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
setAttribute(Qt::WA_QuitOnClose, false);
|
|
|
|
setWindowTitle(windowTitle() + QLatin1String(" - Notify"));
|
2009-08-19 18:15:16 -04:00
|
|
|
|
2009-07-23 13:11:51 -04:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-05-07 19:58:17 -04:00
|
|
|
NotifyPage::~NotifyPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-07-23 13:11:51 -04:00
|
|
|
void
|
|
|
|
NotifyPage::closeEvent (QCloseEvent * event)
|
|
|
|
{
|
|
|
|
QWidget::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Saves the changes on this page */
|
|
|
|
bool
|
|
|
|
NotifyPage::save(QString &errmsg)
|
|
|
|
{
|
2010-06-15 12:51:48 -04:00
|
|
|
/* extract from rsNotify the flags */
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
uint notifyflags = 0;
|
2010-10-07 17:50:15 -04:00
|
|
|
uint traynotifyflags = 0;
|
2010-06-15 12:51:48 -04:00
|
|
|
uint newsflags = 0;
|
|
|
|
uint chatflags = 0;
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
if (ui.popup_Connect->isChecked())
|
|
|
|
notifyflags |= RS_POPUP_CONNECT;
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
if (ui.popup_NewMsg->isChecked())
|
|
|
|
notifyflags |= RS_POPUP_MSG;
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
//if (ui.popup_NewChat->isChecked())
|
|
|
|
notifyflags |= RS_POPUP_CHAT;
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
//if (ui.popup_Call->isChecked())
|
|
|
|
// notifyflags |= RS_POPUP_CALL;
|
2009-07-23 13:11:51 -04:00
|
|
|
|
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
if (ui.notify_Peers->isChecked())
|
|
|
|
newsflags |= RS_FEED_TYPE_PEER;
|
|
|
|
if (ui.notify_Channels->isChecked())
|
|
|
|
newsflags |= RS_FEED_TYPE_CHAN;
|
|
|
|
if (ui.notify_Forums->isChecked())
|
|
|
|
newsflags |= RS_FEED_TYPE_FORUM;
|
|
|
|
if (ui.notify_Blogs->isChecked())
|
|
|
|
newsflags |= RS_FEED_TYPE_BLOG;
|
|
|
|
if (ui.notify_Chat->isChecked())
|
|
|
|
newsflags |= RS_FEED_TYPE_CHAT;
|
|
|
|
if (ui.notify_Messages->isChecked())
|
|
|
|
newsflags |= RS_FEED_TYPE_MSG;
|
2010-08-31 13:13:52 -04:00
|
|
|
if (ui.notify_Chat->isChecked())
|
|
|
|
newsflags |= RS_FEED_TYPE_CHAT;
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
if (ui.chat_NewWindow->isChecked())
|
2010-11-13 16:53:06 -05:00
|
|
|
chatflags |= RS_CHAT_OPEN;
|
2010-06-15 12:51:48 -04:00
|
|
|
if (ui.chat_Focus->isChecked())
|
|
|
|
chatflags |= RS_CHAT_FOCUS;
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-10-07 17:50:15 -04:00
|
|
|
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;
|
|
|
|
|
2010-06-15 07:34:58 -04:00
|
|
|
Settings->setNotifyFlags(notifyflags);
|
2010-10-07 17:50:15 -04:00
|
|
|
Settings->setTrayNotifyFlags(traynotifyflags);
|
2010-06-15 07:34:58 -04:00
|
|
|
Settings->setNewsFeedFlags(newsflags);
|
|
|
|
Settings->setChatFlags(chatflags);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
Settings->setDisplayTrayGroupChat(ui.systray_GroupChat->isChecked());
|
|
|
|
MainWindow::installGroupChatNotifier();
|
|
|
|
|
2010-09-01 16:54:24 -04:00
|
|
|
Settings->setAddFeedsAtEnd(ui.addFeedsAtEnd->isChecked());
|
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
load();
|
|
|
|
return true;
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Loads the settings for this page */
|
|
|
|
void NotifyPage::load()
|
|
|
|
{
|
2010-06-15 12:51:48 -04:00
|
|
|
/* extract from rsNotify the flags */
|
2010-06-15 07:34:58 -04:00
|
|
|
uint notifyflags = Settings->getNotifyFlags();
|
2010-10-07 17:50:15 -04:00
|
|
|
uint traynotifyflags = Settings->getTrayNotifyFlags();
|
2010-06-15 07:34:58 -04:00
|
|
|
uint newsflags = Settings->getNewsFeedFlags();
|
|
|
|
uint chatflags = Settings->getChatFlags();
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT);
|
|
|
|
ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG);
|
2010-06-15 07:34:58 -04:00
|
|
|
//ui.popup_NewChat->setChecked(notifyflags & RS_POPUP_CHAT);
|
2010-06-15 12:51:48 -04:00
|
|
|
//ui.popup_Call->setChecked(notifyflags & RS_POPUP_CALL);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
ui.notify_Peers->setChecked(newsflags & RS_FEED_TYPE_PEER);
|
|
|
|
ui.notify_Channels->setChecked(newsflags & RS_FEED_TYPE_CHAN);
|
|
|
|
ui.notify_Forums->setChecked(newsflags & RS_FEED_TYPE_FORUM);
|
|
|
|
ui.notify_Blogs->setChecked(newsflags & RS_FEED_TYPE_BLOG);
|
|
|
|
ui.notify_Chat->setChecked(newsflags & RS_FEED_TYPE_CHAT);
|
|
|
|
ui.notify_Messages->setChecked(newsflags & RS_FEED_TYPE_MSG);
|
2010-08-31 13:13:52 -04:00
|
|
|
ui.notify_Chat->setChecked(newsflags & RS_FEED_TYPE_CHAT);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-11-13 16:53:06 -05:00
|
|
|
ui.chat_NewWindow->setChecked(chatflags & RS_CHAT_OPEN);
|
2010-06-15 12:51:48 -04:00
|
|
|
ui.chat_Focus->setChecked(chatflags & RS_CHAT_FOCUS);
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
ui.systray_GroupChat->setChecked(Settings->getDisplayTrayGroupChat());
|
2009-07-23 13:11:51 -04:00
|
|
|
|
2010-10-07 17:50:15 -04:00
|
|
|
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);
|
|
|
|
|
2010-09-01 16:54:24 -04:00
|
|
|
ui.addFeedsAtEnd->setChecked(Settings->getAddFeedsAtEnd());
|
2009-07-23 13:11:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Loads the settings for this page */
|
|
|
|
void NotifyPage::updateStatus()
|
|
|
|
{
|
|
|
|
}
|