mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Separate setting to show window on new message (without focusing window)
Setting to always notify on messages in group chats (like normal chats) Check for mentioned name only triggers if name is not in the middle of other word
This commit is contained in:
parent
eade2969fe
commit
3bec2751e0
|
@ -136,7 +136,9 @@ void Settings::load()
|
||||||
currentProfile = s.value("currentProfile", "").toString();
|
currentProfile = s.value("currentProfile", "").toString();
|
||||||
autoAwayTime = s.value("autoAwayTime", 10).toInt();
|
autoAwayTime = s.value("autoAwayTime", 10).toInt();
|
||||||
checkUpdates = s.value("checkUpdates", false).toBool();
|
checkUpdates = s.value("checkUpdates", false).toBool();
|
||||||
|
showWindow = s.value("showWindow", true).toBool();
|
||||||
showInFront = s.value("showInFront", false).toBool();
|
showInFront = s.value("showInFront", false).toBool();
|
||||||
|
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
|
||||||
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
|
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
|
||||||
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
||||||
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
||||||
|
@ -290,7 +292,9 @@ void Settings::save(QString path, bool writeFriends)
|
||||||
s.setValue("currentProfile", currentProfile);
|
s.setValue("currentProfile", currentProfile);
|
||||||
s.setValue("autoAwayTime", autoAwayTime);
|
s.setValue("autoAwayTime", autoAwayTime);
|
||||||
s.setValue("checkUpdates", checkUpdates);
|
s.setValue("checkUpdates", checkUpdates);
|
||||||
|
s.setValue("showWindow", showWindow);
|
||||||
s.setValue("showInFront", showInFront);
|
s.setValue("showInFront", showInFront);
|
||||||
|
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
|
||||||
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
||||||
s.setValue("compactLayout", compactLayout);
|
s.setValue("compactLayout", compactLayout);
|
||||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||||
|
@ -566,6 +570,16 @@ void Settings::setShowInFront(bool newValue)
|
||||||
showInFront = newValue;
|
showInFront = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getGroupAlwaysNotify() const
|
||||||
|
{
|
||||||
|
return groupAlwaysNotify;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setGroupAlwaysNotify(bool newValue)
|
||||||
|
{
|
||||||
|
groupAlwaysNotify = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
QString Settings::getTranslation() const
|
QString Settings::getTranslation() const
|
||||||
{
|
{
|
||||||
return translation;
|
return translation;
|
||||||
|
@ -856,6 +870,16 @@ void Settings::setCheckUpdates(bool newValue)
|
||||||
checkUpdates = newValue;
|
checkUpdates = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getShowWindow() const
|
||||||
|
{
|
||||||
|
return showWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setShowWindow(bool newValue)
|
||||||
|
{
|
||||||
|
showWindow = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray Settings::getSplitterState() const
|
QByteArray Settings::getSplitterState() const
|
||||||
{
|
{
|
||||||
return splitterState;
|
return splitterState;
|
||||||
|
|
|
@ -115,9 +115,15 @@ public:
|
||||||
bool getCheckUpdates() const;
|
bool getCheckUpdates() const;
|
||||||
void setCheckUpdates(bool newValue);
|
void setCheckUpdates(bool newValue);
|
||||||
|
|
||||||
|
bool getShowWindow() const;
|
||||||
|
void setShowWindow(bool newValue);
|
||||||
|
|
||||||
bool getShowInFront() const;
|
bool getShowInFront() const;
|
||||||
void setShowInFront(bool newValue);
|
void setShowInFront(bool newValue);
|
||||||
|
|
||||||
|
bool getGroupAlwaysNotify() const;
|
||||||
|
void setGroupAlwaysNotify(bool newValue);
|
||||||
|
|
||||||
QPixmap getSavedAvatar(const QString& ownerId);
|
QPixmap getSavedAvatar(const QString& ownerId);
|
||||||
void saveAvatar(QPixmap& pic, const QString& ownerId);
|
void saveAvatar(QPixmap& pic, const QString& ownerId);
|
||||||
|
|
||||||
|
@ -259,7 +265,9 @@ private:
|
||||||
bool lightTrayIcon;
|
bool lightTrayIcon;
|
||||||
bool useEmoticons;
|
bool useEmoticons;
|
||||||
bool checkUpdates;
|
bool checkUpdates;
|
||||||
|
bool showWindow;
|
||||||
bool showInFront;
|
bool showInFront;
|
||||||
|
bool groupAlwaysNotify;
|
||||||
|
|
||||||
bool forceTCP;
|
bool forceTCP;
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,9 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
|
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
|
||||||
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
|
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
|
||||||
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
|
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
|
||||||
|
bodyUI->showWindow->setChecked(Settings::getInstance().getShowWindow());
|
||||||
bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront());
|
bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront());
|
||||||
|
bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify());
|
||||||
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
|
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
|
||||||
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
|
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
|
||||||
|
|
||||||
|
@ -125,7 +127,9 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
connect(bodyUI->lightTrayIcon, &QCheckBox::stateChanged, this, &GeneralForm::onSetLightTrayIcon);
|
connect(bodyUI->lightTrayIcon, &QCheckBox::stateChanged, this, &GeneralForm::onSetLightTrayIcon);
|
||||||
connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
|
connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
|
||||||
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
|
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
|
||||||
|
connect(bodyUI->showWindow, &QCheckBox::stateChanged, this, &GeneralForm::onShowWindowChanged);
|
||||||
connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront);
|
connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront);
|
||||||
|
connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify);
|
||||||
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange);
|
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange);
|
||||||
if (bodyUI->autoacceptFiles->isChecked())
|
if (bodyUI->autoacceptFiles->isChecked())
|
||||||
connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange()));
|
connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange()));
|
||||||
|
@ -331,11 +335,21 @@ void GeneralForm::onCheckUpdateChanged()
|
||||||
Settings::getInstance().setCheckUpdates(bodyUI->checkUpdates->isChecked());
|
Settings::getInstance().setCheckUpdates(bodyUI->checkUpdates->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralForm::onShowWindowChanged()
|
||||||
|
{
|
||||||
|
Settings::getInstance().setShowWindow(bodyUI->showWindow->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralForm::onSetShowInFront()
|
void GeneralForm::onSetShowInFront()
|
||||||
{
|
{
|
||||||
Settings::getInstance().setShowInFront(bodyUI->showInFront->isChecked());
|
Settings::getInstance().setShowInFront(bodyUI->showInFront->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralForm::onSetGroupAlwaysNotify()
|
||||||
|
{
|
||||||
|
Settings::getInstance().setGroupAlwaysNotify(bodyUI->groupAlwaysNotify->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralForm::onFauxOfflineMessaging()
|
void GeneralForm::onFauxOfflineMessaging()
|
||||||
{
|
{
|
||||||
Settings::getInstance().setFauxOfflineMessaging(bodyUI->cbFauxOfflineMessaging->isChecked());
|
Settings::getInstance().setFauxOfflineMessaging(bodyUI->cbFauxOfflineMessaging->isChecked());
|
||||||
|
|
|
@ -54,7 +54,9 @@ private slots:
|
||||||
void onAutoAcceptFileChange();
|
void onAutoAcceptFileChange();
|
||||||
void onAutoSaveDirChange();
|
void onAutoSaveDirChange();
|
||||||
void onCheckUpdateChanged();
|
void onCheckUpdateChanged();
|
||||||
|
void onShowWindowChanged();
|
||||||
void onSetShowInFront();
|
void onSetShowInFront();
|
||||||
|
void onSetGroupAlwaysNotify();
|
||||||
void onFauxOfflineMessaging();
|
void onFauxOfflineMessaging();
|
||||||
void onCompactLayout();
|
void onCompactLayout();
|
||||||
void onThemeColorChanged(int);
|
void onThemeColorChanged(int);
|
||||||
|
|
|
@ -275,6 +275,13 @@
|
||||||
<string>Chat</string>
|
<string>Chat</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="groupAlwaysNotify">
|
||||||
|
<property name="text">
|
||||||
|
<string>Group chats always notify</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QCheckBox" name="statusChanges">
|
<widget class="QCheckBox" name="statusChanges">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -294,6 +301,13 @@
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="showWindow">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show window</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="showInFront">
|
<widget class="QCheckBox" name="showInFront">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -700,5 +714,21 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>showWindow</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>showInFront</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>329</x>
|
||||||
|
<y>349</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>451</x>
|
||||||
|
<y>349</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -633,8 +633,7 @@ void Widget::hideMainForms()
|
||||||
|
|
||||||
void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername)
|
void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername)
|
||||||
{
|
{
|
||||||
ui->nameLabel->setText(oldUsername); // restore old username until Core tells us to set it
|
setUsername(oldUsername); // restore old username until Core tells us to set it
|
||||||
ui->nameLabel->setToolTip(oldUsername); // for overlength names
|
|
||||||
core->setUsername(newUsername);
|
core->setUsername(newUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,6 +641,7 @@ void Widget::setUsername(const QString& username)
|
||||||
{
|
{
|
||||||
ui->nameLabel->setText(username);
|
ui->nameLabel->setText(username);
|
||||||
ui->nameLabel->setToolTip(username); // for overlength names
|
ui->nameLabel->setToolTip(username); // for overlength names
|
||||||
|
nameMention = QRegExp("([^a-z]|^)" + QRegExp::escape(username) + "([^a-z]|$)", Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage)
|
void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage)
|
||||||
|
@ -806,25 +806,11 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool
|
||||||
QDateTime timestamp = QDateTime::currentDateTime();
|
QDateTime timestamp = QDateTime::currentDateTime();
|
||||||
f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp, true);
|
f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp, true);
|
||||||
|
|
||||||
if (isAction)
|
HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, isAction ? "/me " + message : message,
|
||||||
HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, "/me " + message, f->getToxID().publicKey, timestamp, true);
|
f->getToxID().publicKey, timestamp, true);
|
||||||
else
|
|
||||||
HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, message, f->getToxID().publicKey, timestamp, true);
|
|
||||||
|
|
||||||
if (activeChatroomWidget != nullptr)
|
f->setEventFlag(static_cast<GenericChatroomWidget*>(f->getFriendWidget()) != activeChatroomWidget);
|
||||||
{
|
|
||||||
if ((static_cast<GenericChatroomWidget*>(f->getFriendWidget()) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
|
||||||
{
|
|
||||||
f->setEventFlag(true);
|
|
||||||
newMessageAlert(f->getFriendWidget());
|
newMessageAlert(f->getFriendWidget());
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f->setEventFlag(true);
|
|
||||||
newMessageAlert(f->getFriendWidget());
|
|
||||||
}
|
|
||||||
|
|
||||||
f->getFriendWidget()->updateStatusLight();
|
f->getFriendWidget()->updateStatusLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,17 +825,22 @@ void Widget::onReceiptRecieved(int friendId, int receipt)
|
||||||
|
|
||||||
void Widget::newMessageAlert(GenericChatroomWidget* chat)
|
void Widget::newMessageAlert(GenericChatroomWidget* chat)
|
||||||
{
|
{
|
||||||
|
bool inactiveWindow = isMinimized() || !isActiveWindow();
|
||||||
|
if (!inactiveWindow && activeChatroomWidget != nullptr && chat == activeChatroomWidget)
|
||||||
|
return;
|
||||||
|
|
||||||
QApplication::alert(this);
|
QApplication::alert(this);
|
||||||
|
|
||||||
static QFile sndFile(":audio/notification.pcm");
|
if (Settings::getInstance().getShowWindow())
|
||||||
if ((isMinimized() || !isActiveWindow()) && Settings::getInstance().getShowInFront())
|
|
||||||
{
|
{
|
||||||
this->show();
|
show();
|
||||||
showNormal();
|
if (inactiveWindow && Settings::getInstance().getShowInFront())
|
||||||
activateWindow();
|
setWindowState(Qt::WindowActive);
|
||||||
emit chat->chatroomWidgetClicked(chat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QFile sndFile(":audio/notification.pcm");
|
||||||
static QByteArray sndData;
|
static QByteArray sndData;
|
||||||
|
|
||||||
if (sndData.isEmpty())
|
if (sndData.isEmpty())
|
||||||
{
|
{
|
||||||
sndFile.open(QIODevice::ReadOnly);
|
sndFile.open(QIODevice::ReadOnly);
|
||||||
|
@ -953,25 +944,22 @@ void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QStri
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ToxID author = Core::getInstance()->getGroupPeerToxID(groupnumber, peernumber);
|
ToxID author = Core::getInstance()->getGroupPeerToxID(groupnumber, peernumber);
|
||||||
QString name = core->getUsername();
|
bool targeted = (!author.isMine()) && message.contains(nameMention);
|
||||||
|
|
||||||
bool targeted = (!author.isMine()) && message.contains(name, Qt::CaseInsensitive);
|
|
||||||
if (targeted && !isAction)
|
if (targeted && !isAction)
|
||||||
g->getChatForm()->addAlertMessage(author, message, QDateTime::currentDateTime());
|
g->getChatForm()->addAlertMessage(author, message, QDateTime::currentDateTime());
|
||||||
else
|
else
|
||||||
g->getChatForm()->addMessage(author, message, isAction, QDateTime::currentDateTime(), true);
|
g->getChatForm()->addMessage(author, message, isAction, QDateTime::currentDateTime(), true);
|
||||||
|
|
||||||
if ((static_cast<GenericChatroomWidget*>(g->getGroupWidget()) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
g->setEventFlag(static_cast<GenericChatroomWidget*>(g->getGroupWidget()) != activeChatroomWidget);
|
||||||
{
|
|
||||||
g->setEventFlag(true);
|
if (targeted || Settings::getInstance().getGroupAlwaysNotify())
|
||||||
if (targeted)
|
|
||||||
{
|
|
||||||
newMessageAlert(g->getGroupWidget());
|
newMessageAlert(g->getGroupWidget());
|
||||||
|
|
||||||
|
if (targeted)
|
||||||
g->setMentionedFlag(true); // useful for highlighting line or desktop notifications
|
g->setMentionedFlag(true); // useful for highlighting line or desktop notifications
|
||||||
}
|
|
||||||
g->getGroupWidget()->updateStatusLight();
|
g->getGroupWidget()->updateStatusLight();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Change)
|
void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Change)
|
||||||
{
|
{
|
||||||
|
|
|
@ -171,6 +171,7 @@ private:
|
||||||
Status beforeDisconnect = Status::Offline;
|
Status beforeDisconnect = Status::Offline;
|
||||||
QTimer* idleTimer;
|
QTimer* idleTimer;
|
||||||
QTranslator* translator;
|
QTranslator* translator;
|
||||||
|
QRegExp nameMention;
|
||||||
};
|
};
|
||||||
|
|
||||||
void toxActivateEventHandler(const QByteArray& data);
|
void toxActivateEventHandler(const QByteArray& data);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user