2013-07-24 16:41:12 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2024-08-03 00:17:29 +00:00
|
|
|
* Copyright (C) 2012 Symless Ltd.
|
2018-06-07 15:23:35 +00:00
|
|
|
*
|
2013-07-24 16:41:12 +00:00
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2015-05-03 02:33:52 +00:00
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
2018-06-07 15:23:35 +00:00
|
|
|
*
|
2013-07-24 16:41:12 +00:00
|
|
|
* 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/>.
|
|
|
|
|
*/
|
2018-06-07 15:23:35 +00:00
|
|
|
|
2013-07-24 16:41:12 +00:00
|
|
|
#include "SetupWizard.h"
|
2024-08-01 00:13:01 +00:00
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
#include "gui/styles.h"
|
2024-08-09 08:08:29 +00:00
|
|
|
#include "gui/validators/ScreenNameValidator.h"
|
|
|
|
|
#include "gui/validators/ValidationError.h"
|
2024-08-01 00:13:01 +00:00
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
using namespace synergy::gui;
|
|
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
SetupWizard::SetupWizard(AppConfig &appConfig) : m_appConfig(appConfig) {
|
2024-07-02 19:07:06 +00:00
|
|
|
setupUi(this);
|
2013-07-24 16:41:12 +00:00
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
m_pLabelError->setStyleSheet(kStyleErrorActiveLabel);
|
|
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
m_pLineEditName->setText(appConfig.screenName());
|
2024-08-01 00:13:01 +00:00
|
|
|
m_pLineEditName->setValidator(new validators::ScreenNameValidator(
|
|
|
|
|
m_pLineEditName, new validators::ValidationError(this, m_pLabelError)));
|
2013-07-24 16:41:12 +00:00
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
connect(m_pButtonApply, &QPushButton::clicked, this, &SetupWizard::accept);
|
2024-07-16 13:36:44 +00:00
|
|
|
connect(
|
2024-08-01 00:13:01 +00:00
|
|
|
m_pLineEditName, &QLineEdit::textChanged, this,
|
|
|
|
|
&SetupWizard::onLineEditNameChanged);
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
void SetupWizard::accept() {
|
2024-08-03 00:17:29 +00:00
|
|
|
m_appConfig.setWizardHasRun();
|
|
|
|
|
m_appConfig.setScreenName(m_pLineEditName->text());
|
2024-07-02 19:07:06 +00:00
|
|
|
QDialog::accept();
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
void SetupWizard::onLineEditNameChanged(const QString &error) {
|
|
|
|
|
m_pButtonApply->setEnabled(m_pLineEditName->hasAcceptableInput());
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
void SetupWizard::reject() {
|
|
|
|
|
QDialog::reject();
|
|
|
|
|
QApplication::exit();
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|