added toasters for incoming audio/video call to voip plugin (patch from Phenom)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8295 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-05-26 15:19:57 +00:00
parent c1061a1e9d
commit cee1819b7d
28 changed files with 2699 additions and 1710 deletions

View file

@ -0,0 +1,74 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015 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 "ToasterNotify.h"
ToasterNotify::ToasterNotify(QObject *parent) :
QObject(parent)
{
}
ToasterNotify::~ToasterNotify()
{
}
bool ToasterNotify::hasSetting(QString &/*name*/)
{
return false;
}
bool ToasterNotify::notifyEnabled()
{
return false;
}
void ToasterNotify::setNotifyEnabled(bool /*enabled*/)
{
}
ToasterItem *ToasterNotify::toasterItem()
{
return NULL;
}
ToasterItem *ToasterNotify::testToasterItem()
{
return NULL;
}
bool ToasterNotify::hasSettings(QString &/*name*/, QMap<QString,QString> &/*tagAndTexts*/)
{
return false;
}
bool ToasterNotify::notifyEnabled(QString /*tag*/)
{
return false;
}
void ToasterNotify::setNotifyEnabled(QString /*tag*/, bool /*enabled*/)
{
}
ToasterItem *ToasterNotify::testToasterItem(QString /*tag*/)
{
return NULL;
}

View file

@ -0,0 +1,51 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015 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 TOASTERNOTIFY_H
#define TOASTERNOTIFY_H
#include <QMap>
#include <QObject>
class ToasterItem;
class ToasterNotify : public QObject
{
Q_OBJECT
public:
ToasterNotify(QObject *parent = 0);
~ToasterNotify();
virtual bool hasSetting(QString &/*name*/);
virtual bool notifyEnabled();
virtual void setNotifyEnabled(bool /*enabled*/);
virtual ToasterItem *toasterItem();
virtual ToasterItem *testToasterItem();
//For Plugin with differents Toasters
virtual bool hasSettings(QString &/*mainName*/, QMap<QString,QString> &/*tagAndTexts*/);
virtual bool notifyEnabled(QString /*tag*/);
virtual void setNotifyEnabled(QString /*tag*/, bool /*enabled*/);
virtual ToasterItem *testToasterItem(QString /*tag*/);
};
#endif // TOASTERNOTIFY_H

View file

