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

minimize to tray

This commit is contained in:
agilob 2014-10-20 12:50:12 +01:00
parent d268360c51
commit 6e5068840d
7 changed files with 55 additions and 9 deletions

View File

@ -138,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();
@ -252,6 +253,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);
@ -402,6 +404,17 @@ 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

@ -55,6 +55,9 @@ public:
bool getCloseToTray() const;
void setCloseToTray(bool newValue);
bool getMinimizeToTray() const;
void setMinimizeToTray(bool newValue);
QString getStyle() const;
void setStyle(const QString& newValue);
@ -189,6 +192,7 @@ private:
static bool makeToxPortable;
bool autostartInTray;
bool closeToTray;
bool minimizeToTray;
bool forceTCP;

View File

@ -40,8 +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->closeToTrayCheckbox->setChecked(Settings::getInstance().getCloseToTray());
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())
{
@ -73,8 +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->closeToTrayCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
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);
@ -113,7 +115,12 @@ void GeneralForm::onSetAutostartInTray()
void GeneralForm::onSetCloseToTray()
{
Settings::getInstance().setCloseToTray(bodyUI->closeToTrayCheckbox->isChecked());
Settings::getInstance().setCloseToTray(bodyUI->closeToTray->isChecked());
}
void GeneralForm::onSetMinimizeToTray()
{
Settings::getInstance().setMinimizeToTray(bodyUI->minimizeToTray->isChecked());
}
void GeneralForm::onStyleSelected(QString style)
@ -132,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

@ -44,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,14 +74,21 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeToTrayCheckbox">
<widget class="QCheckBox" name="closeToTray">
<property name="text">
<string>Close to tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="statusChangesCheckbox">
<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

@ -268,6 +268,18 @@ void Widget::closeEvent(QCloseEvent *event)
}
}
void Widget::changeEvent(QEvent *event)
{
if (event->type() == QEvent::WindowStateChange)
{
if(isMinimized() == true
&& Settings::getInstance().getMinimizeToTray() == true)
{
this->hide();
}
}
}
QString Widget::detectProfile()
{
QDir dir(Settings::getSettingsDirPath());

View File

@ -65,6 +65,8 @@ public:
~Widget();
virtual void closeEvent(QCloseEvent *event);
virtual void changeEvent(QEvent *event);
signals:
void friendRequestAccepted(const QString& userId);