fixed toasters in notifyQt to use rsEvents

This commit is contained in:
csoler 2025-09-16 16:29:47 +02:00
parent 43e0289604
commit e2b2c1ae44
12 changed files with 255 additions and 259 deletions

View file

@ -767,7 +767,6 @@ void SharedFilesDialog::collCreate()
model->getDirDetailsFromSelect(lst, dirVec);
auto RemoteMode = isRemote();
FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
QString dir_name;

View file

@ -1115,16 +1115,6 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> eve
switch (fe->mFileTransferEventCode)
{
case RsFileTransferEventCode::DOWNLOAD_COMPLETE:
{
FileInfo nfo ;
if(!rsFiles->FileDetails(fe->mHash, RS_FILE_HINTS_DOWNLOAD, nfo))
break;
SoundManager::play(SOUND_DOWNLOAD_COMPLETE);
NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),"");
}
[[fallthrough]];
case RsFileTransferEventCode::COMPLETED_FILES_REMOVED:
getUserNotify()->updateIcon();

View file

@ -383,33 +383,6 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
, this );
}, mEventHandlerId_friends, RsEventType::FRIEND_LIST );
mEventHandlerId_system = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
{
RsQThreadUtils::postToObject([=](){
auto ev = dynamic_cast<const RsSystemErrorEvent *>(event.get());
switch(ev->mEventCode)
{
case RsSystemErrorEventCode::TIME_SHIFT_PROBLEM:
std::cerr << "Time shift problem notification. Make sure your machine is on time, because it will break chat rooms." << std::endl;
break;
case RsSystemErrorEventCode::DISK_SPACE_ERROR:
displayDiskSpaceWarning(ev->mDiskErrorLocation,ev->mDiskErrorSizeLimit);
break;
case RsSystemErrorEventCode::DATA_STREAMING_ERROR:
case RsSystemErrorEventCode::GENERAL_ERROR:
displayErrorMessage(0,0,QString::fromUtf8(ev->mErrorMsg.c_str()));
break;
default:
break;
}
}, this );
}, mEventHandlerId_system, RsEventType::SYSTEM_ERROR );
}
@ -422,7 +395,6 @@ MainWindow::~MainWindow()
Settings->setValueToGroup("MainWindow", "State", saveState());
rsEvents->unregisterEventsHandler(mEventHandlerId_friends);
rsEvents->unregisterEventsHandler(mEventHandlerId_system);
delete statusComboBox;
delete peerstatus;
@ -648,28 +620,6 @@ void MainWindow::setNewPage(int page)
}
}
void MainWindow::displayDiskSpaceWarning(int loc,int size_limit_mb)
{
QString locString ;
switch(loc)
{
case RS_PARTIALS_DIRECTORY: locString = "Partials" ;
break ;
case RS_CONFIG_DIRECTORY: locString = "Config" ;
break ;
case RS_DOWNLOAD_DIRECTORY: locString = "Download" ;
break ;
default:
std::cerr << "Error: " << __PRETTY_FUNCTION__ << " was called with an unknown parameter loc=" << loc << std::endl ;
return ;
}
QMessageBox::critical(NULL,tr("Low disk space warning"),
tr("The disk space in your")+" "+locString +" "+tr("directory is running low (current limit is")+" "+QString::number(size_limit_mb)+tr("MB). \n\n RetroShare will now safely suspend any disk access to this directory. \n\n Please make some free space and click Ok.")) ;
}
/** Creates a tray icon with a context menu and adds it to the system
* notification area. */
void MainWindow::createTrayIcon()
@ -1403,11 +1353,6 @@ void MainWindow::receiveNewArgs(QStringList args)
retroshareLinkActivated(link.toUrl());
}
void MainWindow::displayErrorMessage(int /*a*/,int /*b*/,const QString& error_msg)
{
QMessageBox::critical(NULL, tr("Internal Error"),error_msg) ;
}
void MainWindow::closeEvent(QCloseEvent *e)
{
e->ignore();

View file

@ -210,9 +210,7 @@ public:
public slots:
void receiveNewArgs(QStringList args);
void displayErrorMessage(int,int,const QString&) ;
void postModDirectories(bool update_local);
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
void checkAndSetIdle(int idleTime);
void externalLinkActivated(const QUrl &url);
@ -380,7 +378,5 @@ private:
Ui::MainWindow *ui ;
RsEventsHandlerId_t mEventHandlerId_friends;
RsEventsHandlerId_t mEventHandlerId_system;
};
#endif

