mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
status changes messages and sign in notifications
sign in notifications available only in settings and as a message in chat
This commit is contained in:
parent
ff12166753
commit
698902a8dc
@ -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*>(core)->friendStatusChanged(friendId, friendStatus);
|
||||
emit static_cast<Core*>(core)->friendSignedIn(friendId, friendStatus);
|
||||
if (friendStatus == Status::Offline) {
|
||||
static_cast<Core*>(core)->checkLastOnline(friendId);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -43,6 +43,8 @@ private slots:
|
||||
void onProxyPortEdited(int port);
|
||||
void onUseProxyUpdated();
|
||||
void onStyleSelected(QString style);
|
||||
void onSetStatusChange();
|
||||
void onSetSignInNotifications();
|
||||
|
||||
private:
|
||||
Ui::GeneralSettings *bodyUI;
|
||||
|
@ -53,6 +53,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="statusChangesCheckbox">
|
||||
<property name="text">
|
||||
<string>Show status changes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="signInNotificationsCheckbox">
|
||||
<property name="text">
|
||||
<string>Notify me when contacts sign in</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -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)
|
||||
|
@ -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 *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user