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

closing to tray, gui and settings

This commit is contained in:
agilob 2014-10-19 20:47:06 +01:00
parent 9ba1d4cf41
commit d268360c51
No known key found for this signature in database
GPG Key ID: 2CACF3EEF598C663
6 changed files with 43 additions and 4 deletions

View File

@ -112,6 +112,7 @@ void Settings::load()
translation = s.value("translation", "").toString();
makeToxPortable = s.value("makeToxPortable", false).toBool();
autostartInTray = s.value("autostartInTray", false).toBool();
closeToTray = s.value("closeToTray", false).toBool();
forceTCP = s.value("forceTCP", false).toBool();
useProxy = s.value("useProxy", false).toBool();
proxyAddr = s.value("proxyAddr", "").toString();
@ -225,6 +226,7 @@ void Settings::save(QString path)
s.setValue("translation",translation);
s.setValue("makeToxPortable",makeToxPortable);
s.setValue("autostartInTray",autostartInTray);
s.setValue("closeToTray", closeToTray);
s.setValue("useProxy", useProxy);
s.setValue("forceTCP", forceTCP);
s.setValue("proxyAddr", proxyAddr);
@ -390,6 +392,16 @@ void Settings::setAutostartInTray(bool newValue)
autostartInTray = newValue;
}
bool Settings::getCloseToTray() const
{
return closeToTray;
}
void Settings::setCloseToTray(bool newValue)
{
closeToTray = newValue;
}
bool Settings::getStatusChangeNotificationEnabled() const
{
return statusChangeNotificationEnabled;

View File

@ -52,6 +52,9 @@ public:
bool getAutostartInTray() const;
void setAutostartInTray(bool newValue);
bool getCloseToTray() const;
void setCloseToTray(bool newValue);
QString getStyle() const;
void setStyle(const QString& newValue);
@ -185,6 +188,7 @@ private:
QString translation;
static bool makeToxPortable;
bool autostartInTray;
bool closeToTray;
bool forceTCP;

View File

@ -40,6 +40,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
bodyUI->closeToTrayCheckbox->setChecked(Settings::getInstance().getCloseToTray());
bodyUI->statusChangesCheckbox->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
for (auto entry : SmileyPack::listSmileyPacks())
@ -72,6 +73,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
connect(bodyUI->closeToTrayCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
connect(bodyUI->statusChangesCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
// new syntax can't handle overloaded signals... (at least not in a pretty way)
@ -109,6 +111,11 @@ void GeneralForm::onSetAutostartInTray()
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
}
void GeneralForm::onSetCloseToTray()
{
Settings::getInstance().setCloseToTray(bodyUI->closeToTrayCheckbox->isChecked());
}
void GeneralForm::onStyleSelected(QString style)
{
Settings::getInstance().setStyle(style);

View File

@ -35,6 +35,7 @@ private slots:
void onTranslationUpdated();
void onMakeToxPortableUpdated();
void onSetAutostartInTray();
void onSetCloseToTray();
void onSmileyBrowserIndexChanged(int index);
void onUDPUpdated();
void onProxyAddrEdited();

View File

@ -73,6 +73,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeToTrayCheckbox">
<property name="text">
<string>Close to tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="statusChangesCheckbox">
<property name="text">

View File

@ -253,12 +253,20 @@ QThread* Widget::getCoreThread()
}
void Widget::closeEvent(QCloseEvent *event)
{
if(Settings::getInstance().getCloseToTray() == true)
{
event->ignore();
this->hide();
}
else
{
Settings::getInstance().setWindowGeometry(saveGeometry());
Settings::getInstance().setWindowState(saveState());
Settings::getInstance().setSplitterState(ui->mainSplitter->saveState());
QWidget::closeEvent(event);
}
}
QString Widget::detectProfile()
{