From cbad1c49667e4d44f9635662c70896e49e6d58dc Mon Sep 17 00:00:00 2001 From: Kristian Buchman Date: Sun, 9 Nov 2014 17:23:41 -0700 Subject: [PATCH] Add the option to open qTox when a message is recived --- src/misc/settings.cpp | 12 ++++++++++++ src/misc/settings.h | 4 ++++ 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 | 4 ++++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp index 43181ef5b..caa2493dd 100644 --- a/src/misc/settings.cpp +++ b/src/misc/settings.cpp @@ -120,6 +120,7 @@ void Settings::load() currentProfile = s.value("currentProfile", "").toString(); autoAwayTime = s.value("autoAwayTime", 10).toInt(); checkUpdates = s.value("checkUpdates", false).toBool(); + showInFront = s.value("showInFront", false).toBool(); s.endGroup(); s.beginGroup("Widgets"); @@ -257,6 +258,7 @@ void Settings::save(QString path) s.setValue("currentProfile", currentProfile); s.setValue("autoAwayTime", autoAwayTime); s.setValue("checkUpdates", checkUpdates); + s.setValue("showInFront", showInFront); s.endGroup(); s.beginGroup("Widgets"); @@ -480,6 +482,16 @@ void Settings::setStatusChangeNotificationEnabled(bool newValue) statusChangeNotificationEnabled = newValue; } +bool Settings::getShowInFront() const +{ + return showInFront; +} + +void Settings::setShowInFront(bool newValue) +{ + showInFront = newValue; +} + QString Settings::getTranslation() const { return translation; diff --git a/src/misc/settings.h b/src/misc/settings.h index 813ce7390..15131e34a 100644 --- a/src/misc/settings.h +++ b/src/misc/settings.h @@ -102,6 +102,9 @@ public: bool getCheckUpdates() const; void setCheckUpdates(bool newValue); + bool getShowInFront() const; + void setShowInFront(bool newValue); + QPixmap getSavedAvatar(const QString& ownerId); void saveAvatar(QPixmap& pic, const QString& ownerId); @@ -223,6 +226,7 @@ private: bool minimizeToTray; bool useEmoticons; bool checkUpdates; + bool showInFront; bool forceTCP; diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index 91af2ad1e..4c5470466 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -57,6 +57,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons()); bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled()); bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir()); + bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront()); for (auto entry : SmileyPack::listSmileyPacks()) { @@ -106,6 +107,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray); connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange); connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged())); + connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront); connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange); if(bodyUI->autoacceptFiles->isChecked()) connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange())); @@ -291,3 +293,8 @@ void GeneralForm::onCheckUpdateChanged() { Settings::getInstance().setCheckUpdates(bodyUI->checkUpdates->isChecked()); } + +void GeneralForm::onSetShowInFront() +{ + Settings::getInstance().setShowInFront(bodyUI->showInFront->isChecked()); +} diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h index fcebef7fe..29e818bde 100644 --- a/src/widget/form/settings/generalform.h +++ b/src/widget/form/settings/generalform.h @@ -52,6 +52,7 @@ private slots: void onAutoAcceptFileChange(); void onAutoSaveDirChange(); void onCheckUpdateChanged(); + void onSetShowInFront(); private: Ui::GeneralSettings *bodyUI; diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui index e7a86f1a9..bcf633e49 100644 --- a/src/widget/form/settings/generalsettings.ui +++ b/src/widget/form/settings/generalsettings.ui @@ -40,7 +40,7 @@ 0 0 511 - 720 + 796 @@ -128,6 +128,13 @@ + + + + Open qTox on message received + + + diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 74c21d146..3114f667a 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -767,6 +767,10 @@ void Widget::newMessageAlert() QApplication::alert(this); static QFile sndFile(":audio/notification.pcm"); + if(Settings::getInstance().getShowInFront() == true) + { + this->show(); + } static QByteArray sndData; if (sndData.isEmpty()) {