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");
|
||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||
translation = s.value("translation", "en").toString();
|
||||
showSystemTray = s.value("showSystemTray", false).toBool();
|
||||
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
||||
autostartInTray = s.value("autostartInTray", false).toBool();
|
||||
closeToTray = s.value("closeToTray", false).toBool();
|
||||
|
@ -252,6 +253,7 @@ void Settings::save(QString path)
|
|||
s.setValue("enableIPv6", enableIPv6);
|
||||
s.setValue("translation",translation);
|
||||
s.setValue("makeToxPortable",makeToxPortable);
|
||||
s.setValue("showSystemTray", showSystemTray);
|
||||
s.setValue("autostartInTray",autostartInTray);
|
||||
s.setValue("closeToTray", closeToTray);
|
||||
s.setValue("useProxy", useProxy);
|
||||
|
@ -430,6 +432,16 @@ void Settings::setStyle(const QString& newStyle)
|
|||
style = newStyle;
|
||||
}
|
||||
|
||||
bool Settings::getShowSystemTray() const
|
||||
{
|
||||
return showSystemTray;
|
||||
}
|
||||
|
||||
void Settings::setShowSystemTray(const bool& newValue)
|
||||
{
|
||||
showSystemTray = newValue;
|
||||
}
|
||||
|
||||
void Settings::setUseEmoticons(bool newValue)
|
||||
{
|
||||
useEmoticons = newValue;
|
||||
|
|
|
@ -62,6 +62,9 @@ public:
|
|||
|
||||
QString getStyle() const;
|
||||
void setStyle(const QString& newValue);
|
||||
|
||||
bool getShowSystemTray() const;
|
||||
void setShowSystemTray(const bool& newValue);
|
||||
|
||||
bool getUseEmoticons() const;
|
||||
void setUseEmoticons(bool newValue);
|
||||
|
@ -265,7 +268,8 @@ private:
|
|||
QByteArray windowState;
|
||||
QByteArray splitterState;
|
||||
QString style;
|
||||
|
||||
bool showSystemTray;
|
||||
|
||||
// ChatView
|
||||
int firstColumnHandlePos;
|
||||
int secondColumnHandlePosFromRight;
|
||||
|
|
|
@ -51,6 +51,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
bodyUI->transComboBox->insertItem(i, langs[i]);
|
||||
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
|
||||
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
||||
bodyUI->showSystemTray->setChecked(Settings::getInstance().getShowSystemTray());
|
||||
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
|
||||
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
|
||||
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
|
||||
|
@ -104,6 +105,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
connect(bodyUI->checkUpdates, &QCheckBox::stateChanged, this, &GeneralForm::onCheckUpdateChanged);
|
||||
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
|
||||
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->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
|
||||
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
|
||||
|
@ -150,6 +152,12 @@ void GeneralForm::onMakeToxPortableUpdated()
|
|||
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onSetShowSystemTray()
|
||||
{
|
||||
Settings::getInstance().setShowSystemTray(bodyUI->showSystemTray->isChecked());
|
||||
emit parent->setShowSystemTray(bodyUI->showSystemTray->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onSetAutostartInTray()
|
||||
{
|
||||
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
|
||||
|
|
|
@ -34,6 +34,7 @@ private slots:
|
|||
void onEnableIPv6Updated();
|
||||
void onTranslationUpdated();
|
||||
void onMakeToxPortableUpdated();
|
||||
void onSetShowSystemTray();
|
||||
void onSetAutostartInTray();
|
||||
void onSetCloseToTray();
|
||||
void onSmileyBrowserIndexChanged(int index);
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>511</width>
|
||||
<height>698</height>
|
||||
<width>583</width>
|
||||
<height>748</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
|
||||
|
@ -95,6 +95,13 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="trayLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showSystemTray">
|
||||
<property name="text">
|
||||
<string>Show system tray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="startInTray">
|
||||
<property name="sizePolicy">
|
||||
|
@ -190,9 +197,6 @@
|
|||
<property name="toolTip">
|
||||
<string>Set to 0 to disable</string>
|
||||
</property>
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> minutes</string>
|
||||
</property>
|
||||
|
@ -202,6 +206,9 @@
|
|||
<property name="maximum">
|
||||
<number>2147483647</number>
|
||||
</property>
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -503,5 +510,54 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<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>
|
||||
|
|
|
@ -45,6 +45,9 @@ public:
|
|||
private slots:
|
||||
void onTabChanged(int);
|
||||
|
||||
signals:
|
||||
void setShowSystemTray(bool newValue);
|
||||
|
||||
private:
|
||||
QWidget *head, *body; // keep the others private
|
||||
IdentityForm *ifrm;
|
||||
|
|
|
@ -96,7 +96,9 @@ void Widget::init()
|
|||
this,
|
||||
SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
||||
|
||||
icon->show();
|
||||
if (Settings::getInstance().getShowSystemTray()){
|
||||
icon->show();
|
||||
}
|
||||
|
||||
if(Settings::getInstance().getAutostartInTray() == false)
|
||||
this->show();
|
||||
|
@ -197,6 +199,8 @@ void Widget::init()
|
|||
addFriendForm = new AddFriendForm;
|
||||
settingsWidget = new SettingsWidget();
|
||||
|
||||
connect(settingsWidget, SIGNAL(setShowSystemTray(bool)), this, SLOT(onSetShowSystemTray(bool)));
|
||||
|
||||
connect(core, &Core::connected, this, &Widget::onConnected);
|
||||
connect(core, &Core::disconnected, this, &Widget::onDisconnected);
|
||||
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)
|
||||
{
|
||||
// We can only display widgets from the GUI thread
|
||||
|
|
|
@ -127,6 +127,7 @@ private slots:
|
|||
void onIconClick(QSystemTrayIcon::ActivationReason);
|
||||
void onUserAway();
|
||||
void getPassword(QString info, int passtype, uint8_t* salt);
|
||||
void onSetShowSystemTray(bool newValue);
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
|
Loading…
Reference in New Issue
Block a user