SYNERGY-799 Update Synergy UI. Main screen (#6973)

* SYNERGY-799 Add computer name field

* SYNERGY-799 Add field “This computers IP addresses”

* SYNERGY-799 Arrange panels

* SYNERGY-799 Increase size for panels

* SYNERGY-799 Add radio buttons

* SYNERGY-799 Remove unnecessary label

* SYNERGY-799 Radio buttons switch logic

* SYNERGY-799 Move configure server button

* SYNERGY-799 Move “Existing Config” to “Advanced settings”

* SYNERGY-799 Server state label has been added

* SYNERGY-799 Client state label has been added

* SYNERGY-799 Button connect has been added

* SYNERGY-799 Add “TLS/SSL active - view”

* SYNERGY-799 Fixed issue with list on welcome screen

* SYNERGY-799 Fixed issue with auto switching

* SYNERGY-799 Fix issue with server status message

* SYNERGY-799 Disable all tabs if external config is selected

* SYNERGY-799 Fix code smells

* Update ChangeLog
This commit is contained in:
SerhiiGadzhilov 2021-04-12 12:03:37 +03:00 committed by GitHub
parent 4d99707e93
commit 7e562bbf69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 1211 additions and 338 deletions

View file

@ -11,6 +11,7 @@ Enhancements:
- #6954 Move language selection to advanced section
- #6959 Update synergy UI. Setup wizard
- #6969 Update synergy UI. Validation for aliases.
- #6973 Update synergy UI. Main window
- #6962 | #6965 Add macOS 10.13 builder
===========

View file

@ -10,7 +10,7 @@ file (GLOB LEGACY_GUI_SOURCE_FILES
src/*.cpp
src/*.h
src/validators/*
src/validators/*.h
src/widgets/*
)
file (GLOB LEGACY_GUI_UI_FILES src/*.ui)
file (GLOB LEGACY_ACTIVATION_FILES src/*Activation* src/*License*)

View file

@ -533,7 +533,7 @@ bool AppConfig::getUseExternalConfig() const {
return m_UseExternalConfig;
}
QString AppConfig::getConfigFile() const {
const QString& AppConfig::getConfigFile() const {
return m_ConfigFile;
}

View file

@ -125,7 +125,7 @@ class AppConfig: public QObject, public GUI::Config::ConfigBase
bool getServerGroupChecked() const;
bool getUseExternalConfig() const;
QString getConfigFile() const;
const QString& getConfigFile() const;
bool getUseInternalConfig() const;
bool getClientGroupChecked() const;
QString getServerHostname() const;

View file

@ -57,14 +57,6 @@
#include <ApplicationServices/ApplicationServices.h>
#endif
#if defined(Q_OS_WIN)
static const char synergyConfigName[] = "synergy.sgc";
static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.sgc);;All files (*.*)"));
#else
static const char synergyConfigName[] = "synergy.conf";
static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.conf);;All files (*.*)"));
#endif
static const char* tlsCheckString = "network encryption protocol: ";
static const int debugLogLevel = 1;
@ -127,6 +119,7 @@ MainWindow::MainWindow (AppConfig& appConfig,
#endif
setupUi(this);
updateAutoConfigWidgets();
createMenuBar();
loadSettings();
@ -134,7 +127,7 @@ MainWindow::MainWindow (AppConfig& appConfig,
m_pWidgetUpdate->hide();
m_VersionChecker.setApp(appPath(appConfig.synergycName()));
m_pLabelScreenName->setText(appConfig.screenName());
connect(m_AppConfig, SIGNAL(screenNameChanged()), this, SLOT(updateScreenName()));
m_pLabelIpAddresses->setText(getIPAddresses());
@ -161,7 +154,7 @@ MainWindow::MainWindow (AppConfig& appConfig,
// hide padlock icon
secureSocket(false);
updateLocalFingerprint();
connect (this, SIGNAL(windowShown()),
this, SLOT(on_windowShown()), Qt::QueuedConnection);
@ -206,9 +199,9 @@ MainWindow::MainWindow (AppConfig& appConfig,
updateZeroconfService();
addZeroconfServer(m_AppConfig->autoConfigServer());
#endif
updateAutoConfigWidgets();
#endif
}
MainWindow::~MainWindow()
@ -305,14 +298,11 @@ void MainWindow::createMenuBar()
void MainWindow::loadSettings()
{
// the next two must come BEFORE loading groupServerChecked and groupClientChecked or
// disabling and/or enabling the right widgets won't automatically work
m_pRadioExternalConfig->setChecked(appConfig().getUseExternalConfig());
m_pRadioInternalConfig->setChecked(appConfig().getUseInternalConfig());
on_m_pRadioGroupServer_clicked(appConfig().getServerGroupChecked());
on_m_pRadioGroupClient_clicked(appConfig().getClientGroupChecked());
m_pRadioGroupServer->setChecked(appConfig().getServerGroupChecked());
m_pRadioGroupClient->setChecked(appConfig().getClientGroupChecked());
m_pGroupServer->setChecked(appConfig().getServerGroupChecked());
m_pLineEditConfigFile->setText(appConfig().getConfigFile());
m_pGroupClient->setChecked(appConfig().getClientGroupChecked());
m_pLineEditHostname->setText(appConfig().getServerHostname());
}
@ -329,11 +319,8 @@ void MainWindow::initConnections()
void MainWindow::saveSettings()
{
// program settings
appConfig().setServerGroupChecked(m_pGroupServer->isChecked());
appConfig().setClientGroupChecked(m_pGroupClient->isChecked());
appConfig().setUseExternalConfig(m_pRadioExternalConfig->isChecked());
appConfig().setUseInternalConfig(m_pRadioInternalConfig->isChecked());
appConfig().setConfigFile(m_pLineEditConfigFile->text());
appConfig().setServerGroupChecked(m_pRadioGroupServer->isChecked());
appConfig().setClientGroupChecked(m_pRadioGroupClient->isChecked());
appConfig().setServerHostname(m_pLineEditHostname->text());
/* Save everything */
@ -463,6 +450,15 @@ void MainWindow::updateFromLogLine(const QString &line)
void MainWindow::checkConnected(const QString& line)
{
// TODO: implement ipc connection state messages to replace this hack.
if (m_pRadioGroupServer->isChecked())
{
m_pLabelServerState->updateServerState(line);
}
else
{
m_pLabelClientState->updateClientState(line);
}
if (line.contains("connected to server") ||
line.contains("accepted client connection"))
{
@ -798,37 +794,29 @@ bool MainWindow::clientArgs(QStringList& args, QString& app)
QString MainWindow::configFilename()
{
QString filename;
if (m_pRadioInternalConfig->isChecked())
if (appConfig().getUseExternalConfig())
{
// TODO: no need to use a temporary file, since we need it to
// be permenant (since it'll be used for Windows services, etc).
QTemporaryFile tempConfigFile;
tempConfigFile.setAutoRemove(false);
if (!tempConfigFile.open())
{
QMessageBox::critical(this, tr("Cannot write configuration file"), tr("The temporary configuration file required to start synergy can not be written."));
return "";
}
serverConfig().save(tempConfigFile);
filename = tempConfigFile.fileName();
tempConfigFile.close();
filename = appConfig().getConfigFile();
}
else
{
if (!QFile::exists(m_pLineEditConfigFile->text()))
{
if (QMessageBox::warning(this, tr("Configuration filename invalid"),
tr("You have not filled in a valid configuration file for the synergy server. "
"Do you want to browse for the configuration file now?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes
|| !on_m_pButtonBrowseConfigFile_clicked())
return "";
}
// TODO: no need to use a temporary file, since we need it to
// be permenant (since it'll be used for Windows services, etc).
QTemporaryFile tempConfigFile;
tempConfigFile.setAutoRemove(false);
filename = m_pLineEditConfigFile->text();
if (!tempConfigFile.open())
{
QMessageBox::critical(this, tr("Cannot write configuration file"), tr("The temporary configuration file required to start synergy can not be written."));
return "";
}
serverConfig().save(tempConfigFile);
filename = tempConfigFile.fileName();
tempConfigFile.close();
}
return filename;
}
@ -1138,14 +1126,15 @@ void MainWindow::showLicenseNotice(const QString& notice)
void MainWindow::updateLocalFingerprint()
{
if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) {
if (m_AppConfig->getCryptoEnabled() &&
Fingerprint::local().fileExists() &&
m_pRadioGroupServer->isChecked())
{
m_pLabelFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst());
}
else {
else
{
m_pLabelFingerprint->setVisible(false);
m_pLabelLocalFingerprint->setVisible(false);
}
}
@ -1157,33 +1146,6 @@ MainWindow::licenseManager() const
}
#endif
void MainWindow::on_m_pGroupClient_toggled(bool on)
{
m_pGroupServer->setChecked(!on);
// only call in either client or server toggle, but not both
// since the toggle functions call eachother indirectly.
updateZeroconfService();
}
void MainWindow::on_m_pGroupServer_toggled(bool on)
{
m_pGroupClient->setChecked(!on);
}
bool MainWindow::on_m_pButtonBrowseConfigFile_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Browse for a synergys config file"), QString(), synergyConfigFilter);
if (!fileName.isEmpty())
{
m_pLineEditConfigFile->setText(fileName);
return true;
}
return false;
}
bool MainWindow::on_m_pActionSave_triggered()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as..."));
@ -1229,20 +1191,11 @@ void MainWindow::updateZeroconfService()
void MainWindow::updateAutoConfigWidgets()
{
if (appConfig().autoConfig()) {
m_pLabelAutoDetected->show();
m_pComboServerList->show();
m_pLabelServerName->show();
m_pLineEditHostname->show();
m_pLabelServerName->hide();
m_pLineEditHostname->hide();
}
else {
m_pLabelServerName->show();
m_pLineEditHostname->show();
m_pLabelAutoDetected->hide();
m_pComboServerList->hide();
}
m_pLabelAutoDetected->hide();
m_pComboServerList->hide();
}
void MainWindow::on_m_pActionSettings_triggered()
@ -1367,6 +1320,16 @@ void MainWindow::secureSocket(bool secureSocket)
}
}
void MainWindow::on_m_pSettingsLink_linkActivated(const QString&)
{
m_pActionSettings->trigger();
}
void MainWindow::on_m_pLabelFingerprint_linkActivated(const QString&)
{
QMessageBox::information(this, "SSL/TLS fingerprint", Fingerprint::local().readFirst());
}
void MainWindow::on_m_pComboServerList_currentIndexChanged(const QString &server)
{
appConfig().setAutoConfigServer(server);
@ -1383,3 +1346,45 @@ void MainWindow::updateScreenName()
m_pLabelScreenName->setText(appConfig().screenName());
serverConfig().updateServerName();
}
void MainWindow::on_m_pRadioGroupServer_clicked(bool on)
{
m_pRadioGroupServer->setChecked(true);
if (on)
{
//show server controls
m_pButtonConfigureServer->show();
m_pLabelServerState->show();
updateLocalFingerprint();
//hide client controls
m_pRadioGroupClient->setChecked(false);
m_pLabelClientState->hide();
m_pLabelServerName->hide();
m_pLineEditHostname->hide();
m_pButtonConnect->hide();
}
}
void MainWindow::on_m_pRadioGroupClient_clicked(bool on)
{
m_pRadioGroupClient->setChecked(true);
if (on)
{
//show client controls
m_pLabelServerName->show();
m_pLineEditHostname->show();
m_pButtonConnect->show();
//hide server controls
m_pRadioGroupServer->setChecked(false);
m_pLabelFingerprint->hide();
m_pButtonConfigureServer->hide();
m_pLabelServerState->hide();
}
}
void MainWindow::on_m_pButtonConnect_clicked()
{
restartSynergy();
}

View file

@ -105,7 +105,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
public:
void setVisible(bool visible);
int synergyType() const { return m_pGroupClient->isChecked() ? synergyClient : synergyServer; }
int synergyType() const { return m_pRadioGroupClient->isChecked() ? synergyClient : synergyServer; }
int synergyState() const { return m_SynergyState; }
QString hostname() const { return m_pLineEditHostname->text(); }
QString configFilename();
@ -143,9 +143,8 @@ public slots:
protected slots:
void updateLocalFingerprint();
void updateScreenName();
void on_m_pGroupClient_toggled(bool on);
void on_m_pGroupServer_toggled(bool on);
bool on_m_pButtonBrowseConfigFile_clicked();
void on_m_pRadioGroupServer_clicked(bool on);
void on_m_pRadioGroupClient_clicked(bool on);
void on_m_pButtonConfigureServer_clicked();
bool on_m_pActionSave_triggered();
void on_m_pActionAbout_triggered();
@ -244,8 +243,12 @@ private slots:
void on_m_pButtonApply_clicked();
void on_windowShown();
void on_m_pSettingsLink_linkActivated(const QString &link);
void on_m_pLabelFingerprint_linkActivated(const QString& link);
void on_m_pComboServerList_currentIndexChanged(const QString &arg1);
void on_m_pButtonConnect_clicked();
signals:
void windowShown();
};

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<width>720</width>
<height>797</height>
</rect>
</property>
@ -18,7 +18,7 @@
</property>
<property name="minimumSize">
<size>
<width>600</width>
<width>720</width>
<height>0</height>
</size>
</property>
@ -81,6 +81,9 @@
<item>
<widget class="QWidget" name="m_pWidgetUpdate" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
@ -91,7 +94,7 @@
<number>0</number>
</property>
<property name="bottomMargin">
<number>8</number>
<number>2</number>
</property>
<item>
<widget class="QLabel" name="m_pIconUpdate">
@ -130,257 +133,639 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_pGroupServer">
<widget class="QWidget" name="m_pWidgetComputerName" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<kerning>true</kerning>
</font>
<property name="minimumSize">
<size>
<width>582</width>
<height>15</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox::title {
subcontrol-origin: padding;
left: 7px;
}
</string>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="title">
<string>Ser&amp;ver (share this computer's mouse and keyboard):</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QVBoxLayout">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<widget class="QLabel" name="m_pLabelComputerName">
<property name="minimumSize">
<size>
<width>135</width>
<height>15</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>135</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<family>Arial</family>
<kerning>true</kerning>
</font>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>IP addresses:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="m_pLabelIpAddresses">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="m_pLabelFingerprint">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SSL Fingerprint:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_pLabelLocalFingerprint">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="m_pRadioInternalConfig">
<property name="text">
<string>Configure interactively:</string>
</property>
<property name="checked">
<bool>true</bool>
<string>This computers name:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="m_pButtonConfigureServer">
<property name="text">
<string>&amp;Configure Server...</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="m_pRadioExternalConfig">
<widget class="QLabel" name="m_pLabelScreenName">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>15</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<family>Arial</family>
</font>
</property>
<property name="text">
<string>Use existing configuration:</string>
<string notr="true"/>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="m_pLabelConfigurationFile">
<property name="text">
<string>&amp;Configuration file:</string>
</property>
<property name="buddy">
<cstring>m_pLineEditConfigFile</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_pLineEditConfigFile">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_pButtonBrowseConfigFile">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Browse...</string>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="m_pSettingsLink">
<property name="minimumSize">
<size>
<width>0</width>
<height>15</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<family>Arial</family>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style=&quot;margin-left: 5px;&quot;&gt;(&lt;a href=&quot;#&quot;&gt;&lt;span style=&quot; text-decoration: none; font-size: 13px; color:#007af4;&quot;&gt;Settings&lt;/span&gt;&lt;/a&gt;)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_pGroupClient">
<widget class="QWidget" name="m_pWidgetIPAddress" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<kerning>true</kerning>
</font>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox::title {
subcontrol-origin: padding;
left: 7px;
}
</string>
</property>
<property name="title">
<string>&amp;Client (use another computer's mouse and keyboard):</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="m_pLabelComputerName">
<property name="font">
<font>
<kerning>true</kerning>
</font>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>190</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Client name:</string>
<string>This computers IP addresses:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="m_pLabelScreenName">
<item>
<widget class="QLabel" name="m_pLabelIpAddresses">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="m_pLabelServerName">
<property name="text">
<string>&amp;Server:</string>
</property>
<property name="buddy">
<cstring>m_pLineEditHostname</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="m_pLineEditHostname">
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="m_pMainWidgets" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>270</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>270</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="spacing">
<number>16</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>22</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="m_pGroupServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
<width>340</width>
<height>248</height>
</size>
</property>
<property name="toolTip">
<string>Hostname or IP address of the server computer.</string>
<property name="font">
<font>
<kerning>true</kerning>
</font>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox::title {
subcontrol-origin: padding;
left: 7px;
}
</string>
</property>
<property name="title">
<string/>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="ServerLayout">
<property name="spacing">
<number>9</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QRadioButton" name="m_pRadioGroupServer">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>65535</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QRadioButton::indicator{
top: -7px;
}</string>
</property>
<property name="text">
<string>Use this computers keyboard and mouse
(Make this computer the server).</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="synergy_widgets::ServerStateLabel" name="m_pLabelServerState">
<property name="text">
<string>No clients connected</string>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="m_pLabelFingerprint">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;TLS/SSL active - &lt;a href=&quot;#&quot;&gt;view&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="m_pButtonConfigureServer">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Configure server</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="m_pComboServerList">
<item>
<widget class="QGroupBox" name="m_pGroupClient">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<width>340</width>
<height>248</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="m_pLabelAutoDetected">
<property name="text">
<string>Server:</string>
<property name="font">
<font>
<kerning>true</kerning>
</font>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox::title {
subcontrol-origin: padding;
left: 7px;
}
</string>
</property>
<property name="title">
<string/>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="ClientLayout">
<property name="spacing">
<number>9</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<item>
<widget class="QRadioButton" name="m_pRadioGroupClient">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QRadioButton::indicator{
top: -7px;
}</string>
</property>
<property name="text">
<string>Use another computer’s mouse and keyboard
(Make this computer the client).</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>19</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="m_pLabelServerName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Server IP address or name:</string>
</property>
<property name="buddy">
<cstring>m_pLineEditHostname</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_pLineEditHostname">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Hostname or IP address of the server computer.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_pLabelAutoDetected">
<property name="text">
<string>Server:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_pComboServerList">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="synergy_widgets::ClientStateLabel" name="m_pLabelClientState">
<property name="text">
<string>Connected to the server</string>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="topMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="m_pButtonConnect">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
@ -603,58 +988,22 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>synergy_widgets::ServerStateLabel</class>
<extends>QLabel</extends>
<header>widgets/ServerStateLabel.h</header>
</customwidget>
<customwidget>
<class>synergy_widgets::ClientStateLabel</class>
<extends>QLabel</extends>
<header>widgets/ClientStateLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../res/Synergy.qrc"/>
</resources>
<connections>
<connection>
<sender>m_pRadioExternalConfig</sender>
<signal>toggled(bool)</signal>
<receiver>m_pLineEditConfigFile</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>156</x>
<y>179</y>
</hint>
<hint type="destinationlabel">
<x>169</x>
<y>209</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_pRadioExternalConfig</sender>
<signal>toggled(bool)</signal>
<receiver>m_pButtonBrowseConfigFile</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>353</x>
<y>182</y>
</hint>
<hint type="destinationlabel">
<x>356</x>
<y>211</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_pRadioInternalConfig</sender>
<signal>toggled(bool)</signal>
<receiver>m_pButtonConfigureServer</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>204</x>
<y>244</y>
</hint>
<hint type="destinationlabel">
<x>212</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_pButtonToggleStart</sender>
<signal>clicked()</signal>

View file

@ -386,6 +386,26 @@ void ServerConfig::updateServerName()
}
}
const QString& ServerConfig::getConfigFile() const
{
return m_pAppConfig->getConfigFile();
}
bool ServerConfig::getUseExternalConfig() const
{
return m_pAppConfig->getUseExternalConfig();
}
void ServerConfig::setConfigFile(const QString& configFile)
{
m_pAppConfig->setConfigFile(configFile);
}
void ServerConfig::setUseExternalConfig(bool useExternalConfig)
{
m_pAppConfig->setUseExternalConfig(useExternalConfig);
}
bool ServerConfig::findScreenName(const QString& name, int& index)
{
bool found = false;

View file

@ -81,6 +81,8 @@ class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase
int autoAddScreen(const QString name);
const QString& getServerName() const;
void updateServerName();
const QString& getConfigFile() const;
bool getUseExternalConfig() const;
protected:
QSettings& settings();
@ -104,6 +106,8 @@ class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase
void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; }
void setDisableLockToScreen(bool on) { m_DisableLockToScreen = on; }
void setClipboardSharing(bool on) { m_ClipboardSharing = on; }
void setConfigFile(const QString& configFile);
void setUseExternalConfig(bool useExternalConfig);
size_t setClipboardSharingSize(size_t size);
QList<bool>& switchCorners() { return m_SwitchCorners; }
HotkeyList& hotkeys() { return m_Hotkeys; }

View file

@ -24,6 +24,7 @@
#include <QtCore>
#include <QtGui>
#include <QMessageBox>
#include <QFileDialog>
ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
@ -35,6 +36,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config) :
{
setupUi(this);
m_pEditConfigFile->setText(serverConfig().getConfigFile());
m_pCheckBoxUseExternalConfig->setChecked(serverConfig().getUseExternalConfig());
m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
m_pSpinBoxHeartbeat->setValue(serverConfig().heartbeat());
@ -94,6 +97,25 @@ void ServerConfigDialog::showEvent(QShowEvent* event)
void ServerConfigDialog::accept()
{
if (m_pCheckBoxUseExternalConfig->isChecked() &&
!QFile::exists(m_pEditConfigFile->text()))
{
auto title = tr("Configuration filename invalid");
auto description = tr("You have not filled in a valid configuration file for the synergy server. "
"Do you want to browse for the configuration file now?");
auto selectedButton = QMessageBox::warning(this, title, description, QMessageBox::Yes | QMessageBox::No);
if (selectedButton != QMessageBox::Yes ||
!on_m_pButtonBrowseConfigFile_clicked())
{
return;
}
}
serverConfig().setConfigFile(m_pEditConfigFile->text());
serverConfig().setUseExternalConfig(m_pCheckBoxUseExternalConfig->isChecked());
serverConfig().haveHeartbeat(m_pCheckBoxHeartbeat->isChecked());
serverConfig().setHeartbeat(m_pSpinBoxHeartbeat->value());
@ -239,3 +261,33 @@ void ServerConfigDialog::on_m_pListActions_itemSelectionChanged()
m_pButtonEditAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
m_pButtonRemoveAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
}
void ServerConfigDialog::on_m_pCheckBoxUseExternalConfig_toggled(bool checked)
{
m_pLabelConfigFile->setEnabled(checked);
m_pEditConfigFile->setEnabled(checked);
m_pButtonBrowseConfigFile->setEnabled(checked);
m_pTabWidget->setTabEnabled(0, !checked);
m_pTabWidget->setTabEnabled(1, !checked);
m_pTabWidget->setTabEnabled(2, !checked);
}
bool ServerConfigDialog::on_m_pButtonBrowseConfigFile_clicked()
{
#if defined(Q_OS_WIN)
const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.sgc);;All files (*.*)"));
#else
const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.conf);;All files (*.*)"));
#endif
QString fileName = QFileDialog::getOpenFileName(this, tr("Browse for a synergys config file"), QString(), synergyConfigFilter);
if (!fileName.isEmpty())
{
m_pEditConfigFile->setText(fileName);
return true;
}
return false;
}

