mirror of
https://github.com/deskflow/deskflow.git
synced 2026-07-10 21:19:24 +08:00
SYNERGY-799 Update synergy UI. Setup wizard (#6959)
* SYNERGY-799 Add image to the welcome screen * SYNERGY-799 Add title * SYNERGY-799 Update controls positions * SYNERGY-799 Correct font size * SYNERGY-799 Assign validator * SYNERGY-799 Rename buttons and remove unused code * SYNERGY-799 Add validator * SYNERGY-799 Add error messages * SYNERGY-788 Add validator to settings * Update ChangeLog * SYNERGY-799 Fix code smells * SYNERGY-799 Fix github checks * SYNERGY-799 Update labels * SYNERGY-799 Disable button apply * SYNERGY-799 Add separate message for spaces * SYNERGY-799 Show wizard again if user closed it * SYNERGY-799 Add validation for duplicate * SYNERGY-799 Fix compilation * SYNERGY-799 Fix code smells
This commit is contained in:
parent
4878a8c07c
commit
cf66eeaf08
@ -7,6 +7,7 @@ Bug fixes:
|
||||
|
||||
Enhancements:
|
||||
- #6954 Move language selection to advanced section
|
||||
- #6959 Update synergy UI. Setup wizard
|
||||
- #6962 | #6965 Add macOS 10.13 builder
|
||||
===========
|
||||
|
||||
|
||||
@ -19,5 +19,6 @@
|
||||
<file>icons/64x64/synergy-light-transfering.png</file>
|
||||
<file>icons/64x64/synergy-light-disconnected.png</file>
|
||||
<file>icons/64x64/synergy-light-connected.png</file>
|
||||
<file>image/welcome.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
src/gui/res/image/welcome.png
Normal file
BIN
src/gui/res/image/welcome.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@ -267,7 +267,7 @@ void AppConfig::loadSettings()
|
||||
|
||||
void AppConfig::saveSettings()
|
||||
{
|
||||
setCommonSetting(kWizardLastRun, kWizardVersion);
|
||||
setCommonSetting(kWizardLastRun, m_WizardLastRun);
|
||||
setCommonSetting(kLoadSystemSettings, m_LoadFromSystemScope);
|
||||
|
||||
if (isWritable()) {
|
||||
|
||||
@ -17,8 +17,138 @@
|
||||
*/
|
||||
#include "ScreenNameValidator.h"
|
||||
|
||||
ScreenNameValidator::ScreenNameValidator(QObject *parent) :
|
||||
QRegExpValidator(QRegExp("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive), parent)
|
||||
namespace {
|
||||
|
||||
|
||||
class EmptyNameValidator : public INameValidator
|
||||
{
|
||||
public:
|
||||
bool validate(const QString& input) const override
|
||||
{
|
||||
return !input.isEmpty();
|
||||
}
|
||||
|
||||
QString getMessage() const override
|
||||
{
|
||||
return "Computer name can't be empty";
|
||||
}
|
||||
};
|
||||
|
||||
class SpacesValidator : public INameValidator
|
||||
{
|
||||
public:
|
||||
bool validate(const QString& input) const override
|
||||
{
|
||||
return !input.contains(' ');
|
||||
}
|
||||
|
||||
QString getMessage() const override
|
||||
{
|
||||
return "Remove spaces";
|
||||
}
|
||||
};
|
||||
|
||||
class SpecialCharactersValidator : public INameValidator
|
||||
{
|
||||
|
||||
public:
|
||||
bool validate(const QString& input) const override
|
||||
{
|
||||
auto validator = QRegExp("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive);
|
||||
return (validator.exactMatch(input));
|
||||
}
|
||||
|
||||
QString getMessage() const override
|
||||
{
|
||||
return "Remove unsupported characters";
|
||||
}
|
||||
};
|
||||
|
||||
class DuplicationsValidator : public INameValidator
|
||||
{
|
||||
const QString m_defaultName;
|
||||
const ScreenList* m_pScreenList = nullptr;
|
||||
|
||||
public:
|
||||
DuplicationsValidator(const QString defaultName,const ScreenList* pScreens) :
|
||||
m_defaultName(defaultName),
|
||||
m_pScreenList(pScreens)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool validate(const QString& input) const override
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
if (m_pScreenList)
|
||||
{
|
||||
for(const auto& screen : (*m_pScreenList))
|
||||
{
|
||||
if (m_defaultName != input && input == screen.name())
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString getMessage() const override
|
||||
{
|
||||
return "Computer with this name already exists";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ScreenNameValidator::ScreenNameValidator(QLineEdit* parent, QLabel* errors, const ScreenList* pScreens) :
|
||||
m_pErrors(errors),
|
||||
m_pControl(parent)
|
||||
{
|
||||
if (m_pErrors) {
|
||||
m_pErrors->hide();
|
||||
}
|
||||
|
||||
m_Validators.push_back(std::make_unique<EmptyNameValidator>());
|
||||
m_Validators.push_back(std::make_unique<SpacesValidator>());
|
||||
m_Validators.push_back(std::make_unique<SpecialCharactersValidator>());
|
||||
m_Validators.push_back(std::make_unique<DuplicationsValidator>(m_pControl ? m_pControl->text() : "", pScreens));
|
||||
}
|
||||
|
||||
QValidator::State ScreenNameValidator::validate(QString& input, int& pos) const
|
||||
{
|
||||
if (m_pControl) {
|
||||
showError("");
|
||||
m_pControl->setStyleSheet("");
|
||||
|
||||
for(const auto& validator : m_Validators)
|
||||
{
|
||||
if (!validator->validate(input))
|
||||
{
|
||||
m_pControl->setStyleSheet("border: 1px solid #EC4C47");
|
||||
showError(validator->getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Acceptable;
|
||||
}
|
||||
|
||||
void ScreenNameValidator::showError(const QString& message) const
|
||||
{
|
||||
if (m_pErrors) {
|
||||
m_pErrors->setText(message);
|
||||
if (m_pErrors->text().isEmpty()) {
|
||||
m_pErrors->hide();
|
||||
}
|
||||
else {
|
||||
m_pErrors->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,12 +18,33 @@
|
||||
#ifndef SCREENNAMEVALIDATOR_H
|
||||
#define SCREENNAMEVALIDATOR_H
|
||||
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <qvalidator.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "Screen.h"
|
||||
|
||||
class ScreenNameValidator : public QRegExpValidator
|
||||
class INameValidator
|
||||
{
|
||||
public:
|
||||
explicit ScreenNameValidator(QObject *parent = nullptr);
|
||||
virtual bool validate(const QString& input) const = 0;
|
||||
virtual QString getMessage() const = 0;
|
||||
virtual ~INameValidator() = default;
|
||||
};
|
||||
|
||||
class ScreenNameValidator : public QValidator
|
||||
{
|
||||
public:
|
||||
explicit ScreenNameValidator(QLineEdit* parent = nullptr, QLabel* errors = nullptr, const ScreenList* pScreens = nullptr);
|
||||
QValidator::State validate(QString& input, int& pos) const override;
|
||||
|
||||
private:
|
||||
QLabel* m_pErrors = nullptr;
|
||||
QLineEdit* m_pControl = nullptr;
|
||||
std::vector<std::unique_ptr<INameValidator>> m_Validators;
|
||||
|
||||
void showError(const QString& message) const;
|
||||
};
|
||||
|
||||
#endif // SCREENNAMEVALIDATOR_H
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <ScreenNameValidator.h>
|
||||
|
||||
ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) :
|
||||
ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen,const ScreenList* pScreens) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ScreenSettingsDialogBase(),
|
||||
m_pScreen(pScreen)
|
||||
@ -32,7 +32,7 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) :
|
||||
setupUi(this);
|
||||
|
||||
m_pLineEditName->setText(m_pScreen->name());
|
||||
m_pLineEditName->setValidator(new ScreenNameValidator(m_pLineEditName));
|
||||
m_pLineEditName->setValidator(new ScreenNameValidator(m_pLineEditName, m_pLabelNameError, pScreens));
|
||||
m_pLineEditName->selectAll();
|
||||
|
||||
m_pLineEditAlias->setValidator(new ScreenNameValidator(m_pLineEditName));
|
||||
@ -68,6 +68,9 @@ void ScreenSettingsDialog::accept()
|
||||
"Please either fill in a name or cancel the dialog."));
|
||||
return;
|
||||
}
|
||||
else if (!m_pLabelNameError->text().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_pScreen->init();
|
||||
|
||||
|
||||
@ -28,13 +28,14 @@ class QWidget;
|
||||
class QString;
|
||||
|
||||
class Screen;
|
||||
using ScreenList = QList<Screen>;
|
||||
|
||||
class ScreenSettingsDialog : public QDialog, public Ui::ScreenSettingsDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScreenSettingsDialog(QWidget* parent, Screen* pScreen = NULL);
|
||||
ScreenSettingsDialog(QWidget* parent, Screen* pScreen = nullptr, const ScreenList* pScreens = nullptr);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
@ -31,6 +31,22 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_pLabelNameError">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: #EC4C47;
|
||||
font-size: 13px;
|
||||
font-family: Arial;
|
||||
font-weight: bold;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
|
||||
@ -74,7 +74,7 @@ void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
|
||||
if (!model()->screen(col, row).isNull())
|
||||
{
|
||||
ScreenSettingsDialog dlg(this, &model()->screen(col, row));
|
||||
ScreenSettingsDialog dlg(this, &model()->screen(col, row), &model()->m_Screens);
|
||||
dlg.exec();
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,18 +51,20 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||
m_isSystemAtStart = appConfig().isSystemScoped();
|
||||
buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
|
||||
enableControls(appConfig().isWritable());
|
||||
m_pLineEditScreenName->setValidator(new ScreenNameValidator(m_pLineEditScreenName));
|
||||
|
||||
connect(m_pLineEditLogFilename, SIGNAL(textChanged(const QString&)), this, SLOT(onChange()));
|
||||
connect(m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this, SLOT(onChange()));
|
||||
connect(m_pLineEditCertificatePath, SIGNAL(textChanged(const QString&)), this, SLOT(onChange()));
|
||||
connect(m_pCheckBoxAutoConfig, SIGNAL(clicked()), this, SLOT(onChange()));
|
||||
connect(m_pCheckBoxMinimizeToTray, SIGNAL(clicked()), this, SLOT(onChange()));
|
||||
connect(m_pCheckBoxAutoHide, SIGNAL(clicked()), this, SLOT(onChange()));
|
||||
connect(m_pLineEditInterface, SIGNAL(textEdited(const QString&)), this, SLOT(onChange()));
|
||||
connect(m_pSpinBoxPort, SIGNAL(valueChanged(int)), this, SLOT(onChange()));
|
||||
connect(m_pLineEditScreenName, SIGNAL(textEdited(const QString&)), this, SLOT(onChange()));
|
||||
connect(m_pComboElevate, SIGNAL(currentIndexChanged(int)), this, SLOT(onChange()));
|
||||
const auto& serveConfig = m_pMainWindow->serverConfig();
|
||||
m_pLineEditScreenName->setValidator(new ScreenNameValidator(m_pLineEditScreenName, m_pLabelNameError, (&serveConfig.screens())));
|
||||
|
||||
connect(m_pLineEditLogFilename, SIGNAL(textChanged(QString)), this, SLOT(onChange()));
|
||||
connect(m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this, SLOT(onChange()));
|
||||
connect(m_pLineEditCertificatePath, SIGNAL(textChanged(QString)), this, SLOT(onChange()));
|
||||
connect(m_pCheckBoxAutoConfig, SIGNAL(clicked()), this, SLOT(onChange()));
|
||||
connect(m_pCheckBoxMinimizeToTray, SIGNAL(clicked()), this, SLOT(onChange()));
|
||||
connect(m_pCheckBoxAutoHide, 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()));
|
||||
}
|
||||
|
||||
void SettingsDialog::accept()
|
||||
@ -308,6 +310,7 @@ void SettingsDialog::updateKeyLengthOnFile(const QString &path) {
|
||||
bool SettingsDialog::isModified()
|
||||
{
|
||||
return (!m_pLineEditScreenName->text().isEmpty() &&
|
||||
m_pLabelNameError->text().isEmpty() &&
|
||||
(appConfig().screenName() != m_pLineEditScreenName->text()
|
||||
|| appConfig().port() != m_pSpinBoxPort->value()
|
||||
|| appConfig().networkInterface() != m_pLineEditInterface->text()
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>396</width>
|
||||
<height>857</height>
|
||||
<height>879</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -44,33 +44,7 @@
|
||||
<string>&Miscellaneous</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_20">
|
||||
<property name="text">
|
||||
<string>P&ort:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pSpinBoxPort</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_19">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sc&reen name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditScreenName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="m_pComboElevate">
|
||||
<property name="toolTip">
|
||||
<string>Specify when the Synergy service should run at an elevated privilege level</string>
|
||||
@ -95,28 +69,34 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditScreenName">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="m_pLabelElevate">
|
||||
<widget class="QLabel" name="m_pLabel_21">
|
||||
<property name="text">
|
||||
<string>Elevate</string>
|
||||
<string>&Interface:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditInterface</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxMinimizeToTray">
|
||||
<property name="text">
|
||||
<string>Minimize to System &Tray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditScreenName">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>15</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_pSpinBoxPort">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -135,30 +115,75 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_21">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_19">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Interface:</string>
|
||||
<string>Sc&reen name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditInterface</cstring>
|
||||
<cstring>m_pLineEditScreenName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_20">
|
||||
<property name="text">
|
||||
<string>P&ort:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pSpinBoxPort</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="m_pLabelElevate">
|
||||
<property name="text">
|
||||
<string>Elevate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxAutoHide">
|
||||
<property name="text">
|
||||
<string>&Hide on startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditInterface">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="m_pLabelNameError">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</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>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -17,118 +17,39 @@
|
||||
|
||||
#include "SetupWizard.h"
|
||||
#include "MainWindow.h"
|
||||
#include "ActivationNotifier.h"
|
||||
#include "LicenseManager.h"
|
||||
#include "QSynergyApplication.h"
|
||||
#include "QUtility.h"
|
||||
#include "ScreenNameValidator.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
|
||||
m_MainWindow(mainWindow),
|
||||
m_StartMain(startMain)
|
||||
SetupWizard::SetupWizard(MainWindow& mainWindow) :
|
||||
m_MainWindow(mainWindow)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
m_pLineEditName->setText(m_MainWindow.appConfig().screenName());
|
||||
m_pLineEditName->setValidator(new ScreenNameValidator(m_pLineEditName, label_ErrorMessage));
|
||||
|
||||
// the mac style needs a little more room because of the
|
||||
// graphic on the left.
|
||||
resize(600, 500);
|
||||
setMinimumSize(size());
|
||||
|
||||
// additionally, we identified an issue with presenting dots, see SYNERGY-719
|
||||
duplicateSpaces();
|
||||
|
||||
#elif defined(Q_OS_WIN)
|
||||
|
||||
// when areo is disabled on windows, the next/back buttons
|
||||
// are hidden (must be a qt bug) -- resizing the window
|
||||
// to +1 of the original height seems to fix this.
|
||||
// NOTE: calling setMinimumSize after this will break
|
||||
// it again, so don't do that.
|
||||
resize(size().width(), size().height() + 1);
|
||||
|
||||
#endif
|
||||
|
||||
connect(m_pServerRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupServer, SLOT(setChecked(bool)));
|
||||
connect(m_pClientRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupClient, SLOT(setChecked(bool)));
|
||||
}
|
||||
|
||||
SetupWizard::~SetupWizard()
|
||||
{
|
||||
}
|
||||
|
||||
bool SetupWizard::validateCurrentPage()
|
||||
{
|
||||
QMessageBox message;
|
||||
message.setWindowTitle(tr("Setup Synergy"));
|
||||
message.setIcon(QMessageBox::Information);
|
||||
|
||||
if (currentPage() == m_pNodePage)
|
||||
{
|
||||
bool result = m_pClientRadioButton->isChecked() ||
|
||||
m_pServerRadioButton->isChecked();
|
||||
|
||||
if (!result)
|
||||
{
|
||||
message.setText(tr("Please select an option."));
|
||||
message.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
connect(m_pButtonApply, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
connect(m_pLineEditName, SIGNAL(textEdited(QString)), this, SLOT(onNameChanged()));
|
||||
}
|
||||
|
||||
void SetupWizard::accept()
|
||||
{
|
||||
AppConfig& appConfig = m_MainWindow.appConfig();
|
||||
AppConfig& appConfig = m_MainWindow.appConfig();
|
||||
|
||||
appConfig.setWizardHasRun();
|
||||
appConfig.saveSettings();
|
||||
appConfig.setWizardHasRun();
|
||||
appConfig.setScreenName(m_pLineEditName->text());
|
||||
appConfig.saveSettings();
|
||||
|
||||
QSettings& settings = m_MainWindow.settings();
|
||||
if (m_pServerRadioButton->isChecked())
|
||||
{
|
||||
settings.setValue("groupServerChecked", true);
|
||||
settings.setValue("groupClientChecked", false);
|
||||
}
|
||||
if (m_pClientRadioButton->isChecked())
|
||||
{
|
||||
settings.setValue("groupClientChecked", true);
|
||||
settings.setValue("groupServerChecked", false);
|
||||
}
|
||||
m_MainWindow.open();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
QWizard::accept();
|
||||
|
||||
if (m_StartMain)
|
||||
{
|
||||
m_MainWindow.open();
|
||||
}
|
||||
void SetupWizard::onNameChanged()
|
||||
{
|
||||
m_pButtonApply->setEnabled(label_ErrorMessage->text().isEmpty());
|
||||
}
|
||||
|
||||
void SetupWizard::reject()
|
||||
{
|
||||
QSynergyApplication::getInstance()->switchTranslator(m_MainWindow.appConfig().language());
|
||||
|
||||
if (m_StartMain)
|
||||
{
|
||||
m_MainWindow.open();
|
||||
}
|
||||
|
||||
QWizard::reject();
|
||||
QDialog::reject();
|
||||
QApplication::exit();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
void SetupWizard::duplicateSpaces()
|
||||
{
|
||||
auto list = this->findChildren<QLabel *>();
|
||||
foreach(QLabel *l, list) {
|
||||
if (l->wordWrap()) {
|
||||
l->setText(l->text().replace(". ", ". "));
|
||||
l->setText(l->text().replace(", ", ", "));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // defined(Q_OS_MAC)
|
||||
|
||||
@ -18,36 +18,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui_SetupWizardBase.h"
|
||||
#include "SynergyLocale.h"
|
||||
|
||||
#include <QWizard>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QDialog>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class SetupWizard : public QWizard, public Ui::SetupWizardBase
|
||||
class SetupWizard : public QDialog, public Ui::SetupWizardBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {
|
||||
kMaximiumLoginAttemps = 3
|
||||
};
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetupWizard(MainWindow& mainWindow, bool startMain);
|
||||
virtual ~SetupWizard();
|
||||
bool validateCurrentPage();
|
||||
explicit SetupWizard(MainWindow& mainWindow);
|
||||
|
||||
protected:
|
||||
void accept();
|
||||
void reject();
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
private:
|
||||
MainWindow& m_MainWindow;
|
||||
bool m_StartMain;
|
||||
SynergyLocale m_Locale;
|
||||
MainWindow& m_MainWindow;
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
void duplicateSpaces();
|
||||
#endif // defined(Q_OS_MAC)
|
||||
private slots:
|
||||
void onNameChanged();
|
||||
};
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SetupWizardBase</class>
|
||||
<widget class="QWizard" name="SetupWizardBase">
|
||||
<widget class="QDialog" name="SetupWizardBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>556</width>
|
||||
<height>464</height>
|
||||
<width>720</width>
|
||||
<height>552</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -18,173 +18,201 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>390</height>
|
||||
<width>720</width>
|
||||
<height>552</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>720</width>
|
||||
<height>552</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>720</width>
|
||||
<height>552</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Setup Synergy</string>
|
||||
</property>
|
||||
<widget class="QWizardPage" name="m_pWelcomePage">
|
||||
<property name="title">
|
||||
<string>Welcome</string>
|
||||
<property name="windowOpacity">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_Image">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>70</y>
|
||||
<width>181</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Thanks for installing Synergy!</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedKingdom"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Synergy lets you easily share your mouse and keyboard between multiple computers on your desk. Just move your mouse off the edge of one computer's screen on to another. You can even share all of your clipboards. All you need is a network connection. Synergy is cross-platform (works on Windows, macOS and Linux).</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWizardPage" name="m_pNodePage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Server or Client?</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../res/Synergy.qrc">:/res/image/welcome.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_Title">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>253</y>
|
||||
<width>261</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><html><head/><body><p style="font-size:18px">Name your computer</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_Name">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>184</x>
|
||||
<y>294</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p style="font-size:13px;">Computer name</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="m_pLineEditName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>293</y>
|
||||
<width>230</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>230</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_HelpTitle">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>132</x>
|
||||
<y>354</y>
|
||||
<width>481</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p style="font-size: 13px;">Call your computer something short and meaningful, but it must have: </p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_HelpInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>193</x>
|
||||
<y>380</y>
|
||||
<width>311</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<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>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="m_pButtonApply">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>650</x>
|
||||
<y>510</y>
|
||||
<width>56</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_ErrorMessage">
|
||||
<property name="geometry">
|
||||
<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>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_pServerRadioButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Server (share this computer's mouse and keyboard)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_pClientLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>My main mouse and keyboard are connected to this computer. This will allow you to move your mouse over to another computer's screen. There can only be one server in your setup.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_pClientRadioButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Client (use another computer's mouse and keyboard)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_pServerLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>You have already set up a server. This computer will be controlled using the server's mouse and keyboard. There can be many clients in your setup.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_pServerRadioButton</tabstop>
|
||||
<tabstop>m_pClientRadioButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../res/Synergy.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@ -100,7 +100,7 @@ int main(int argc, char* argv[])
|
||||
std::unique_ptr<SetupWizard> setupWizard;
|
||||
if (appConfig.wizardShouldRun())
|
||||
{
|
||||
setupWizard.reset(new SetupWizard(mainWindow, true));
|
||||
setupWizard.reset(new SetupWizard(mainWindow));
|
||||
setupWizard->show();
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user