From 698902a8dcd493814f3dac964032154cd15cdb64 Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 11 Oct 2014 00:18:32 +0100 Subject: [PATCH 1/4] status changes messages and sign in notifications sign in notifications available only in settings and as a message in chat --- src/core.cpp | 2 +- src/core.h | 1 + src/misc/settings.cpp | 24 ++++++++++++++ src/misc/settings.h | 9 ++++++ src/widget/form/settings/generalform.cpp | 16 ++++++++- src/widget/form/settings/generalform.h | 2 ++ src/widget/form/settings/generalsettings.ui | 14 ++++++++ src/widget/widget.cpp | 36 ++++++++++++++++++++- src/widget/widget.h | 1 + 9 files changed, 102 insertions(+), 3 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index 325028b03..b496f0960 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -410,7 +410,7 @@ void Core::onUserStatusChanged(Tox*/* tox*/, int friendId, uint8_t userstatus, v void Core::onConnectionStatusChanged(Tox*/* tox*/, int friendId, uint8_t status, void* core) { Status friendStatus = status ? Status::Online : Status::Offline; - emit static_cast(core)->friendStatusChanged(friendId, friendStatus); + emit static_cast(core)->friendSignedIn(friendId, friendStatus); if (friendStatus == Status::Offline) { static_cast(core)->checkLastOnline(friendId); diff --git a/src/core.h b/src/core.h index 189f4060a..f0172b38c 100644 --- a/src/core.h +++ b/src/core.h @@ -115,6 +115,7 @@ signals: void friendAdded(int friendId, const QString& userId); void friendStatusChanged(int friendId, Status status); + void friendSignedIn(int friendId, Status friendStatus); void friendStatusMessageChanged(int friendId, const QString& message); void friendUsernameChanged(int friendId, const QString& username); void friendTypingChanged(int friendId, bool isTyping); diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp index 47fccab47..bbe062750 100644 --- a/src/misc/settings.cpp +++ b/src/misc/settings.cpp @@ -138,6 +138,8 @@ void Settings::load() minimizeOnClose = s.value("minimizeOnClose", false).toBool(); useNativeStyle = s.value("nativeStyle", false).toBool(); style = s.value("style", "None").toString(); + statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool(); + signInNotificationEnabled = s.value("signInNotificationEnabled", false).toBool(); s.endGroup(); s.beginGroup("State"); @@ -245,6 +247,8 @@ void Settings::save(QString path) s.setValue("minimizeOnClose", minimizeOnClose); s.setValue("nativeStyle", useNativeStyle); s.setValue("style",style); + s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled); + s.setValue("signInNotificationEnabled", signInNotificationEnabled); s.endGroup(); s.beginGroup("State"); @@ -377,6 +381,26 @@ void Settings::setAutostartInTray(bool newValue) autostartInTray = newValue; } +bool Settings::getSignInNotificationEnabled() const +{ + return signInNotificationEnabled; +} + +void Settings::setSignInNotificationEnabled(bool newValue) +{ + signInNotificationEnabled = newValue; +} + +bool Settings::getStatusChangeNotificationEnabled() const +{ + return statusChangeNotificationEnabled; +} + +void Settings::setStatusChangeNotificationEnabled(bool newValue) +{ + statusChangeNotificationEnabled = newValue; +} + bool Settings::getUseTranslations() const { return useTranslations; diff --git a/src/misc/settings.h b/src/misc/settings.h index 9ff506ba3..545619160 100644 --- a/src/misc/settings.h +++ b/src/misc/settings.h @@ -137,11 +137,18 @@ public: bool isMinimizeOnCloseEnabled() const; void setMinimizeOnClose(bool newValue); + + bool getSignInNotificationEnabled() const; + void setSignInNotificationEnabled(bool newValue); + + bool getStatusChangeNotificationEnabled() const; + void setStatusChangeNotificationEnabled(bool newValue); // Privacy bool isTypingNotificationEnabled() const; void setTypingNotification(bool enabled); + // State bool getUseNativeStyle() const; void setUseNativeStyle(bool value); @@ -211,6 +218,8 @@ private: int firstColumnHandlePos; int secondColumnHandlePosFromRight; QString timestampFormat; + bool signInNotificationEnabled; + bool statusChangeNotificationEnabled; // Privacy bool typingNotification; diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index e2ae4cb1c..df083105e 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -33,6 +33,8 @@ GeneralForm::GeneralForm() : bodyUI->cbUseTranslations->setChecked(Settings::getInstance().getUseTranslations()); bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable()); bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray()); + bodyUI->statusChangesCheckbox->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled()); + bodyUI->signInNotificationsCheckbox->setChecked(Settings::getInstance().getSignInNotificationEnabled()); for (auto entry : SmileyPack::listSmileyPacks()) { @@ -40,7 +42,7 @@ GeneralForm::GeneralForm() : } bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack())); reloadSmiles(); - + bodyUI->styleBrowser->addItems(QStyleFactory::keys()); bodyUI->styleBrowser->addItem("None"); if(QStyleFactory::keys().contains(Settings::getInstance().getStyle())) @@ -61,6 +63,8 @@ GeneralForm::GeneralForm() : connect(bodyUI->cbUseTranslations, &QCheckBox::stateChanged, this, &GeneralForm::onUseTranslationUpdated); connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated); connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray); + connect(bodyUI->statusChangesCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange); + connect(bodyUI->signInNotificationsCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetSignInNotifications); connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); // new syntax can't handle overloaded signals... (at least not in a pretty way) connect(bodyUI->cbUDPDisabled, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated); @@ -101,6 +105,16 @@ void GeneralForm::onStyleSelected(QString style) this->setStyle(QStyleFactory::create(style)); } +void GeneralForm::onSetStatusChange() +{ + Settings::getInstance().setStatusChangeNotificationEnabled(bodyUI->statusChangesCheckbox->isChecked()); +} + +void GeneralForm::onSetSignInNotifications() +{ + Settings::getInstance().setSignInNotificationEnabled(bodyUI->signInNotificationsCheckbox->isChecked()); +} + void GeneralForm::onSmileyBrowserIndexChanged(int index) { QString filename = bodyUI->smileyPackBrowser->itemData(index).toString(); diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h index b2ca84b56..06eeb2ac0 100644 --- a/src/widget/form/settings/generalform.h +++ b/src/widget/form/settings/generalform.h @@ -43,6 +43,8 @@ private slots: void onProxyPortEdited(int port); void onUseProxyUpdated(); void onStyleSelected(QString style); + void onSetStatusChange(); + void onSetSignInNotifications(); private: Ui::GeneralSettings *bodyUI; diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui index d0d31b622..ffbbabae4 100644 --- a/src/widget/form/settings/generalsettings.ui +++ b/src/widget/form/settings/generalsettings.ui @@ -53,6 +53,20 @@ + + + + Show status changes + + + + + + + Notify me when contacts sign in + + + diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 124f60f90..0080b6e60 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -151,9 +151,9 @@ Widget::Widget(QWidget *parent) connect(core, SIGNAL(fileUploadFinished(const QString&)), &filesForm, SLOT(onFileUploadComplete(const QString&))); connect(core, &Core::friendAdded, this, &Widget::addFriend); connect(core, &Core::failedToAddFriend, this, &Widget::addFriendFailed); - connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged); connect(core, &Core::friendUsernameChanged, this, &Widget::onFriendUsernameChanged); connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged); + connect(core, &Core::friendSignedIn, this, &Widget::onFriendBecameOnline); connect(core, &Core::friendStatusMessageChanged, this, &Widget::onFriendStatusMessageChanged); connect(core, &Core::friendRequestReceived, this, &Widget::onFriendRequestReceived); connect(core, &Core::friendMessageReceived, this, &Widget::onFriendMessageReceived); @@ -538,6 +538,40 @@ void Widget::onFriendStatusChanged(int friendId, Status status) f->friendStatus = status; f->widget->updateStatusLight(); + + QString fStatus = ""; + switch(f->friendStatus){ + case Status::Away: + fStatus = "away"; break; + case Status::Busy: + fStatus = "busy"; break; + case Status::Offline: + fStatus = "offline"; break; + default: + fStatus = "online"; break; + } + + //won't print the message if there were no messages before + if(f->chatForm->actions().size() != 0 + && Settings::getInstance().getStatusChangeNotificationEnabled() == true) + f->chatForm->addSystemInfoMessage(f->getName() + " has changed status to " + fStatus, "white"); +} + +void Widget::onFriendBecameOnline(int friendId, Status status) +{ + Friend* f = FriendList::findFriend(friendId); + if (!f) + return; + + contactListWidget->moveWidget(f->widget, status); + + f->friendStatus = status; + f->widget->updateStatusLight(); + + //won't print the message if there were no messages before + if(f->chatForm->actions().size() != 0 + && Settings::getInstance().getSignInNotificationEnabled() == true) + f->chatForm->addSystemInfoMessage(f->getName() + " has became online", "white"); } void Widget::onFriendStatusMessageChanged(int friendId, const QString& message) diff --git a/src/widget/widget.h b/src/widget/widget.h index 4f50a133c..5f3300364 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -91,6 +91,7 @@ private slots: void addFriend(int friendId, const QString& userId); void addFriendFailed(const QString& userId); void onFriendStatusChanged(int friendId, Status status); + void onFriendBecameOnline(int friendId, Status status); void onFriendStatusMessageChanged(int friendId, const QString& message); void onFriendUsernameChanged(int friendId, const QString& username); void onChatroomWidgetClicked(GenericChatroomWidget *); From fea3fa3ac71c72c106c46dbd0611ba5b6c225764 Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 11 Oct 2014 00:39:24 +0100 Subject: [PATCH 2/4] renamed function --- src/widget/widget.cpp | 4 ++-- src/widget/widget.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 0080b6e60..a5a5c839a 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -153,7 +153,7 @@ Widget::Widget(QWidget *parent) connect(core, &Core::failedToAddFriend, this, &Widget::addFriendFailed); connect(core, &Core::friendUsernameChanged, this, &Widget::onFriendUsernameChanged); connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged); - connect(core, &Core::friendSignedIn, this, &Widget::onFriendBecameOnline); + connect(core, &Core::friendSignedIn, this, &Widget::onFriendSignIn); connect(core, &Core::friendStatusMessageChanged, this, &Widget::onFriendStatusMessageChanged); connect(core, &Core::friendRequestReceived, this, &Widget::onFriendRequestReceived); connect(core, &Core::friendMessageReceived, this, &Widget::onFriendMessageReceived); @@ -557,7 +557,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status) f->chatForm->addSystemInfoMessage(f->getName() + " has changed status to " + fStatus, "white"); } -void Widget::onFriendBecameOnline(int friendId, Status status) +void Widget::onFriendSignIn(int friendId, Status status) { Friend* f = FriendList::findFriend(friendId); if (!f) diff --git a/src/widget/widget.h b/src/widget/widget.h index 5f3300364..eaa0917a6 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -91,7 +91,7 @@ private slots: void addFriend(int friendId, const QString& userId); void addFriendFailed(const QString& userId); void onFriendStatusChanged(int friendId, Status status); - void onFriendBecameOnline(int friendId, Status status); + void onFriendSignIn(int friendId, Status status); void onFriendStatusMessageChanged(int friendId, const QString& message); void onFriendUsernameChanged(int friendId, const QString& username); void onChatroomWidgetClicked(GenericChatroomWidget *); From 8788931f3666370c3e8fadd6069b2dfa723c0348 Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 11 Oct 2014 11:48:45 +0100 Subject: [PATCH 3/4] number of messages is more reliable then activities --- src/widget/chatareawidget.cpp | 5 +++++ src/widget/chatareawidget.h | 1 + src/widget/form/genericchatform.cpp | 5 +++++ src/widget/form/genericchatform.h | 3 ++- src/widget/widget.cpp | 8 ++------ 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/widget/chatareawidget.cpp b/src/widget/chatareawidget.cpp index 542e3be40..0e5b58eb3 100644 --- a/src/widget/chatareawidget.cpp +++ b/src/widget/chatareawidget.cpp @@ -118,6 +118,11 @@ void ChatAreaWidget::insertMessage(ChatAction *msgAction) messages.append(msgAction); } +int ChatAreaWidget::getNumberOfMessages() +{ + return messages.size(); +} + void ChatAreaWidget::onSliderRangeChanged() { QScrollBar* scroll = verticalScrollBar(); diff --git a/src/widget/chatareawidget.h b/src/widget/chatareawidget.h index d1e2dbe8f..923da19af 100644 --- a/src/widget/chatareawidget.h +++ b/src/widget/chatareawidget.h @@ -33,6 +33,7 @@ public: int nameColWidth() {return nameWidth;} void setNameColWidth(int w); + int getNumberOfMessages(); signals: void onFileTranfertInterract(QString widgetName, QString buttonName); diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 0d31288e1..a42a956dd 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -127,6 +127,11 @@ GenericChatForm::GenericChatForm(QWidget *parent) : connect(chatWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); } +int GenericChatForm::getNumberOfMessages() +{ + return chatWidget->getNumberOfMessages(); +} + void GenericChatForm::setName(const QString &newName) { nameLabel->setText(newName); diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index b8c373d23..0baa4f315 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -46,7 +46,8 @@ public: virtual void show(Ui::MainWindow &ui); void addMessage(QString author, QString message, bool isAction = false, QDateTime datetime=QDateTime::currentDateTime()); void addSystemInfoMessage(const QString &message, const QString &type, const QDateTime &datetime=QDateTime::currentDateTime()); - + int getNumberOfMessages(); + signals: void sendMessage(int, QString); void sendAction(int, QString); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index a5a5c839a..e41ed7df0 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -550,9 +550,9 @@ void Widget::onFriendStatusChanged(int friendId, Status status) default: fStatus = "online"; break; } - + //won't print the message if there were no messages before - if(f->chatForm->actions().size() != 0 + if(f->chatForm->getNumberOfMessages() != 0 && Settings::getInstance().getStatusChangeNotificationEnabled() == true) f->chatForm->addSystemInfoMessage(f->getName() + " has changed status to " + fStatus, "white"); } @@ -568,10 +568,6 @@ void Widget::onFriendSignIn(int friendId, Status status) f->friendStatus = status; f->widget->updateStatusLight(); - //won't print the message if there were no messages before - if(f->chatForm->actions().size() != 0 - && Settings::getInstance().getSignInNotificationEnabled() == true) - f->chatForm->addSystemInfoMessage(f->getName() + " has became online", "white"); } void Widget::onFriendStatusMessageChanged(int friendId, const QString& message) From 8be4725acdf824cde510941c176160045879feee Mon Sep 17 00:00:00 2001 From: dubslow Date: Thu, 16 Oct 2014 09:07:35 -0500 Subject: [PATCH 4/4] cleanup "sign in change", since it's unnecessary --- src/core.cpp | 2 +- src/core.h | 1 - src/misc/settings.cpp | 12 ----------- src/misc/settings.h | 6 +----- src/widget/form/settings/generalform.cpp | 7 ------ src/widget/form/settings/generalform.h | 1 - src/widget/form/settings/generalsettings.ui | 9 +------- src/widget/widget.cpp | 24 +++++---------------- src/widget/widget.h | 3 +-- 9 files changed, 9 insertions(+), 56 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index b496f0960..325028b03 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -410,7 +410,7 @@ void Core::onUserStatusChanged(Tox*/* tox*/, int friendId, uint8_t userstatus, v void Core::onConnectionStatusChanged(Tox*/* tox*/, int friendId, uint8_t status, void* core) { Status friendStatus = status ? Status::Online : Status::Offline; - emit static_cast(core)->friendSignedIn(friendId, friendStatus); + emit static_cast(core)->friendStatusChanged(friendId, friendStatus); if (friendStatus == Status::Offline) { static_cast(core)->checkLastOnline(friendId); diff --git a/src/core.h b/src/core.h index f0172b38c..189f4060a 100644 --- a/src/core.h +++ b/src/core.h @@ -115,7 +115,6 @@ signals: void friendAdded(int friendId, const QString& userId); void friendStatusChanged(int friendId, Status status); - void friendSignedIn(int friendId, Status friendStatus); void friendStatusMessageChanged(int friendId, const QString& message); void friendUsernameChanged(int friendId, const QString& username); void friendTypingChanged(int friendId, bool isTyping); diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp index bbe062750..037b4cbb6 100644 --- a/src/misc/settings.cpp +++ b/src/misc/settings.cpp @@ -139,7 +139,6 @@ void Settings::load() useNativeStyle = s.value("nativeStyle", false).toBool(); style = s.value("style", "None").toString(); statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool(); - signInNotificationEnabled = s.value("signInNotificationEnabled", false).toBool(); s.endGroup(); s.beginGroup("State"); @@ -248,7 +247,6 @@ void Settings::save(QString path) s.setValue("nativeStyle", useNativeStyle); s.setValue("style",style); s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled); - s.setValue("signInNotificationEnabled", signInNotificationEnabled); s.endGroup(); s.beginGroup("State"); @@ -381,16 +379,6 @@ void Settings::setAutostartInTray(bool newValue) autostartInTray = newValue; } -bool Settings::getSignInNotificationEnabled() const -{ - return signInNotificationEnabled; -} - -void Settings::setSignInNotificationEnabled(bool newValue) -{ - signInNotificationEnabled = newValue; -} - bool Settings::getStatusChangeNotificationEnabled() const { return statusChangeNotificationEnabled; diff --git a/src/misc/settings.h b/src/misc/settings.h index 545619160..79675fbd8 100644 --- a/src/misc/settings.h +++ b/src/misc/settings.h @@ -137,10 +137,7 @@ public: bool isMinimizeOnCloseEnabled() const; void setMinimizeOnClose(bool newValue); - - bool getSignInNotificationEnabled() const; - void setSignInNotificationEnabled(bool newValue); - + bool getStatusChangeNotificationEnabled() const; void setStatusChangeNotificationEnabled(bool newValue); @@ -218,7 +215,6 @@ private: int firstColumnHandlePos; int secondColumnHandlePosFromRight; QString timestampFormat; - bool signInNotificationEnabled; bool statusChangeNotificationEnabled; // Privacy diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index df083105e..df952892a 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -34,7 +34,6 @@ GeneralForm::GeneralForm() : bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable()); bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray()); bodyUI->statusChangesCheckbox->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled()); - bodyUI->signInNotificationsCheckbox->setChecked(Settings::getInstance().getSignInNotificationEnabled()); for (auto entry : SmileyPack::listSmileyPacks()) { @@ -64,7 +63,6 @@ GeneralForm::GeneralForm() : connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated); connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray); connect(bodyUI->statusChangesCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange); - connect(bodyUI->signInNotificationsCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetSignInNotifications); connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); // new syntax can't handle overloaded signals... (at least not in a pretty way) connect(bodyUI->cbUDPDisabled, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated); @@ -110,11 +108,6 @@ void GeneralForm::onSetStatusChange() Settings::getInstance().setStatusChangeNotificationEnabled(bodyUI->statusChangesCheckbox->isChecked()); } -void GeneralForm::onSetSignInNotifications() -{ - Settings::getInstance().setSignInNotificationEnabled(bodyUI->signInNotificationsCheckbox->isChecked()); -} - void GeneralForm::onSmileyBrowserIndexChanged(int index) { QString filename = bodyUI->smileyPackBrowser->itemData(index).toString(); diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h index 06eeb2ac0..ab8325526 100644 --- a/src/widget/form/settings/generalform.h +++ b/src/widget/form/settings/generalform.h @@ -44,7 +44,6 @@ private slots: void onUseProxyUpdated(); void onStyleSelected(QString style); void onSetStatusChange(); - void onSetSignInNotifications(); private: Ui::GeneralSettings *bodyUI; diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui index ffbbabae4..f10025c52 100644 --- a/src/widget/form/settings/generalsettings.ui +++ b/src/widget/form/settings/generalsettings.ui @@ -56,14 +56,7 @@ - Show status changes - - - - - - - Notify me when contacts sign in + Show contacts' status changes diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index e41ed7df0..bbff4ad90 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -153,7 +153,6 @@ Widget::Widget(QWidget *parent) connect(core, &Core::failedToAddFriend, this, &Widget::addFriendFailed); connect(core, &Core::friendUsernameChanged, this, &Widget::onFriendUsernameChanged); connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged); - connect(core, &Core::friendSignedIn, this, &Widget::onFriendSignIn); connect(core, &Core::friendStatusMessageChanged, this, &Widget::onFriendStatusMessageChanged); connect(core, &Core::friendRequestReceived, this, &Widget::onFriendRequestReceived); connect(core, &Core::friendMessageReceived, this, &Widget::onFriendMessageReceived); @@ -542,32 +541,19 @@ void Widget::onFriendStatusChanged(int friendId, Status status) QString fStatus = ""; switch(f->friendStatus){ case Status::Away: - fStatus = "away"; break; + fStatus = tr("away", "contact status"); break; case Status::Busy: - fStatus = "busy"; break; + fStatus = tr("busy", "contact status"); break; case Status::Offline: - fStatus = "offline"; break; + fStatus = tr("offline", "contact status"); break; default: - fStatus = "online"; break; + fStatus = tr("online", "contact status"); break; } //won't print the message if there were no messages before if(f->chatForm->getNumberOfMessages() != 0 && Settings::getInstance().getStatusChangeNotificationEnabled() == true) - f->chatForm->addSystemInfoMessage(f->getName() + " has changed status to " + fStatus, "white"); -} - -void Widget::onFriendSignIn(int friendId, Status status) -{ - Friend* f = FriendList::findFriend(friendId); - if (!f) - return; - - contactListWidget->moveWidget(f->widget, status); - - f->friendStatus = status; - f->widget->updateStatusLight(); - + f->chatForm->addSystemInfoMessage(tr("%1 is now %2", "e.g. \"Dubslow is now online\"").arg(f->getName()).arg(fStatus), "white"); } void Widget::onFriendStatusMessageChanged(int friendId, const QString& message) diff --git a/src/widget/widget.h b/src/widget/widget.h index eaa0917a6..602e8a889 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -90,8 +90,7 @@ private slots: void setStatusMessage(const QString &statusMessage); void addFriend(int friendId, const QString& userId); void addFriendFailed(const QString& userId); - void onFriendStatusChanged(int friendId, Status status); - void onFriendSignIn(int friendId, Status status); + void onFriendStatusChanged(int friendId, Status status); void onFriendStatusMessageChanged(int friendId, const QString& message); void onFriendUsernameChanged(int friendId, const QString& username); void onChatroomWidgetClicked(GenericChatroomWidget *);