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

Merge branch 'pr482' into HEAD

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-10-20 20:21:36 +02:00
commit 50e1ecf46b
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
7 changed files with 94 additions and 9 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();
@ -137,6 +138,7 @@ void Settings::load()
secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt();
timestampFormat = s.value("timestampFormat", "hh:mm").toString();
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
minimizeToTray = s.value("minimizeToTray", false).toBool();
useNativeStyle = s.value("nativeStyle", false).toBool();
style = s.value("style", "None").toString();
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
@ -226,6 +228,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);
@ -251,6 +254,7 @@ void Settings::save(QString path)
s.setValue("secondColumnHandlePosFromRight", secondColumnHandlePosFromRight);
s.setValue("timestampFormat", timestampFormat);
s.setValue("minimizeOnClose", minimizeOnClose);
s.setValue("minimizeToTray", minimizeToTray);
s.setValue("nativeStyle", useNativeStyle);
s.setValue("style",style);
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
@ -392,6 +396,27 @@ void Settings::setAutostartInTray(bool newValue)
autostartInTray = newValue;
}
bool Settings::getCloseToTray() const
{
return closeToTray;
}
void Settings::setCloseToTray(bool newValue)
{
closeToTray = newValue;
}
bool Settings::getMinimizeToTray() const
{
return minimizeToTray;
}
void Settings::setMinimizeToTray(bool newValue)
{
minimizeToTray = newValue;
}
bool Settings::getStatusChangeNotificationEnabled() const
{
return statusChangeNotificationEnabled;

View File

@ -52,6 +52,12 @@ public:
bool getAutostartInTray() const;
void setAutostartInTray(bool newValue);
bool getCloseToTray() const;
void setCloseToTray(bool newValue);
bool getMinimizeToTray() const;
void setMinimizeToTray(bool newValue);
QString getStyle() const;
void setStyle(const QString& newValue);
@ -188,6 +194,8 @@ private:
QString translation;
static bool makeToxPortable;
bool autostartInTray;
bool closeToTray;
bool minimizeToTray;
bool forceTCP;

View File

@ -40,7 +40,9 @@ 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->statusChangesCheckbox->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
for (auto entry : SmileyPack::listSmileyPacks())
{
@ -72,7 +74,9 @@ 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->statusChangesCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
connect(bodyUI->statusChanges, &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)
connect(bodyUI->cbUDPDisabled, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated);
@ -109,6 +113,16 @@ void GeneralForm::onSetAutostartInTray()
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
}
void GeneralForm::onSetCloseToTray()
{
Settings::getInstance().setCloseToTray(bodyUI->closeToTray->isChecked());
}
void GeneralForm::onSetMinimizeToTray()
{
Settings::getInstance().setMinimizeToTray(bodyUI->minimizeToTray->isChecked());
}
void GeneralForm::onStyleSelected(QString style)
{
Settings::getInstance().setStyle(style);
@ -125,7 +139,7 @@ void GeneralForm::onAutoAwayChanged()
void GeneralForm::onSetStatusChange()
{
Settings::getInstance().setStatusChangeNotificationEnabled(bodyUI->statusChangesCheckbox->isChecked());
Settings::getInstance().setStatusChangeNotificationEnabled(bodyUI->statusChanges->isChecked());
}
void GeneralForm::onSmileyBrowserIndexChanged(int index)

View File

@ -35,6 +35,7 @@ private slots:
void onTranslationUpdated();
void onMakeToxPortableUpdated();
void onSetAutostartInTray();
void onSetCloseToTray();
void onSmileyBrowserIndexChanged(int index);
void onUDPUpdated();
void onProxyAddrEdited();
@ -43,6 +44,7 @@ private slots:
void onStyleSelected(QString style);
void onSetStatusChange();
void onAutoAwayChanged();
void onSetMinimizeToTray();
private:

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>527</width>
<height>500</height>
<height>525</height>
</rect>
</property>
<property name="windowTitle">
@ -74,7 +74,21 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="statusChangesCheckbox">
<widget class="QCheckBox" name="closeToTray">
<property name="text">
<string>Close to tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="minimizeToTray">
<property name="text">
<string>Minimize to tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="statusChanges">
<property name="text">
<string>Show contacts' status changes</string>
</property>

View File

@ -253,10 +253,30 @@ QThread* Widget::getCoreThread()
void Widget::closeEvent(QCloseEvent *event)
{
Settings::getInstance().setWindowGeometry(saveGeometry());
Settings::getInstance().setWindowState(saveState());
Settings::getInstance().setSplitterState(ui->mainSplitter->saveState());
QWidget::closeEvent(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);
}
}
void Widget::changeEvent(QEvent *event)
{
if (event->type() == QEvent::WindowStateChange)
{
if(isMinimized() == true
&& Settings::getInstance().getMinimizeToTray() == true)
{
this->hide();
}
}
}
QString Widget::detectProfile()

View File

@ -65,6 +65,8 @@ public:
~Widget();
virtual void closeEvent(QCloseEvent *event);
virtual void changeEvent(QEvent *event);
public slots:
void onSettingsClicked();