Introduce 'Advanced' tab to Preferences window (#7419)
* Add QML and QtQuick deps * Keep only Qt declarative * Fixed delcarative package name * Use `qt6-qtdeclarative` on OpenSUSE * Fixed warnings * Introduce tabs for settings and make some settings easier to understand * Further reorganization of settings UI * Revert config.yml * Show Qt version in config * Remove custom font * Improve wording of elevate privs * Fixed window sizes and default tabs * Save main window size and position * Fixed slot warning * Fixed hacky use of validators * Make activation cancel more intuitive * Save window state in dtor and add try-catch to prevent exceptions propagating * Fixed consistency of fatal messages * Improve color conssitency and add tooltip * Clean up styles and weird layout * Move config files to new gui lib * Core interface integ tests * Rename `Config` to `ConfigScopes` * Add 'Schoeneman' to cspell * Fixed incorrect `Config` (should be `ConfigScopes`) * Fixed typo * Missed a spot * Delete accidentally re-added file * Fixed formatting * Add short opt * Coverage for `AppConfig` * Update ChangeLog * Remove redundant includes * Fixed date * Remove rogue include
This commit is contained in:
parent
6a6de24f59
commit
9eeb1cb7ee
64 changed files with 2064 additions and 2004 deletions
|
|
@ -64,6 +64,7 @@ Enhancements:
|
||||||
- #7415 Assert arg value `num > 0` for BSD socket poll unblock pipe
|
- #7415 Assert arg value `num > 0` for BSD socket poll unblock pipe
|
||||||
- #7416 Catch exception propagating to `Server` dtor
|
- #7416 Catch exception propagating to `Server` dtor
|
||||||
- #7421 Only load core after settings have fully loaded
|
- #7421 Only load core after settings have fully loaded
|
||||||
|
- #7419 Introduce 'Advanced' tab to Preferences window
|
||||||
|
|
||||||
# 1.14.6
|
# 1.14.6
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,8 @@ macro(config_qt)
|
||||||
COMPONENTS Core Widgets Network
|
COMPONENTS Core Widgets Network
|
||||||
REQUIRED)
|
REQUIRED)
|
||||||
|
|
||||||
|
message(STATUS "Qt version: ${Qt6_VERSION}")
|
||||||
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(configure_openssl)
|
macro(configure_openssl)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
"dictionaryDefinitions": [],
|
"dictionaryDefinitions": [],
|
||||||
"dictionaries": [],
|
"dictionaries": [],
|
||||||
"words": [
|
"words": [
|
||||||
|
"Schoeneman",
|
||||||
"aqtinstall",
|
"aqtinstall",
|
||||||
"codesign",
|
"codesign",
|
||||||
"codesigning",
|
"codesigning",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ def main():
|
||||||
"""
|
"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
"-f",
|
||||||
"--format",
|
"--format",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="In-place format all files",
|
help="In-place format all files",
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ def main():
|
||||||
"""
|
"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
"-f",
|
||||||
"--format",
|
"--format",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="In-place format all files",
|
help="In-place format all files",
|
||||||
|
|
|
||||||
|
|
@ -51,19 +51,11 @@ AboutDialog::AboutDialog(MainWindow *parent, const AppConfig &config)
|
||||||
int AboutDialog::exec() {
|
int AboutDialog::exec() {
|
||||||
m_pDevelopersLabel->setText(getImportantDevelopers());
|
m_pDevelopersLabel->setText(getImportantDevelopers());
|
||||||
m_pCopyrightLabel->setText(getCopyright());
|
m_pCopyrightLabel->setText(getCopyright());
|
||||||
resizeWindow();
|
|
||||||
updateLogo();
|
updateLogo();
|
||||||
|
|
||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::resizeWindow() {
|
|
||||||
QSize size(600, 310);
|
|
||||||
setMaximumSize(size);
|
|
||||||
setMinimumSize(size);
|
|
||||||
resize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AboutDialog::updateLogo() const {
|
void AboutDialog::updateLogo() const {
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
if (isOSXInterfaceStyleDark()) {
|
if (isOSXInterfaceStyleDark()) {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ private:
|
||||||
VersionChecker m_versionChecker;
|
VersionChecker m_versionChecker;
|
||||||
void updateLogo() const;
|
void updateLogo() const;
|
||||||
|
|
||||||
virtual void resizeWindow();
|
|
||||||
virtual QString getCopyright() const;
|
virtual QString getCopyright() const;
|
||||||
virtual QString getImportantDevelopers() const;
|
virtual QString getImportantDevelopers() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,15 @@
|
||||||
|
|
||||||
#include "ActivationDialog.h"
|
#include "ActivationDialog.h"
|
||||||
|
|
||||||
#include "gui/license_notices.h"
|
|
||||||
#include "ui_ActivationDialog.h"
|
|
||||||
|
|
||||||
#include "AppConfig.h"
|
|
||||||
#include "CancelActivationDialog.h"
|
#include "CancelActivationDialog.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include "gui/AppConfig.h"
|
||||||
#include "gui/LicenseHandler.h"
|
#include "gui/LicenseHandler.h"
|
||||||
#include "gui/constants.h"
|
#include "gui/constants.h"
|
||||||
#include "gui/license_notices.h"
|
#include "gui/license_notices.h"
|
||||||
#include "license/ProductEdition.h"
|
#include "license/ProductEdition.h"
|
||||||
#include "license/parse_serial_key.h"
|
#include "license/parse_serial_key.h"
|
||||||
|
#include "ui_ActivationDialog.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
@ -44,6 +42,9 @@ ActivationDialog::ActivationDialog(
|
||||||
m_licenseHandler(licenseHandler) {
|
m_licenseHandler(licenseHandler) {
|
||||||
|
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
m_ui->m_pLabelNotice->setStyleSheet(kStyleNoticeLabel);
|
||||||
|
|
||||||
refreshSerialKey();
|
refreshSerialKey();
|
||||||
|
|
||||||
if (!m_licenseHandler.license().isExpired()) {
|
if (!m_licenseHandler.license().isExpired()) {
|
||||||
|
|
@ -64,7 +65,7 @@ void ActivationDialog::refreshSerialKey() {
|
||||||
|
|
||||||
const auto &license = m_licenseHandler.license();
|
const auto &license = m_licenseHandler.license();
|
||||||
if (license.isTimeLimited()) {
|
if (license.isTimeLimited()) {
|
||||||
m_ui->m_labelNotice->setText(licenseNotice(license));
|
m_ui->m_pLabelNotice->setText(licenseNotice(license));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,9 +79,9 @@ void ActivationDialog::reject() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the user is told that the 'No' button will exit the app.
|
// the accept button should be labeled "Exit" on the cancel dialoig.
|
||||||
CancelActivationDialog cancelActivationDialog(this);
|
CancelActivationDialog cancelActivationDialog(this);
|
||||||
if (cancelActivationDialog.exec() == QDialog::Rejected) {
|
if (cancelActivationDialog.exec() == QDialog::Accepted) {
|
||||||
QApplication::exit();
|
QApplication::exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -126,19 +127,21 @@ void ActivationDialog::showResultDialog(
|
||||||
case kInvalid:
|
case kInvalid:
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
this, title,
|
this, title,
|
||||||
QString("Invalid serial key. "
|
QString(
|
||||||
R"(Please <a href="%1" style="%2">contact us</a> for help.)")
|
"Invalid serial key. "
|
||||||
|
R"(Please <a href="%1" style="color: %2">contact us</a> for help.)")
|
||||||
.arg(kUrlContact)
|
.arg(kUrlContact)
|
||||||
.arg(kLinkStyleSecondary));
|
.arg(kColorSecondary));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kExpired:
|
case kExpired:
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, title,
|
this, title,
|
||||||
QString("Sorry, that serial key has expired. "
|
QString(
|
||||||
R"(Please <a href="%1" style="%1">renew</a> your license.)")
|
"Sorry, that serial key has expired. "
|
||||||
|
R"(Please <a href="%1" style="color: %1">renew</a> your license.)")
|
||||||
.arg(kUrlPurchase)
|
.arg(kUrlPurchase)
|
||||||
.arg(kLinkStyleSecondary));
|
.arg(kColorSecondary));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -180,11 +183,11 @@ void ActivationDialog::showSuccessDialog() {
|
||||||
void ActivationDialog::showErrorDialog(const QString &message) {
|
void ActivationDialog::showErrorDialog(const QString &message) {
|
||||||
QString fullMessage =
|
QString fullMessage =
|
||||||
QString("<p>There was a problem activating Synergy.</p>"
|
QString("<p>There was a problem activating Synergy.</p>"
|
||||||
R"(<p>Please <a href="%1" style="%2">contact us</a> )"
|
R"(<p>Please <a href="%1" style="color: %2">contact us</a> )"
|
||||||
"and provide the following information:</p>"
|
"and provide the following information:</p>"
|
||||||
"%3")
|
"%3")
|
||||||
.arg(kUrlContact)
|
.arg(kUrlContact)
|
||||||
.arg(kLinkStyleSecondary)
|
.arg(kColorSecondary)
|
||||||
.arg(message);
|
.arg(message);
|
||||||
QMessageBox::critical(this, "Activation failed", fullMessage);
|
QMessageBox::critical(this, "Activation failed", fullMessage);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,16 +75,9 @@ li.checked::marker { content: "\2612"; }
|
||||||
<number>8</number>
|
<number>8</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_labelNotice">
|
<widget class="QLabel" name="m_pLabelNotice">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding: 3px 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
background-color: #3B67D3;
|
|
||||||
color: #ffffff;
|
|
||||||
top: 3px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>m_labelNotice</string>
|
<string>m_pLabelNotice</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="openExternalLinks">
|
<property name="openExternalLinks">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
@ -94,7 +87,7 @@ top: 3px;</string>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
|
@ -110,10 +103,10 @@ top: 3px;</string>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,33 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2016 Symless Ltd.
|
||||||
|
*
|
||||||
|
* 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 "CancelActivationDialog.h"
|
#include "CancelActivationDialog.h"
|
||||||
|
|
||||||
#include "ui_CancelActivationDialog.h"
|
#include "ui_CancelActivationDialog.h"
|
||||||
|
|
||||||
|
#include "QPushButton"
|
||||||
|
|
||||||
CancelActivationDialog::CancelActivationDialog(QWidget *parent)
|
CancelActivationDialog::CancelActivationDialog(QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::CancelActivationDialog) {
|
ui(new Ui::CancelActivationDialog) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->m_pButtonBox->button(QDialogButtonBox::Cancel)->setText("&Back");
|
||||||
|
ui->m_pButtonBox->button(QDialogButtonBox::Ok)->setText("&Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
CancelActivationDialog::~CancelActivationDialog() { delete ui; }
|
CancelActivationDialog::~CancelActivationDialog() { delete ui; }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,21 @@
|
||||||
#ifndef CANCELACTIVATIONDIALOG_H
|
/*
|
||||||
#define CANCELACTIVATIONDIALOG_H
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2016 Symless Ltd.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
@ -17,5 +33,3 @@ public:
|
||||||
private:
|
private:
|
||||||
Ui::CancelActivationDialog *ui;
|
Ui::CancelActivationDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CANCELACTIVATIONDIALOG_H
|
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,18 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>429</width>
|
||||||
<height>246</height>
|
<height>273</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Cancel Activation</string>
|
<string>Cancel Activation</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item alignment="Qt::AlignmentFlag::AlignTop">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p>You'll need to purchase a license to use this build of Synergy.</p><p><a href="https://symless.com/synergy/purchase?source=gui"><span style=" text-decoration: underline; color:#007af4;">Purchase Synergy</span></a></p><p>If you'd prefer to use the community edition instead, visit us on GitHub.</p><p><a href="https://github.com/symless/synergy-core"><span style=" text-decoration: underline; color:#007af4;">GitHub project</span></a></p><p>Would you like to go back and enter a serial key?</p><p>Choosing 'No' will quit Synergy.</p></body></html></string>
|
<string><html><head/><body><p>You'll need to purchase a license to use this build of Synergy.</p><p><a href="https://symless.com/synergy/purchase?source=gui"><span style=" text-decoration: underline; color:#007af4;">Purchase Synergy</span></a></p><p>If you'd prefer to use the community edition instead, visit us on GitHub.</p><p><a href="https://github.com/symless/synergy-core"><span style=" text-decoration: underline; color:#007af4;">GitHub project</span></a></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
@ -28,25 +28,12 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<widget class="QDialogButtonBox" name="m_pButtonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
|
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -55,7 +42,7 @@
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>m_pButtonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>CancelActivationDialog</receiver>
|
<receiver>CancelActivationDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
|
|
@ -71,7 +58,7 @@
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>m_pButtonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>CancelActivationDialog</receiver>
|
<receiver>CancelActivationDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
|
|
|
||||||
|
|
@ -94,19 +94,89 @@ MainWindow::MainWindow(AppConfig &appConfig)
|
||||||
m_ServerConfig(5, 3, &m_AppConfig, this),
|
m_ServerConfig(5, 3, &m_AppConfig, this),
|
||||||
m_ServerConnection(*this),
|
m_ServerConnection(*this),
|
||||||
m_ClientConnection(*this),
|
m_ClientConnection(*this),
|
||||||
m_TlsUtility(appConfig, m_LicenseHandler.license()) {
|
m_TlsUtility(appConfig, m_LicenseHandler.license()),
|
||||||
|
m_WindowSaveTimer(this) {
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
setupControls();
|
||||||
connectSlots();
|
connectSlots();
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
|
||||||
|
// TODO: only connect permenantly to ipc when switching to service mode.
|
||||||
|
// if switching from service to desktop, connect only to stop the service
|
||||||
|
// and don't retry.
|
||||||
|
m_IpcClient.connectToHost();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
emit created();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow() {
|
||||||
|
try {
|
||||||
|
if (appConfig().processMode() == ProcessMode::kDesktop) {
|
||||||
|
m_ExpectedRunningState = RuningState::Stopped;
|
||||||
|
stopDesktop();
|
||||||
|
}
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
qFatal("failed to stop core on main window close: %s", e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
saveWindow();
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
qFatal("failed to save window on main window close: %s", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::restoreWindow() {
|
||||||
|
|
||||||
|
const auto &config = appConfig();
|
||||||
|
|
||||||
|
const auto &size = config.mainWindowSize();
|
||||||
|
if (size.has_value()) {
|
||||||
|
qDebug("restoring main window size");
|
||||||
|
resize(size.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &position = config.mainWindowPosition();
|
||||||
|
if (position.has_value()) {
|
||||||
|
qDebug("restoring main window position");
|
||||||
|
move(position.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
// give the window chance to restore its size and position before the window
|
||||||
|
// size and position are saved. this prevents the window from being saved
|
||||||
|
// with the wrong size and position.
|
||||||
|
m_SaveWindow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveWindow() {
|
||||||
|
if (!m_SaveWindow) {
|
||||||
|
qDebug("not yet ready to save window size and position, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("saving window size and position");
|
||||||
|
auto &config = appConfig();
|
||||||
|
config.setMainWindowSize(size());
|
||||||
|
config.setMainWindowPosition(pos());
|
||||||
|
config.saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupControls() {
|
||||||
createMenuBar();
|
createMenuBar();
|
||||||
secureSocket(false);
|
secureSocket(false);
|
||||||
|
|
||||||
|
m_pLabelUpdate->setStyleSheet(kStyleNoticeLabel);
|
||||||
m_pLabelUpdate->hide();
|
m_pLabelUpdate->hide();
|
||||||
|
|
||||||
m_pLabelIpAddresses->setText(
|
m_pLabelNotice->setStyleSheet(kStyleNoticeLabel);
|
||||||
tr("This computer's IP addresses: %1").arg(getIPAddresses()));
|
m_pLabelNotice->hide();
|
||||||
|
|
||||||
m_labelNotice->hide();
|
m_pLabelIpAddresses->setText(
|
||||||
|
QString("This computer's IP addresses: %1").arg(getIPAddresses()));
|
||||||
|
|
||||||
if (m_AppConfig.lastVersion() != SYNERGY_VERSION) {
|
if (m_AppConfig.lastVersion() != SYNERGY_VERSION) {
|
||||||
m_AppConfig.setLastVersion(SYNERGY_VERSION);
|
m_AppConfig.setLastVersion(SYNERGY_VERSION);
|
||||||
|
|
@ -118,34 +188,10 @@ MainWindow::MainWindow(AppConfig &appConfig)
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
|
||||||
resize(720, 550);
|
|
||||||
setMinimumSize(size());
|
|
||||||
|
|
||||||
m_pRadioGroupServer->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
m_pRadioGroupServer->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||||
m_pRadioGroupClient->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
m_pRadioGroupClient->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||||
|
|
||||||
#elif defined(Q_OS_LINUX)
|
|
||||||
|
|
||||||
resize(700, 530);
|
|
||||||
setMinimumSize(size());
|
|
||||||
|
|
||||||
#elif defined(Q_OS_WIN)
|
|
||||||
|
|
||||||
// TODO: only connect permenantly to ipc when switching to service mode.
|
|
||||||
// if switching from service to desktop, connect only to stop the service and
|
|
||||||
// don't retry.
|
|
||||||
m_IpcClient.connectToHost();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
emit created();
|
|
||||||
}
|
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
|
||||||
if (appConfig().processMode() == ProcessMode::kDesktop) {
|
|
||||||
m_ExpectedRunningState = RuningState::Stopped;
|
|
||||||
stopDesktop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -175,7 +221,7 @@ void MainWindow::connectSlots() const {
|
||||||
&MainWindow::onAppConfigScreenNameChanged);
|
&MainWindow::onAppConfigScreenNameChanged);
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
&m_AppConfig, &AppConfig::invertConnection, this,
|
&m_AppConfig, &AppConfig::invertConnectionChanged, this,
|
||||||
&MainWindow::onAppConfigInvertConnection);
|
&MainWindow::onAppConfigInvertConnection);
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
|
|
@ -215,6 +261,10 @@ void MainWindow::connectSlots() const {
|
||||||
connect(
|
connect(
|
||||||
&m_VersionChecker, &VersionChecker::updateFound, this,
|
&m_VersionChecker, &VersionChecker::updateFound, this,
|
||||||
&MainWindow::onVersionCheckerUpdateFound);
|
&MainWindow::onVersionCheckerUpdateFound);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
&m_WindowSaveTimer, &QTimer::timeout, this,
|
||||||
|
&MainWindow::onWindowSaveTimerTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAppAboutToQuit() { m_AppConfig.saveSettings(); }
|
void MainWindow::onAppAboutToQuit() { m_AppConfig.saveSettings(); }
|
||||||
|
|
@ -263,8 +313,10 @@ void MainWindow::onAppConfigLoaded() {
|
||||||
if (!m_AppConfig.serialKey().isEmpty()) {
|
if (!m_AppConfig.serialKey().isEmpty()) {
|
||||||
m_LicenseHandler.changeSerialKey(m_AppConfig.serialKey());
|
m_LicenseHandler.changeSerialKey(m_AppConfig.serialKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScreenName();
|
updateScreenName();
|
||||||
applyConfig();
|
applyConfig();
|
||||||
|
restoreWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAppConfigTlsChanged() {
|
void MainWindow::onAppConfigTlsChanged() {
|
||||||
|
|
@ -315,7 +367,7 @@ void MainWindow::onCoreProcessReadyReadStandardError() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onVersionCheckerUpdateFound(const QString &version) {
|
void MainWindow::onVersionCheckerUpdateFound(const QString &version) {
|
||||||
const auto link = QString(kLinkDownload).arg(kUrlDownload, kLinkStyleWhite);
|
const auto link = QString(kLinkDownload).arg(kUrlDownload, kColorWhite);
|
||||||
const auto text =
|
const auto text =
|
||||||
QString("A new version is available (v%1). %2").arg(version, link);
|
QString("A new version is available (v%1). %2").arg(version, link);
|
||||||
|
|
||||||
|
|
@ -367,11 +419,12 @@ void MainWindow::onCoreProcessFinished(int exitCode, QProcess::ExitStatus) {
|
||||||
|
|
||||||
bool MainWindow::on_m_pActionSave_triggered() {
|
bool MainWindow::on_m_pActionSave_triggered() {
|
||||||
QString fileName =
|
QString fileName =
|
||||||
QFileDialog::getSaveFileName(this, tr("Save configuration as..."));
|
QFileDialog::getSaveFileName(this, QString("Save configuration as..."));
|
||||||
|
|
||||||
if (!fileName.isEmpty() && !serverConfig().save(fileName)) {
|
if (!fileName.isEmpty() && !serverConfig().save(fileName)) {
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("Save failed"), tr("Could not save configuration to file."));
|
this, QString("Save failed"),
|
||||||
|
QString("Could not save configuration to file."));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,10 +492,28 @@ void MainWindow::on_m_pButtonConnectToClient_clicked() {
|
||||||
on_m_pButtonApply_clicked();
|
on_m_pButtonApply_clicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onWindowSaveTimerTimeout() { saveWindow(); }
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// End slots
|
// End slots
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void MainWindow::resizeEvent(QResizeEvent *event) {
|
||||||
|
QMainWindow::resizeEvent(event);
|
||||||
|
|
||||||
|
// postpone save so that settings are not written every delta change.
|
||||||
|
m_WindowSaveTimer.setSingleShot(true);
|
||||||
|
m_WindowSaveTimer.start(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::moveEvent(QMoveEvent *event) {
|
||||||
|
QMainWindow::moveEvent(event);
|
||||||
|
|
||||||
|
// postpone save so that settings are not written every delta change.
|
||||||
|
m_WindowSaveTimer.setSingleShot(true);
|
||||||
|
m_WindowSaveTimer.start(1000);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::open() {
|
void MainWindow::open() {
|
||||||
|
|
||||||
std::array<QAction *, 7> trayMenu = {
|
std::array<QAction *, 7> trayMenu = {
|
||||||
|
|
@ -522,7 +593,7 @@ void MainWindow::saveSettings() {
|
||||||
appConfig().setServerHostname(m_pLineEditHostname->text());
|
appConfig().setServerHostname(m_pLineEditHostname->text());
|
||||||
serverConfig().setClientAddress(m_pLineEditClientIp->text());
|
serverConfig().setClientAddress(m_pLineEditClientIp->text());
|
||||||
|
|
||||||
appConfig().config().saveAll();
|
appConfig().scopes().saveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setIcon(CoreState state) const {
|
void MainWindow::setIcon(CoreState state) const {
|
||||||
|
|
@ -555,7 +626,7 @@ void MainWindow::appendLogInfo(const QString &text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::appendLogDebug(const QString &text) {
|
void MainWindow::appendLogDebug(const QString &text) {
|
||||||
qDebug() << text;
|
qDebug("%s", text.toStdString().c_str());
|
||||||
|
|
||||||
if (appConfig().logLevel() >= kDebugLogLevel) {
|
if (appConfig().logLevel() >= kDebugLogLevel) {
|
||||||
processCoreLogLine(getTimeStamp() + " DEBUG: " + text);
|
processCoreLogLine(getTimeStamp() + " DEBUG: " + text);
|
||||||
|
|
@ -621,9 +692,9 @@ void MainWindow::checkConnected(const QString &line) {
|
||||||
if (!appConfig().startedBefore() && isVisible()) {
|
if (!appConfig().startedBefore() && isVisible()) {
|
||||||
QMessageBox::information(
|
QMessageBox::information(
|
||||||
this, "Synergy",
|
this, "Synergy",
|
||||||
tr("Synergy is now connected. You can close the "
|
QString("Synergy is now connected. You can close the "
|
||||||
"config window and Synergy will remain connected in "
|
"config window and Synergy will remain connected in "
|
||||||
"the background."));
|
"the background."));
|
||||||
|
|
||||||
appConfig().setStartedBefore(true);
|
appConfig().setStartedBefore(true);
|
||||||
}
|
}
|
||||||
|
|
@ -663,15 +734,16 @@ void MainWindow::checkFingerprint(const QString &line) {
|
||||||
|
|
||||||
messageBoxAlreadyShown = true;
|
messageBoxAlreadyShown = true;
|
||||||
QMessageBox::StandardButton fingerprintReply = QMessageBox::information(
|
QMessageBox::StandardButton fingerprintReply = QMessageBox::information(
|
||||||
this, tr("Security question"),
|
this, QString("Security question"),
|
||||||
tr("You are connecting to a server. Here is it's fingerprint:\n\n"
|
QString(
|
||||||
"%1\n\n"
|
"You are connecting to a server. Here is it's fingerprint:\n\n"
|
||||||
"Compare this fingerprint to the one on your server's screen."
|
"%1\n\n"
|
||||||
"If the two don't match exactly, then it's probably not the server "
|
"Compare this fingerprint to the one on your server's screen."
|
||||||
"you're expecting (it could be a malicious user).\n\n"
|
"If the two don't match exactly, then it's probably not the server "
|
||||||
"To automatically trust this fingerprint for future "
|
"you're expecting (it could be a malicious user).\n\n"
|
||||||
"connections, click Yes. To reject this fingerprint and "
|
"To automatically trust this fingerprint for future "
|
||||||
"disconnect from the server, click No.")
|
"connections, click Yes. To reject this fingerprint and "
|
||||||
|
"disconnect from the server, click No.")
|
||||||
.arg(fingerprint),
|
.arg(fingerprint),
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
|
|
@ -806,7 +878,7 @@ void MainWindow::startCore() {
|
||||||
args << "--profile-dir" << getProfileRootForArg();
|
args << "--profile-dir" << getProfileRootForArg();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
qDebug() << e.what();
|
qDebug() << e.what();
|
||||||
qFatal("Failed to get profile dir, skipping arg");
|
qFatal("failed to get profile dir, skipping arg");
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
@ -861,11 +933,12 @@ void MainWindow::startCore() {
|
||||||
if (!m_pCoreProcess->waitForStarted()) {
|
if (!m_pCoreProcess->waitForStarted()) {
|
||||||
show();
|
show();
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("Program can not be started"),
|
this, QString("Program can not be started"),
|
||||||
QString(
|
QString(
|
||||||
tr("The executable<br><br>%1<br><br>could not be successfully "
|
QString(
|
||||||
"started, although it does exist. Please check if you have "
|
"The executable<br><br>%1<br><br>could not be successfully "
|
||||||
"sufficient permissions to run this program.")
|
"started, although it does exist. Please check if you have "
|
||||||
|
"sufficient permissions to run this program.")
|
||||||
.arg(app)));
|
.arg(app)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -881,8 +954,8 @@ bool MainWindow::clientArgs(QStringList &args, QString &app) {
|
||||||
if (!QFile::exists(app)) {
|
if (!QFile::exists(app)) {
|
||||||
show();
|
show();
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("Synergy client not found"),
|
this, QString("Synergy client not found"),
|
||||||
tr("The executable for the synergy client does not exist."));
|
QString("The executable for the synergy client does not exist."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -906,8 +979,8 @@ bool MainWindow::clientArgs(QStringList &args, QString &app) {
|
||||||
if (m_pLineEditHostname->text().isEmpty()) {
|
if (m_pLineEditHostname->text().isEmpty()) {
|
||||||
show();
|
show();
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("IP/hostname is empty"),
|
this, QString("IP/hostname is empty"),
|
||||||
tr("Please enter a server hostname or IP address."));
|
QString("Please enter a server hostname or IP address."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -937,15 +1010,15 @@ QString MainWindow::configFilename() {
|
||||||
{QStandardPaths::AppDataLocation, QStandardPaths::AppConfigLocation}) {
|
{QStandardPaths::AppDataLocation, QStandardPaths::AppConfigLocation}) {
|
||||||
auto configDirPath = QStandardPaths::writableLocation(path);
|
auto configDirPath = QStandardPaths::writableLocation(path);
|
||||||
if (!QDir().mkpath(configDirPath)) {
|
if (!QDir().mkpath(configDirPath)) {
|
||||||
errors.push_back(
|
errors.push_back(QString("Failed to create config folder \"%1\"")
|
||||||
tr("Failed to create config folder \"%1\"").arg(configDirPath));
|
.arg(configDirPath));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile configFile(configDirPath + "/LastConfig.cfg");
|
QFile configFile(configDirPath + "/LastConfig.cfg");
|
||||||
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
errors.push_back(
|
errors.push_back(
|
||||||
tr("File:\"%1\" Error:%2")
|
QString("File:\"%1\" Error:%2")
|
||||||
.arg(configFile.fileName(), configFile.errorString()));
|
.arg(configFile.fileName(), configFile.errorString()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -959,7 +1032,7 @@ QString MainWindow::configFilename() {
|
||||||
|
|
||||||
if (configFullPath.isEmpty()) {
|
if (configFullPath.isEmpty()) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
this, tr("Cannot write configuration file"), errors.join('\n'));
|
this, QString("Cannot write configuration file"), errors.join('\n'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -990,15 +1063,15 @@ bool MainWindow::serverArgs(QStringList &args, QString &app) {
|
||||||
|
|
||||||
if (!QFile::exists(app)) {
|
if (!QFile::exists(app)) {
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("Synergy server not found"),
|
this, QString("Synergy server not found"),
|
||||||
tr("The executable for the synergy server does not exist."));
|
QString("The executable for the synergy server does not exist."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appConfig().invertConnection() && m_pLineEditClientIp->text().isEmpty()) {
|
if (appConfig().invertConnection() && m_pLineEditClientIp->text().isEmpty()) {
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("Client IP address or name is empty"),
|
this, QString("Client IP address or name is empty"),
|
||||||
tr("Please fill in a client IP address or name."));
|
QString("Please fill in a client IP address or name."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1080,7 +1153,7 @@ void MainWindow::setCoreState(CoreState state) {
|
||||||
m_pButtonToggleStart, &QPushButton::clicked, m_pActionStopCore,
|
m_pButtonToggleStart, &QPushButton::clicked, m_pActionStopCore,
|
||||||
&QAction::trigger);
|
&QAction::trigger);
|
||||||
|
|
||||||
m_pButtonToggleStart->setText(tr("&Stop"));
|
m_pButtonToggleStart->setText(QString("&Stop"));
|
||||||
m_pButtonApply->setEnabled(true);
|
m_pButtonApply->setEnabled(true);
|
||||||
|
|
||||||
m_pActionStartCore->setEnabled(false);
|
m_pActionStartCore->setEnabled(false);
|
||||||
|
|
@ -1094,7 +1167,7 @@ void MainWindow::setCoreState(CoreState state) {
|
||||||
m_pButtonToggleStart, &QPushButton::clicked, m_pActionStartCore,
|
m_pButtonToggleStart, &QPushButton::clicked, m_pActionStartCore,
|
||||||
&QAction::trigger);
|
&QAction::trigger);
|
||||||
|
|
||||||
m_pButtonToggleStart->setText(tr("&Start"));
|
m_pButtonToggleStart->setText(QString("&Start"));
|
||||||
m_pButtonApply->setEnabled(false);
|
m_pButtonApply->setEnabled(false);
|
||||||
|
|
||||||
m_pActionStartCore->setEnabled(true);
|
m_pActionStartCore->setEnabled(true);
|
||||||
|
|
@ -1106,8 +1179,7 @@ void MainWindow::setCoreState(CoreState state) {
|
||||||
|
|
||||||
case Listening: {
|
case Listening: {
|
||||||
if (coreMode() == CoreMode::Server) {
|
if (coreMode() == CoreMode::Server) {
|
||||||
setStatus(
|
setStatus("Synergy is waiting for clients");
|
||||||
tr("Synergy is waiting for clients").arg(m_SecureSocketVersion));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -1115,21 +1187,20 @@ void MainWindow::setCoreState(CoreState state) {
|
||||||
case Connected: {
|
case Connected: {
|
||||||
if (m_SecureSocket) {
|
if (m_SecureSocket) {
|
||||||
setStatus(
|
setStatus(
|
||||||
tr("Synergy is connected (with %1)").arg(m_SecureSocketVersion));
|
QString("Synergy is connected (with %1)").arg(m_SecureSocketVersion));
|
||||||
} else {
|
} else {
|
||||||
setStatus(tr("Synergy is running (without TLS encryption)")
|
setStatus("Synergy is running (without TLS encryption)");
|
||||||
.arg(m_SecureSocketVersion));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Connecting:
|
case Connecting:
|
||||||
setStatus(tr("Synergy is starting..."));
|
setStatus("Synergy is starting...");
|
||||||
break;
|
break;
|
||||||
case PendingRetry:
|
case PendingRetry:
|
||||||
setStatus(tr("There was an error, retrying..."));
|
setStatus("There was an error, retrying...");
|
||||||
break;
|
break;
|
||||||
case Disconnected:
|
case Disconnected:
|
||||||
setStatus(tr("Synergy is not running"));
|
setStatus("Synergy is not running");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1176,8 +1247,8 @@ QString MainWindow::getIPAddresses() const {
|
||||||
// usually 192.168.x.x is a useful ip for the user, so indicate
|
// usually 192.168.x.x is a useful ip for the user, so indicate
|
||||||
// this by making it bold.
|
// this by making it bold.
|
||||||
if (!hinted && address.isInSubnet(localnet)) {
|
if (!hinted && address.isInSubnet(localnet)) {
|
||||||
QString format = "<span style=\"color:#4285F4;\">%1</span>";
|
QString format = R"(<span style="color:%1;">%2</span>)";
|
||||||
result.append(format.arg(address.toString()));
|
result.append(format.arg(kColorTertiary, address.toString()));
|
||||||
hinted = true;
|
hinted = true;
|
||||||
} else {
|
} else {
|
||||||
result.append(address.toString());
|
result.append(address.toString());
|
||||||
|
|
@ -1186,7 +1257,7 @@ QString MainWindow::getIPAddresses() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
result.append(tr("Unknown"));
|
result.append("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.join(", ");
|
return result.join(", ");
|
||||||
|
|
@ -1196,10 +1267,10 @@ void MainWindow::showLicenseNotice() {
|
||||||
const auto &license = m_LicenseHandler.license();
|
const auto &license = m_LicenseHandler.license();
|
||||||
const bool timeLimited = license.isTimeLimited();
|
const bool timeLimited = license.isTimeLimited();
|
||||||
|
|
||||||
m_labelNotice->setVisible(timeLimited);
|
m_pLabelNotice->setVisible(timeLimited);
|
||||||
if (timeLimited) {
|
if (timeLimited) {
|
||||||
auto notice = licenseNotice(m_LicenseHandler.license());
|
auto notice = licenseNotice(m_LicenseHandler.license());
|
||||||
this->m_labelNotice->setText(notice);
|
this->m_pLabelNotice->setText(notice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1209,7 +1280,7 @@ void MainWindow::updateLocalFingerprint() {
|
||||||
fingerprintExists = TlsFingerprint::local().fileExists();
|
fingerprintExists = TlsFingerprint::local().fileExists();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
qDebug() << e.what();
|
qDebug() << e.what();
|
||||||
qFatal("Failed to check if fingerprint exists");
|
qFatal("failed to check if fingerprint exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_AppConfig.tlsEnabled() && fingerprintExists &&
|
if (m_AppConfig.tlsEnabled() && fingerprintExists &&
|
||||||
|
|
@ -1244,13 +1315,13 @@ void MainWindow::autoAddScreen(const QString name) {
|
||||||
if (r != kAutoAddScreenOk) {
|
if (r != kAutoAddScreenOk) {
|
||||||
switch (r) {
|
switch (r) {
|
||||||
case kAutoAddScreenManualServer:
|
case kAutoAddScreenManualServer:
|
||||||
showConfigureServer(tr("Please add the server (%1) to the grid.")
|
showConfigureServer(QString("Please add the server (%1) to the grid.")
|
||||||
.arg(appConfig().screenName()));
|
.arg(appConfig().screenName()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kAutoAddScreenManualClient:
|
case kAutoAddScreenManualClient:
|
||||||
showConfigureServer(tr("Please drag the new client screen (%1) "
|
showConfigureServer(QString("Please drag the new client screen (%1) "
|
||||||
"to the desired position on the grid.")
|
"to the desired position on the grid.")
|
||||||
.arg(name));
|
.arg(name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1316,17 +1387,12 @@ void MainWindow::secureSocket(bool secureSocket) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::windowStateChanged() {
|
|
||||||
if (windowState() == Qt::WindowMinimized && appConfig().minimizeToTray())
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateScreenName() {
|
void MainWindow::updateScreenName() {
|
||||||
m_pLabelComputerName->setText(
|
m_pLabelComputerName->setText(
|
||||||
QString("This computer's name: %1 "
|
QString("This computer's name: %1 "
|
||||||
R"((<a href="#" style="%2;">change</a>))")
|
R"((<a href="#" style="color: %2">change</a>))")
|
||||||
.arg(appConfig().screenName())
|
.arg(appConfig().screenName())
|
||||||
.arg(kLinkStyleSecondary));
|
.arg(kColorSecondary));
|
||||||
serverConfig().updateServerName();
|
serverConfig().updateServerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,13 @@
|
||||||
#include "ui_MainWindowBase.h"
|
#include "ui_MainWindowBase.h"
|
||||||
|
|
||||||
#include "ActivationDialog.h"
|
#include "ActivationDialog.h"
|
||||||
#include "AppConfig.h"
|
|
||||||
#include "ClientConnection.h"
|
#include "ClientConnection.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
#include "ServerConnection.h"
|
#include "ServerConnection.h"
|
||||||
#include "TrayIcon.h"
|
#include "TrayIcon.h"
|
||||||
#include "global/Ipc.h"
|
#include "global/Ipc.h"
|
||||||
|
#include "gui/AppConfig.h"
|
||||||
|
#include "gui/ConfigScopes.h"
|
||||||
#include "gui/QIpcClient.h"
|
#include "gui/QIpcClient.h"
|
||||||
#include "gui/TlsUtility.h"
|
#include "gui/TlsUtility.h"
|
||||||
#include "gui/VersionChecker.h"
|
#include "gui/VersionChecker.h"
|
||||||
|
|
@ -126,6 +126,9 @@ private slots:
|
||||||
void onActionStopCoreTriggered();
|
void onActionStopCoreTriggered();
|
||||||
void onCoreProcessReadyReadStandardOutput();
|
void onCoreProcessReadyReadStandardOutput();
|
||||||
void onCoreProcessReadyReadStandardError();
|
void onCoreProcessReadyReadStandardError();
|
||||||
|
void onWindowSaveTimerTimeout();
|
||||||
|
|
||||||
|
// autoconnect slots
|
||||||
void on_m_pButtonApply_clicked();
|
void on_m_pButtonApply_clicked();
|
||||||
void on_m_pLabelComputerName_linkActivated(const QString &link);
|
void on_m_pLabelComputerName_linkActivated(const QString &link);
|
||||||
void on_m_pLabelFingerprint_linkActivated(const QString &link);
|
void on_m_pLabelFingerprint_linkActivated(const QString &link);
|
||||||
|
|
@ -141,7 +144,7 @@ private slots:
|
||||||
void on_m_pActivate_triggered();
|
void on_m_pActivate_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings &settings() { return *appConfig().config().currentSettings(); }
|
QSettings &settings() { return *appConfig().scopes().currentSettings(); }
|
||||||
AppConfig &appConfig() { return m_AppConfig; }
|
AppConfig &appConfig() { return m_AppConfig; }
|
||||||
AppConfig const &appConfig() const { return m_AppConfig; }
|
AppConfig const &appConfig() const { return m_AppConfig; }
|
||||||
void createMenuBar();
|
void createMenuBar();
|
||||||
|
|
@ -184,6 +187,11 @@ private:
|
||||||
void showConfigureServer() { showConfigureServer(""); }
|
void showConfigureServer() { showConfigureServer(""); }
|
||||||
void showLicenseNotice();
|
void showLicenseNotice();
|
||||||
void stopCore();
|
void stopCore();
|
||||||
|
void restoreWindow();
|
||||||
|
void saveWindow();
|
||||||
|
void setupControls();
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
void moveEvent(QMoveEvent *event) override;
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
void checkOSXNotification(const QString &line);
|
void checkOSXNotification(const QString &line);
|
||||||
|
|
@ -207,6 +215,7 @@ private:
|
||||||
bool m_AlreadyHidden = false;
|
bool m_AlreadyHidden = false;
|
||||||
bool m_SecureSocket = false;
|
bool m_SecureSocket = false;
|
||||||
QString m_SecureSocketVersion = "";
|
QString m_SecureSocketVersion = "";
|
||||||
|
bool m_SaveWindow = false;
|
||||||
|
|
||||||
AppConfig &m_AppConfig;
|
AppConfig &m_AppConfig;
|
||||||
LicenseHandler m_LicenseHandler;
|
LicenseHandler m_LicenseHandler;
|
||||||
|
|
@ -214,4 +223,5 @@ private:
|
||||||
ServerConnection m_ServerConnection;
|
ServerConnection m_ServerConnection;
|
||||||
ClientConnection m_ClientConnection;
|
ClientConnection m_ClientConnection;
|
||||||
synergy::gui::TlsUtility m_TlsUtility;
|
synergy::gui::TlsUtility m_TlsUtility;
|
||||||
|
QTimer m_WindowSaveTimer;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>750</width>
|
<width>800</width>
|
||||||
<height>700</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -57,13 +57,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_pLabelUpdate">
|
<widget class="QLabel" name="m_pLabelUpdate">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding: 3px 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
background-color: #3B67D3;
|
|
||||||
color: #ffffff;
|
|
||||||
top: 3px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">m_pLabelUpdate</string>
|
<string notr="true">m_pLabelUpdate</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -92,6 +85,9 @@ top: 3px;</string>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_pLabelIpAddresses">
|
<widget class="QLabel" name="m_pLabelIpAddresses">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>The highlighted IP is the one we think you should use. The server listens on all IPs, so the other IPs may work as well.</p></body></html></string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">This computer's IP addresses:</string>
|
<string notr="true">This computer's IP addresses:</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -106,21 +102,6 @@ top: 3px;</string>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
<property name="spacing">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>15</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="m_pGroupServer">
|
<widget class="QFrame" name="m_pGroupServer">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -129,29 +110,30 @@ top: 3px;</string>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);;
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>15</number>
|
<number>15</number>
|
||||||
</property>
|
</property>
|
||||||
<item alignment="Qt::AlignTop">
|
<item>
|
||||||
<widget class="QRadioButton" name="m_pRadioGroupServer">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="styleSheet">
|
<item>
|
||||||
<string notr="true">QRadioButton::indicator{
|
<widget class="QRadioButton" name="m_pRadioGroupServer">
|
||||||
top: -7px;
|
<property name="text">
|
||||||
}</string>
|
<string>Use this computer's keyboard and mouse</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Use this computer's keyboard and mouse
|
</item>
|
||||||
(make this computer the &server)</string>
|
<item>
|
||||||
</property>
|
<widget class="QLabel" name="label">
|
||||||
</widget>
|
<property name="text">
|
||||||
|
<string>(make this computer the server)</string>
|
||||||
|
</property>
|
||||||
|
<property name="indent">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignTop">
|
<item alignment="Qt::AlignTop">
|
||||||
<widget class="QWidget" name="m_pWidgetServer" native="true">
|
<widget class="QWidget" name="m_pWidgetServer" native="true">
|
||||||
|
|
@ -293,32 +275,30 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>15</number>
|
<number>15</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<item>
|
||||||
<number>11</number>
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
</property>
|
<item>
|
||||||
<item alignment="Qt::AlignTop">
|
<widget class="QRadioButton" name="m_pRadioGroupClient">
|
||||||
<widget class="QRadioButton" name="m_pRadioGroupClient">
|
<property name="text">
|
||||||
<property name="styleSheet">
|
<string>Use another computer’s mouse and keyboard</string>
|
||||||
<string notr="true">QRadioButton::indicator{
|
</property>
|
||||||
top: -7px;
|
</widget>
|
||||||
}</string>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
<property name="text">
|
<widget class="QLabel" name="label_2">
|
||||||
<string>Use another computer’s mouse and keyboard
|
<property name="text">
|
||||||
(make this computer the &client)</string>
|
<string>(make this computer the client)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="indent">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignTop">
|
<item alignment="Qt::AlignTop">
|
||||||
<widget class="QWidget" name="m_pWidgetClient" native="true">
|
<widget class="QWidget" name="m_pWidgetClient" native="true">
|
||||||
|
|
@ -409,9 +389,6 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_pLabelLogs">
|
<widget class="QLabel" name="m_pLabelLogs">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Logs</string>
|
<string>Logs</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -441,13 +418,6 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);;
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -481,9 +451,6 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
<kerning>true</kerning>
|
<kerning>true</kerning>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoFillBackground">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="undoRedoEnabled">
|
<property name="undoRedoEnabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -546,19 +513,12 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_labelNotice">
|
<widget class="QLabel" name="m_pLabelNotice">
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding: 3px 5px;
|
|
||||||
border-radius: 3px;
|
|
||||||
background-color: #3B67D3;
|
|
||||||
color: #ffffff;
|
|
||||||
top: 3px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">m_labelNotice</string>
|
<string notr="true">m_pLabelNotice</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
|
@ -736,6 +696,18 @@ top: 3px;</string>
|
||||||
<header>widgets/ClientStateLabel.h</header>
|
<header>widgets/ClientStateLabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pRadioGroupServer</tabstop>
|
||||||
|
<tabstop>m_pRadioGroupClient</tabstop>
|
||||||
|
<tabstop>m_pLineEditClientIp</tabstop>
|
||||||
|
<tabstop>m_pButtonConnectToClient</tabstop>
|
||||||
|
<tabstop>m_pButtonConfigureServer</tabstop>
|
||||||
|
<tabstop>m_pLineEditHostname</tabstop>
|
||||||
|
<tabstop>m_pButtonConnect</tabstop>
|
||||||
|
<tabstop>m_pLogOutput</tabstop>
|
||||||
|
<tabstop>m_pButtonApply</tabstop>
|
||||||
|
<tabstop>m_pButtonToggleStart</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../res/Synergy.qrc"/>
|
<include location="../res/Synergy.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,6 @@
|
||||||
QSynergyApplication::QSynergyApplication(int &argc, char **argv)
|
QSynergyApplication::QSynergyApplication(int &argc, char **argv)
|
||||||
: QApplication(argc, argv) {
|
: QApplication(argc, argv) {
|
||||||
|
|
||||||
QFontDatabase::addApplicationFont(":/res/fonts/Arial.ttf");
|
|
||||||
QFont Arial("Arial");
|
|
||||||
Arial.setPixelSize(13);
|
|
||||||
Arial.setStyleHint(QFont::SansSerif);
|
|
||||||
setFont(Arial);
|
|
||||||
|
|
||||||
// Setting the style to 'Fusion' seems to fix issues such as text being
|
// Setting the style to 'Fusion' seems to fix issues such as text being
|
||||||
// rendered as black on black. This may not be the style we want long-term
|
// rendered as black on black. This may not be the style we want long-term
|
||||||
// but it does fix the style issues for now.
|
// but it does fix the style issues for now.
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,10 @@
|
||||||
|
|
||||||
#include "ScreenSettingsDialog.h"
|
#include "ScreenSettingsDialog.h"
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
|
#include "gui/constants.h"
|
||||||
#include "validators/AliasValidator.h"
|
#include "validators/AliasValidator.h"
|
||||||
#include "validators/ScreenNameValidator.h"
|
#include "validators/ScreenNameValidator.h"
|
||||||
|
#include "validators/ValidationError.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
@ -30,15 +32,21 @@ ScreenSettingsDialog::ScreenSettingsDialog(
|
||||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::ScreenSettingsDialogBase(),
|
Ui::ScreenSettingsDialogBase(),
|
||||||
m_pScreen(pScreen) {
|
m_pScreen(pScreen) {
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
m_pLabelAliasError->setStyleSheet(kStyleErrorActiveLabel);
|
||||||
|
m_pLabelNameError->setStyleSheet(kStyleErrorActiveLabel);
|
||||||
|
|
||||||
m_pLineEditName->setText(m_pScreen->name());
|
m_pLineEditName->setText(m_pScreen->name());
|
||||||
m_pLineEditName->setValidator(new validators::ScreenNameValidator(
|
m_pLineEditName->setValidator(new validators::ScreenNameValidator(
|
||||||
m_pLineEditName, m_pLabelNameError, pScreens));
|
m_pLineEditName, new validators::ValidationError(this, m_pLabelNameError),
|
||||||
|
pScreens));
|
||||||
m_pLineEditName->selectAll();
|
m_pLineEditName->selectAll();
|
||||||
|
|
||||||
m_pLineEditAlias->setValidator(
|
m_pLineEditAlias->setValidator(new validators::AliasValidator(
|
||||||
new validators::AliasValidator(m_pLineEditAlias, m_pLabelAliasError));
|
m_pLineEditAlias,
|
||||||
|
new validators::ValidationError(this, m_pLabelAliasError)));
|
||||||
|
|
||||||
for (int i = 0; i < m_pScreen->aliases().count(); i++)
|
for (int i = 0; i < m_pScreen->aliases().count(); i++)
|
||||||
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
|
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2016 Symless Ltd.
|
* Copyright (C) 2012 Symless Ltd.
|
||||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
|
|
@ -16,10 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(SCREENSETTINGSDIALOG__H)
|
#pragma once
|
||||||
|
|
||||||
#define SCREENSETTINGSDIALOG__H
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
@ -52,5 +49,3 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Screen *m_pScreen;
|
Screen *m_pScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>403</width>
|
<width>440</width>
|
||||||
<height>675</height>
|
<height>739</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -43,13 +43,6 @@
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="groupBox">
|
<widget class="QFrame" name="groupBox">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -106,14 +99,8 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #EC4C47;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: Arial;
|
|
||||||
font-weight: bold;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>m_pLabelNameError</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
|
@ -154,13 +141,6 @@ font-weight: bold;</string>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="m_pGroupModifiers">
|
<widget class="QFrame" name="m_pGroupModifiers">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -477,13 +457,6 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -648,13 +621,6 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="m_pGroupFixes">
|
<widget class="QFrame" name="m_pGroupFixes">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -760,19 +726,6 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="m_pGroupAliases">
|
<widget class="QFrame" name="m_pGroupAliases">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">.QFrame{
|
|
||||||
border: 1px solid rgba(192,192,192, 0.2);
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: rgba(192,192,192, 0.1);
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -809,26 +762,6 @@ background-color: rgba(192,192,192, 0.1);
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>43</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="layoutDirection">
|
|
||||||
<enum>Qt::LeftToRight</enum>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QPushButton#m_pButtonAddAlias{
|
|
||||||
left: 30px;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Add</string>
|
<string>&Add</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -848,9 +781,6 @@ left: 30px;
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="maxLength">
|
<property name="maxLength">
|
||||||
<number>255</number>
|
<number>255</number>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -876,14 +806,8 @@ left: 30px;
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #EC4C47;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: Arial;
|
|
||||||
font-weight: bold;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>m_pLabelNameError</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
@ -933,9 +857,6 @@ font-weight: bold;</string>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -946,12 +867,6 @@ font-weight: bold;</string>
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Remove</string>
|
<string>&Remove</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ ScreenSetupModel::ScreenSetupModel(
|
||||||
// this is unlikely to happen, as the grid size is only 3x9.
|
// this is unlikely to happen, as the grid size is only 3x9.
|
||||||
if (m_NumColumns > 100 || m_NumRows > 100) {
|
if (m_NumColumns > 100 || m_NumRows > 100) {
|
||||||
qFatal(
|
qFatal(
|
||||||
"Grid size out of bounds: %d columns x %d rows", m_NumColumns,
|
"grid size out of bounds: %d columns x %d rows", m_NumColumns,
|
||||||
m_NumRows);
|
m_NumRows);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_NumColumns * m_NumRows > screens.size()) {
|
if (m_NumColumns * m_NumRows > screens.size()) {
|
||||||
qFatal(
|
qFatal(
|
||||||
"Scrren list (%lld) too small for %d columns x %d rows", screens.size(),
|
"scrren list (%lld) too small for %d columns x %d rows", screens.size(),
|
||||||
m_NumColumns, m_NumRows);
|
m_NumColumns, m_NumRows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,9 @@ void ScreenSetupView::dragMoveEvent(QDragMoveEvent *event) {
|
||||||
event->setDropAction(Qt::MoveAction);
|
event->setDropAction(Qt::MoveAction);
|
||||||
event->accept();
|
event->accept();
|
||||||
} else {
|
} else {
|
||||||
int col = columnAt(event->pos().x());
|
const auto &point = event->position().toPoint();
|
||||||
int row = rowAt(event->pos().y());
|
int col = columnAt(point.x());
|
||||||
|
int row = rowAt(point.y());
|
||||||
|
|
||||||
// a drop from outside is not allowed if there's a screen already there.
|
// a drop from outside is not allowed if there's a screen already there.
|
||||||
if (!model()->screen(col, row).isNull())
|
if (!model()->screen(col, row).isNull())
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
|
|
||||||
#include "AddClientDialog.h"
|
#include "AddClientDialog.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "Hotkey.h"
|
#include "Hotkey.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include "gui/ConfigScopes.h"
|
||||||
#include "gui/constants.h"
|
#include "gui/constants.h"
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
|
|
@ -51,7 +51,7 @@ ServerConfig::ServerConfig(
|
||||||
m_NumColumns(numColumns),
|
m_NumColumns(numColumns),
|
||||||
m_NumRows(numRows),
|
m_NumRows(numRows),
|
||||||
m_ClipboardSharingSize(defaultClipboardSharingSize()) {
|
m_ClipboardSharingSize(defaultClipboardSharingSize()) {
|
||||||
appConfig->config().registerReceiever(this);
|
appConfig->scopes().registerReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerConfig::~ServerConfig() {
|
ServerConfig::~ServerConfig() {
|
||||||
|
|
@ -553,5 +553,5 @@ QString ServerConfig::getClientAddress() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings &ServerConfig::settings() {
|
QSettings &ServerConfig::settings() {
|
||||||
return *m_pAppConfig->config().currentSettings();
|
return *m_pAppConfig->scopes().currentSettings();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
#include "CommonConfig.h"
|
|
||||||
#include "Hotkey.h"
|
#include "Hotkey.h"
|
||||||
#include "ScreenConfig.h"
|
#include "ScreenConfig.h"
|
||||||
#include "ScreenList.h"
|
#include "ScreenList.h"
|
||||||
|
#include "gui/CommonConfig.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
class QTextStream;
|
class QTextStream;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ServerConfigDialog.h"
|
#include "ServerConfigDialog.h"
|
||||||
|
|
||||||
#include "ActionDialog.h"
|
#include "ActionDialog.h"
|
||||||
#include "HotkeyDialog.h"
|
#include "HotkeyDialog.h"
|
||||||
#include "ScreenSettingsDialog.h"
|
#include "ScreenSettingsDialog.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
#include "UpgradeDialog.h"
|
|
||||||
#include "gui/constants.h"
|
|
||||||
#include "license/ProductEdition.h"
|
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
@ -43,8 +41,13 @@ ServerConfigDialog::ServerConfigDialog(
|
||||||
serverConfig().numRows()),
|
serverConfig().numRows()),
|
||||||
m_Message(""),
|
m_Message(""),
|
||||||
m_appConfig(appConfig) {
|
m_appConfig(appConfig) {
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
// force the first tab, since qt creator sets the active tab as the last one
|
||||||
|
// the developer was looking at, and it's easy to accidentally save that.
|
||||||
|
m_pTabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
m_pEditConfigFile->setText(serverConfig().configFile());
|
m_pEditConfigFile->setText(serverConfig().configFile());
|
||||||
m_pCheckBoxUseExternalConfig->setChecked(serverConfig().useExternalConfig());
|
m_pCheckBoxUseExternalConfig->setChecked(serverConfig().useExternalConfig());
|
||||||
m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
|
m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
#define SERVERCONFIGDIALOG__H
|
#define SERVERCONFIGDIALOG__H
|
||||||
|
|
||||||
#include "AppConfig.h"
|
|
||||||
#include "ScreenSetupModel.h"
|
#include "ScreenSetupModel.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
|
#include "gui/AppConfig.h"
|
||||||
#include "ui_ServerConfigDialogBase.h"
|
#include "ui_ServerConfigDialogBase.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>799</width>
|
<width>814</width>
|
||||||
<height>508</height>
|
<height>588</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_pTabScreens">
|
<widget class="QWidget" name="m_pTabScreens">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -359,12 +359,6 @@
|
||||||
<kerning>true</kerning>
|
<kerning>true</kerning>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QGroupBox::title{
|
|
||||||
left: -5px;
|
|
||||||
top: -2px;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Switch computer</string>
|
<string>&Switch computer</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -510,12 +504,6 @@
|
||||||
<kerning>true</kerning>
|
<kerning>true</kerning>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QGroupBox::title{
|
|
||||||
left: -2px;
|
|
||||||
top: -2px;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Clipboard sharing</string>
|
<string>Clipboard sharing</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -617,12 +605,6 @@
|
||||||
<kerning>true</kerning>
|
<kerning>true</kerning>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QGroupBox::title{
|
|
||||||
left: -5px;
|
|
||||||
top: -2px;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Dead corners for this computer</string>
|
<string>&Dead corners for this computer</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -707,12 +689,6 @@
|
||||||
<kerning>false</kerning>
|
<kerning>false</kerning>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QGroupBox::title{
|
|
||||||
left: -5px;
|
|
||||||
top: -2px;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Options</string>
|
<string>&Options</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -738,9 +714,6 @@
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding-left: 2px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use &relative mouse moves</string>
|
<string>Use &relative mouse moves</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -759,9 +732,6 @@
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">left: -2px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Check clients every</string>
|
<string>&Check clients every</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -816,9 +786,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QCheckBox" name="m_pCheckBoxIgnoreAutoConfigClient">
|
<widget class="QCheckBox" name="m_pCheckBoxIgnoreAutoConfigClient">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding-left: 2px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Ignore auto config clients</string>
|
<string>Ignore auto config clients</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -826,9 +793,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QCheckBox" name="m_pCheckBoxDisableLockToScreen">
|
<widget class="QCheckBox" name="m_pCheckBoxDisableLockToScreen">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding-left: 2px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Disable lock to screen</string>
|
<string>Disable lock to screen</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -839,9 +803,6 @@
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding-left: 2px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Don't take &foreground window on Windows servers</string>
|
<string>Don't take &foreground window on Windows servers</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -1110,9 +1071,6 @@
|
||||||
<property name="cursor">
|
<property name="cursor">
|
||||||
<cursorShape>PointingHandCursor</cursorShape>
|
<cursorShape>PointingHandCursor</cursorShape>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">margin: 0px; padding: 0px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -1193,6 +1151,39 @@
|
||||||
<header>TrashScreenWidget.h</header>
|
<header>TrashScreenWidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pButtonBrowseConfigFile</tabstop>
|
||||||
|
<tabstop>m_pButtonAddComputer</tabstop>
|
||||||
|
<tabstop>m_pScreenSetupView</tabstop>
|
||||||
|
<tabstop>m_pListHotkeys</tabstop>
|
||||||
|
<tabstop>m_pButtonNewHotkey</tabstop>
|
||||||
|
<tabstop>m_pButtonEditHotkey</tabstop>
|
||||||
|
<tabstop>m_pButtonRemoveHotkey</tabstop>
|
||||||
|
<tabstop>m_pListActions</tabstop>
|
||||||
|
<tabstop>m_pButtonNewAction</tabstop>
|
||||||
|
<tabstop>m_pButtonEditAction</tabstop>
|
||||||
|
<tabstop>m_pButtonRemoveAction</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxSwitchDelay</tabstop>
|
||||||
|
<tabstop>m_pSpinBoxSwitchDelay</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxSwitchDoubleTap</tabstop>
|
||||||
|
<tabstop>m_pSpinBoxSwitchDoubleTap</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxEnableClipboard</tabstop>
|
||||||
|
<tabstop>m_pSpinBoxClipboardSizeLimit</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxHeartbeat</tabstop>
|
||||||
|
<tabstop>m_pSpinBoxHeartbeat</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxRelativeMouseMoves</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxWin32KeepForeground</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxIgnoreAutoConfigClient</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxDisableLockToScreen</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxCornerTopLeft</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxCornerBottomLeft</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxCornerTopRight</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxCornerBottomRight</tabstop>
|
||||||
|
<tabstop>m_pSpinBoxSwitchCornerSize</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxUseExternalConfig</tabstop>
|
||||||
|
<tabstop>m_pEditConfigFile</tabstop>
|
||||||
|
<tabstop>m_pTabWidget</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../res/Synergy.qrc"/>
|
<include location="../res/Synergy.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
|
|
||||||
#include "ServerConnection.h"
|
#include "ServerConnection.h"
|
||||||
|
|
||||||
#include "AppConfig.h"
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "ServerConfigDialog.h"
|
#include "ServerConfigDialog.h"
|
||||||
#include "ServerMessage.h"
|
#include "ServerMessage.h"
|
||||||
|
#include "gui/AppConfig.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,19 @@
|
||||||
|
|
||||||
#include "SettingsDialog.h"
|
#include "SettingsDialog.h"
|
||||||
|
|
||||||
#include "AppConfig.h"
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "UpgradeDialog.h"
|
#include "UpgradeDialog.h"
|
||||||
|
#include "gui/AppConfig.h"
|
||||||
#include "gui/TlsCertificate.h"
|
#include "gui/TlsCertificate.h"
|
||||||
#include "gui/constants.h"
|
#include "gui/constants.h"
|
||||||
|
#include "validators/ScreenNameValidator.h"
|
||||||
|
#include "validators/ValidationError.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
using namespace synergy::license;
|
using namespace synergy::license;
|
||||||
|
|
||||||
|
|
@ -45,6 +46,10 @@ SettingsDialog::SettingsDialog(
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
// force the first tab, since qt creator sets the active tab as the last one
|
||||||
|
// the developer was looking at, and it's easy to accidentally save that.
|
||||||
|
m_pTabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
m_pMainWindow = dynamic_cast<MainWindow *>(parent);
|
m_pMainWindow = dynamic_cast<MainWindow *>(parent);
|
||||||
|
|
||||||
loadFromConfig();
|
loadFromConfig();
|
||||||
|
|
@ -52,45 +57,16 @@ SettingsDialog::SettingsDialog(
|
||||||
updateControlsEnabled();
|
updateControlsEnabled();
|
||||||
|
|
||||||
const auto &serveConfig = m_pMainWindow->serverConfig();
|
const auto &serveConfig = m_pMainWindow->serverConfig();
|
||||||
m_screenNameValidator = std::make_unique<validators::ScreenNameValidator>(
|
|
||||||
m_pLineEditScreenName, nullptr, (&serveConfig.screens()));
|
|
||||||
connect(
|
|
||||||
m_screenNameValidator.get(), SIGNAL(finished(QString)), this,
|
|
||||||
SLOT(on_m_pScreenNameValidator_finished(QString)));
|
|
||||||
m_pLineEditScreenName->setValidator(m_screenNameValidator.get());
|
|
||||||
|
|
||||||
connect(
|
m_pScreenNameError = new validators::ValidationError(this);
|
||||||
m_pLineEditLogFilename, SIGNAL(textChanged(QString)), this,
|
m_pLineEditScreenName->setValidator(new validators::ScreenNameValidator(
|
||||||
SLOT(onChange()));
|
m_pLineEditScreenName, m_pScreenNameError, &serveConfig.screens()));
|
||||||
connect(
|
|
||||||
m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this,
|
|
||||||
SLOT(onChange()));
|
|
||||||
connect(
|
|
||||||
m_pLineEditCertificatePath, SIGNAL(textChanged(QString)), this,
|
|
||||||
SLOT(onChange()));
|
|
||||||
connect(m_pCheckBoxMinimizeToTray, SIGNAL(clicked()), this, SLOT(onChange()));
|
|
||||||
connect(m_pCheckBoxAutoHide, SIGNAL(clicked()), this, SLOT(onChange()));
|
|
||||||
connect(m_pCheckBoxPreventSleep, SIGNAL(clicked()), this, SLOT(onChange()));
|
|
||||||
connect(
|
|
||||||
m_pLineEditInterface, SIGNAL(textEdited(QString)), this,
|
|
||||||
SLOT(onChange()));
|
|
||||||
connect(m_pSpinBoxPort, SIGNAL(valueChanged(int)), this, SLOT(onChange()));
|
|
||||||
connect(
|
|
||||||
m_pLineEditScreenName, SIGNAL(textEdited(QString)), this,
|
|
||||||
SLOT(onChange()));
|
|
||||||
connect(
|
|
||||||
m_pComboElevate, SIGNAL(currentIndexChanged(int)), this,
|
|
||||||
SLOT(onChange()));
|
|
||||||
connect(m_pCheckBoxLanguageSync, SIGNAL(clicked()), this, SLOT(onChange()));
|
|
||||||
connect(
|
|
||||||
m_pCheckBoxScrollDirection, SIGNAL(clicked()), this, SLOT(onChange()));
|
|
||||||
|
|
||||||
adjustSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::accept() {
|
void SettingsDialog::accept() {
|
||||||
if (!m_nameError.isEmpty()) {
|
if (!m_pLineEditScreenName->hasAcceptableInput()) {
|
||||||
QMessageBox::warning(this, tr("Invalid screen name"), m_nameError);
|
QMessageBox::warning(
|
||||||
|
this, tr("Invalid screen name"), m_pScreenNameError->message());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +81,6 @@ void SettingsDialog::accept() {
|
||||||
static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||||
appConfig().setPreventSleep(m_pCheckBoxPreventSleep->isChecked());
|
appConfig().setPreventSleep(m_pCheckBoxPreventSleep->isChecked());
|
||||||
appConfig().setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
|
|
||||||
appConfig().setTlsCertPath(m_pLineEditCertificatePath->text());
|
appConfig().setTlsCertPath(m_pLineEditCertificatePath->text());
|
||||||
appConfig().setTlsKeyLength(m_pComboBoxKeyLength->currentText());
|
appConfig().setTlsKeyLength(m_pComboBoxKeyLength->currentText());
|
||||||
appConfig().setTlsEnabled(m_pCheckBoxEnableCrypto->isChecked());
|
appConfig().setTlsEnabled(m_pCheckBoxEnableCrypto->isChecked());
|
||||||
|
|
@ -138,7 +113,6 @@ void SettingsDialog::loadFromConfig() {
|
||||||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||||
m_pCheckBoxAutoHide->setChecked(appConfig().autoHide());
|
m_pCheckBoxAutoHide->setChecked(appConfig().autoHide());
|
||||||
m_pCheckBoxPreventSleep->setChecked(appConfig().preventSleep());
|
m_pCheckBoxPreventSleep->setChecked(appConfig().preventSleep());
|
||||||
m_pCheckBoxMinimizeToTray->setChecked(appConfig().minimizeToTray());
|
|
||||||
m_pLineEditCertificatePath->setText(appConfig().tlsCertPath());
|
m_pLineEditCertificatePath->setText(appConfig().tlsCertPath());
|
||||||
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.tlsEnabled());
|
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.tlsEnabled());
|
||||||
m_pCheckBoxLanguageSync->setChecked(m_appConfig.languageSync());
|
m_pCheckBoxLanguageSync->setChecked(m_appConfig.languageSync());
|
||||||
|
|
@ -179,7 +153,7 @@ void SettingsDialog::updateTlsControlsEnabled() {
|
||||||
auto enabled = !clientMode && tlsAvailable && tlsChecked;
|
auto enabled = !clientMode && tlsAvailable && tlsChecked;
|
||||||
|
|
||||||
qDebug(
|
qDebug(
|
||||||
"TLS controls enabled=%d, client=%d, available=%d, checked=%d", enabled,
|
"tls enabled=%d, client=%d, available=%d, checked=%d", enabled,
|
||||||
clientMode, tlsAvailable, tlsChecked);
|
clientMode, tlsAvailable, tlsChecked);
|
||||||
|
|
||||||
m_pLabelKeyLength->setEnabled(enabled);
|
m_pLabelKeyLength->setEnabled(enabled);
|
||||||
|
|
@ -290,7 +264,6 @@ void SettingsDialog::updateControlsEnabled() {
|
||||||
m_pComboElevate->setEnabled(writable);
|
m_pComboElevate->setEnabled(writable);
|
||||||
m_pCheckBoxAutoHide->setEnabled(writable);
|
m_pCheckBoxAutoHide->setEnabled(writable);
|
||||||
m_pCheckBoxPreventSleep->setEnabled(writable);
|
m_pCheckBoxPreventSleep->setEnabled(writable);
|
||||||
m_pCheckBoxMinimizeToTray->setEnabled(writable);
|
|
||||||
m_pLineEditCertificatePath->setEnabled(writable);
|
m_pLineEditCertificatePath->setEnabled(writable);
|
||||||
m_pComboBoxKeyLength->setEnabled(writable);
|
m_pComboBoxKeyLength->setEnabled(writable);
|
||||||
m_pPushButtonBrowseCert->setEnabled(writable);
|
m_pPushButtonBrowseCert->setEnabled(writable);
|
||||||
|
|
@ -326,7 +299,3 @@ void SettingsDialog::updateControlsEnabled() {
|
||||||
|
|
||||||
updateTlsControls();
|
updateTlsControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_m_pScreenNameValidator_finished(const QString &error) {
|
|
||||||
m_nameError = error;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gui/TlsUtility.h"
|
|
||||||
#include "ui_SettingsDialogBase.h"
|
#include "ui_SettingsDialogBase.h"
|
||||||
|
|
||||||
#include "gui/CoreInterface.h"
|
#include "gui/CoreInterface.h"
|
||||||
|
#include "gui/TlsUtility.h"
|
||||||
#include "license/License.h"
|
#include "license/License.h"
|
||||||
#include "validators/ScreenNameValidator.h"
|
#include "validators/ValidationError.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class AppConfig;
|
class AppConfig;
|
||||||
|
|
@ -67,13 +66,12 @@ protected:
|
||||||
void updateTlsControlsEnabled();
|
void updateTlsControlsEnabled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_nameError = "";
|
|
||||||
MainWindow *m_pMainWindow;
|
MainWindow *m_pMainWindow;
|
||||||
AppConfig &m_appConfig;
|
AppConfig &m_appConfig;
|
||||||
CoreInterface m_coreInterface;
|
CoreInterface m_coreInterface;
|
||||||
const synergy::license::License &m_license;
|
const synergy::license::License &m_license;
|
||||||
synergy::gui::TlsUtility m_tlsUtility;
|
synergy::gui::TlsUtility m_tlsUtility;
|
||||||
std::unique_ptr<validators::ScreenNameValidator> m_screenNameValidator;
|
validators::ValidationError *m_pScreenNameError;
|
||||||
|
|
||||||
/// @brief Stores settings scope at start of settings dialog
|
/// @brief Stores settings scope at start of settings dialog
|
||||||
/// This is neccessary to restore state if user changes
|
/// This is neccessary to restore state if user changes
|
||||||
|
|
@ -84,23 +82,8 @@ private slots:
|
||||||
void on_m_pCheckBoxEnableCrypto_clicked(bool checked);
|
void on_m_pCheckBoxEnableCrypto_clicked(bool checked);
|
||||||
void on_m_pCheckBoxLogToFile_stateChanged(int);
|
void on_m_pCheckBoxLogToFile_stateChanged(int);
|
||||||
void on_m_pButtonBrowseLog_clicked();
|
void on_m_pButtonBrowseLog_clicked();
|
||||||
|
|
||||||
/// @brief Handles the toggling of the system scoped radio button
|
|
||||||
/// As the user scope radio is connected this will fire for either
|
|
||||||
/// radio button
|
|
||||||
void on_m_pRadioSystemScope_toggled(bool checked);
|
void on_m_pRadioSystemScope_toggled(bool checked);
|
||||||
|
|
||||||
/// @brief Handles the click event of the Cert Path browse button
|
|
||||||
/// displaying a file browser
|
|
||||||
void on_m_pPushButtonBrowseCert_clicked();
|
void on_m_pPushButtonBrowseCert_clicked();
|
||||||
|
|
||||||
/// @brief Handles the TLS cert key length changed event
|
|
||||||
void on_m_pComboBoxKeyLength_currentIndexChanged(int index);
|
void on_m_pComboBoxKeyLength_currentIndexChanged(int index);
|
||||||
|
|
||||||
/// @brief handels the regenerate cert button event
|
|
||||||
/// This will regenerate the TLS certificate as long as the settings
|
|
||||||
/// haven't changed
|
|
||||||
void on_m_pPushButtonRegenCert_clicked();
|
void on_m_pPushButtonRegenCert_clicked();
|
||||||
|
|
||||||
void on_m_pScreenNameValidator_finished(const QString &error);
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -16,35 +16,41 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SetupWizard.h"
|
#include "SetupWizard.h"
|
||||||
#include "MainWindow.h"
|
|
||||||
#include "validators/ScreenNameValidator.h"
|
|
||||||
|
|
||||||
SetupWizard::SetupWizard(MainWindow &mainWindow) : m_MainWindow(mainWindow) {
|
#include "MainWindow.h"
|
||||||
|
#include "gui/constants.h"
|
||||||
|
#include "validators/ScreenNameValidator.h"
|
||||||
|
#include "validators/ValidationError.h"
|
||||||
|
|
||||||
|
SetupWizard::SetupWizard(MainWindow &mainWindow) : m_mainWindow(mainWindow) {
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
m_pLineEditName->setText(m_MainWindow.appConfig().screenName());
|
m_pLabelError->setStyleSheet(kStyleErrorActiveLabel);
|
||||||
m_pLineEditName->setValidator(
|
|
||||||
new validators::ScreenNameValidator(m_pLineEditName, label_ErrorMessage));
|
|
||||||
|
|
||||||
connect(m_pButtonApply, SIGNAL(clicked()), this, SLOT(accept()));
|
m_pLineEditName->setText(m_mainWindow.appConfig().screenName());
|
||||||
|
m_pLineEditName->setValidator(new validators::ScreenNameValidator(
|
||||||
|
m_pLineEditName, new validators::ValidationError(this, m_pLabelError)));
|
||||||
|
|
||||||
|
connect(m_pButtonApply, &QPushButton::clicked, this, &SetupWizard::accept);
|
||||||
connect(
|
connect(
|
||||||
m_pLineEditName, SIGNAL(textEdited(QString)), this,
|
m_pLineEditName, &QLineEdit::textChanged, this,
|
||||||
SLOT(onNameChanged()));
|
&SetupWizard::onLineEditNameChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizard::accept() {
|
void SetupWizard::accept() {
|
||||||
AppConfig &appConfig = m_MainWindow.appConfig();
|
AppConfig &appConfig = m_mainWindow.appConfig();
|
||||||
|
|
||||||
appConfig.setWizardHasRun();
|
appConfig.setWizardHasRun();
|
||||||
appConfig.setScreenName(m_pLineEditName->text());
|
appConfig.setScreenName(m_pLineEditName->text());
|
||||||
appConfig.saveSettings();
|
appConfig.saveSettings();
|
||||||
|
|
||||||
m_MainWindow.open();
|
m_mainWindow.open();
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizard::onNameChanged() {
|
void SetupWizard::onLineEditNameChanged(const QString &error) {
|
||||||
m_pButtonApply->setEnabled(label_ErrorMessage->text().isEmpty());
|
m_pButtonApply->setEnabled(m_pLineEditName->hasAcceptableInput());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizard::reject() {
|
void SetupWizard::reject() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2016 Symless Ltd.
|
* Copyright (C) 2012 Symless Ltd.
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -16,9 +16,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_SetupWizardBase.h"
|
#include "ui_SetupWizardBase.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <memory>
|
#include <QObject>
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
|
||||||
|
|
@ -33,8 +35,8 @@ protected:
|
||||||
void reject();
|
void reject();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow &m_MainWindow;
|
MainWindow &m_mainWindow;
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
void onNameChanged();
|
void onLineEditNameChanged(const QString &error);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>720</width>
|
<width>772</width>
|
||||||
<height>552</height>
|
<height>634</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -16,18 +16,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>720</width>
|
|
||||||
<height>552</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>720</width>
|
|
||||||
<height>552</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
<property name="baseSize">
|
||||||
<size>
|
<size>
|
||||||
<width>720</width>
|
<width>720</width>
|
||||||
|
|
@ -43,173 +31,151 @@
|
||||||
<property name="windowOpacity">
|
<property name="windowOpacity">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="label_Image">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="geometry">
|
<property name="spacing">
|
||||||
<rect>
|
<number>20</number>
|
||||||
<x>270</x>
|
|
||||||
<y>70</y>
|
|
||||||
<width>181</width>
|
|
||||||
<height>161</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="leftMargin">
|
||||||
<string/>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<property name="rightMargin">
|
||||||
<pixmap resource="../res/Synergy.qrc">:/res/image/welcome.png</pixmap>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<item>
|
||||||
<widget class="QLabel" name="label_Title">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="geometry">
|
<property name="orientation">
|
||||||
<rect>
|
<enum>Qt::Vertical</enum>
|
||||||
<x>270</x>
|
</property>
|
||||||
<y>253</y>
|
<property name="sizeHint" stdset="0">
|
||||||
<width>261</width>
|
<size>
|
||||||
<height>21</height>
|
<width>20</width>
|
||||||
</rect>
|
<height>40</height>
|
||||||
</property>
|
</size>
|
||||||
<property name="font">
|
</property>
|
||||||
<font>
|
</spacer>
|
||||||
<family>Arial</family>
|
</item>
|
||||||
<weight>75</weight>
|
<item alignment="Qt::AlignHCenter">
|
||||||
<bold>true</bold>
|
<widget class="QLabel" name="m_pLabelImage">
|
||||||
</font>
|
<property name="text">
|
||||||
</property>
|
<string/>
|
||||||
<property name="text">
|
</property>
|
||||||
<string notr="true"><html><head/><body><p style="font-size:18px">Name your computer</p></body></html></string>
|
<property name="pixmap">
|
||||||
</property>
|
<pixmap resource="../res/Synergy.qrc">:/res/image/welcome.png</pixmap>
|
||||||
<property name="textFormat">
|
</property>
|
||||||
<enum>Qt::RichText</enum>
|
<property name="margin">
|
||||||
</property>
|
<number>30</number>
|
||||||
</widget>
|
</property>
|
||||||
<widget class="QLabel" name="label_Name">
|
</widget>
|
||||||
<property name="geometry">
|
</item>
|
||||||
<rect>
|
<item alignment="Qt::AlignHCenter">
|
||||||
<x>184</x>
|
<widget class="QLabel" name="m_pLabelTitle">
|
||||||
<y>294</y>
|
<property name="font">
|
||||||
<width>111</width>
|
<font>
|
||||||
<height>16</height>
|
<family>Cantarell</family>
|
||||||
</rect>
|
<pointsize>18</pointsize>
|
||||||
</property>
|
<bold>true</bold>
|
||||||
<property name="font">
|
</font>
|
||||||
<font>
|
</property>
|
||||||
<family>Arial</family>
|
<property name="text">
|
||||||
<weight>75</weight>
|
<string>Name your computer</string>
|
||||||
<bold>true</bold>
|
</property>
|
||||||
</font>
|
<property name="textFormat">
|
||||||
</property>
|
<enum>Qt::PlainText</enum>
|
||||||
<property name="text">
|
</property>
|
||||||
<string><html><head/><body><p style="font-size:13px;">Computer name</p></body></html></string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="textFormat">
|
<item>
|
||||||
<enum>Qt::RichText</enum>
|
<layout class="QFormLayout" name="formLayout">
|
||||||
</property>
|
<item row="0" column="0">
|
||||||
</widget>
|
<widget class="QLabel" name="m_pLabelName">
|
||||||
<widget class="QLineEdit" name="m_pLineEditName">
|
<property name="text">
|
||||||
<property name="geometry">
|
<string>Computer name</string>
|
||||||
<rect>
|
</property>
|
||||||
<x>300</x>
|
<property name="textFormat">
|
||||||
<y>293</y>
|
<enum>Qt::PlainText</enum>
|
||||||
<width>230</width>
|
</property>
|
||||||
<height>20</height>
|
<property name="margin">
|
||||||
</rect>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
</widget>
|
||||||
<size>
|
</item>
|
||||||
<width>230</width>
|
<item row="0" column="1">
|
||||||
<height>20</height>
|
<widget class="QLineEdit" name="m_pLineEditName">
|
||||||
</size>
|
<property name="minimumSize">
|
||||||
</property>
|
<size>
|
||||||
<property name="maxLength">
|
<width>230</width>
|
||||||
<number>255</number>
|
<height>20</height>
|
||||||
</property>
|
</size>
|
||||||
</widget>
|
</property>
|
||||||
<widget class="QLabel" name="label_HelpTitle">
|
<property name="maxLength">
|
||||||
<property name="geometry">
|
<number>255</number>
|
||||||
<rect>
|
</property>
|
||||||
<x>132</x>
|
</widget>
|
||||||
<y>354</y>
|
</item>
|
||||||
<width>481</width>
|
<item row="1" column="1">
|
||||||
<height>16</height>
|
<widget class="QLabel" name="m_pLabelError">
|
||||||
</rect>
|
<property name="text">
|
||||||
</property>
|
<string>m_pLabelError</string>
|
||||||
<property name="font">
|
</property>
|
||||||
<font>
|
</widget>
|
||||||
<family>Arial</family>
|
</item>
|
||||||
<weight>75</weight>
|
</layout>
|
||||||
<bold>true</bold>
|
</item>
|
||||||
</font>
|
<item alignment="Qt::AlignHCenter">
|
||||||
</property>
|
<widget class="QLabel" name="m_pHelpList">
|
||||||
<property name="text">
|
<property name="sizePolicy">
|
||||||
<string><html><head/><body><p style="font-size: 13px;">Call your computer something short and meaningful, but it must have: </p></body></html></string>
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
</property>
|
<horstretch>0</horstretch>
|
||||||
<property name="textFormat">
|
<verstretch>0</verstretch>
|
||||||
<enum>Qt::RichText</enum>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="text">
|
||||||
<widget class="QLabel" name="label_HelpInfo">
|
<string>Call your computer something short and meaningful, but it must have:
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
- No spaces
|
||||||
<x>193</x>
|
- Only these special characters: _ - .
|
||||||
<y>380</y>
|
- Only English characters and numbers
|
||||||
<width>311</width>
|
- A different name from other computers
|
||||||
<height>91</height>
|
</string>
|
||||||
</rect>
|
</property>
|
||||||
</property>
|
<property name="textFormat">
|
||||||
<property name="font">
|
<enum>Qt::MarkdownText</enum>
|
||||||
<font>
|
</property>
|
||||||
<family>Arial</family>
|
</widget>
|
||||||
<pointsize>20</pointsize>
|
</item>
|
||||||
<weight>75</weight>
|
<item>
|
||||||
<bold>true</bold>
|
<spacer name="verticalSpacer">
|
||||||
</font>
|
<property name="orientation">
|
||||||
</property>
|
<enum>Qt::Vertical</enum>
|
||||||
<property name="text">
|
</property>
|
||||||
<string><html><head/><body><ul style="list-style-type:none; font-size: 13px;"><li style="line-height:140%">- A different name from other computers </li><li style="line-height:140%">- Only these special characters _ - .</li><li style="line-height:140%">- No spaces </li><li style="line-height:140%">- Only english characters and numbers</li></body></html></string>
|
<property name="sizeHint" stdset="0">
|
||||||
</property>
|
<size>
|
||||||
<property name="textFormat">
|
<width>20</width>
|
||||||
<enum>Qt::RichText</enum>
|
<height>40</height>
|
||||||
</property>
|
</size>
|
||||||
</widget>
|
</property>
|
||||||
<widget class="QPushButton" name="m_pButtonApply">
|
</spacer>
|
||||||
<property name="geometry">
|
</item>
|
||||||
<rect>
|
<item alignment="Qt::AlignHCenter">
|
||||||
<x>650</x>
|
<widget class="QPushButton" name="m_pButtonApply">
|
||||||
<y>510</y>
|
<property name="sizePolicy">
|
||||||
<width>56</width>
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<height>25</height>
|
<horstretch>0</horstretch>
|
||||||
</rect>
|
<verstretch>0</verstretch>
|
||||||
</property>
|
</sizepolicy>
|
||||||
<property name="font">
|
</property>
|
||||||
<font>
|
<property name="minimumSize">
|
||||||
<family>Arial</family>
|
<size>
|
||||||
<weight>50</weight>
|
<width>150</width>
|
||||||
<bold>false</bold>
|
<height>40</height>
|
||||||
</font>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Apply</string>
|
<string>Continue</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_ErrorMessage">
|
</item>
|
||||||
<property name="geometry">
|
</layout>
|
||||||
<rect>
|
|
||||||
<x>300</x>
|
|
||||||
<y>320</y>
|
|
||||||
<width>391</width>
|
|
||||||
<height>16</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #EC4C47;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: Arial;
|
|
||||||
font-weight: bold;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../res/Synergy.qrc"/>
|
<include location="../res/Synergy.qrc"/>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2016 Symless Ltd.
|
* Copyright (C) 2016 Symless Ltd.
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -15,18 +15,19 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "SetupWizardBlocker.h"
|
||||||
|
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "MainWindow.h"
|
|
||||||
#include "SetupWizardBlocker.h"
|
|
||||||
|
|
||||||
static const std::vector<const char *> blockerTitels = {
|
static const std::vector<const char *> blockerTitels = {
|
||||||
"No Wayland support",
|
"Wayland is not yet supported",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::vector<const char *> blockerText = {
|
static const std::vector<const char *> blockerText = {
|
||||||
"We have detected your system is using Wayland. It is not currently \n"
|
"We have detected your system is using Wayland which is not currently \n"
|
||||||
"supported, but we are working on it. It's top of our priority list. \n"
|
"supported, but we are working on it. It's top of our priority list. \n"
|
||||||
"\n"
|
"\n"
|
||||||
"Please switch to Xorg if you wish to continue using Synergy today.",
|
"Please switch to Xorg if you wish to continue using Synergy today.",
|
||||||
|
|
@ -37,9 +38,8 @@ SetupWizardBlocker::SetupWizardBlocker(
|
||||||
: m_MainWindow(mainWindow) {
|
: m_MainWindow(mainWindow) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
label_Title->setText(blockerTitels[static_cast<int>(type)]);
|
m_pLabelTitle->setText(blockerTitels[static_cast<int>(type)]);
|
||||||
|
m_pLabelInfo->setText(blockerText[static_cast<int>(type)]);
|
||||||
label_HelpInfo->setText(blockerText[static_cast<int>(type)]);
|
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
m_pButtonSupport, &QPushButton::released, this,
|
m_pButtonSupport, &QPushButton::released, this,
|
||||||
|
|
|
||||||
|
|
@ -6,39 +6,10 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>720</width>
|
<width>750</width>
|
||||||
<height>580</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>720</width>
|
|
||||||
<height>580</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>720</width>
|
|
||||||
<height>580</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
|
||||||
<size>
|
|
||||||
<width>720</width>
|
|
||||||
<height>580</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Arial</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::NoContextMenu</enum>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -48,127 +19,108 @@
|
||||||
<property name="windowOpacity">
|
<property name="windowOpacity">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="label_Image">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="geometry">
|
<property name="spacing">
|
||||||
<rect>
|
<number>20</number>
|
||||||
<x>278</x>
|
|
||||||
<y>87</y>
|
|
||||||
<width>165</width>
|
|
||||||
<height>165</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="bottomMargin">
|
||||||
<string/>
|
<number>40</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<item>
|
||||||
<pixmap resource="../res/Synergy.qrc">:/res/image/setupBlocker.png</pixmap>
|
<spacer name="verticalSpacer">
|
||||||
</property>
|
<property name="orientation">
|
||||||
<property name="scaledContents">
|
<enum>Qt::Vertical</enum>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
<property name="sizeHint" stdset="0">
|
||||||
</widget>
|
<size>
|
||||||
<widget class="QLabel" name="label_Title">
|
<width>20</width>
|
||||||
<property name="geometry">
|
<height>40</height>
|
||||||
<rect>
|
</size>
|
||||||
<x>0</x>
|
</property>
|
||||||
<y>273</y>
|
</spacer>
|
||||||
<width>720</width>
|
</item>
|
||||||
<height>25</height>
|
<item alignment="Qt::AlignHCenter">
|
||||||
</rect>
|
<widget class="QLabel" name="m_pLabelImage">
|
||||||
</property>
|
<property name="sizePolicy">
|
||||||
<property name="font">
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
<font>
|
<horstretch>0</horstretch>
|
||||||
<family>Arial</family>
|
<verstretch>0</verstretch>
|
||||||
<pointsize>18</pointsize>
|
</sizepolicy>
|
||||||
<weight>50</weight>
|
</property>
|
||||||
<bold>false</bold>
|
<property name="text">
|
||||||
</font>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="pixmap">
|
||||||
<string notr="true">Test header</string>
|
<pixmap resource="../res/Synergy.qrc">:/res/image/setupBlocker.png</pixmap>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="scaledContents">
|
||||||
<enum>Qt::RichText</enum>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="margin">
|
||||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
<number>30</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
</widget>
|
||||||
<bool>true</bool>
|
</item>
|
||||||
</property>
|
<item alignment="Qt::AlignHCenter">
|
||||||
</widget>
|
<widget class="QLabel" name="m_pLabelTitle">
|
||||||
<widget class="QLabel" name="label_HelpInfo">
|
<property name="font">
|
||||||
<property name="geometry">
|
<font>
|
||||||
<rect>
|
<pointsize>18</pointsize>
|
||||||
<x>153</x>
|
<bold>true</bold>
|
||||||
<y>321</y>
|
</font>
|
||||||
<width>455</width>
|
</property>
|
||||||
<height>150</height>
|
<property name="text">
|
||||||
</rect>
|
<string notr="true">m_pLabelTitle</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
</widget>
|
||||||
<font>
|
</item>
|
||||||
<family>Arial</family>
|
<item alignment="Qt::AlignHCenter">
|
||||||
<pointsize>13</pointsize>
|
<widget class="QLabel" name="m_pLabelInfo">
|
||||||
<weight>50</weight>
|
<property name="text">
|
||||||
<bold>false</bold>
|
<string>m_pLabelInfo</string>
|
||||||
</font>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="text">
|
</item>
|
||||||
<string>large text test large text test large text test</string>
|
<item>
|
||||||
</property>
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="textFormat">
|
<property name="orientation">
|
||||||
<enum>Qt::RichText</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="sizeHint" stdset="0">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<size>
|
||||||
</property>
|
<width>20</width>
|
||||||
<property name="wordWrap">
|
<height>40</height>
|
||||||
<bool>true</bool>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</spacer>
|
||||||
<widget class="QPushButton" name="m_pButtonCancel">
|
</item>
|
||||||
<property name="geometry">
|
<item alignment="Qt::AlignHCenter">
|
||||||
<rect>
|
<widget class="QPushButton" name="m_pButtonSupport">
|
||||||
<x>642</x>
|
<property name="sizePolicy">
|
||||||
<y>540</y>
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<width>71</width>
|
<horstretch>0</horstretch>
|
||||||
<height>25</height>
|
<verstretch>0</verstretch>
|
||||||
</rect>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="text">
|
||||||
<font>
|
<string>Get technical support</string>
|
||||||
<family>Arial</family>
|
</property>
|
||||||
<pointsize>13</pointsize>
|
</widget>
|
||||||
<weight>50</weight>
|
</item>
|
||||||
<bold>false</bold>
|
<item alignment="Qt::AlignHCenter">
|
||||||
</font>
|
<widget class="QPushButton" name="m_pButtonCancel">
|
||||||
</property>
|
<property name="sizePolicy">
|
||||||
<property name="text">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<string>Cancel</string>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
</widget>
|
</sizepolicy>
|
||||||
<widget class="QPushButton" name="m_pButtonSupport">
|
</property>
|
||||||
<property name="geometry">
|
<property name="text">
|
||||||
<rect>
|
<string>Exit</string>
|
||||||
<x>500</x>
|
</property>
|
||||||
<y>540</y>
|
</widget>
|
||||||
<width>131</width>
|
</item>
|
||||||
<height>25</height>
|
</layout>
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Arial</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
<weight>50</weight>
|
|
||||||
<bold>false</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Online support</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../res/Synergy.qrc"/>
|
<include location="../res/Synergy.qrc"/>
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AppConfig.h"
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "QSynergyApplication.h"
|
#include "QSynergyApplication.h"
|
||||||
#include "SetupWizard.h"
|
#include "SetupWizard.h"
|
||||||
#include "SetupWizardBlocker.h"
|
#include "SetupWizardBlocker.h"
|
||||||
|
#include "gui/AppConfig.h"
|
||||||
#include "gui/dotenv.h"
|
#include "gui/dotenv.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2021 Symless Ltd.
|
* Copyright (C) 2021 Symless Ltd.
|
||||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -15,6 +14,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "validators/ComputerNameValidator.h"
|
#include "validators/ComputerNameValidator.h"
|
||||||
#include "validators/SpacesValidator.h"
|
#include "validators/SpacesValidator.h"
|
||||||
|
|
||||||
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
namespace validators {
|
namespace validators {
|
||||||
|
|
||||||
AliasValidator::AliasValidator(QLineEdit *parent, QLabel *errors)
|
AliasValidator::AliasValidator(QLineEdit *parent, ValidationError *error)
|
||||||
: LineEditValidator(parent, errors) {
|
: LineEditValidator(parent, error) {
|
||||||
addValidator(
|
addValidator(
|
||||||
std::make_unique<SpacesValidator>("Computer name cannot contain spaces"));
|
std::make_unique<SpacesValidator>("Computer name cannot contain spaces"));
|
||||||
addValidator(std::make_unique<ComputerNameValidator>(
|
addValidator(std::make_unique<ComputerNameValidator>(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2021 Symless Ltd.
|
* Copyright (C) 2021 Symless Ltd.
|
||||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -15,19 +14,18 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef ALIASVALIDATOR_H
|
|
||||||
#define ALIASVALIDATOR_H
|
#pragma once
|
||||||
|
|
||||||
#include "LineEditValidator.h"
|
#include "LineEditValidator.h"
|
||||||
|
#include "validators/ValidationError.h"
|
||||||
|
|
||||||
namespace validators {
|
namespace validators {
|
||||||
|
|
||||||
class AliasValidator : public LineEditValidator {
|
class AliasValidator : public LineEditValidator {
|
||||||
public:
|
public:
|
||||||
explicit AliasValidator(
|
explicit AliasValidator(
|
||||||
QLineEdit *parent = nullptr, QLabel *errors = nullptr);
|
QLineEdit *parent = nullptr, ValidationError *error = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace validators
|
} // namespace validators
|
||||||
|
|
||||||
#endif // ALIASVALIDATOR_H
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2021 Symless Ltd.
|
* Copyright (C) 2021 Symless Ltd.
|
||||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -15,15 +14,21 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LineEditValidator.h"
|
#include "LineEditValidator.h"
|
||||||
|
|
||||||
|
#include "gui/constants.h"
|
||||||
|
#include <qvalidator.h>
|
||||||
|
|
||||||
namespace validators {
|
namespace validators {
|
||||||
|
|
||||||
LineEditValidator::LineEditValidator(QLineEdit *parent, QLabel *errors)
|
LineEditValidator::LineEditValidator(
|
||||||
: m_pErrors(errors),
|
QLineEdit *lineEdit, ValidationError *error)
|
||||||
m_pControl(parent) {
|
: m_pError(error),
|
||||||
if (m_pErrors) {
|
m_pLineEdit(lineEdit) {
|
||||||
m_pErrors->hide();
|
|
||||||
|
if (!m_pLineEdit) {
|
||||||
|
qFatal("validator line edit not set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,40 +38,27 @@ void LineEditValidator::addValidator(
|
||||||
}
|
}
|
||||||
|
|
||||||
QValidator::State LineEditValidator::validate(QString &input, int &pos) const {
|
QValidator::State LineEditValidator::validate(QString &input, int &pos) const {
|
||||||
if (!m_pControl) {
|
assert(m_pLineEdit);
|
||||||
qFatal("Validator control not set");
|
|
||||||
return Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString error;
|
QString errorMessage;
|
||||||
for (const auto &validator : m_Validators) {
|
for (const auto &validator : m_Validators) {
|
||||||
if (!validator->validate(input)) {
|
if (!validator->validate(input)) {
|
||||||
error = validator->getMessage();
|
errorMessage = validator->getMessage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.isEmpty()) {
|
if (errorMessage.isEmpty()) {
|
||||||
m_pControl->setStyleSheet("");
|
m_pLineEdit->setStyleSheet("");
|
||||||
} else {
|
} else {
|
||||||
showError(error);
|
m_pLineEdit->setStyleSheet(kStyleLineEditErrorBorder);
|
||||||
m_pControl->setStyleSheet("border: 1px solid #EC4C47");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finished(error);
|
if (m_pError) {
|
||||||
return Acceptable;
|
m_pError->setMessage(errorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
void LineEditValidator::showError(const QString &message) const {
|
|
||||||
if (m_pErrors) {
|
|
||||||
m_pErrors->setText(message);
|
|
||||||
|
|
||||||
if (m_pErrors->text().isEmpty()) {
|
|
||||||
m_pErrors->hide();
|
|
||||||
} else {
|
|
||||||
m_pErrors->show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return errorMessage.isEmpty() ? Acceptable : Intermediate;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace validators
|
} // namespace validators
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012 Symless Ltd.
|
* Copyright (C) 2021 Symless Ltd.
|
||||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -20,32 +19,29 @@
|
||||||
|
|
||||||
#include "IStringValidator.h"
|
#include "IStringValidator.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
#include <QtWidgets/QLabel>
|
|
||||||
#include <QtWidgets/QLineEdit>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "ValidationError.h"
|
||||||
|
|
||||||
namespace validators {
|
namespace validators {
|
||||||
|
|
||||||
class LineEditValidator : public QValidator {
|
class LineEditValidator : public QValidator {
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LineEditValidator(
|
explicit LineEditValidator(
|
||||||
QLineEdit *parent = nullptr, QLabel *errors = nullptr);
|
QLineEdit *lineEdit = nullptr, ValidationError *error = nullptr);
|
||||||
QValidator::State validate(QString &input, int &pos) const override;
|
QValidator::State validate(QString &input, int &pos) const override;
|
||||||
void addValidator(std::unique_ptr<IStringValidator> validator);
|
void addValidator(std::unique_ptr<IStringValidator> validator);
|
||||||
|
|
||||||
signals:
|
|
||||||
void finished(const QString &message) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *m_pErrors = nullptr;
|
ValidationError *m_pError = nullptr;
|
||||||
QLineEdit *m_pControl = nullptr;
|
QLineEdit *m_pLineEdit = nullptr;
|
||||||
std::vector<std::unique_ptr<IStringValidator>> m_Validators;
|
std::vector<std::unique_ptr<IStringValidator>> m_Validators;
|
||||||
|
|
||||||
void showError(const QString &message) const;
|
void setError(const QString &message) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace validators
|
} // namespace validators
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ScreenNameValidator.h"
|
#include "ScreenNameValidator.h"
|
||||||
|
|
||||||
#include "validators/ComputerNameValidator.h"
|
#include "validators/ComputerNameValidator.h"
|
||||||
#include "validators/EmptyStringValidator.h"
|
#include "validators/EmptyStringValidator.h"
|
||||||
#include "validators/ScreenDuplicationsValidator.h"
|
#include "validators/ScreenDuplicationsValidator.h"
|
||||||
#include "validators/SpacesValidator.h"
|
#include "validators/SpacesValidator.h"
|
||||||
|
#include "validators/ValidationError.h"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -28,8 +30,8 @@
|
||||||
namespace validators {
|
namespace validators {
|
||||||
|
|
||||||
ScreenNameValidator::ScreenNameValidator(
|
ScreenNameValidator::ScreenNameValidator(
|
||||||
QLineEdit *parent, QLabel *errors, const ScreenList *pScreens)
|
QLineEdit *lineEdit, ValidationError *error, const ScreenList *pScreens)
|
||||||
: LineEditValidator(parent, errors) {
|
: LineEditValidator(lineEdit, error) {
|
||||||
addValidator(
|
addValidator(
|
||||||
std::make_unique<EmptyStringValidator>("Computer name cannot be empty"));
|
std::make_unique<EmptyStringValidator>("Computer name cannot be empty"));
|
||||||
addValidator(
|
addValidator(
|
||||||
|
|
@ -37,8 +39,8 @@ ScreenNameValidator::ScreenNameValidator(
|
||||||
addValidator(std::make_unique<ComputerNameValidator>(
|
addValidator(std::make_unique<ComputerNameValidator>(
|
||||||
"Contains invalid characters or is too long"));
|
"Contains invalid characters or is too long"));
|
||||||
addValidator(std::make_unique<ScreenDuplicationsValidator>(
|
addValidator(std::make_unique<ScreenDuplicationsValidator>(
|
||||||
"A computer with this name already exists", parent ? parent->text() : "",
|
"A computer with this name already exists",
|
||||||
pScreens));
|
lineEdit ? lineEdit->text() : "", pScreens));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace validators
|
} // namespace validators
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2021 Symless Ltd.
|
* Copyright (C) 2021 Symless Ltd.
|
||||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
@ -15,21 +14,20 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef SCREENNAMEVALIDATOR_H
|
|
||||||
#define SCREENNAMEVALIDATOR_H
|
#pragma once
|
||||||
|
|
||||||
#include "LineEditValidator.h"
|
#include "LineEditValidator.h"
|
||||||
#include "ScreenList.h"
|
#include "ScreenList.h"
|
||||||
|
#include "validators/ValidationError.h"
|
||||||
|
|
||||||
namespace validators {
|
namespace validators {
|
||||||
|
|
||||||
class ScreenNameValidator : public LineEditValidator {
|
class ScreenNameValidator : public LineEditValidator {
|
||||||
public:
|
public:
|
||||||
explicit ScreenNameValidator(
|
explicit ScreenNameValidator(
|
||||||
QLineEdit *parent = nullptr, QLabel *errors = nullptr,
|
QLineEdit *lineEdit = nullptr, ValidationError *error = nullptr,
|
||||||
const ScreenList *pScreens = nullptr);
|
const ScreenList *pScreens = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace validators
|
} // namespace validators
|
||||||
|
|
||||||
#endif // SCREENNAMEVALIDATOR_H
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SPACESVALIDATOR_H
|
#ifndef SPACESVALIDATOR_H
|
||||||
#define SPACESVALIDATOR_H
|
#define SPACESVALIDATOR_H
|
||||||
|
|
||||||
|
|
|
||||||
55
src/gui/src/validators/ValidationError.cpp
Normal file
55
src/gui/src/validators/ValidationError.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2024 Symless Ltd.
|
||||||
|
*
|
||||||
|
* 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 "ValidationError.h"
|
||||||
|
|
||||||
|
#include "gui/constants.h"
|
||||||
|
|
||||||
|
namespace validators {
|
||||||
|
|
||||||
|
void clear(QLabel *label) {
|
||||||
|
if (label) {
|
||||||
|
label->setStyleSheet(kStyleErrorInactiveLabel);
|
||||||
|
label->setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationError::ValidationError(QObject *parent, QLabel *label)
|
||||||
|
: QObject(parent),
|
||||||
|
m_pLabel(label) {
|
||||||
|
|
||||||
|
if (m_pLabel) {
|
||||||
|
clear(m_pLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &ValidationError::message() const { return m_message; }
|
||||||
|
|
||||||
|
void ValidationError::setMessage(const QString &message) {
|
||||||
|
m_message = message;
|
||||||
|
|
||||||
|
if (m_pLabel) {
|
||||||
|
if (message.isEmpty()) {
|
||||||
|
clear(m_pLabel);
|
||||||
|
} else {
|
||||||
|
m_pLabel->setStyleSheet(kStyleErrorActiveLabel);
|
||||||
|
m_pLabel->setText(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace validators
|
||||||
36
src/gui/src/validators/ValidationError.h
Normal file
36
src/gui/src/validators/ValidationError.h
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2024 Symless Ltd.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QString>
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
|
namespace validators {
|
||||||
|
|
||||||
|
class ValidationError : QObject {
|
||||||
|
QString m_message;
|
||||||
|
QLabel *m_pLabel = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ValidationError(QObject *parent, QLabel *label = nullptr);
|
||||||
|
const QString &message() const;
|
||||||
|
void setMessage(const QString &message);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace validators
|
||||||
|
|
@ -128,7 +128,7 @@ private:
|
||||||
void throwNameError(int);
|
void throwNameError(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ArchMutex m_mutex{};
|
|
||||||
Deps &m_deps;
|
|
||||||
static Deps s_deps;
|
static Deps s_deps;
|
||||||
|
Deps &m_deps;
|
||||||
|
ArchMutex m_mutex{};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,18 @@
|
||||||
|
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
|
|
||||||
#include "Config.h"
|
#include "ConfigScopes.h"
|
||||||
#include "gui/constants.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QVariant>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
using synergy::gui::Config;
|
using ConfigScopes = synergy::gui::ConfigScopes;
|
||||||
|
using IConfigScopes = synergy::gui::IConfigScopes;
|
||||||
|
|
||||||
// this should be incremented each time the wizard is changed,
|
// this should be incremented each time the wizard is changed,
|
||||||
// which will force it to re-run for existing installations.
|
// which will force it to re-run for existing installations.
|
||||||
|
|
@ -64,7 +66,7 @@ const char *const AppConfig::m_SettingsName[] = {
|
||||||
"lastVersion",
|
"lastVersion",
|
||||||
"", // 15 = lastExpiringWarningTime, obsolete
|
"", // 15 = lastExpiringWarningTime, obsolete
|
||||||
"activationHasRun",
|
"activationHasRun",
|
||||||
"minimizeToTray",
|
"", // 17 = minimizeToTray, obsolete
|
||||||
"", // 18 = ActivateEmail, obsolete
|
"", // 18 = ActivateEmail, obsolete
|
||||||
"loadFromSystemScope",
|
"loadFromSystemScope",
|
||||||
"groupServerChecked", // kServerGroupChecked
|
"groupServerChecked", // kServerGroupChecked
|
||||||
|
|
@ -85,23 +87,33 @@ const char *const AppConfig::m_SettingsName[] = {
|
||||||
"", // 35 = clientHostMode, obsolete
|
"", // 35 = clientHostMode, obsolete
|
||||||
"", // 36 = serverClientMode, obsolete
|
"", // 36 = serverClientMode, obsolete
|
||||||
"serviceEnabled",
|
"serviceEnabled",
|
||||||
"closeToTray"};
|
"closeToTray",
|
||||||
|
"mainWindowSize",
|
||||||
|
"mainWindowPosition",
|
||||||
|
};
|
||||||
|
|
||||||
static const char *logLevelNames[] = {"INFO", "DEBUG", "DEBUG1", "DEBUG2"};
|
static const char *logLevelNames[] = {"INFO", "DEBUG", "DEBUG1", "DEBUG2"};
|
||||||
|
|
||||||
AppConfig::AppConfig() { m_Config.registerReceiever(this); }
|
AppConfig::Deps AppConfig::s_Deps;
|
||||||
|
|
||||||
|
AppConfig::AppConfig(Deps &deps) : m_Deps(deps), m_ScreenName(deps.hostname()) {
|
||||||
|
|
||||||
|
m_Deps.scopes().registerReceiver(this);
|
||||||
|
}
|
||||||
|
|
||||||
void AppConfig::loadAllScopes() {
|
void AppConfig::loadAllScopes() {
|
||||||
m_Config.loadAll();
|
m_Deps.scopes().loadAll();
|
||||||
|
|
||||||
// User settings exist and the load from system scope variable is true
|
// User settings exist and the load from system scope variable is true
|
||||||
if (m_Config.hasSetting(
|
if (m_Deps.scopes().hasSetting(
|
||||||
settingName(Setting::kLoadSystemSettings), Config::Scope::User)) {
|
settingName(Setting::kLoadSystemSettings),
|
||||||
|
ConfigScopes::Scope::User)) {
|
||||||
setLoadFromSystemScope(m_LoadFromSystemScope);
|
setLoadFromSystemScope(m_LoadFromSystemScope);
|
||||||
}
|
}
|
||||||
// If user setting don't exist but system ones do, load the system settings
|
// If user setting don't exist but system ones do, load the system settings
|
||||||
else if (m_Config.hasSetting(
|
else if (m_Deps.scopes().hasSetting(
|
||||||
settingName(Setting::kScreenName), Config::Scope::System)) {
|
settingName(Setting::kScreenName),
|
||||||
|
ConfigScopes::Scope::System)) {
|
||||||
setLoadFromSystemScope(true);
|
setLoadFromSystemScope(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -111,66 +123,63 @@ void AppConfig::loadSettings() {
|
||||||
|
|
||||||
qDebug("loading settings");
|
qDebug("loading settings");
|
||||||
|
|
||||||
m_ScreenName =
|
loadCommonSettings();
|
||||||
loadSetting(kScreenName, QHostInfo::localHostName()).toString();
|
loadScopeSettings();
|
||||||
if (m_ScreenName.isEmpty()) {
|
loadSerialKey();
|
||||||
m_ScreenName = QHostInfo::localHostName();
|
loadElevateMode();
|
||||||
}
|
|
||||||
|
|
||||||
m_Port = loadSetting(kPort, 24800).toInt();
|
emit loaded();
|
||||||
m_Interface = loadSetting(kInterface).toString();
|
}
|
||||||
m_LogLevel = loadSetting(kLogLevel, 0).toInt();
|
|
||||||
m_LogToFile = loadSetting(kLogToFile, false).toBool();
|
|
||||||
m_LogFilename =
|
|
||||||
loadSetting(kLogFilename, logDir() + "synergy.log").toString();
|
|
||||||
m_WizardLastRun = loadCommonSetting(kWizardLastRun, 0).toInt();
|
|
||||||
m_StartedBefore = loadSetting(kStartedBefore, false).toBool();
|
|
||||||
|
|
||||||
QVariant elevateMode = loadSetting(kElevateModeEnum);
|
void AppConfig::loadCommonSettings() {
|
||||||
if (!elevateMode.isValid()) {
|
using enum Setting;
|
||||||
elevateMode = loadSetting(
|
|
||||||
kElevateMode, QVariant(static_cast<int>(kDefaultElevateMode)));
|
|
||||||
}
|
|
||||||
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
|
||||||
|
|
||||||
m_AutoHide = loadSetting(kAutoHide, false).toBool();
|
m_WizardLastRun = loadCommonSetting(kWizardLastRun, m_WizardLastRun).toInt();
|
||||||
m_LastVersion = loadSetting(kLastVersion, "Unknown").toString();
|
|
||||||
m_ActivationHasRun = loadSetting(kActivationHasRun, false).toBool();
|
|
||||||
m_MinimizeToTray = loadSetting(kMinimizeToTray, false).toBool();
|
|
||||||
m_LoadFromSystemScope =
|
m_LoadFromSystemScope =
|
||||||
loadCommonSetting(kLoadSystemSettings, false).toBool();
|
loadCommonSetting(kLoadSystemSettings, m_LoadFromSystemScope).toBool();
|
||||||
m_ServerGroupChecked = loadSetting(kServerGroupChecked, false).toBool();
|
m_licenseNextCheck =
|
||||||
m_UseExternalConfig = loadSetting(kUseExternalConfig, false).toBool();
|
loadCommonSetting(kLicenseNextCheck, m_licenseNextCheck).toULongLong();
|
||||||
m_ConfigFile =
|
}
|
||||||
loadSetting(kConfigFile, QDir::homePath() + "/" + m_ConfigFilename)
|
|
||||||
.toString();
|
|
||||||
m_UseInternalConfig = loadSetting(kUseInternalConfig, false).toBool();
|
|
||||||
m_ClientGroupChecked = loadSetting(kClientGroupChecked, false).toBool();
|
|
||||||
m_ServerHostname = loadSetting(kServerHostname).toString();
|
|
||||||
m_PreventSleep = loadSetting(kPreventSleep, false).toBool();
|
|
||||||
m_LanguageSync = loadSetting(kLanguageSync, false).toBool();
|
|
||||||
m_InvertScrollDirection = loadSetting(kInvertScrollDirection, false).toBool();
|
|
||||||
m_licenseNextCheck = loadCommonSetting(kLicenseNextCheck, 0).toULongLong();
|
|
||||||
m_InvertConnection = loadSetting(kInvertConnection, false).toBool();
|
|
||||||
|
|
||||||
// only change the serial key if the settings being loaded contains a key
|
void AppConfig::loadScopeSettings() {
|
||||||
bool loadSerial = m_Config.hasSetting(
|
using enum Setting;
|
||||||
settingName(kLoadSystemSettings), Config::Scope::Current);
|
|
||||||
|
|
||||||
if (loadSerial) {
|
|
||||||
const auto &serialKey = loadSetting(kSerialKey, "").toString().trimmed();
|
|
||||||
if (!serialKey.isEmpty()) {
|
|
||||||
m_SerialKey = serialKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
m_ScreenName = loadSetting(kScreenName, m_ScreenName).toString();
|
||||||
|
m_Port = loadSetting(kPort, m_Port).toInt();
|
||||||
|
m_Interface = loadSetting(kInterface, m_Interface).toString();
|
||||||
|
m_LogLevel = loadSetting(kLogLevel, m_LogLevel).toInt();
|
||||||
|
m_LogToFile = loadSetting(kLogToFile, m_LogToFile).toBool();
|
||||||
|
m_LogFilename = loadSetting(kLogFilename, m_LogFilename).toString();
|
||||||
|
m_StartedBefore = loadSetting(kStartedBefore, m_StartedBefore).toBool();
|
||||||
|
m_AutoHide = loadSetting(kAutoHide, m_AutoHide).toBool();
|
||||||
|
m_LastVersion = loadSetting(kLastVersion, m_LastVersion).toString();
|
||||||
|
m_ActivationHasRun =
|
||||||
|
loadSetting(kActivationHasRun, m_ActivationHasRun).toBool();
|
||||||
|
m_ServerGroupChecked =
|
||||||
|
loadSetting(kServerGroupChecked, m_ServerGroupChecked).toBool();
|
||||||
|
m_UseExternalConfig =
|
||||||
|
loadSetting(kUseExternalConfig, m_UseExternalConfig).toBool();
|
||||||
|
m_ConfigFile = loadSetting(kConfigFile, m_ConfigFile).toString();
|
||||||
|
m_UseInternalConfig =
|
||||||
|
loadSetting(kUseInternalConfig, m_UseInternalConfig).toBool();
|
||||||
|
m_ClientGroupChecked =
|
||||||
|
loadSetting(kClientGroupChecked, m_ClientGroupChecked).toBool();
|
||||||
|
m_ServerHostname = loadSetting(kServerHostname, m_ServerHostname).toString();
|
||||||
|
m_PreventSleep = loadSetting(kPreventSleep, m_PreventSleep).toBool();
|
||||||
|
m_LanguageSync = loadSetting(kLanguageSync, m_LanguageSync).toBool();
|
||||||
|
m_InvertScrollDirection =
|
||||||
|
loadSetting(kInvertScrollDirection, m_InvertScrollDirection).toBool();
|
||||||
|
m_InvertConnection =
|
||||||
|
loadSetting(kInvertConnection, m_InvertConnection).toBool();
|
||||||
m_ServiceEnabled = loadSetting(kServiceEnabled, m_ServiceEnabled).toBool();
|
m_ServiceEnabled = loadSetting(kServiceEnabled, m_ServiceEnabled).toBool();
|
||||||
m_CloseToTray = loadSetting(kCloseToTray, m_CloseToTray).toBool();
|
m_CloseToTray = loadSetting(kCloseToTray, m_CloseToTray).toBool();
|
||||||
m_TlsEnabled = loadSetting(kTlsEnabled, m_TlsEnabled).toBool();
|
m_TlsEnabled = loadSetting(kTlsEnabled, m_TlsEnabled).toBool();
|
||||||
m_TlsCertPath = loadSetting(kTlsCertPath, defaultTlsCertPath()).toString();
|
m_TlsCertPath = loadSetting(kTlsCertPath, m_TlsCertPath).toString();
|
||||||
m_TlsKeyLength = loadSetting(kTlsKeyLength, m_TlsKeyLength).toString();
|
m_TlsKeyLength = loadSetting(kTlsKeyLength, m_TlsKeyLength).toString();
|
||||||
|
m_MainWindowPosition = loadOptional<QPoint>(
|
||||||
emit loaded();
|
kMainWindowPosition, [](QVariant v) { return v.toPoint(); });
|
||||||
|
m_MainWindowSize = loadOptional<QSize>(
|
||||||
|
kMainWindowSize, [](QVariant v) { return v.toSize(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::saveSettings() {
|
void AppConfig::saveSettings() {
|
||||||
|
|
@ -192,13 +201,13 @@ void AppConfig::saveSettings() {
|
||||||
setSetting(kLogToFile, m_LogToFile);
|
setSetting(kLogToFile, m_LogToFile);
|
||||||
setSetting(kLogFilename, m_LogFilename);
|
setSetting(kLogFilename, m_LogFilename);
|
||||||
setSetting(kStartedBefore, m_StartedBefore);
|
setSetting(kStartedBefore, m_StartedBefore);
|
||||||
setSetting(kElevateModeEnum, static_cast<int>(m_ElevateMode));
|
setSetting(kElevateMode, static_cast<int>(m_ElevateMode));
|
||||||
|
setSetting(kElevateModeLegacy, m_ElevateMode == ElevateAlways);
|
||||||
setSetting(kTlsEnabled, m_TlsEnabled);
|
setSetting(kTlsEnabled, m_TlsEnabled);
|
||||||
setSetting(kAutoHide, m_AutoHide);
|
setSetting(kAutoHide, m_AutoHide);
|
||||||
setSetting(kSerialKey, m_SerialKey);
|
setSetting(kSerialKey, m_SerialKey);
|
||||||
setSetting(kLastVersion, m_LastVersion);
|
setSetting(kLastVersion, m_LastVersion);
|
||||||
setSetting(kActivationHasRun, m_ActivationHasRun);
|
setSetting(kActivationHasRun, m_ActivationHasRun);
|
||||||
setSetting(kMinimizeToTray, m_MinimizeToTray);
|
|
||||||
setSetting(kUseExternalConfig, m_UseExternalConfig);
|
setSetting(kUseExternalConfig, m_UseExternalConfig);
|
||||||
setSetting(kConfigFile, m_ConfigFile);
|
setSetting(kConfigFile, m_ConfigFile);
|
||||||
setSetting(kUseInternalConfig, m_UseInternalConfig);
|
setSetting(kUseInternalConfig, m_UseInternalConfig);
|
||||||
|
|
@ -209,13 +218,13 @@ void AppConfig::saveSettings() {
|
||||||
setSetting(kInvertConnection, m_InvertConnection);
|
setSetting(kInvertConnection, m_InvertConnection);
|
||||||
setSetting(kServiceEnabled, m_ServiceEnabled);
|
setSetting(kServiceEnabled, m_ServiceEnabled);
|
||||||
setSetting(kCloseToTray, m_CloseToTray);
|
setSetting(kCloseToTray, m_CloseToTray);
|
||||||
|
setOptional(kMainWindowSize, m_MainWindowSize);
|
||||||
// See enum ElevateMode declaration to understand why this setting is bool
|
setOptional(kMainWindowPosition, m_MainWindowPosition);
|
||||||
setSetting(kElevateMode, m_ElevateMode == ElevateAlways);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setModified(false);
|
setModified(false);
|
||||||
saved();
|
|
||||||
|
emit saved();
|
||||||
|
|
||||||
if (m_TlsChanged) {
|
if (m_TlsChanged) {
|
||||||
m_TlsChanged = false;
|
m_TlsChanged = false;
|
||||||
|
|
@ -223,8 +232,49 @@ void AppConfig::saveSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppConfig::loadSerialKey() {
|
||||||
|
using enum Setting;
|
||||||
|
|
||||||
|
// only set the serial key if the current settings scope has they key.
|
||||||
|
bool shouldLoad = m_Deps.scopes().hasSetting(
|
||||||
|
settingName(kLoadSystemSettings), ConfigScopes::Scope::Current);
|
||||||
|
|
||||||
|
if (!shouldLoad) {
|
||||||
|
qDebug("no serial key in current scope, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &serialKey =
|
||||||
|
loadSetting(kSerialKey, m_SerialKey).toString().trimmed();
|
||||||
|
|
||||||
|
if (serialKey.isEmpty()) {
|
||||||
|
qDebug("serial key is empty, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_SerialKey = serialKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppConfig::loadElevateMode() {
|
||||||
|
using enum Setting;
|
||||||
|
|
||||||
|
if (!m_Deps.scopes().hasSetting(settingName(kElevateMode))) {
|
||||||
|
qDebug("elevate mode not set yet, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant elevateMode = loadSetting(kElevateMode);
|
||||||
|
if (!elevateMode.isValid()) {
|
||||||
|
qDebug("elevate mode not valid, loading legacy setting");
|
||||||
|
elevateMode = loadSetting(
|
||||||
|
kElevateModeLegacy, QVariant(static_cast<int>(kDefaultElevateMode)));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
||||||
|
}
|
||||||
|
|
||||||
QString AppConfig::defaultTlsCertPath() const {
|
QString AppConfig::defaultTlsCertPath() const {
|
||||||
QDir path(m_CoreInterface.getProfileDir());
|
QDir path(m_Deps.profileDir());
|
||||||
path = path.filePath("SSL");
|
path = path.filePath("SSL");
|
||||||
path = path.filePath("Synergy.pem");
|
path = path.filePath("Synergy.pem");
|
||||||
return path.absolutePath();
|
return path.absolutePath();
|
||||||
|
|
@ -236,16 +286,35 @@ QString AppConfig::settingName(Setting name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void AppConfig::setSetting(Setting name, T value) {
|
template <typename T> void AppConfig::setSetting(Setting name, T value) {
|
||||||
m_Config.setSetting(settingName(name), value);
|
m_Deps.scopes().setSetting(settingName(name), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void AppConfig::setCommonSetting(Setting name, T value) {
|
template <typename T> void AppConfig::setCommonSetting(Setting name, T value) {
|
||||||
m_Config.setSetting(settingName(name), value, Config::Scope::User);
|
m_Deps.scopes().setSetting(
|
||||||
m_Config.setSetting(settingName(name), value, Config::Scope::System);
|
settingName(name), value, ConfigScopes::Scope::User);
|
||||||
|
m_Deps.scopes().setSetting(
|
||||||
|
settingName(name), value, ConfigScopes::Scope::System);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant AppConfig::loadSetting(Setting name, const QVariant &defaultValue) {
|
QVariant AppConfig::loadSetting(Setting name, const QVariant &defaultValue) {
|
||||||
return m_Config.loadSetting(settingName(name), defaultValue);
|
return m_Deps.scopes().loadSetting(settingName(name), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::optional<T>
|
||||||
|
AppConfig::loadOptional(Setting name, std::function<T(QVariant)> toType) const {
|
||||||
|
if (m_Deps.scopes().hasSetting(settingName(name))) {
|
||||||
|
return toType(m_Deps.scopes().loadSetting(settingName(name)));
|
||||||
|
} else {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void AppConfig::setOptional(Setting name, const std::optional<T> &value) {
|
||||||
|
if (value.has_value()) {
|
||||||
|
m_Deps.scopes().setSetting(settingName(name), value.value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
|
|
@ -253,28 +322,30 @@ AppConfig::loadCommonSetting(Setting name, const QVariant &defaultValue) const {
|
||||||
QVariant result(defaultValue);
|
QVariant result(defaultValue);
|
||||||
QString setting(settingName(name));
|
QString setting(settingName(name));
|
||||||
|
|
||||||
if (m_Config.hasSetting(setting)) {
|
if (m_Deps.scopes().hasSetting(setting)) {
|
||||||
result = m_Config.loadSetting(setting, defaultValue);
|
result = m_Deps.scopes().loadSetting(setting, defaultValue);
|
||||||
} else if (m_Config.getScope() == Config::Scope::System) {
|
} else if (m_Deps.scopes().getScope() == ConfigScopes::Scope::System) {
|
||||||
if (m_Config.hasSetting(setting, Config::Scope::User)) {
|
if (m_Deps.scopes().hasSetting(setting, ConfigScopes::Scope::User)) {
|
||||||
result = m_Config.loadSetting(setting, defaultValue, Config::Scope::User);
|
result = m_Deps.scopes().loadSetting(
|
||||||
|
setting, defaultValue, ConfigScopes::Scope::User);
|
||||||
}
|
}
|
||||||
} else if (m_Config.hasSetting(setting, Config::Scope::System)) {
|
} else if (m_Deps.scopes().hasSetting(setting, ConfigScopes::Scope::System)) {
|
||||||
result = m_Config.loadSetting(setting, defaultValue, Config::Scope::System);
|
result = m_Deps.scopes().loadSetting(
|
||||||
|
setting, defaultValue, ConfigScopes::Scope::System);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::loadScope(Config::Scope scope) {
|
void AppConfig::loadScope(ConfigScopes::Scope scope) {
|
||||||
|
|
||||||
if (m_Config.getScope() != scope) {
|
if (m_Deps.scopes().getScope() != scope) {
|
||||||
setDefaultValues();
|
setDefaultValues();
|
||||||
m_Config.setScope(scope);
|
m_Deps.scopes().setScope(scope);
|
||||||
if (m_Config.hasSetting(
|
if (m_Deps.scopes().hasSetting(
|
||||||
settingName(Setting::kScreenName), m_Config.getScope())) {
|
settingName(Setting::kScreenName), m_Deps.scopes().getScope())) {
|
||||||
// If the user already has settings, then load them up now.
|
// If the user already has settings, then load them up now.
|
||||||
m_Config.loadAll();
|
m_Deps.scopes().loadAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -285,10 +356,10 @@ void AppConfig::setLoadFromSystemScope(bool value) {
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
qDebug("loading system settings scope");
|
qDebug("loading system settings scope");
|
||||||
loadScope(Config::Scope::System);
|
loadScope(ConfigScopes::Scope::System);
|
||||||
} else {
|
} else {
|
||||||
qDebug("loading user settings scope");
|
qDebug("loading user settings scope");
|
||||||
loadScope(Config::Scope::User);
|
loadScope(ConfigScopes::Scope::User);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -298,10 +369,10 @@ void AppConfig::setLoadFromSystemScope(bool value) {
|
||||||
m_LoadFromSystemScope = value;
|
m_LoadFromSystemScope = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppConfig::isWritable() const { return m_Config.isWritable(); }
|
bool AppConfig::isWritable() const { return m_Deps.scopes().isWritable(); }
|
||||||
|
|
||||||
bool AppConfig::isSystemScoped() const {
|
bool AppConfig::isSystemScoped() const {
|
||||||
return m_Config.getScope() == Config::Scope::System;
|
return m_Deps.scopes().getScope() == ConfigScopes::Scope::System;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
@ -329,12 +400,12 @@ void AppConfig::persistLogDir() const {
|
||||||
// Begin getters
|
// Begin getters
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
IConfigScopes &AppConfig::scopes() { return m_Deps.scopes(); }
|
||||||
|
|
||||||
bool AppConfig::activationHasRun() const { return m_ActivationHasRun; }
|
bool AppConfig::activationHasRun() const { return m_ActivationHasRun; }
|
||||||
|
|
||||||
QString AppConfig::serialKey() const { return m_SerialKey; }
|
QString AppConfig::serialKey() const { return m_SerialKey; }
|
||||||
|
|
||||||
Config &AppConfig::config() { return m_Config; }
|
|
||||||
|
|
||||||
const QString &AppConfig::screenName() const { return m_ScreenName; }
|
const QString &AppConfig::screenName() const { return m_ScreenName; }
|
||||||
|
|
||||||
int AppConfig::port() const { return m_Port; }
|
int AppConfig::port() const { return m_Port; }
|
||||||
|
|
@ -385,8 +456,6 @@ bool AppConfig::preventSleep() const { return m_PreventSleep; }
|
||||||
|
|
||||||
bool AppConfig::invertConnection() const { return m_InvertConnection; }
|
bool AppConfig::invertConnection() const { return m_InvertConnection; }
|
||||||
|
|
||||||
bool AppConfig::minimizeToTray() const { return m_MinimizeToTray; }
|
|
||||||
|
|
||||||
QString AppConfig::tlsCertPath() const { return m_TlsCertPath; }
|
QString AppConfig::tlsCertPath() const { return m_TlsCertPath; }
|
||||||
|
|
||||||
QString AppConfig::tlsKeyLength() const { return m_TlsKeyLength; }
|
QString AppConfig::tlsKeyLength() const { return m_TlsKeyLength; }
|
||||||
|
|
@ -409,6 +478,14 @@ QString AppConfig::serverHostname() const { return m_ServerHostname; }
|
||||||
|
|
||||||
void AppConfig::setActivationHasRun(bool value) { m_ActivationHasRun = value; }
|
void AppConfig::setActivationHasRun(bool value) { m_ActivationHasRun = value; }
|
||||||
|
|
||||||
|
std::optional<QSize> AppConfig::mainWindowSize() const {
|
||||||
|
return m_MainWindowSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<QPoint> AppConfig::mainWindowPosition() const {
|
||||||
|
return m_MainWindowPosition;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// End getters
|
// End getters
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -497,10 +574,6 @@ void AppConfig::setElevateMode(ElevateMode em) {
|
||||||
|
|
||||||
void AppConfig::setAutoHide(bool b) { setSettingModified(m_AutoHide, b); }
|
void AppConfig::setAutoHide(bool b) { setSettingModified(m_AutoHide, b); }
|
||||||
|
|
||||||
void AppConfig::setMinimizeToTray(bool newValue) {
|
|
||||||
setSettingModified(m_MinimizeToTray, newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppConfig::setLicenseNextCheck(unsigned long long time) {
|
void AppConfig::setLicenseNextCheck(unsigned long long time) {
|
||||||
setSettingModified(m_licenseNextCheck, time);
|
setSettingModified(m_licenseNextCheck, time);
|
||||||
}
|
}
|
||||||
|
|
@ -530,6 +603,14 @@ void AppConfig::setInvertConnection(bool value) {
|
||||||
emit invertConnectionChanged();
|
emit invertConnectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppConfig::setMainWindowSize(const QSize &size) {
|
||||||
|
m_MainWindowSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppConfig::setMainWindowPosition(const QPoint &position) {
|
||||||
|
m_MainWindowPosition = position;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// End setters
|
// End setters
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -19,25 +19,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CommonConfig.h"
|
#include "CommonConfig.h"
|
||||||
#include "Config.h"
|
#include "ConfigScopes.h"
|
||||||
#include "gui/CoreInterface.h"
|
#include "CoreInterface.h"
|
||||||
#include "gui/ElevateMode.h"
|
#include "ElevateMode.h"
|
||||||
#include "gui/IAppConfig.h"
|
#include "IAppConfig.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QHostInfo>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPoint>
|
||||||
|
#include <QSize>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
class QSettings;
|
|
||||||
class SettingsDialog;
|
|
||||||
class ServerConfig;
|
|
||||||
class LicenseHandler;
|
|
||||||
class ActivationDialog;
|
|
||||||
|
|
||||||
enum class ProcessMode { kService, kDesktop };
|
enum class ProcessMode { kService, kDesktop };
|
||||||
|
|
||||||
const ElevateMode kDefaultElevateMode = ElevateAsNeeded;
|
const ElevateMode kDefaultElevateMode = ElevateAsNeeded;
|
||||||
|
const QString kDefaultLogFile = "synergy.log";
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
const ProcessMode kDefaultProcessMode = ProcessMode::kService;
|
const ProcessMode kDefaultProcessMode = ProcessMode::kService;
|
||||||
|
|
@ -58,12 +57,6 @@ class AppConfig : public QObject,
|
||||||
public synergy::gui::IAppConfig {
|
public synergy::gui::IAppConfig {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class SettingsDialog;
|
|
||||||
friend class MainWindow;
|
|
||||||
friend class SetupWizard;
|
|
||||||
friend class ServerConfig;
|
|
||||||
friend class ActivationDialog;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Setting {
|
enum class Setting {
|
||||||
kScreenName = 0,
|
kScreenName = 0,
|
||||||
|
|
@ -74,8 +67,8 @@ private:
|
||||||
kLogFilename = 5,
|
kLogFilename = 5,
|
||||||
kWizardLastRun = 6,
|
kWizardLastRun = 6,
|
||||||
kStartedBefore = 7,
|
kStartedBefore = 7,
|
||||||
kElevateMode = 8,
|
kElevateModeLegacy = 8,
|
||||||
kElevateModeEnum = 9,
|
kElevateMode = 9,
|
||||||
// 10 = edition, obsolete (using serial key instead)
|
// 10 = edition, obsolete (using serial key instead)
|
||||||
kTlsEnabled = 11,
|
kTlsEnabled = 11,
|
||||||
kAutoHide = 12,
|
kAutoHide = 12,
|
||||||
|
|
@ -83,7 +76,7 @@ private:
|
||||||
kLastVersion = 14,
|
kLastVersion = 14,
|
||||||
// 15 = last expire time, obsolete
|
// 15 = last expire time, obsolete
|
||||||
kActivationHasRun = 16,
|
kActivationHasRun = 16,
|
||||||
kMinimizeToTray = 17,
|
// 17 = minimize to tray, obsolete
|
||||||
// 18 = activate email, obsolete
|
// 18 = activate email, obsolete
|
||||||
kLoadSystemSettings = 19,
|
kLoadSystemSettings = 19,
|
||||||
kServerGroupChecked = 20,
|
kServerGroupChecked = 20,
|
||||||
|
|
@ -105,21 +98,37 @@ private:
|
||||||
// 36 = server-client-mode, obsolete
|
// 36 = server-client-mode, obsolete
|
||||||
kServiceEnabled = 37,
|
kServiceEnabled = 37,
|
||||||
kCloseToTray = 38,
|
kCloseToTray = 38,
|
||||||
|
kMainWindowSize = 39,
|
||||||
|
kMainWindowPosition = 40,
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AppConfig();
|
struct Deps {
|
||||||
|
virtual ~Deps() = default;
|
||||||
|
virtual QString profileDir() const {
|
||||||
|
return m_coreInterface.getProfileDir();
|
||||||
|
}
|
||||||
|
virtual synergy::gui::IConfigScopes &scopes() { return m_Scopes; }
|
||||||
|
virtual QString hostname() const { return QHostInfo::localHostName(); }
|
||||||
|
|
||||||
/// @brief Underlying configuration reader/writer
|
private:
|
||||||
synergy::gui::Config &config();
|
[[no_unique_address]] CoreInterface m_coreInterface;
|
||||||
|
synergy::gui::ConfigScopes m_Scopes;
|
||||||
|
};
|
||||||
|
|
||||||
/// @brief Saves the setting to the current scope
|
explicit AppConfig() : AppConfig(s_Deps) {}
|
||||||
|
explicit AppConfig(Deps &deps);
|
||||||
|
|
||||||
|
synergy::gui::IConfigScopes &scopes();
|
||||||
void saveSettings() override;
|
void saveSettings() override;
|
||||||
|
void loadAllScopes();
|
||||||
|
void loadSettings() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getters
|
* Getters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void setActivationHasRun(bool value);
|
||||||
bool isWritable() const;
|
bool isWritable() const;
|
||||||
bool isSystemScoped() const;
|
bool isSystemScoped() const;
|
||||||
const QString &screenName() const;
|
const QString &screenName() const;
|
||||||
|
|
@ -151,19 +160,14 @@ public:
|
||||||
QString serverHostname() const;
|
QString serverHostname() const;
|
||||||
QString lastVersion() const;
|
QString lastVersion() const;
|
||||||
bool serviceEnabled() const;
|
bool serviceEnabled() const;
|
||||||
bool minimizeToTray() const;
|
|
||||||
bool closeToTray() const;
|
bool closeToTray() const;
|
||||||
QString serialKey() const;
|
QString serialKey() const;
|
||||||
bool activationHasRun() const;
|
bool activationHasRun() const;
|
||||||
bool tlsEnabled() const override;
|
bool tlsEnabled() const override;
|
||||||
QString tlsCertPath() const override;
|
QString tlsCertPath() const override;
|
||||||
QString tlsKeyLength() const override;
|
QString tlsKeyLength() const override;
|
||||||
|
std::optional<QSize> mainWindowSize() const;
|
||||||
private:
|
std::optional<QPoint> mainWindowPosition() const;
|
||||||
/// @brief Loads the setting from the current scope
|
|
||||||
void loadSettings() override;
|
|
||||||
|
|
||||||
static QString settingName(AppConfig::Setting name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setters
|
* Setters
|
||||||
|
|
@ -192,14 +196,14 @@ private:
|
||||||
void setUseInternalConfig(bool);
|
void setUseInternalConfig(bool);
|
||||||
void setClientGroupChecked(bool);
|
void setClientGroupChecked(bool);
|
||||||
void setServerHostname(const QString &);
|
void setServerHostname(const QString &);
|
||||||
void setMinimizeToTray(bool b);
|
|
||||||
void setLastVersion(const QString &version);
|
void setLastVersion(const QString &version);
|
||||||
void setServiceEnabled(bool enabled);
|
void setServiceEnabled(bool enabled);
|
||||||
void setCloseToTray(bool minimize);
|
void setCloseToTray(bool minimize);
|
||||||
void setActivationHasRun(bool value);
|
|
||||||
void setTlsCertPath(const QString &path);
|
void setTlsCertPath(const QString &path);
|
||||||
void setTlsKeyLength(const QString &length);
|
void setTlsKeyLength(const QString &length);
|
||||||
void setInvertConnection(bool value);
|
void setInvertConnection(bool value);
|
||||||
|
void setMainWindowSize(const QSize &size);
|
||||||
|
void setMainWindowPosition(const QPoint &position);
|
||||||
|
|
||||||
/// @brief Sets the user preference to load from SystemScope.
|
/// @brief Sets the user preference to load from SystemScope.
|
||||||
/// @param [in] value
|
/// @param [in] value
|
||||||
|
|
@ -208,8 +212,27 @@ private:
|
||||||
/// scope settings.
|
/// scope settings.
|
||||||
void setLoadFromSystemScope(bool value);
|
void setLoadFromSystemScope(bool value);
|
||||||
|
|
||||||
/// @brief Loads config from the underlying reader/writer
|
private:
|
||||||
void loadAllScopes();
|
static QString settingName(AppConfig::Setting name);
|
||||||
|
void loadSerialKey();
|
||||||
|
void loadElevateMode();
|
||||||
|
void loadCommonSettings();
|
||||||
|
void loadScopeSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Loads a setting if it exists, otherwise returns `std::nullopt`
|
||||||
|
*
|
||||||
|
* @param toType A function to convert the QVariant to the desired type.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
std::optional<T>
|
||||||
|
loadOptional(Setting name, std::function<T(QVariant)> toType) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets a setting if the value is not `std::nullopt`.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
void setOptional(Setting name, const std::optional<T> &value);
|
||||||
|
|
||||||
/// @brief Sets the value of a setting
|
/// @brief Sets the value of a setting
|
||||||
/// @param [in] name The Setting to be saved
|
/// @param [in] name The Setting to be saved
|
||||||
|
|
@ -243,7 +266,7 @@ private:
|
||||||
|
|
||||||
/// @brief This method loads config from specified scope
|
/// @brief This method loads config from specified scope
|
||||||
/// @param [in] scope which should be loaded.
|
/// @param [in] scope which should be loaded.
|
||||||
void loadScope(synergy::gui::Config::Scope scope);
|
void loadScope(synergy::gui::ConfigScopes::Scope scope);
|
||||||
|
|
||||||
/// @brief This function sets default values
|
/// @brief This function sets default values
|
||||||
/// for settings that shouldn't be copied from between scopes.
|
/// for settings that shouldn't be copied from between scopes.
|
||||||
|
|
@ -254,14 +277,14 @@ private:
|
||||||
*/
|
*/
|
||||||
QString defaultTlsCertPath() const;
|
QString defaultTlsCertPath() const;
|
||||||
|
|
||||||
synergy::gui::Config m_Config;
|
static Deps s_Deps;
|
||||||
CoreInterface m_CoreInterface;
|
Deps &m_Deps;
|
||||||
QString m_ScreenName = "";
|
QString m_ScreenName;
|
||||||
int m_Port = 24800;
|
int m_Port = 24800;
|
||||||
QString m_Interface = "";
|
QString m_Interface = "";
|
||||||
int m_LogLevel = 0;
|
int m_LogLevel = 0;
|
||||||
bool m_LogToFile = false;
|
bool m_LogToFile = false;
|
||||||
QString m_LogFilename = "";
|
QString m_LogFilename = logDir() + kDefaultLogFile;
|
||||||
int m_WizardLastRun = 0;
|
int m_WizardLastRun = 0;
|
||||||
bool m_StartedBefore = false;
|
bool m_StartedBefore = false;
|
||||||
ElevateMode m_ElevateMode = kDefaultElevateMode;
|
ElevateMode m_ElevateMode = kDefaultElevateMode;
|
||||||
|
|
@ -272,21 +295,22 @@ private:
|
||||||
QString m_LastVersion = "";
|
QString m_LastVersion = "";
|
||||||
unsigned long long m_licenseNextCheck = 0;
|
unsigned long long m_licenseNextCheck = 0;
|
||||||
bool m_ActivationHasRun = false;
|
bool m_ActivationHasRun = false;
|
||||||
bool m_MinimizeToTray = true;
|
|
||||||
bool m_InvertScrollDirection = false;
|
bool m_InvertScrollDirection = false;
|
||||||
bool m_LanguageSync = true;
|
bool m_LanguageSync = true;
|
||||||
bool m_PreventSleep = false;
|
bool m_PreventSleep = false;
|
||||||
bool m_InvertConnection = false;
|
bool m_InvertConnection = false;
|
||||||
bool m_ServerGroupChecked = false;
|
bool m_ServerGroupChecked = false;
|
||||||
bool m_UseExternalConfig = false;
|
bool m_UseExternalConfig = false;
|
||||||
QString m_ConfigFile = "";
|
QString m_ConfigFile = QDir::homePath() + "/" + m_ConfigFilename;
|
||||||
bool m_UseInternalConfig = false;
|
bool m_UseInternalConfig = false;
|
||||||
bool m_ClientGroupChecked = false;
|
bool m_ClientGroupChecked = false;
|
||||||
QString m_ServerHostname = "";
|
QString m_ServerHostname = "";
|
||||||
bool m_ServiceEnabled = kDefaultProcessMode == ProcessMode::kService;
|
bool m_ServiceEnabled = kDefaultProcessMode == ProcessMode::kService;
|
||||||
bool m_CloseToTray = false;
|
bool m_CloseToTray = false;
|
||||||
QString m_TlsCertPath = "";
|
QString m_TlsCertPath = defaultTlsCertPath();
|
||||||
QString m_TlsKeyLength = "2048";
|
QString m_TlsKeyLength = "2048";
|
||||||
|
std::optional<QSize> m_MainWindowSize;
|
||||||
|
std::optional<QPoint> m_MainWindowPosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Flag is set when any TLS is setting is changed, and is reset
|
* @brief Flag is set when any TLS is setting is changed, and is reset
|
||||||
|
|
@ -47,9 +47,9 @@ QString CommandProcess::run() {
|
||||||
|
|
||||||
if (int code = process.exitCode(); !success || code != 0) {
|
if (int code = process.exitCode(); !success || code != 0) {
|
||||||
qFatal(
|
qFatal(
|
||||||
"Command failed: %s %s\nCode: %d\nError: %s", qUtf8Printable(m_Command),
|
"command failed: %s %s\ncode: %d\nerror: %s", qUtf8Printable(m_Command),
|
||||||
qUtf8Printable(m_Arguments.join(" ")), code,
|
qUtf8Printable(m_Arguments.join(" ")), code,
|
||||||
error.isEmpty() ? "None" : qUtf8Printable(error));
|
error.isEmpty() ? "none" : qUtf8Printable(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit finished();
|
emit finished();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "ConfigScopes.h"
|
||||||
|
|
||||||
#include "CommonConfig.h"
|
#include "CommonConfig.h"
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ void loadWindowsLegacy(QSettings &settings) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Config::Config() {
|
ConfigScopes::ConfigScopes() {
|
||||||
QSettings::setPath(
|
QSettings::setPath(
|
||||||
QSettings::Format::IniFormat, QSettings::Scope::SystemScope,
|
QSettings::Format::IniFormat, QSettings::Scope::SystemScope,
|
||||||
getSystemSettingPath());
|
getSystemSettingPath());
|
||||||
|
|
@ -88,20 +88,20 @@ Config::Config() {
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::~Config() {
|
ConfigScopes::~ConfigScopes() {
|
||||||
while (!m_pReceievers.empty()) {
|
while (!m_pReceivers.empty()) {
|
||||||
m_pReceievers.pop_back();
|
m_pReceivers.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::load() {
|
void ConfigScopes::load() {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// This call is needed for backwardcapability with old settings.
|
// This call is needed for backwardcapability with old settings.
|
||||||
loadWindowsLegacy(*m_pSystemSettings);
|
loadWindowsLegacy(*m_pSystemSettings);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::hasSetting(const QString &name, Scope scope) const {
|
bool ConfigScopes::hasSetting(const QString &name, Scope scope) const {
|
||||||
switch (scope) {
|
switch (scope) {
|
||||||
case Scope::User:
|
case Scope::User:
|
||||||
return m_pUserSettings->contains(name);
|
return m_pUserSettings->contains(name);
|
||||||
|
|
@ -112,9 +112,11 @@ bool Config::hasSetting(const QString &name, Scope scope) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::isWritable() const { return currentSettings()->isWritable(); }
|
bool ConfigScopes::isWritable() const {
|
||||||
|
return currentSettings()->isWritable();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant Config::loadSetting(
|
QVariant ConfigScopes::loadSetting(
|
||||||
const QString &name, const QVariant &defaultValue, Scope scope) const {
|
const QString &name, const QVariant &defaultValue, Scope scope) const {
|
||||||
switch (scope) {
|
switch (scope) {
|
||||||
case Scope::User:
|
case Scope::User:
|
||||||
|
|
@ -126,21 +128,23 @@ QVariant Config::loadSetting(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setScope(Config::Scope scope) { m_CurrentScope = scope; }
|
void ConfigScopes::setScope(ConfigScopes::Scope scope) {
|
||||||
|
m_CurrentScope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
Config::Scope Config::getScope() const { return m_CurrentScope; }
|
ConfigScopes::Scope ConfigScopes::getScope() const { return m_CurrentScope; }
|
||||||
|
|
||||||
void Config::loadAll() {
|
void ConfigScopes::loadAll() {
|
||||||
for (auto &i : m_pReceievers) {
|
for (auto &i : m_pReceivers) {
|
||||||
i->loadSettings();
|
i->loadSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::saveAll() {
|
void ConfigScopes::saveAll() {
|
||||||
|
|
||||||
// Save if there are any unsaved changes otherwise skip
|
// Save if there are any unsaved changes otherwise skip
|
||||||
if (unsavedChanges()) {
|
if (unsavedChanges()) {
|
||||||
for (auto &i : m_pReceievers) {
|
for (auto &i : m_pReceivers) {
|
||||||
i->saveSettings();
|
i->saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,7 +155,7 @@ void Config::saveAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings *Config::currentSettings() const {
|
QSettings *ConfigScopes::currentSettings() const {
|
||||||
if (m_CurrentScope == Scope::User) {
|
if (m_CurrentScope == Scope::User) {
|
||||||
return m_pUserSettings.get();
|
return m_pUserSettings.get();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -159,16 +163,16 @@ QSettings *Config::currentSettings() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::registerReceiever(CommonConfig *receiver) {
|
void ConfigScopes::registerReceiver(CommonConfig *receiver) {
|
||||||
m_pReceievers.push_back(receiver);
|
m_pReceivers.push_back(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::unsavedChanges() const {
|
bool ConfigScopes::unsavedChanges() const {
|
||||||
if (m_unsavedChanges) {
|
if (m_unsavedChanges) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &i : m_pReceievers) {
|
for (const auto &i : m_pReceivers) {
|
||||||
if (i->modified()) {
|
if (i->modified()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -176,6 +180,12 @@ bool Config::unsavedChanges() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::markUnsaved() { m_unsavedChanges = true; }
|
void ConfigScopes::markUnsaved() { m_unsavedChanges = true; }
|
||||||
|
|
||||||
|
void ConfigScopes::setSetting(
|
||||||
|
const QString &name, const QVariant &value, Scope scope) {
|
||||||
|
currentSettings()->setValue(name, value);
|
||||||
|
m_unsavedChanges = true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace synergy::gui
|
} // namespace synergy::gui
|
||||||
|
|
@ -14,8 +14,11 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "IConfigScopes.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -25,31 +28,31 @@ namespace synergy::gui {
|
||||||
class CommonConfig;
|
class CommonConfig;
|
||||||
|
|
||||||
/// @brief A general config reader and writer for user and gloabl settings
|
/// @brief A general config reader and writer for user and gloabl settings
|
||||||
class Config : private QObject {
|
class ConfigScopes : public IConfigScopes {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Scope { Current, System, User };
|
explicit ConfigScopes();
|
||||||
|
virtual ~ConfigScopes();
|
||||||
explicit Config();
|
|
||||||
~Config() override;
|
|
||||||
|
|
||||||
/// @brief Checks if the setting exists
|
/// @brief Checks if the setting exists
|
||||||
/// @param [in] name The name of the setting to check
|
/// @param [in] name The name of the setting to check
|
||||||
/// @param [in] scope The scope to search in
|
/// @param [in] scope The scope to search in
|
||||||
/// @return bool True if the current scope has the named setting
|
/// @return bool True if the current scope has the named setting
|
||||||
bool hasSetting(const QString &name, Scope scope = Scope::Current) const;
|
bool
|
||||||
|
hasSetting(const QString &name, Scope scope = Scope::Current) const override;
|
||||||
|
|
||||||
/// @brief Checks if the current scope settings writable
|
/// @brief Checks if the current scope settings writable
|
||||||
/// @return bool True if the current scope writable
|
/// @return bool True if the current scope writable
|
||||||
bool isWritable() const;
|
bool isWritable() const override;
|
||||||
|
|
||||||
/// @brief Sets the value of a setting
|
/// @brief Sets the value of a setting
|
||||||
/// @param [in] name The Setting to be saved
|
/// @param [in] name The Setting to be saved
|
||||||
/// @param [in] value The Value to be saved (Templated)
|
/// @param [in] value The Value to be saved (Templated)
|
||||||
/// @param [in] scope The scope to get the value from, default is current
|
/// @param [in] scope The scope to get the value from, default is current
|
||||||
/// scope
|
/// scope
|
||||||
template <typename T>
|
void setSetting(
|
||||||
void setSetting(const QString &name, T value, Scope scope = Scope::Current);
|
const QString &name, const QVariant &value,
|
||||||
|
Scope scope = Scope::Current) override;
|
||||||
|
|
||||||
/// @brief Loads a setting
|
/// @brief Loads a setting
|
||||||
/// @param [in] name The setting to be loaded
|
/// @param [in] name The setting to be loaded
|
||||||
|
|
@ -58,35 +61,35 @@ public:
|
||||||
/// scope
|
/// scope
|
||||||
QVariant loadSetting(
|
QVariant loadSetting(
|
||||||
const QString &name, const QVariant &defaultValue = QVariant(),
|
const QString &name, const QVariant &defaultValue = QVariant(),
|
||||||
Scope scope = Scope::Current) const;
|
Scope scope = Scope::Current) const override;
|
||||||
|
|
||||||
/// @brief Changes the setting save and load location between System and User
|
/// @brief Changes the setting save and load location between System and User
|
||||||
/// scope
|
/// scope
|
||||||
/// @param [in] scope The scope to set
|
/// @param [in] scope The scope to set
|
||||||
void setScope(Scope scope = Scope::User);
|
void setScope(Scope scope = Scope::User) override;
|
||||||
|
|
||||||
/// @brief Get the current scope the settings are loading and save from.
|
/// @brief Get the current scope the settings are loading and save from.
|
||||||
/// @return Scope An enum defining the current scope
|
/// @return Scope An enum defining the current scope
|
||||||
Scope getScope() const;
|
Scope getScope() const override;
|
||||||
|
|
||||||
/// @brief trigger a config load across all registered classes
|
/// @brief trigger a config load across all registered classes
|
||||||
void loadAll();
|
void loadAll() override;
|
||||||
|
|
||||||
/// @brief trigger a config save across all registered classes
|
/// @brief trigger a config save across all registered classes
|
||||||
void saveAll();
|
void saveAll() override;
|
||||||
|
|
||||||
/// @brief Returns the current scopes settings object
|
/// @brief Returns the current scopes settings object
|
||||||
/// If more specialize control into the settings is needed this can
|
/// If more specialize control into the settings is needed this can
|
||||||
/// provide direct access to the settings file handler
|
/// provide direct access to the settings file handler
|
||||||
/// @return QSettings The Settings object as a reference
|
/// @return QSettings The Settings object as a reference
|
||||||
QSettings *currentSettings() const;
|
QSettings *currentSettings() const override;
|
||||||
|
|
||||||
/// @brief This marks the settings as unsaved if the settings() was used to
|
/// @brief This marks the settings as unsaved if the settings() was used to
|
||||||
/// directly affect the config file
|
/// directly affect the config file
|
||||||
void markUnsaved();
|
void markUnsaved();
|
||||||
|
|
||||||
/// @brief Register a class to receives requests to save and load settings
|
/// @brief Register a class to receives requests to save and load settings
|
||||||
void registerReceiever(CommonConfig *receiver);
|
void registerReceiver(CommonConfig *receiver) override;
|
||||||
|
|
||||||
/// @brief Checks if any registered class has any unsaved changes
|
/// @brief Checks if any registered class has any unsaved changes
|
||||||
/// @return bool True if any registered class has unsaved changes
|
/// @return bool True if any registered class has unsaved changes
|
||||||
|
|
@ -100,16 +103,10 @@ private:
|
||||||
std::unique_ptr<QSettings> m_pSystemSettings;
|
std::unique_ptr<QSettings> m_pSystemSettings;
|
||||||
|
|
||||||
/// @brief Receivers of load/save callbacks
|
/// @brief Receivers of load/save callbacks
|
||||||
std::list<CommonConfig *> m_pReceievers;
|
std::list<CommonConfig *> m_pReceivers;
|
||||||
|
|
||||||
/// @brief Is set to true when settings are changed
|
/// @brief Is set to true when settings are changed
|
||||||
bool m_unsavedChanges = false;
|
bool m_unsavedChanges = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void Config::setSetting(const QString &name, T value, Scope scope) {
|
|
||||||
currentSettings()->setValue(name, value);
|
|
||||||
m_unsavedChanges = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace synergy::gui
|
} // namespace synergy::gui
|
||||||
51
src/lib/gui/IConfigScopes.h
Normal file
51
src/lib/gui/IConfigScopes.h
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2024 Symless Ltd.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "gui/CommonConfig.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
namespace synergy::gui {
|
||||||
|
|
||||||
|
class IConfigScopes {
|
||||||
|
public:
|
||||||
|
enum class Scope { Current, System, User };
|
||||||
|
|
||||||
|
virtual ~IConfigScopes() = default;
|
||||||
|
|
||||||
|
virtual void registerReceiver(CommonConfig *receiver) = 0;
|
||||||
|
virtual void loadAll() = 0;
|
||||||
|
virtual bool
|
||||||
|
hasSetting(const QString &name, Scope scope = Scope::Current) const = 0;
|
||||||
|
virtual QVariant loadSetting(
|
||||||
|
const QString &name, const QVariant &defaultValue = QVariant(),
|
||||||
|
Scope scope = Scope::Current) const = 0;
|
||||||
|
virtual void setSetting(
|
||||||
|
const QString &name, const QVariant &value,
|
||||||
|
Scope scope = Scope::Current) = 0;
|
||||||
|
virtual Scope getScope() const = 0;
|
||||||
|
virtual void setScope(Scope scope = Scope::User) = 0;
|
||||||
|
virtual bool isWritable() const = 0;
|
||||||
|
virtual QSettings *currentSettings() const = 0;
|
||||||
|
virtual void saveAll() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace synergy::gui
|
||||||
|
|
@ -58,7 +58,7 @@ QString openSslWindowsDir() {
|
||||||
|
|
||||||
// if the path still isn't found, something is seriously wrong.
|
// if the path still isn't found, something is seriously wrong.
|
||||||
if (!openSslDir.exists()) {
|
if (!openSslDir.exists()) {
|
||||||
qFatal() << "OpenSSL dir not found: " << openSslDir;
|
qFatal() << "openssl dir not found: " << openSslDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QDir::cleanPath(openSslDir.absolutePath());
|
return QDir::cleanPath(openSslDir.absolutePath());
|
||||||
|
|
@ -77,7 +77,7 @@ QString openSslWindowsBinary() {
|
||||||
|
|
||||||
// if the path still isn't found, something is seriously wrong.
|
// if the path still isn't found, something is seriously wrong.
|
||||||
if (!QFile::exists(path)) {
|
if (!QFile::exists(path)) {
|
||||||
qFatal() << "OpenSSL binary not found: " << path;
|
qFatal() << "openssl binary not found: " << path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#include "IAppConfig.h"
|
#include "IAppConfig.h"
|
||||||
|
|
||||||
#include "license/License.h"
|
#include "license/License.h"
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
namespace synergy::gui {
|
namespace synergy::gui {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,23 +28,39 @@ const bool kLicensingEnabled = false;
|
||||||
const auto kColorWhite = "#ffffff";
|
const auto kColorWhite = "#ffffff";
|
||||||
const auto kColorPrimary = "#ff7c00";
|
const auto kColorPrimary = "#ff7c00";
|
||||||
const auto kColorSecondary = "#4285f4";
|
const auto kColorSecondary = "#4285f4";
|
||||||
|
const auto kColorTertiary = "#33b2cc";
|
||||||
|
const auto kColorError = "#ec4c47";
|
||||||
|
const auto kColorNotice = "#3b67d3";
|
||||||
|
|
||||||
const auto kLinkStyleWhite = QString("color: %1").arg(kColorWhite);
|
const auto kLinkBuy = R"(<a href="%1" style="color: %2">Buy now</a>)";
|
||||||
const auto kLinkStylePrimary = QString("color: %1").arg(kColorPrimary);
|
const auto kLinkRenew = R"(<a href="%1" style="color: %2">Renew now</a>)";
|
||||||
const auto kLinkStyleSecondary = QString("color: %1").arg(kColorSecondary);
|
const auto kLinkDownload = R"(<a href="%1" style="color: %2">Download now</a>)";
|
||||||
|
|
||||||
const auto kLinkBuy = R"(<a href="%1" style="%2">Buy now</a>)";
|
|
||||||
const auto kLinkRenew = R"(<a href="%1" style="%2">Renew now</a>)";
|
|
||||||
const auto kLinkDownload = R"(<a href="%1" style="%2">Download now</a>)";
|
|
||||||
|
|
||||||
const auto kUrlSourceQuery = "source=gui";
|
const auto kUrlSourceQuery = "source=gui";
|
||||||
const auto kUrlWebsite = "https://symless.com";
|
const auto kUrlWebsite = "https://symless.com";
|
||||||
const auto kUrlProduct = QString("%1/synergy").arg(kUrlWebsite);
|
const auto kUrlProduct = QString("%1/synergy").arg(kUrlWebsite);
|
||||||
const auto kUrlPurchase =
|
const auto kUrlPurchase =
|
||||||
QString("%1/purchase?%2").arg(kUrlProduct).arg(kUrlSourceQuery);
|
QString("%1/purchase?%2").arg(kUrlProduct, kUrlSourceQuery);
|
||||||
const auto kUrlContact =
|
const auto kUrlContact =
|
||||||
QString("%1/contact?%2").arg(kUrlProduct).arg(kUrlSourceQuery);
|
QString("%1/contact?%2").arg(kUrlProduct, kUrlSourceQuery);
|
||||||
const auto kUrlHelp =
|
const auto kUrlHelp = QString("%1/help?%2").arg(kUrlProduct, kUrlSourceQuery);
|
||||||
QString("%1/help?%2").arg(kUrlProduct).arg(kUrlSourceQuery);
|
|
||||||
const auto kUrlDownload =
|
const auto kUrlDownload =
|
||||||
QString("%1/download?%2").arg(kUrlProduct).arg(kUrlSourceQuery);
|
QString("%1/download?%2").arg(kUrlProduct, kUrlSourceQuery);
|
||||||
|
|
||||||
|
const auto kStyleLineEditErrorBorder =
|
||||||
|
QString("border: 1px solid %1; border-radius: 2px; padding: 2px;")
|
||||||
|
.arg(kColorError);
|
||||||
|
|
||||||
|
const auto kStyleErrorActiveLabel = //
|
||||||
|
QString("padding: 3px 5px; border-radius: 3px; "
|
||||||
|
"background-color: %1; color: %2")
|
||||||
|
.arg(kColorError, kColorWhite);
|
||||||
|
|
||||||
|
const auto kStyleErrorInactiveLabel = //
|
||||||
|
QString("padding: 3px 5px; border-radius: 3px;"
|
||||||
|
"background-color: none");
|
||||||
|
|
||||||
|
const auto kStyleNoticeLabel = //
|
||||||
|
QString("padding: 3px 5px; border-radius: 3px;"
|
||||||
|
"background-color: %1; color: %2")
|
||||||
|
.arg(kColorNotice, kColorWhite);
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,7 @@ QString licenseNotice(const License &license) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString trialLicenseNotice(const License &license) {
|
QString trialLicenseNotice(const License &license) {
|
||||||
const QString buyLink =
|
const QString buyLink = QString(kLinkBuy).arg(kUrlPurchase).arg(kColorWhite);
|
||||||
QString(kLinkBuy).arg(kUrlPurchase).arg(kLinkStyleWhite);
|
|
||||||
if (license.isExpired()) {
|
if (license.isExpired()) {
|
||||||
return QString("<p>Your trial has expired. %1</p>").arg(buyLink);
|
return QString("<p>Your trial has expired. %1</p>").arg(buyLink);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -57,7 +56,7 @@ QString trialLicenseNotice(const License &license) {
|
||||||
|
|
||||||
QString subscriptionLicenseNotice(const License &license) {
|
QString subscriptionLicenseNotice(const License &license) {
|
||||||
const QString renewLink =
|
const QString renewLink =
|
||||||
QString(kLinkRenew).arg(kUrlPurchase).arg(kLinkStyleWhite);
|
QString(kLinkRenew).arg(kUrlPurchase).arg(kColorWhite);
|
||||||
if (license.isExpired()) {
|
if (license.isExpired()) {
|
||||||
return QString("<p>Your license has expired. %1</p>").arg(renewLink);
|
return QString("<p>Your license has expired. %1</p>").arg(renewLink);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
55
src/test/integtests/gui/CoreInterfaceTests.cpp
Normal file
55
src/test/integtests/gui/CoreInterfaceTests.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2024 Symless Ltd.
|
||||||
|
*
|
||||||
|
* 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 "gui/CoreInterface.h"
|
||||||
|
#include "shared/gui/QtCoreTest.h"
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
class CoreInterfaceTests : public QtCoreTest {};
|
||||||
|
|
||||||
|
TEST_F(CoreInterfaceTests, getProfileDir_noMock_returnsNonEmpty) {
|
||||||
|
CoreInterface coreInterface;
|
||||||
|
|
||||||
|
QString profileDir = coreInterface.getProfileDir();
|
||||||
|
|
||||||
|
EXPECT_FALSE(profileDir.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CoreInterfaceTests, getInstalledDir_noMock_returnsNonEmpty) {
|
||||||
|
CoreInterface coreInterface;
|
||||||
|
|
||||||
|
QString installedDir = coreInterface.getInstalledDir();
|
||||||
|
|
||||||
|
EXPECT_FALSE(installedDir.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CoreInterfaceTests, getArch_noMock_returnsNonEmpty) {
|
||||||
|
CoreInterface coreInterface;
|
||||||
|
|
||||||
|
QString arch = coreInterface.getArch();
|
||||||
|
|
||||||
|
EXPECT_FALSE(arch.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CoreInterfaceTests, getSerialKeyFilePath_noMock_returnsNonEmpty) {
|
||||||
|
CoreInterface coreInterface;
|
||||||
|
|
||||||
|
QString serialKeyFilePath = coreInterface.getSerialKeyFilePath();
|
||||||
|
|
||||||
|
EXPECT_FALSE(serialKeyFilePath.isEmpty());
|
||||||
|
}
|
||||||
|
|
@ -17,26 +17,24 @@
|
||||||
|
|
||||||
#include "test/shared/TestEventQueue.h"
|
#include "test/shared/TestEventQueue.h"
|
||||||
|
|
||||||
#include "base/Log.h"
|
|
||||||
#include "base/SimpleEventQueueBuffer.h"
|
|
||||||
#include "base/TMethodEventJob.h"
|
#include "base/TMethodEventJob.h"
|
||||||
#include "common/stdexcept.h"
|
#include "common/stdexcept.h"
|
||||||
|
|
||||||
void TestEventQueue::raiseQuitEvent() { addEvent(Event(Event::kQuit)); }
|
void TestEventQueue::raiseQuitEvent() { addEvent(Event(Event::kQuit)); }
|
||||||
|
|
||||||
void TestEventQueue::initQuitTimeout(double timeout) {
|
void TestEventQueue::initQuitTimeout(double timeout) {
|
||||||
assert(m_quitTimeoutTimer == nullptr);
|
assert(m_pQuitTimeoutTimer == nullptr);
|
||||||
m_quitTimeoutTimer = newOneShotTimer(timeout, NULL);
|
m_pQuitTimeoutTimer = newOneShotTimer(timeout, NULL);
|
||||||
adoptHandler(
|
adoptHandler(
|
||||||
Event::kTimer, m_quitTimeoutTimer,
|
Event::kTimer, m_pQuitTimeoutTimer,
|
||||||
new TMethodEventJob<TestEventQueue>(
|
new TMethodEventJob<TestEventQueue>(
|
||||||
this, &TestEventQueue::handleQuitTimeout));
|
this, &TestEventQueue::handleQuitTimeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestEventQueue::cleanupQuitTimeout() {
|
void TestEventQueue::cleanupQuitTimeout() {
|
||||||
removeHandler(Event::kTimer, m_quitTimeoutTimer);
|
removeHandler(Event::kTimer, m_pQuitTimeoutTimer);
|
||||||
delete m_quitTimeoutTimer;
|
delete m_pQuitTimeoutTimer;
|
||||||
m_quitTimeoutTimer = nullptr;
|
m_pQuitTimeoutTimer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestEventQueue::handleQuitTimeout(const Event &, void *vclient) {
|
void TestEventQueue::handleQuitTimeout(const Event &, void *vclient) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class EventQueueTimer;
|
||||||
|
|
||||||
class TestEventQueue : public EventQueue {
|
class TestEventQueue : public EventQueue {
|
||||||
public:
|
public:
|
||||||
TestEventQueue() : m_quitTimeoutTimer(nullptr) {}
|
TestEventQueue() : m_pQuitTimeoutTimer(nullptr) {}
|
||||||
|
|
||||||
void handleQuitTimeout(const Event &, void *vclient);
|
void handleQuitTimeout(const Event &, void *vclient);
|
||||||
void raiseQuitEvent();
|
void raiseQuitEvent();
|
||||||
|
|
@ -34,5 +34,5 @@ private:
|
||||||
void timeoutThread(void *);
|
void timeoutThread(void *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventQueueTimer *m_quitTimeoutTimer;
|
EventQueueTimer *m_pQuitTimeoutTimer;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,12 @@
|
||||||
class QtCoreTest : public ::testing::Test {
|
class QtCoreTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
static void SetUpTestSuite() {
|
static void SetUpTestSuite() {
|
||||||
GTEST_LOG_(INFO) << "Qt core app setup";
|
|
||||||
char **argv = nullptr;
|
char **argv = nullptr;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
s_app = std::make_unique<QCoreApplication>(argc, argv);
|
s_app = std::make_unique<QCoreApplication>(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestSuite() {
|
static void TearDownTestSuite() { s_app.reset(); }
|
||||||
s_app.reset();
|
|
||||||
GTEST_LOG_(INFO) << "Qt core app teardown";
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::unique_ptr<QCoreApplication> s_app;
|
static std::unique_ptr<QCoreApplication> s_app;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,12 @@
|
||||||
class QtTest : public ::testing::Test {
|
class QtTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
static void SetUpTestSuite() {
|
static void SetUpTestSuite() {
|
||||||
GTEST_LOG_(INFO) << "Qt app setup";
|
|
||||||
char **argv = nullptr;
|
char **argv = nullptr;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
s_app = std::make_unique<QApplication>(argc, argv);
|
s_app = std::make_unique<QApplication>(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TearDownTestSuite() {
|
static void TearDownTestSuite() { s_app.reset(); }
|
||||||
s_app.reset();
|
|
||||||
GTEST_LOG_(INFO) << "Qt app teardown";
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::unique_ptr<QApplication> s_app;
|
static std::unique_ptr<QApplication> s_app;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ using ::testing::NiceMock;
|
||||||
using PollEntries = std::vector<IArchNetwork::PollEntry>;
|
using PollEntries = std::vector<IArchNetwork::PollEntry>;
|
||||||
using PollFD = struct pollfd[];
|
using PollFD = struct pollfd[];
|
||||||
|
|
||||||
|
namespace {
|
||||||
struct MockDeps : public ArchNetworkBSD::Deps {
|
struct MockDeps : public ArchNetworkBSD::Deps {
|
||||||
MockDeps() {
|
MockDeps() {
|
||||||
ON_CALL(*this, makePollFD(_)).WillByDefault([this](nfds_t n) {
|
ON_CALL(*this, makePollFD(_)).WillByDefault([this](nfds_t n) {
|
||||||
|
|
@ -47,19 +48,7 @@ struct MockDeps : public ArchNetworkBSD::Deps {
|
||||||
|
|
||||||
std::shared_ptr<PollFD> m_pollFD;
|
std::shared_ptr<PollFD> m_pollFD;
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
#ifndef NDEBUG
|
|
||||||
|
|
||||||
TEST(ArchNetworkBSDTests, pollSocket_negativeNum_death) {
|
|
||||||
MockDeps deps;
|
|
||||||
ArchNetworkBSD networkBSD(deps);
|
|
||||||
|
|
||||||
PollEntries entries{{nullptr, 0, 0}};
|
|
||||||
|
|
||||||
EXPECT_DEATH({ networkBSD.pollSocket(entries.data(), -1, 1); }, "num > 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DEBUG
|
|
||||||
|
|
||||||
TEST(ArchNetworkBSDTests, pollSocket_zeroEntries_callsSleep) {
|
TEST(ArchNetworkBSDTests, pollSocket_zeroEntries_callsSleep) {
|
||||||
MockDeps deps;
|
MockDeps deps;
|
||||||
|
|
|
||||||
108
src/test/unittests/gui/AppConfigTests.cpp
Normal file
108
src/test/unittests/gui/AppConfigTests.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2024 Symless Ltd.
|
||||||
|
*
|
||||||
|
* 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 "gui/AppConfig.h"
|
||||||
|
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
using namespace testing;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class MockScopes : public synergy::gui::IConfigScopes {
|
||||||
|
public:
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, registerReceiver, (synergy::gui::CommonConfig * receiver),
|
||||||
|
(override));
|
||||||
|
MOCK_METHOD(void, loadAll, (), (override));
|
||||||
|
MOCK_METHOD(
|
||||||
|
bool, hasSetting, (const QString &name, Scope scope), (const, override));
|
||||||
|
MOCK_METHOD(
|
||||||
|
QVariant, loadSetting,
|
||||||
|
(const QString &name, const QVariant &defaultValue, Scope scope),
|
||||||
|
(const, override));
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, setSetting,
|
||||||
|
(const QString &name, const QVariant &value, Scope scope), (override));
|
||||||
|
MOCK_METHOD(Scope, getScope, (), (const, override));
|
||||||
|
MOCK_METHOD(void, setScope, (Scope scope), (override));
|
||||||
|
MOCK_METHOD(bool, isWritable, (), (const, override));
|
||||||
|
MOCK_METHOD(QSettings *, currentSettings, (), (const, override));
|
||||||
|
MOCK_METHOD(void, saveAll, (), (override));
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MockDeps : public AppConfig::Deps {
|
||||||
|
NiceMock<MockScopes> m_scopes;
|
||||||
|
|
||||||
|
MockDeps() {
|
||||||
|
ON_CALL(*this, profileDir()).WillByDefault(Return("stub"));
|
||||||
|
ON_CALL(*this, scopes()).WillByDefault(ReturnRef(m_scopes));
|
||||||
|
ON_CALL(*this, hostname()).WillByDefault(Return("stub"));
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCK_METHOD(QString, profileDir, (), (const, override));
|
||||||
|
MOCK_METHOD(synergy::gui::IConfigScopes &, scopes, (), (override));
|
||||||
|
MOCK_METHOD(QString, hostname, (), (const, override));
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class AppConfigTests : public Test {};
|
||||||
|
|
||||||
|
TEST_F(AppConfigTests, ctor_byDefault_screenNameIsHostname) {
|
||||||
|
NiceMock<MockDeps> deps;
|
||||||
|
ON_CALL(deps, hostname()).WillByDefault(Return("test"));
|
||||||
|
|
||||||
|
AppConfig appConfig(deps);
|
||||||
|
|
||||||
|
ASSERT_EQ(appConfig.screenName().toStdString(), "test");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AppConfigTests, loadAllScopes_byDefault_callsScopesLoadAll) {
|
||||||
|
NiceMock<MockDeps> deps;
|
||||||
|
AppConfig appConfig(deps);
|
||||||
|
|
||||||
|
EXPECT_CALL(deps.m_scopes, loadAll());
|
||||||
|
|
||||||
|
appConfig.loadAllScopes();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AppConfigTests, loadSettings_byDefault_callsScopesLoadSetting) {
|
||||||
|
NiceMock<MockDeps> deps;
|
||||||
|
AppConfig appConfig(deps);
|
||||||
|
|
||||||
|
ON_CALL(deps.m_scopes, hasSetting(_, _)).WillByDefault(Return(true));
|
||||||
|
ON_CALL(deps.m_scopes, loadSetting(_, _, _))
|
||||||
|
.WillByDefault(Return(QVariant("test")));
|
||||||
|
EXPECT_CALL(deps.m_scopes, loadSetting(_, _, _)).Times(AnyNumber());
|
||||||
|
|
||||||
|
appConfig.loadSettings();
|
||||||
|
|
||||||
|
ASSERT_EQ(appConfig.screenName().toStdString(), "test");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(AppConfigTests, saveSettings_byDefault_callsScopesSetSetting) {
|
||||||
|
NiceMock<MockDeps> deps;
|
||||||
|
AppConfig appConfig(deps);
|
||||||
|
|
||||||
|
ON_CALL(deps.m_scopes, isWritable()).WillByDefault(Return(true));
|
||||||
|
EXPECT_CALL(deps.m_scopes, setSetting(_, _, _)).Times(AnyNumber());
|
||||||
|
|
||||||
|
appConfig.saveSettings();
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue