mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
I implemented a new setting, which toggles the visibility of the system tray icon.
Background: On Ubuntu 14.04, system trays in Qt5 don't integrate into Unity.
This commit is contained in:
parent
05c9ae9390
commit
11f9cb0cbf
|
@ -112,6 +112,7 @@ void Settings::load()
|
||||||
s.beginGroup("General");
|
s.beginGroup("General");
|
||||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||||
translation = s.value("translation", "en").toString();
|
translation = s.value("translation", "en").toString();
|
||||||
|
showSystemTray = s.value("showSystemTray", false).toBool();
|
||||||
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
||||||
autostartInTray = s.value("autostartInTray", false).toBool();
|
autostartInTray = s.value("autostartInTray", false).toBool();
|
||||||
closeToTray = s.value("closeToTray", false).toBool();
|
closeToTray = s.value("closeToTray", false).toBool();
|
||||||
|
@ -252,6 +253,7 @@ void Settings::save(QString path)
|
||||||
s.setValue("enableIPv6", enableIPv6);
|
s.setValue("enableIPv6", enableIPv6);
|
||||||
s.setValue("translation",translation);
|
s.setValue("translation",translation);
|
||||||
s.setValue("makeToxPortable",makeToxPortable);
|
s.setValue("makeToxPortable",makeToxPortable);
|
||||||
|
s.setValue("showSystemTray", showSystemTray);
|
||||||
s.setValue("autostartInTray",autostartInTray);
|
s.setValue("autostartInTray",autostartInTray);
|
||||||
s.setValue("closeToTray", closeToTray);
|
s.setValue("closeToTray", closeToTray);
|
||||||
s.setValue("useProxy", useProxy);
|
s.setValue("useProxy", useProxy);
|
||||||
|
@ -430,6 +432,16 @@ void Settings::setStyle(const QString& newStyle)
|
||||||
style = newStyle;
|
style = newStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getShowSystemTray() const
|
||||||
|
{
|
||||||
|
return showSystemTray;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setShowSystemTray(const bool& newValue)
|
||||||
|
{
|
||||||
|
showSystemTray = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::setUseEmoticons(bool newValue)
|
void Settings::setUseEmoticons(bool newValue)
|
||||||
{
|
{
|
||||||
useEmoticons = newValue;
|
useEmoticons = newValue;
|
||||||
|
|
|
@ -62,6 +62,9 @@ public:
|
||||||
|
|
||||||
QString getStyle() const;
|
QString getStyle() const;
|
||||||
void setStyle(const QString& newValue);
|
void setStyle(const QString& newValue);
|
||||||
|
|
||||||
|
bool getShowSystemTray() const;
|
||||||
|
void setShowSystemTray(const bool& newValue);
|
||||||
|
|
||||||
bool getUseEmoticons() const;
|
bool getUseEmoticons() const;
|
||||||
void setUseEmoticons(bool newValue);
|
void setUseEmoticons(bool newValue);
|
||||||
|
@ -265,7 +268,8 @@ private:
|
||||||
QByteArray windowState;
|
QByteArray windowState;
|
||||||
QByteArray splitterState;
|
QByteArray splitterState;
|
||||||
QString style;
|
QString style;
|
||||||
|
bool showSystemTray;
|
||||||
|
|
||||||
// ChatView
|
// ChatView
|
||||||
int firstColumnHandlePos;
|
int firstColumnHandlePos;
|
||||||
int secondColumnHandlePosFromRight;
|
int secondColumnHandlePosFromRight;
|
||||||
|
|
|
@ -51,6 +51,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
bodyUI->transComboBox->insertItem(i, langs[i]);
|
bodyUI->transComboBox->insertItem(i, langs[i]);
|
||||||
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
|
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
|
||||||
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
||||||
|
bodyUI->showSystemTray->setChecked(Settings::getInstance().getShowSystemTray());
|
||||||
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
|
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
|
||||||
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
|
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
|
||||||
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
|
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
|
||||||
|
@ -104,6 +105,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
connect(bodyUI->checkUpdates, &QCheckBox::stateChanged, this, &GeneralForm::onCheckUpdateChanged);
|
connect(bodyUI->checkUpdates, &QCheckBox::stateChanged, this, &GeneralForm::onCheckUpdateChanged);
|
||||||
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
|
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
|
||||||
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
|
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
|
||||||
|
connect(bodyUI->showSystemTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowSystemTray);
|
||||||
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
|
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
|
||||||
connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
|
connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
|
||||||
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
|
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
|
||||||
|
@ -150,6 +152,12 @@ void GeneralForm::onMakeToxPortableUpdated()
|
||||||
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked());
|
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralForm::onSetShowSystemTray()
|
||||||
|
{
|
||||||
|
Settings::getInstance().setShowSystemTray(bodyUI->showSystemTray->isChecked());
|
||||||
|
emit parent->setShowSystemTray(bodyUI->showSystemTray->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralForm::onSetAutostartInTray()
|
void GeneralForm::onSetAutostartInTray()
|
||||||
{
|
{
|
||||||
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
|
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
|
||||||
|
|
|
@ -34,6 +34,7 @@ private slots:
|
||||||
void onEnableIPv6Updated();
|
void onEnableIPv6Updated();
|
||||||
void onTranslationUpdated();
|
void onTranslationUpdated();
|
||||||
void onMakeToxPortableUpdated();
|
void onMakeToxPortableUpdated();
|
||||||
|
void onSetShowSystemTray();
|
||||||
void onSetAutostartInTray();
|
void onSetAutostartInTray();
|
||||||
void onSetCloseToTray();
|
void onSetCloseToTray();
|
||||||
void onSmileyBrowserIndexChanged(int index);
|
void onSmileyBrowserIndexChanged(int index);
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>511</width>
|
<width>583</width>
|
||||||
<height>698</height>
|
<height>748</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
|
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
|
||||||
|
@ -95,6 +95,13 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="trayLayout">
|
<layout class="QHBoxLayout" name="trayLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="showSystemTray">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show system tray</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="startInTray">
|
<widget class="QCheckBox" name="startInTray">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -190,9 +197,6 @@
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Set to 0 to disable</string>
|
<string>Set to 0 to disable</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="showGroupSeparator" stdset="0">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string> minutes</string>
|
<string> minutes</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -202,6 +206,9 @@
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>2147483647</number>
|
<number>2147483647</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="showGroupSeparator" stdset="0">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -503,5 +510,54 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>showSystemTray</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>startInTray</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>125</x>
|
||||||
|
<y>122</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>207</x>
|
||||||
|
<y>124</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>showSystemTray</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>closeToTray</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>66</x>
|
||||||
|
<y>119</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>346</x>
|
||||||
|
<y>116</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>showSystemTray</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>minimizeToTray</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>83</x>
|
||||||
|
<y>121</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>476</x>
|
||||||
|
<y>120</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void onTabChanged(int);
|
void onTabChanged(int);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void setShowSystemTray(bool newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *head, *body; // keep the others private
|
QWidget *head, *body; // keep the others private
|
||||||
IdentityForm *ifrm;
|
IdentityForm *ifrm;
|
||||||
|
|
|
@ -96,7 +96,9 @@ void Widget::init()
|
||||||
this,
|
this,
|
||||||
SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
||||||
|
|
||||||
icon->show();
|
if (Settings::getInstance().getShowSystemTray()){
|
||||||
|
icon->show();
|
||||||
|
}
|
||||||
|
|
||||||
if(Settings::getInstance().getAutostartInTray() == false)
|
if(Settings::getInstance().getAutostartInTray() == false)
|
||||||
this->show();
|
this->show();
|
||||||
|
@ -197,6 +199,8 @@ void Widget::init()
|
||||||
addFriendForm = new AddFriendForm;
|
addFriendForm = new AddFriendForm;
|
||||||
settingsWidget = new SettingsWidget();
|
settingsWidget = new SettingsWidget();
|
||||||
|
|
||||||
|
connect(settingsWidget, SIGNAL(setShowSystemTray(bool)), this, SLOT(onSetShowSystemTray(bool)));
|
||||||
|
|
||||||
connect(core, &Core::connected, this, &Widget::onConnected);
|
connect(core, &Core::connected, this, &Widget::onConnected);
|
||||||
connect(core, &Core::disconnected, this, &Widget::onDisconnected);
|
connect(core, &Core::disconnected, this, &Widget::onDisconnected);
|
||||||
connect(core, &Core::failedToStart, this, &Widget::onFailedToStartCore);
|
connect(core, &Core::failedToStart, this, &Widget::onFailedToStartCore);
|
||||||
|
@ -1105,6 +1109,11 @@ void Widget::getPassword(QString info, int passtype, uint8_t* salt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::onSetShowSystemTray(bool newValue){
|
||||||
|
icon->setVisible(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QMessageBox::StandardButton Widget::showWarningMsgBox(const QString& title, const QString& msg, QMessageBox::StandardButtons buttons)
|
QMessageBox::StandardButton Widget::showWarningMsgBox(const QString& title, const QString& msg, QMessageBox::StandardButtons buttons)
|
||||||
{
|
{
|
||||||
// We can only display widgets from the GUI thread
|
// We can only display widgets from the GUI thread
|
||||||
|
|
|
@ -127,6 +127,7 @@ private slots:
|
||||||
void onIconClick(QSystemTrayIcon::ActivationReason);
|
void onIconClick(QSystemTrayIcon::ActivationReason);
|
||||||
void onUserAway();
|
void onUserAway();
|
||||||
void getPassword(QString info, int passtype, uint8_t* salt);
|
void getPassword(QString info, int passtype, uint8_t* salt);
|
||||||
|
void onSetShowSystemTray(bool newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user