#6524 Adds new minimize to tray functionality and setting to enable/disable
This commit is contained in:
parent
629ed12885
commit
d67f2e8036
|
@ -57,7 +57,8 @@ AppConfig::AppConfig(QSettings* settings) :
|
|||
m_CryptoEnabled(false),
|
||||
m_AutoHide(false),
|
||||
m_LastExpiringWarningTime(0),
|
||||
m_AutoConfigServer()
|
||||
m_AutoConfigServer(),
|
||||
m_MinimizeToTray(false)
|
||||
{
|
||||
Q_ASSERT(m_pSettings);
|
||||
|
||||
|
@ -165,6 +166,7 @@ void AppConfig::loadSettings()
|
|||
m_lastVersion = settings().value("lastVersion", "Unknown").toString();
|
||||
m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt();
|
||||
m_ActivationHasRun = settings().value("activationHasRun", false).toBool();
|
||||
m_MinimizeToTray = settings().value("minimizeToTray", false).toBool();
|
||||
}
|
||||
|
||||
void AppConfig::saveSettings()
|
||||
|
@ -191,6 +193,7 @@ void AppConfig::saveSettings()
|
|||
settings().setValue("lastVersion", m_lastVersion);
|
||||
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
||||
settings().setValue("activationHasRun", m_ActivationHasRun);
|
||||
settings().setValue("minimizeToTray", m_MinimizeToTray);
|
||||
settings().sync();
|
||||
}
|
||||
|
||||
|
@ -298,3 +301,7 @@ bool AppConfig::getCryptoEnabled() const {
|
|||
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
||||
|
||||
bool AppConfig::getAutoHide() { return m_AutoHide; }
|
||||
|
||||
void AppConfig::setMinimizeToTray(bool b) { m_MinimizeToTray = b; }
|
||||
|
||||
bool AppConfig::getMinimizeToTray() { return m_MinimizeToTray; }
|
||||
|
|
|
@ -110,6 +110,9 @@ class AppConfig: public QObject
|
|||
|
||||
QString lastVersion() const;
|
||||
|
||||
void setMinimizeToTray(bool b);
|
||||
bool getMinimizeToTray();
|
||||
|
||||
void saveSettings();
|
||||
void setLastVersion(QString version);
|
||||
|
||||
|
@ -150,6 +153,7 @@ protected:
|
|||
QString m_lastVersion;
|
||||
int m_LastExpiringWarningTime;
|
||||
bool m_ActivationHasRun;
|
||||
bool m_MinimizeToTray;
|
||||
|
||||
static const char m_SynergysName[];
|
||||
static const char m_SynergycName[];
|
||||
|
|
|
@ -223,28 +223,6 @@ void MainWindow::open()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::onModeChanged(bool startDesktop, bool applyService)
|
||||
{
|
||||
if (appConfig().processMode() == Service)
|
||||
{
|
||||
// ensure that the apply button actually does something, since desktop
|
||||
// mode screws around with connecting/disconnecting the action.
|
||||
disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
|
||||
connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
|
||||
|
||||
if (applyService)
|
||||
{
|
||||
stopDesktop();
|
||||
startSynergy();
|
||||
}
|
||||
}
|
||||
else if ((appConfig().processMode() == Desktop) && startDesktop)
|
||||
{
|
||||
stopService();
|
||||
startSynergy();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setStatus(const QString &status)
|
||||
{
|
||||
m_pStatusLabel->setText(status);
|
||||
|
@ -1093,10 +1071,15 @@ void MainWindow::changeEvent(QEvent* event)
|
|||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
QMainWindow::changeEvent(event);
|
||||
case QEvent::WindowStateChange:
|
||||
{
|
||||
windowStateChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// all that do not return are allowing the event to propagate
|
||||
QMainWindow::changeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::addZeroconfServer(const QString name)
|
||||
|
@ -1291,21 +1274,7 @@ void MainWindow::updateAutoConfigWidgets()
|
|||
|
||||
void MainWindow::on_m_pActionSettings_triggered()
|
||||
{
|
||||
ProcessMode lastProcessMode = appConfig().processMode();
|
||||
bool lastAutoConfig = appConfig().autoConfig();
|
||||
|
||||
SettingsDialog dlg(this, appConfig());
|
||||
dlg.exec();
|
||||
|
||||
if (lastProcessMode != appConfig().processMode())
|
||||
{
|
||||
onModeChanged(true, true);
|
||||
}
|
||||
|
||||
if (lastAutoConfig != appConfig().autoConfig()) {
|
||||
updateAutoConfigWidgets();
|
||||
updateZeroconfService();
|
||||
}
|
||||
SettingsDialog(this, appConfig()).exec();
|
||||
}
|
||||
|
||||
void MainWindow::autoAddScreen(const QString name)
|
||||
|
@ -1439,3 +1408,9 @@ void MainWindow::on_m_pComboServerList_currentIndexChanged(const QString &server
|
|||
appConfig().setAutoConfigServer(server);
|
||||
appConfig().saveSettings();
|
||||
}
|
||||
|
||||
void MainWindow::windowStateChanged()
|
||||
{
|
||||
if (windowState() == Qt::WindowMinimized && appConfig().getMinimizeToTray())
|
||||
hide();
|
||||
}
|
||||
|
|
|
@ -176,7 +176,6 @@ public slots:
|
|||
bool serverArgs(QStringList& args, QString& app);
|
||||
void setStatus(const QString& status);
|
||||
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
||||
void onModeChanged(bool startDesktop, bool applyService);
|
||||
void updateFromLogLine(const QString& line);
|
||||
QString getIPAddresses();
|
||||
void stopService();
|
||||
|
@ -203,6 +202,9 @@ public slots:
|
|||
void showEvent (QShowEvent*);
|
||||
void secureSocket(bool secureSocket);
|
||||
|
||||
void windowStateChanged();
|
||||
|
||||
|
||||
private:
|
||||
#ifndef SYNERGY_ENTERPRISE
|
||||
LicenseManager* m_LicenseManager;
|
||||
|
|
|
@ -57,6 +57,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
|||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
||||
m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide());
|
||||
m_pCheckBoxMinimizeToTray->setChecked(appConfig().getMinimizeToTray());
|
||||
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled());
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
m_pBonjourWindows = new BonjourWindows(this, m_pMainWindow, m_appConfig);
|
||||
|
@ -66,7 +68,6 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
|||
|
||||
m_pComboElevate->setCurrentIndex(static_cast<int>(appConfig().elevateMode()));
|
||||
|
||||
m_pCheckBoxAutoHide->hide();
|
||||
#else
|
||||
// elevate checkbox is only useful on ms windows.
|
||||
m_pLabelElevate->hide();
|
||||
|
@ -106,9 +107,10 @@ void SettingsDialog::accept()
|
|||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||
appConfig().setAutoConfig(m_pCheckBoxAutoConfig->isChecked());
|
||||
appConfig().setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
|
||||
appConfig().saveSettings();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
|
|
@ -114,13 +114,6 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_pComboLanguage"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxAutoHide">
|
||||
<property name="text">
|
||||
<string>&Hide on startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="m_pComboElevate">
|
||||
<property name="toolTip">
|
||||
|
@ -153,6 +146,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxAutoHide">
|
||||
<property name="text">
|
||||
<string>&Hide on startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxMinimizeToTray">
|
||||
<property name="text">
|
||||
<string>Minimize to System &Tray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -392,6 +399,7 @@
|
|||
<tabstop>m_pLineEditScreenName</tabstop>
|
||||
<tabstop>m_pSpinBoxPort</tabstop>
|
||||
<tabstop>m_pLineEditInterface</tabstop>
|
||||
<tabstop>m_pCheckBoxMinimizeToTray</tabstop>
|
||||
<tabstop>m_pComboElevate</tabstop>
|
||||
<tabstop>m_pCheckBoxAutoHide</tabstop>
|
||||
<tabstop>m_pComboLogLevel</tabstop>
|
||||
|
|
Loading…
Reference in New Issue