1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Add the option to open qTox when a message is recived

This commit is contained in:
Kristian Buchman 2014-11-09 17:23:41 -07:00 committed by Tux3 / Mlkj / !Lev.uXFMLA
parent 4941ec2673
commit cbad1c4966
6 changed files with 36 additions and 1 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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());
}

View File

@ -52,6 +52,7 @@ private slots:
void onAutoAcceptFileChange();
void onAutoSaveDirChange();
void onCheckUpdateChanged();
void onSetShowInFront();
private:
Ui::GeneralSettings *bodyUI;

View File

@ -40,7 +40,7 @@
<x>0</x>
<y>0</y>
<width>511</width>
<height>720</height>
<height>796</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
@ -128,6 +128,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showInFront">
<property name="text">
<string>Open qTox on message received</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item alignment="Qt::AlignLeft">

View File

@ -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())
{