View file

@ -441,7 +441,6 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
{
case RsFriendListEventCode::NODE_CONNECTED:
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true);
NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", "");
break;
case RsFriendListEventCode::NODE_DISCONNECTED: // not handled yet
break;
@ -506,8 +505,6 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr<const RsEvent> event)
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT)
MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")"));
NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str());
}
void NewsFeed::testFeeds(uint /*notifyFlags*/)

View file

@ -97,12 +97,7 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr<const RsEvent> e
switch (fe->mMailStatusEventCode)
{
case RsMailStatusEventCode::NEW_MESSAGE:
for (it = fe->mChangedMsgIds.begin(); it != fe->mChangedMsgIds.end(); ++it) {
MessageInfo msgInfo;
if (rsMail->getMessage(*it, msgInfo)) {
NotifyQt::getInstance()->addToaster(RS_POPUP_MSG, msgInfo.msgId.c_str(), msgInfo.title.c_str(), msgInfo.msg.c_str() );
}
}
updateIcon();
break;
case RsMailStatusEventCode::MESSAGE_CHANGED:

View file

@ -25,7 +25,9 @@
#include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsidentity.h>
#include <retroshare/rsmsgs.h>
#include <util/rsdir.h>
#include <util/qtthreadsutils.h>
#include <retroshare-gui/RsAutoUpdatePage.h>
@ -102,6 +104,13 @@ NotifyQt::NotifyQt() : cDialog(NULL)
_enabled = false ;
}
#warning TODO: do we need a timer anymore??
// Catch all events that require toasters and
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject([=](){ handleIncomingEvent(event); }, this ); }, mEventHandlerId); // No event type means we expect to catch all possible events
#ifdef TO_REMOVE
// register to allow sending over Qt::QueuedConnection
qRegisterMetaType<ChatId>("ChatId");
@ -673,22 +682,13 @@ void NotifyQt::enable()
_enabled = true ;
}
void NotifyQt::UpdateGUI()
void NotifyQt::handleIncomingEvent(std::shared_ptr<const RsEvent> event)
{
if(RsAutoUpdatePage::eventsLocked())
return ;
{
QMutexLocker m(&_mutex) ;
if(!_enabled)
return ;
}
static bool already_updated = false ; // these only update once at start because they may already have been set before
// the gui is running, then they get updated by callbacks.
#warning Is this needed anymore??
if(!already_updated)
{
// emit neighboursChanged();
emit configChanged();
already_updated = true ;
@ -696,177 +696,197 @@ void NotifyQt::UpdateGUI()
/* Finally Check for PopupMessages / System Error Messages */
if (rsNotify)
{
uint32_t sysid;
uint32_t type;
std::string title, id, msg;
uint popupflags = Settings->getNotifyFlags();
/* 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();
auto insertToaster = [this](ToasterItem *toaster) {
switch(type)
{
case RS_POPUP_ENCRYPTED_MSG:
SoundManager::play(SOUND_MESSAGE_ARRIVED);
/* init attributes */
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
{
toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
}
break;
case RS_POPUP_MSG:
SoundManager::play(SOUND_MESSAGE_ARRIVED);
/* add toaster to waiting list */
waitingToasterList.push_back(toaster);
};
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
{
toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CONNECT:
SoundManager::play(SOUND_USER_ONLINE);
// check for all possibly handled events
if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster)
{
toaster = new ToasterItem(new OnlineToaster(RsPeerId(id)));
}
break;
case RS_POPUP_DOWNLOAD:
SoundManager::play(SOUND_DOWNLOAD_COMPLETE);
auto ev1 = dynamic_cast<const RsMailStatusEvent*>(event.get());
if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
{
/* id = file hash */
toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
}
break;
case RS_POPUP_CHAT:
if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster)
{
// TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT
ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id)));
ChatWidget *chatWidget;
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
// do not show when active
break;
}
toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_GROUPCHAT:
if(ev1)
{
if(ev1->mMailStatusEventCode == RsMailStatusEventCode::NEW_MESSAGE)
{
SoundManager::play(SOUND_MESSAGE_ARRIVED);
if((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
{
for(auto msgid:ev1->mChangedMsgIds)
{
Rs::Msgs::MessageInfo msgInfo;
if(rsMsgs->getMessage(msgid, msgInfo))
insertToaster(new ToasterItem(new MessageToaster(msgInfo.from.toStdString(), QString::fromUtf8(msgInfo.title.c_str()), QString::fromUtf8(msgInfo.msg.c_str()))));
}
}
}
return;
}
auto ev2 = dynamic_cast<const RsFriendListEvent*>(event.get());
if(ev2)
{
if(ev2->mEventCode == RsFriendListEventCode::NODE_CONNECTED)
{
SoundManager::play(SOUND_USER_ONLINE);
if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster)
insertToaster(new ToasterItem(new OnlineToaster(ev2->mSslId)));
}
return;
}
auto ev3 = dynamic_cast<const RsFileTransferEvent*>(event.get());
if(ev3)
{
if(ev3->mFileTransferEventCode == RsFileTransferEventCode::DOWNLOAD_COMPLETE)
{
SoundManager::play(SOUND_DOWNLOAD_COMPLETE);
if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
insertToaster(new ToasterItem(new DownloadToaster(ev3->mHash)));
}
return;
}
auto ev4 = dynamic_cast<const RsAuthSslConnectionAutenticationEvent*>(event.get());
if(ev4)
{
if(ev4->mErrorCode == RsAuthSslError::NOT_A_FRIEND)
{
if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster)
// id = gpgid
// title = ssl name
// msg = peer id
insertToaster(new ToasterItem(new FriendRequestToaster(ev4->mPgpId, ev4->mSslId)));
}
return;
}
// Probably an old thing. To be removed.
// case RS_POPUP_ENCRYPTED_MSG:
// SoundManager::play(SOUND_MESSAGE_ARRIVED);
//
// if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
// {
// toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
// }
// break;
auto ev5 = dynamic_cast<const RsChatServiceEvent*>(event.get());
if(ev5)
{
// This code below should be simplified. In particular GroupChatToaster, ChatToaster and ChatLobbyToaster should be only one class.
if(ev5->mEventCode == RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED)
{
if (ev5->mCid.isPeerId() && (popupflags & RS_POPUP_CHAT) && !_disableAllToaster)
{
// TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT
ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid);
ChatWidget *chatWidget;
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) // do not show when active
return;
insertToaster(new ToasterItem(new ChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str()))));
}
#ifdef RS_DIRECT_CHAT
if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster)
{
MainWindow *mainWindow = MainWindow::getInstance();
if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) {
if (MainWindow::getActivatePage() == MainWindow::Friends) {
if (FriendsDialog::isGroupChatActive()) {
// do not show when active
break;
}
}
}
toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
}
#endif // RS_DIRECT_CHAT
break;
case RS_POPUP_CHATLOBBY:
if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster)
{
ChatId chat_id(id);
else if (ev5->mCid.isBroadcast() && (popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster)
{
MainWindow *mainWindow = MainWindow::getInstance();
if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()
&& (MainWindow::getActivatePage() == MainWindow::Friends) && (FriendsDialog::isGroupChatActive()))
return;
ChatDialog *chatDialog = ChatDialog::getChat(chat_id);
ChatWidget *chatWidget;
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
// do not show when active
break;
}
ChatLobbyDialog *chatLobbyDialog = dynamic_cast<ChatLobbyDialog*>(chatDialog);
insertToaster(new ToasterItem(new GroupChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str()))));
}
#endif
else if (ev5->mCid.isLobbyId() && (popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster)
{
ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid);
ChatWidget *chatWidget;
RsGxsId sender(title);
if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender))
break; // participant is muted
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive())
return;
toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str())));
}
break;
case RS_POPUP_CONNECT_ATTEMPT:
if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster)
{
// id = gpgid
// title = ssl name
// msg = peer id
toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg)));
}
break;
}
}
ChatLobbyDialog *chatLobbyDialog = dynamic_cast<ChatLobbyDialog*>(chatDialog);
/*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 (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(ev5->mMsg.lobby_peer_gxs_id))
return;
if (toaster) {
/* init attributes */
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
insertToaster(new ToasterItem(new ChatLobbyToaster(ev5->mCid.toLobbyId(), ev5->mMsg.lobby_peer_gxs_id, QString::fromUtf8(ev5->mMsg.msg.c_str()))));
}
else
return;
}
/* add toaster to waiting list */
//QMutexLocker lock(&waitingToasterMutex);
waitingToasterList.push_back(toaster);
}
return;
}
if (rsNotify->NotifySysMessage(sysid, type, title, msg))
{
/* make a warning message */
switch(type)
{
case RS_SYS_ERROR:
QMessageBox::critical(MainWindow::getInstance(),
QString::fromUtf8(title.c_str()),
QString::fromUtf8(msg.c_str()));
break;
case RS_SYS_WARNING:
QMessageBox::warning(MainWindow::getInstance(),
QString::fromUtf8(title.c_str()),
QString::fromUtf8(msg.c_str()));
break;
default:
case RS_SYS_INFO:
QMessageBox::information(MainWindow::getInstance(),
QString::fromUtf8(title.c_str()),
QString::fromUtf8(msg.c_str()));
break;
}
}
auto ev6 = dynamic_cast<const RsSystemErrorEvent*>(event.get());
if (rsNotify->NotifyLogMessage(sysid, type, title, msg))
{
/* make a log message */
std::string logMesString = title + " " + msg;
switch(type)
{
case RS_SYS_ERROR:
case RS_SYS_WARNING:
case RS_SYS_INFO:
emit logInfoChanged(QString::fromUtf8(logMesString.c_str()));
}
}
}
if(ev6)
{
switch(ev6->mEventCode)
{
case RsSystemErrorEventCode::TIME_SHIFT_PROBLEM:
displayErrorMessage(RS_SYS_WARNING,tr("System time mismatch"),tr("Time shift problem notification. Make sure your machine is on time, because it will break chat rooms."));
break;
case RsSystemErrorEventCode::DISK_SPACE_ERROR:
displayDiskSpaceWarning(ev6->mDiskErrorLocation,ev6->mDiskErrorSizeLimit);
break;
case RsSystemErrorEventCode::DATA_STREAMING_ERROR:
case RsSystemErrorEventCode::GENERAL_ERROR:
displayErrorMessage(RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str()));
break;
default: break;
}
return;
};
/*Now check Plugins*/
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) {
insertToaster(toasterNotify->toasterItem());
continue;
}
}
}
// if (rsNotify->NotifyLogMessage(sysid, type, title, msg))
// {
// /* make a log message */
// std::string logMesString = title + " " + msg;
// switch(type)
// {
// case RS_SYS_ERROR:
// case RS_SYS_WARNING:
// case RS_SYS_INFO:
// emit logInfoChanged(QString::fromUtf8(logMesString.c_str()));
// }
// }
// }
/* Now start the waiting toasters */
startWaitingToasters();
}
@ -900,7 +920,7 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit
toaster = new ToasterItem(new OnlineToaster(id));
break;
case RS_POPUP_DOWNLOAD:
toaster = new ToasterItem(new DownloadToaster(RsFileHash::random(), title));
toaster = new ToasterItem(new DownloadToaster(RsFileHash::random()));
break;
case RS_POPUP_CHAT:
toaster = new ToasterItem(new ChatToaster(id, message));
@ -919,7 +939,7 @@ void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosit
break;
}
case RS_POPUP_CONNECT_ATTEMPT:
toaster = new ToasterItem(new FriendRequestToaster(pgpid, title, id));
toaster = new ToasterItem(new FriendRequestToaster(pgpid, id));
break;
}
@ -1166,6 +1186,7 @@ void NotifyQt::runningTick()
}
}
#ifdef TO_REMOVE
void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg)
{
uint pos = 0;
@ -1210,7 +1231,7 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st
if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
{
toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
toaster = new ToasterItem(new DownloadToaster(RsFileHash(id)));
}
break;
case RS_POPUP_CHAT:
@ -1287,3 +1308,46 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st
/* Now start the waiting toasters */
startWaitingToasters();
}
#endif
void NotifyQt::displayErrorMessage(int type,const QString& title,const QString& error_msg)
{
/* make a warning message */
switch(type)
{
case RS_SYS_ERROR: QMessageBox::critical(MainWindow::getInstance(),title,error_msg);
break;
case RS_SYS_WARNING: QMessageBox::warning(MainWindow::getInstance(),title,error_msg);
break;
case RS_SYS_INFO: QMessageBox::information(MainWindow::getInstance(),title,error_msg);
break;
default: std::cerr << "Warning: unhandled system error type " << type << std::endl;
break;
}
}
void NotifyQt::displayDiskSpaceWarning(int loc,int size_limit_mb)
{
QString locString ;
switch(loc)
{
case RS_PARTIALS_DIRECTORY: locString = "Partials" ;
break ;
case RS_CONFIG_DIRECTORY: locString = "Config" ;
break ;
case RS_DOWNLOAD_DIRECTORY: locString = "Download" ;
break ;
default:
std::cerr << "Error: " << __PRETTY_FUNCTION__ << " was called with an unknown parameter loc=" << loc << std::endl ;
return ;
}
QMessageBox::critical(NULL,tr("Low disk space warning"),
tr("The disk space in your")+" "+locString +" "+tr("directory is running low (current limit is")+" "+QString::number(size_limit_mb)+tr("MB). \n\n RetroShare will now safely suspend any disk access to this directory. \n\n Please make some free space and click Ok.")) ;
}

