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

View File

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

View File

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

View File

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

View File

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

View File

@ -86,7 +86,7 @@ void Widget::init()
if (QSystemTrayIcon::isSystemTrayAvailable()) if (QSystemTrayIcon::isSystemTrayAvailable())
{ {
icon = new QSystemTrayIcon(this); icon = new QSystemTrayIcon(this);
icon->setIcon(this->windowIcon()); updateTrayIcon();
trayMenu = new QMenu; trayMenu = new QMenu;
statusOnline = new QAction(tr("Online"), this); statusOnline = new QAction(tr("Online"), this);
@ -293,6 +293,26 @@ void Widget::setTranslation()
QCoreApplication::installTranslator(translator); 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() Widget::~Widget()
{ {
core->saveConfiguration(); core->saveConfiguration();
@ -541,7 +561,7 @@ void Widget::onStatusSet(Status status)
ui->statusButton->setProperty("status" ,"offline"); ui->statusButton->setProperty("status" ,"offline");
break; break;
} }
updateTrayIcon();
Style::repolish(ui->statusButton); Style::repolish(ui->statusButton);
} }

View File

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

View File

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