View file

@ -49,8 +49,9 @@ class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase
void on_m_pListActions_itemSelectionChanged();
void on_m_pButtonEditAction_clicked();
void on_m_pButtonRemoveAction_clicked();
void on_m_pCheckBoxEnableClipboard_stateChanged(int state);
void on_m_pCheckBoxUseExternalConfig_toggled(bool checked = false);
bool on_m_pButtonBrowseConfigFile_clicked();
protected:
ServerConfig& serverConfig() { return m_ServerConfig; }

View file

@ -681,6 +681,267 @@ Double click on a screen to edit its settings.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_pTabAdvancedConfig">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>Advance config</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style=&quot;text-align: center; font-family: Arial; font-size: 18px; line-height: 25px;&quot;&gt;Config override&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style=&quot;text-align: center; font-size: 13px; font-family: Arial; line-hegiht: 18px;&quot;&gt;If you have a config file and want to override all setttings with this file.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="m_pCheckBoxUseExternalConfig">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Use configuration file</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>95</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="m_pLabelConfigFile">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>96</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Config file path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="m_pEditConfigFile">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_pButtonBrowseConfigFile">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&amp;Browse...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>

View file

@ -153,7 +153,7 @@
<x>193</x>
<y>380</y>
<width>311</width>
<height>81</height>
<height>91</height>
</rect>
</property>
<property name="font">