View file

@ -96,8 +96,9 @@ class NotifyQt: public QObject, public NotifyClient
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);
#ifdef TO_REMOVE
void addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg);
#endif
void notifySettingsChanged();
signals:
@ -141,7 +142,6 @@ class NotifyQt: public QObject, public NotifyClient
void disableAllChanged(bool disableAll) const;
public slots:
void UpdateGUI(); /* called by timer */
void SetDisableAll(bool bValue);
private slots:
@ -152,7 +152,10 @@ class NotifyQt: public QObject, public NotifyClient
private:
NotifyQt();
static NotifyQt *_instance;
static void displayDiskSpaceWarning(int loc,int size_limit_mb);
static void displayErrorMessage(int type,const QString& title,const QString& error_msg);
static NotifyQt *_instance;
static bool _disableAllToaster;
/* system notifications */
@ -172,6 +175,9 @@ class NotifyQt: public QObject, public NotifyClient
/* so we can update windows */
NetworkDialog *cDialog;
void handleIncomingEvent(std::shared_ptr<const RsEvent> e); /* called by timer */
RsEventsHandlerId_t mEventHandlerId;
};
#endif

View file

@ -28,7 +28,7 @@
#include <retroshare/rsfiles.h>
DownloadToaster::DownloadToaster(const RsFileHash &hash, const QString &name) : QWidget(NULL)
DownloadToaster::DownloadToaster(const RsFileHash &hash) : QWidget(NULL)
{
ui.setupUi(this);
@ -38,8 +38,11 @@ DownloadToaster::DownloadToaster(const RsFileHash &hash, const QString &name) :
connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(play()));
FileInfo info;
rsFiles->FileDetails(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_DOWNLOAD, info ) ;
/* set informations */
ui.textLabel->setText(name);
ui.textLabel->setText(QString::fromStdString(info.fname));
}
void DownloadToaster::play()