@ -41,6 +41,8 @@
#include "toaster/GroupChatToaster.h"
#include "toaster/ChatLobbyToaster.h"
#include "toaster/FriendRequestToaster.h"
#include "toaster/ToasterItem.h"
#include "common/ToasterNotify.h"
#include "chat/ChatDialog.h"
#include "chat/ChatLobbyDialog.h"
@ -49,53 +51,12 @@
#include "gui/settings/rsharesettings.h"
#include "SoundManager.h"
#include "retroshare/rsplugin.h"
/*****
* #define NOTIFY_DEBUG
****/
class Toaster
{
public:
Toaster(QWidget *widget)
{
this->widget = widget;
/* Values from settings */
position = Settings->getToasterPosition();
Settings->getToasterMargin();
/* Standard values */
timeToShow = 500;
timeToLive = 3000;
timeToHide = 500;
/* Calculated values */
elapsedTimeToShow = 0;
elapsedTimeToLive = 0;
elapsedTimeToHide = 0;
}
public:
QWidget *widget;
/* Values from settings */
RshareSettings::enumToasterPosition position;
QPoint margin;
/* Standard values */
int timeToShow;
int timeToLive;
int timeToHide;
/* Calculated values */
QPoint startPos;
QPoint endPos;
int elapsedTimeToShow;
int elapsedTimeToLive;
int elapsedTimeToHide;
};
/*static*/ NotifyQt *NotifyQt::_instance = NULL;
/*static*/ bool NotifyQt::_disableAllToaster = false;
@ -820,13 +781,12 @@ void NotifyQt::UpdateGUI()
uint32_t type;
std::string title, id, msg;
/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
ToasterItem *toaster = NULL;
if (rsNotify->NotifyPopupMessage(type, id, title, msg))
{
uint popupflags = Settings->getNotifyFlags();
/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
Toaster *toaster = NULL;
switch(type)
{
case RS_POPUP_ENCRYPTED_MSG:
@ -834,7 +794,7 @@ void NotifyQt::UpdateGUI()
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
{
toaster = new Toaster(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
}
break;
case RS_POPUP_MSG:
@ -842,7 +802,7 @@ void NotifyQt::UpdateGUI()
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
{
toaster = new Toaster(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CONNECT:
@ -850,7 +810,7 @@ void NotifyQt::UpdateGUI()
if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster)
{
toaster = new Toaster(new OnlineToaster(RsPeerId(id)));
toaster = new ToasterItem(new OnlineToaster(RsPeerId(id)));
}
break;
case RS_POPUP_DOWNLOAD:
@ -859,7 +819,7 @@ void NotifyQt::UpdateGUI()
if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
{
/* id = file hash */
toaster = new Toaster(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
}
break;
case RS_POPUP_CHAT:
@ -872,7 +832,7 @@ void NotifyQt::UpdateGUI()
// do not show when active
break;
}
toaster = new Toaster(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_GROUPCHAT:
@ -887,7 +847,7 @@ void NotifyQt::UpdateGUI()
}
}
}
toaster = new Toaster(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CHATLOBBY:
@ -914,7 +874,7 @@ void NotifyQt::UpdateGUI()
if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(RsGxsId(title)))
break; // participant is muted
toaster = new Toaster(new ChatLobbyToaster(lobby_id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
toaster = new ToasterItem(new ChatLobbyToaster(lobby_id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CONNECT_ATTEMPT:
@ -923,21 +883,36 @@ void NotifyQt::UpdateGUI()
// id = gpgid
// title = ssl name
// msg = peer id
toaster = new Toaster(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg)));
toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg)));
}
break;
}
}
if (toaster) {
/* init attributes */
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
/* add toaster to waiting list */
//QMutexLocker lock(&waitingToasterMutex);
waitingToasterList.push_back(toaster);
/*Now check Plugins*/
if (!toaster) {
int pluginCount = rsPlugins->nbPlugins();
for (int i = 0; i < pluginCount; ++i) {
RsPlugin *rsPlugin = rsPlugins->plugin(i);
if (rsPlugin) {
ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify();
if (toasterNotify) {
toaster = toasterNotify->toasterItem();
continue;
}
}
}
}
if (toaster) {
/* init attributes */
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
/* add toaster to waiting list */
//QMutexLocker lock(&waitingToasterMutex);
waitingToasterList.push_back(toaster);
}
if (rsNotify->NotifySysMessage(sysid, type, title, msg))
{
/* make a warning message */
@ -980,7 +955,7 @@ void NotifyQt::UpdateGUI()
startWaitingToasters();
}
void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
{
QString title = tr("Test");
QString message = tr("This is a test.");
@ -995,33 +970,33 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi
notifyFlags &= ~(1 << pos);
++pos;
Toaster *toaster = NULL;
ToasterItem *toaster = NULL;
switch(type)
{
case RS_POPUP_ENCRYPTED_MSG:
toaster = new Toaster(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message"))));
toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message"))));
break;
case RS_POPUP_MSG:
toaster = new Toaster(new MessageToaster(id.toStdString(), title, message));
toaster = new ToasterItem(new MessageToaster(id.toStdString(), title, message));
break;
case RS_POPUP_CONNECT:
toaster = new Toaster(new OnlineToaster(id));
toaster = new ToasterItem(new OnlineToaster(id));
break;
case RS_POPUP_DOWNLOAD:
toaster = new Toaster(new DownloadToaster(RsFileHash::random(), title));
toaster = new ToasterItem(new DownloadToaster(RsFileHash::random(), title));
break;
case RS_POPUP_CHAT:
toaster = new Toaster(new ChatToaster(id, message));
toaster = new ToasterItem(new ChatToaster(id, message));
break;
case RS_POPUP_GROUPCHAT:
toaster = new Toaster(new GroupChatToaster(id, message));
toaster = new ToasterItem(new GroupChatToaster(id, message));
break;
case RS_POPUP_CHATLOBBY:
toaster = new Toaster(new ChatLobbyToaster(0, title, message));
toaster = new ToasterItem(new ChatLobbyToaster(0, title, message));
break;
case RS_POPUP_CONNECT_ATTEMPT:
toaster = new Toaster(new FriendRequestToaster(pgpid, title, id));
toaster = new ToasterItem(new FriendRequestToaster(pgpid, title, id));
break;
}
@ -1038,6 +1013,48 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi
}
}
void NotifyQt::testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
{
if (!toasterNotify) {
return;
}
ToasterItem *toaster = toasterNotify->testToasterItem();
if (toaster) {
/* init attributes */
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
toaster->position = (RshareSettings::enumToasterPosition) position;
toaster->margin = margin;
/* add toaster to waiting list */
//QMutexLocker lock(&waitingToasterMutex);
waitingToasterList.push_back(toaster);
}
}
void NotifyQt::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin)
{
if (!toasterNotify) {
return;
}
ToasterItem *toaster = toasterNotify->testToasterItem(tag);
if (toaster) {
/* init attributes */
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
toaster->position = (RshareSettings::enumToasterPosition) position;
toaster->margin = margin;
/* add toaster to waiting list */
//QMutexLocker lock(&waitingToasterMutex);
waitingToasterList.push_back(toaster);
}
}
void NotifyQt::notifyChatFontChanged()
{
{
@ -1084,7 +1101,7 @@ void NotifyQt::startWaitingToasters()
}
}
Toaster *toaster = NULL;
ToasterItem *toaster = NULL;
{
//QMutexLocker lock(&waitingToasterMutex);
@ -1149,9 +1166,9 @@ void NotifyQt::runningTick()
int interval = runningToasterTimer->interval();
QPoint diff;
QList<Toaster*>::iterator it = runningToasterList.begin();
QList<ToasterItem*>::iterator it = runningToasterList.begin();
while (it != runningToasterList.end()) {
Toaster *toaster = *it;
ToasterItem *toaster = *it;
bool visible = true;
if (toaster->elapsedTimeToShow) {
@ -1192,7 +1209,7 @@ void NotifyQt::runningTick()
} else {
/* Toaster is hidden, delete it */
it = runningToasterList.erase(it);
delete(toaster->widget);
//delete(toaster->widget);
delete(toaster);
continue;
}

View file

@ -21,7 +21,8 @@ class ChatDialog;
class MessagesDialog;
class ChannelsDialog;
class MessengerWindow;
class Toaster;
class ToasterItem;
class ToasterNotify;
class SignatureEventData ;
struct TurtleFileInfo;
@ -90,7 +91,9 @@ class NotifyQt: public QObject, public NotifyClient
void notifyChatFontChanged();
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
void testToaster(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
void testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
void notifySettingsChanged();
@ -169,10 +172,10 @@ class NotifyQt: public QObject, public NotifyClient
void startWaitingToasters();
// QMutex waitingToasterMutex; // for lock of the waiting toaster list
QList<Toaster*> waitingToasterList;
QList<ToasterItem*> waitingToasterList;
QTimer *runningToasterTimer;
QList<Toaster*> runningToasterList;
QList<ToasterItem*> runningToasterList;
bool _enabled ;
QMutex _mutex ;

View file

@ -29,6 +29,7 @@
#include "gui/MainWindow.h"
#include "gui/common/UserNotify.h"
#include "gui/common/FeedNotify.h"
#include "gui/common/ToasterNotify.h"
#include "gui/notifyqt.h"
#include "gui/NewsFeed.h"
@ -39,8 +40,8 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect(ui.notifyButton, SIGNAL(clicked()), this, SLOT(testNotify()));
connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster()));
connect(ui.testFeedButton, SIGNAL(clicked()), this, SLOT(testFeed()));
connect(ui.testToasterButton, 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)));
connect(ui.chatLobbies_CountFollowingText,SIGNAL(toggled(bool)),ui.chatLobbies_TextToNotify,SLOT(setEnabled(bool))) ;
@ -49,8 +50,9 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
QFont font = ui.notify_Peers->font(); // use font from existing checkbox
/* add feed notify */
int row = 0;
/* add feed and Toaster notify */
int rowFeed = 0;
int rowToaster = 0;
int pluginCount = rsPlugins->nbPlugins();
for (int i = 0; i < pluginCount; ++i) {
RsPlugin *rsPlugin = rsPlugins->plugin(i);
@ -58,15 +60,48 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
FeedNotify *feedNotify = rsPlugin->qt_feedNotify();
if (feedNotify) {
QString name;
if (!feedNotify->hasSetting(name)) {
continue;
if (feedNotify->hasSetting(name)) {
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
enabledCheckBox->setFont(font);
ui.feedLayout->addWidget(enabledCheckBox, rowFeed++);
mFeedNotifySettingList.push_back(FeedNotifySetting(feedNotify, enabledCheckBox));
}
}
ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify();
if (toasterNotify) {
QString name;
if (toasterNotify->hasSetting(name)) {
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
enabledCheckBox->setFont(font);
ui.toasterLayout->addWidget(enabledCheckBox, rowToaster++);
mToasterNotifySettingList.push_back(ToasterNotifySetting(toasterNotify, enabledCheckBox));
}
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
enabledCheckBox->setFont(font);
ui.feedLayout->addWidget(enabledCheckBox, row++);
mFeedNotifySettingList.push_back(FeedNotifySetting(feedNotify, enabledCheckBox));
QMap<QString, QString> map;
if (toasterNotify->hasSettings(name, map)) {
if (!map.empty()){
QWidget* widget = new QWidget();
QVBoxLayout* vbLayout = new QVBoxLayout(widget);
QLabel *label = new QLabel(name, this);
QFont fontBold = QFont(font);
fontBold.setBold(true);
label->setFont(fontBold);
vbLayout->addWidget(label);
for (QMap<QString, QString>::const_iterator it = map.begin(); it != map.end(); ++it){
QCheckBox *enabledCheckBox = new QCheckBox(it.value(), this);
enabledCheckBox->setAccessibleName(it.key());
enabledCheckBox->setFont(font);
vbLayout->addWidget(enabledCheckBox);
mToasterNotifySettingList.push_back(ToasterNotifySetting(toasterNotify, enabledCheckBox));
}
ui.toasterLayout->addWidget(widget, rowToaster++);
}
}
}
}
}
@ -74,7 +109,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
/* add user notify */
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
QList<UserNotify*>::const_iterator it;
row = 0;
rowFeed = 0;
mChatLobbyUserNotify = 0;
for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) {
UserNotify *userNotify = *it;
@ -86,16 +121,16 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
enabledCheckBox->setFont(font);
ui.notifyLayout->addWidget(enabledCheckBox, row, 0, 0);
ui.notifyLayout->addWidget(enabledCheckBox, rowFeed, 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);
ui.notifyLayout->addWidget(combinedCheckBox, rowFeed, 1);
QCheckBox *blinkCheckBox = new QCheckBox(tr("Blink"), this);
blinkCheckBox->setFont(font);
ui.notifyLayout->addWidget(blinkCheckBox, row++, 2);
ui.notifyLayout->addWidget(blinkCheckBox, rowFeed++, 2);
mUserNotifySettingList.push_back(UserNotifySetting(userNotify, enabledCheckBox, combinedCheckBox, blinkCheckBox));
@ -188,6 +223,16 @@ NotifyPage::save(QString &/*errmsg*/)
feedNotifyIt->mFeedNotify->setNotifyEnabled(feedNotifyIt->mEnabledCheckBox->isChecked());
}
/* save toaster notify */
QList<ToasterNotifySetting>::iterator toasterNotifyIt;
for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) {
if(toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()){
toasterNotifyIt->mToasterNotify->setNotifyEnabled(toasterNotifyIt->mEnabledCheckBox->isChecked()) ;
} else {
toasterNotifyIt->mToasterNotify->setNotifyEnabled(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mEnabledCheckBox->isChecked()) ;
}
}
/* save user notify */
QList<UserNotifySetting>::iterator notifyIt;
for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) {
@ -284,6 +329,16 @@ void NotifyPage::load()
feedNotifyIt->mEnabledCheckBox->setChecked(feedNotifyIt->mFeedNotify->notifyEnabled());
}
/* load toaster notify */
QList<ToasterNotifySetting>::iterator toasterNotifyIt;
for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) {
if (toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()) {
toasterNotifyIt->mEnabledCheckBox->setChecked(toasterNotifyIt->mToasterNotify->notifyEnabled()) ;
} else {
toasterNotifyIt->mEnabledCheckBox->setChecked(toasterNotifyIt->mToasterNotify->notifyEnabled(toasterNotifyIt->mEnabledCheckBox->accessibleName())) ;
}
}
/* load user notify */
QList<UserNotifySetting>::iterator userNotifyIt;
for (userNotifyIt = mUserNotifySettingList.begin(); userNotifyIt != mUserNotifySettingList.end(); ++userNotifyIt) {
@ -321,7 +376,7 @@ void NotifyPage::notifyToggled()
}
}
void NotifyPage::testNotify()
void NotifyPage::testFeed()
{
NewsFeed::testFeeds(getNewsFlags());
@ -336,5 +391,19 @@ void NotifyPage::testNotify()
void NotifyPage::testToaster()
{
NotifyQt::getInstance()->testToaster(getNotifyFlags(), (RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(ui.comboBoxToasterPosition->currentIndex()).toInt(), QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value()));
RshareSettings::enumToasterPosition pos = (RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(ui.comboBoxToasterPosition->currentIndex()).toInt();
QPoint margin = QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value());
NotifyQt::getInstance()->testToasters(getNotifyFlags(), pos, margin);
/* notify of plugins */
QList<ToasterNotifySetting>::iterator toasterNotifyIt;
for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) {
if (toasterNotifyIt->mEnabledCheckBox->isChecked()){
if (toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()){
NotifyQt::getInstance()->testToaster(toasterNotifyIt->mToasterNotify, pos, margin) ;
} else {
NotifyQt::getInstance()->testToaster(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mToasterNotify, pos, margin) ;
}
}
}
}