View file

@ -0,0 +1,41 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2021 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ClientStateLabel.h"
namespace synergy_widgets
{
ClientStateLabel::ClientStateLabel(QWidget* parent) :
QLabel(parent)
{
hide();
}
void ClientStateLabel::updateClientState(const QString& line)
{
if (line.contains("connected to server"))
{
show();
}
else if (line.contains("disconnected from server") || line.contains("process exited"))
{
hide();
}
}
}

View file

@ -0,0 +1,36 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2021 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLIENTSTATELABEL_H
#define CLIENTSTATELABEL_H
#include <QLabel>
namespace synergy_widgets
{
class ClientStateLabel : public QLabel
{
public:
explicit ClientStateLabel(QWidget* parent = nullptr);
void updateClientState(const QString& line);
};
} // namespace synergy_widgets
#endif // CLIENTSTATELABEL_H

View file

@ -0,0 +1,59 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2021 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ServerStateLabel.h"
namespace synergy_widgets
{
ServerStateLabel::ServerStateLabel(QWidget* parent) :
QLabel(parent)
{
}
void ServerStateLabel::updateServerState(const QString& line)
{
if (line.contains("process exited"))
{
m_clientsCounter = 0;
}
else if (line.contains("has connected"))
{
++m_clientsCounter;
}
else if (line.contains("has disconnected") && m_clientsCounter)
{
--m_clientsCounter;
}
updateState();
}
void ServerStateLabel::updateState()
{
if (m_clientsCounter)
{
hide();
}
else
{
show();
}
}
} //namespace synergy_widgets

View file

@ -0,0 +1,41 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2021 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SERVERSTATELABEL_H
#define SERVERSTATELABEL_H
#include <QLabel>
namespace synergy_widgets
{
class ServerStateLabel : public QLabel
{
public:
explicit ServerStateLabel(QWidget* parent = nullptr);
void updateServerState(const QString& line);
private:
unsigned int m_clientsCounter = 0;
void updateState();
};
} //namespace synergy_widgets
#endif // SERVERSTATELABEL_H