Skip to content

Commit

Permalink
SYNERGY-799 Update Synergy UI. Main screen (#6973)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SerhiiGadzhilov committed Apr 12, 2021
1 parent 4d99707 commit 7e562bb
Show file tree
Hide file tree
Showing 17 changed files with 1,211 additions and 338 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -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
===========

Expand Down
2 changes: 1 addition & 1 deletion src/gui/CMakeLists.txt
Expand Up @@ -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*)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/AppConfig.cpp
Expand Up @@ -533,7 +533,7 @@ bool AppConfig::getUseExternalConfig() const {
return m_UseExternalConfig;
}

QString AppConfig::getConfigFile() const {
const QString& AppConfig::getConfigFile() const {
return m_ConfigFile;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/AppConfig.h
Expand Up @@ -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;
Expand Down
191 changes: 98 additions & 93 deletions src/gui/src/MainWindow.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -127,14 +119,15 @@ MainWindow::MainWindow (AppConfig& appConfig,
#endif

setupUi(this);
updateAutoConfigWidgets();

createMenuBar();
loadSettings();
initConnections();

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());
Expand All @@ -161,7 +154,7 @@ MainWindow::MainWindow (AppConfig& appConfig,
// hide padlock icon
secureSocket(false);

updateLocalFingerprint();


connect (this, SIGNAL(windowShown()),
this, SLOT(on_windowShown()), Qt::QueuedConnection);
Expand Down Expand Up @@ -206,9 +199,9 @@ MainWindow::MainWindow (AppConfig& appConfig,
updateZeroconfService();

addZeroconfServer(m_AppConfig->autoConfigServer());
#endif

updateAutoConfigWidgets();
#endif
}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -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());
}

Expand All @@ -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 */
Expand Down Expand Up @@ -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"))
{
Expand Down Expand Up @@ -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);

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 "";
}

filename = m_pLineEditConfigFile->text();
serverConfig().save(tempConfigFile);
filename = tempConfigFile.fileName();

tempConfigFile.close();
}

return filename;
}

Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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..."));
Expand Down Expand Up @@ -1229,20 +1191,11 @@ void MainWindow::updateZeroconfService()

void MainWindow::updateAutoConfigWidgets()
{
if (appConfig().autoConfig()) {
m_pLabelAutoDetected->show();
m_pComboServerList->show();

m_pLabelServerName->hide();
m_pLineEditHostname->hide();
}
else {
m_pLabelServerName->show();
m_pLineEditHostname->show();
m_pLabelServerName->show();
m_pLineEditHostname->show();

m_pLabelAutoDetected->hide();
m_pComboServerList->hide();
}
m_pLabelAutoDetected->hide();
m_pComboServerList->hide();
}

void MainWindow::on_m_pActionSettings_triggered()
Expand Down Expand Up @@ -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);
Expand All @@ -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();
}
11 changes: 7 additions & 4 deletions src/gui/src/MainWindow.h
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
};

0 comments on commit 7e562bb

Please sign in to comment.