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

Merge branch 'pr870'

Conflicts:
	src/widget/form/settings/generalform.cpp
This commit is contained in:
Dubslow 2014-12-01 14:47:54 -06:00
commit 173eda7700
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
8 changed files with 242 additions and 153 deletions

View File

@ -125,6 +125,7 @@ void Settings::load()
makeToxPortable = s.value("makeToxPortable", false).toBool();
autostartInTray = s.value("autostartInTray", false).toBool();
closeToTray = s.value("closeToTray", false).toBool();
trayShowsUserStatus = s.value("trayShowsUserStatus", false).toBool();
forceTCP = s.value("forceTCP", false).toBool();
useProxy = s.value("useProxy", false).toBool();
proxyAddr = s.value("proxyAddr", "").toString();
@ -266,6 +267,7 @@ void Settings::save(QString path)
s.setValue("showSystemTray", showSystemTray);
s.setValue("autostartInTray",autostartInTray);
s.setValue("closeToTray", closeToTray);
s.setValue("trayShowsUserStatus", trayShowsUserStatus);
s.setValue("useProxy", useProxy);
s.setValue("forceTCP", forceTCP);
s.setValue("proxyAddr", proxyAddr);
@ -487,6 +489,16 @@ void Settings::setCloseToTray(bool newValue)
closeToTray = newValue;
}
bool Settings::getTrayShowsUserStatus() const
{
return trayShowsUserStatus;
}
void Settings::setTrayShowsUserStatus(bool newValue)
{
trayShowsUserStatus = newValue;
}
bool Settings::getMinimizeToTray() const
{
return minimizeToTray;

View File

@ -58,6 +58,9 @@ public:
bool getCloseToTray() const;
void setCloseToTray(bool newValue);
bool getTrayShowsUserStatus() const;
void setTrayShowsUserStatus(bool newValue);
bool getMinimizeToTray() const;
void setMinimizeToTray(bool newValue);
@ -240,6 +243,7 @@ private:
bool autostartInTray;
bool closeToTray;
bool minimizeToTray;
bool trayShowsUserStatus;
bool useEmoticons;
bool checkUpdates;
bool showInFront;

View File

@ -45,17 +45,25 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED);
bodyUI->checkUpdates->setChecked(Settings::getInstance().getCheckUpdates());
bodyUI->trayLayout->addStretch();
bodyUI->trayBehavior->addStretch();
bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6());
for (int i = 0; i < langs.size(); i++)
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());
bool showSystemTray = Settings::getInstance().getShowSystemTray();
bodyUI->showSystemTray->setChecked(showSystemTray);
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
bodyUI->startInTray->setEnabled(showSystemTray);
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
bodyUI->closeToTray->setEnabled(showSystemTray);
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
bodyUI->minimizeToTray->setEnabled(showSystemTray);
bodyUI->trayShowsUserStatus->setChecked(Settings::getInstance().getTrayShowsUserStatus());
bodyUI->trayShowsUserStatus->setEnabled(showSystemTray);
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
@ -114,6 +122,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
connect(bodyUI->trayShowsUserStatus, &QCheckBox::stateChanged, this, &GeneralForm::onSettrayShowsUserStatus);
connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront);
@ -179,6 +188,12 @@ void GeneralForm::onSetMinimizeToTray()
Settings::getInstance().setMinimizeToTray(bodyUI->minimizeToTray->isChecked());
}
void GeneralForm::onSettrayShowsUserStatus()
{
Settings::getInstance().setTrayShowsUserStatus(bodyUI->trayShowsUserStatus->isChecked());
Widget::getInstance()->updateTrayIcon();
}
void GeneralForm::onStyleSelected(QString style)
{
if(bodyUI->styleBrowser->currentIndex() == 0)

View File

@ -49,6 +49,7 @@ private slots:
void onAutoAwayChanged();
void onUseEmoticonsChange();
void onSetMinimizeToTray();
void onSettrayShowsUserStatus();
void onReconnectClicked();
void onAutoAcceptFileChange();
void onAutoSaveDirChange();

View File

@ -39,8 +39,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>524</width>
<height>726</height>
<width>509</width>
<height>849</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
@ -94,14 +94,23 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="trayLayout">
<item>
<widget class="QGroupBox" name="trayGroup">
<property name="title">
<string>System tray integration</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="showSystemTray">
<property name="text">
<string>Show system tray icon</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="trayBehavior">
<item>
<widget class="QCheckBox" name="startInTray">
<property name="sizePolicy">
@ -143,6 +152,22 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="trayShowsUserStatus">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Tray icon displays user status</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="statusChanges">
<property name="text">
@ -197,9 +222,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>
@ -209,6 +231,9 @@
<property name="maximum">
<number>2147483647</number>
</property>
<property name="showGroupSeparator" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@ -274,15 +299,21 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="smileyHLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="smileyPackLabel">
<property name="text">
<string extracomment="Text on smiley pack label">Smiley Pack</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QComboBox" name="smileyPackBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -292,9 +323,24 @@
</property>
</widget>
</item>
</layout>
<item row="2" column="0">
<widget class="QLabel" name="styleLabel">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QComboBox" name="styleBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
@ -351,37 +397,14 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="styleHLayout">
<item>
<widget class="QLabel" name="styleLabel">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QComboBox" name="styleBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="themeColorLayour">
<item>
<item row="3" column="0">
<widget class="QLabel" name="themeColorLabel">
<property name="text">
<string>Theme color</string>
</property>
</widget>
</item>
<item>
<item row="3" column="1">
<widget class="QComboBox" name="themeColorCBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -391,18 +414,14 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="emoiticonHLayout">
<item>
<item row="4" column="0">
<widget class="QLabel" name="emoticonSizeLabel">
<property name="text">
<string>Emoticon size</string>
</property>
</widget>
</item>
<item>
<item row="4" column="1">
<widget class="QSpinBox" name="emoticonSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -427,18 +446,14 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="timestampHLayout">
<item>
<item row="5" column="0">
<widget class="QLabel" name="timestampLabel">
<property name="text">
<string>Timestamp format</string>
</property>
</widget>
</item>
<item>
<item row="5" column="1">
<widget class="QComboBox" name="timestamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -548,12 +563,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>125</x>
<y>122</y>
<x>105</x>
<y>144</y>
</hint>
<hint type="destinationlabel">
<x>207</x>
<y>124</y>
<x>119</x>
<y>177</y>
</hint>
</hints>
</connection>
@ -564,12 +579,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>66</x>
<y>119</y>
<x>205</x>
<y>146</y>
</hint>
<hint type="destinationlabel">
<x>346</x>
<y>116</y>
<x>224</x>
<y>178</y>
</hint>
</hints>
</connection>
@ -580,12 +595,28 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>83</x>
<y>121</y>
<x>180</x>
<y>144</y>
</hint>
<hint type="destinationlabel">
<x>476</x>
<y>120</y>
<x>359</x>
<y>178</y>
</hint>
</hints>
</connection>
<connection>
<sender>showSystemTray</sender>
<signal>toggled(bool)</signal>
<receiver>trayShowsUserStatus</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>148</x>
<y>143</y>
</hint>
<hint type="destinationlabel">
<x>158</x>
<y>205</y>
</hint>
</hints>
</connection>

View File

@ -86,7 +86,7 @@ void Widget::init()
if (QSystemTrayIcon::isSystemTrayAvailable())
{
icon = new QSystemTrayIcon(this);
icon->setIcon(this->windowIcon());
updateTrayIcon();
trayMenu = new QMenu;
statusOnline = new QAction(tr("Online"), this);
@ -293,6 +293,26 @@ void Widget::setTranslation()
QCoreApplication::installTranslator(translator);
}
void Widget::updateTrayIcon()
{
if(Settings::getInstance().getTrayShowsUserStatus())
{
QString status = ui->statusButton->property("status").toString();
QString icon;
if(status == "online")
icon = ":img/status/dot_online_2x.png";
else if(status == "away")
icon = ":img/status/dot_idle_2x.png";
else if(status == "busy")
icon = ":img/status/dot_busy_2x.png";
else
icon = ":img/status/dot_away_2x.png";
this->icon->setIcon(QIcon(icon));
}
else
icon->setIcon(windowIcon());
}
Widget::~Widget()
{
core->saveConfiguration();
@ -541,7 +561,7 @@ void Widget::onStatusSet(Status status)
ui->statusButton->setProperty("status" ,"offline");
break;
}
updateTrayIcon();
Style::repolish(ui->statusButton);
}

View File

@ -64,6 +64,7 @@ public:
void clearContactsList();
void setIdleTimer(int minutes);
void setTranslation();
void updateTrayIcon();
Q_INVOKABLE QMessageBox::StandardButton showWarningMsgBox(const QString& title, const QString& msg,
QMessageBox::StandardButtons buttonss = QMessageBox::Ok);
Q_INVOKABLE void setEnabledThreadsafe(bool enabled);

View File

@ -29,6 +29,11 @@ QCheckBox
color: black;
}
QCheckBox:disabled
{
color: grey;
}
QSpinBox
{
background: white;