View file

@ -30,7 +30,7 @@ class DownloadToaster : public QWidget
Q_OBJECT
public:
DownloadToaster(const RsFileHash &hash, const QString &name);
DownloadToaster(const RsFileHash &hash);
private slots:
void play();

View file

@ -24,8 +24,8 @@
#include <retroshare/rspeers.h>
FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId)
: QWidget(NULL), mGpgId(gpgId), mSslId(peerId), mSslName(sslName)
FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const RsPeerId &peerId)
: QWidget(NULL), mGpgId(gpgId), mSslId(peerId)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -33,7 +33,8 @@ FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString &
bool knownPeer = false;
RsPeerDetails details;
if (rsPeers->getGPGDetails(mGpgId, details)) {
knownPeer = true;
knownPeer = true;
mSslName = QString::fromUtf8(details.name.c_str());
}
if (knownPeer) {
@ -51,7 +52,7 @@ FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString &
ui.textLabel->setText( peerName + " " + tr("wants to be friend with you on RetroShare"));
ui.avatarWidget->setDefaultAvatar(":/images/avatar_request.png");
} else {
ui.textLabel->setText( sslName + " " + tr("Unknown (Incoming) Connect Attempt"));
ui.textLabel->setText( mSslName + " " + tr("Unknown (Incoming) Connect Attempt"));
ui.avatarWidget->setDefaultAvatar(":/images/avatar_request_unknown.png");
}
}

View file

@ -33,7 +33,7 @@ class FriendRequestToaster : public QWidget
Q_OBJECT
public:
FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId);
FriendRequestToaster(const RsPgpId &gpgId, const RsPeerId &peerId);
private slots:
void friendrequestButtonSlot();