View file

@ -25,10 +25,11 @@
#include <retroshare-gui/configpage.h>
#include "ui_NotifyPage.h"
#include "gui/chat/ChatLobbyUserNotify.h"
#include "gui/chat/ChatLobbyUserNotify.h"
class UserNotify;
class FeedNotify;
class ToasterNotify;
class UserNotifySetting
{
@ -54,6 +55,17 @@ public:
: mFeedNotify(feedNotify), mEnabledCheckBox(enabledCheckBox) {}
};
class ToasterNotifySetting
{
public:
ToasterNotify *mToasterNotify;
QCheckBox *mEnabledCheckBox;
public:
ToasterNotifySetting(ToasterNotify *toasterNotify, QCheckBox *enabledCheckBox)
: mToasterNotify(toasterNotify), mEnabledCheckBox(enabledCheckBox) {}
};
class NotifyPage : public ConfigPage
{
Q_OBJECT
@ -76,14 +88,15 @@ public:
private slots:
void notifyToggled();
void testToaster();
void testNotify();
void testFeed();
private:
uint getNewsFlags();
uint getNotifyFlags();
ChatLobbyUserNotify* mChatLobbyUserNotify;
ChatLobbyUserNotify* mChatLobbyUserNotify;
QList<FeedNotifySetting> mFeedNotifySettingList;
QList<ToasterNotifySetting> mToasterNotifySettingList;
QList<UserNotifySetting> mUserNotifySettingList;
/** Qt Designer generated object */

View file

@ -14,7 +14,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabFeed">
<attribute name="title">
@ -99,7 +99,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QPushButton" name="notifyButton">
<widget class="QPushButton" name="testFeedButton">
<property name="text">
<string>Test</string>
</property>
@ -237,12 +237,15 @@
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="toasterLayout"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QPushButton" name="toasterButton">
<widget class="QPushButton" name="testToasterButton">
<property name="text">
<string>Test</string>
</property>

View file

@ -0,0 +1,49 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015 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 "ToasterItem.h"
/** Constructor */
ToasterItem::ToasterItem(QWidget *child) : QObject(NULL)
{
/* Set widget */
widget = child;
/* Values from settings */
position = Settings->getToasterPosition();
margin = Settings->getToasterMargin();
/* Standard values */
timeToShow = 500;
timeToLive = 3000;
timeToHide = 500;
/* Calculated values */
elapsedTimeToShow = 0;
elapsedTimeToLive = 0;
elapsedTimeToHide = 0;
}
ToasterItem::~ToasterItem()
{
emit toasterItemDestroyed(this);
delete widget;
}

View file

@ -0,0 +1,61 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2015 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 _TOASTER_ITEM_H
#define _TOASTER_ITEM_H
#include "gui/settings/rsharesettings.h"
#include <QWidget>
class ToasterItem : public QObject
{
Q_OBJECT
public:
/** Default Constructor */
ToasterItem(QWidget *child = 0);
/** Default Destructor */
virtual ~ToasterItem();
QWidget *widget;
/* Values from settings */
RshareSettings::enumToasterPosition position;
QPoint margin;
/* Standard values */
int timeToShow;
int timeToLive;
int timeToHide;
/* Calculated values */
QPoint startPos;
QPoint endPos;
int elapsedTimeToShow;
int elapsedTimeToLive;
int elapsedTimeToHide;
signals:
void toasterItemDestroyed(ToasterItem *toasterItem);//Can't use QObject::detroyed() signal as it's emitted after this class was destroyed.
};
#endif //_TOASTER_ITEM_H

File diff suppressed because it is too large Load diff