2013-07-24 16:41:12 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2016-09-07 14:24:00 +00:00
|
|
|
* Copyright (C) 2012-2016 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"
|
|
|
|
|
#include "MainWindow.h"
|
2021-03-24 12:38:50 +00:00
|
|
|
#include "validators/ScreenNameValidator.h"
|
2013-07-24 16:41:12 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
SetupWizard::SetupWizard(MainWindow &mainWindow) : m_MainWindow(mainWindow) {
|
|
|
|
|
setupUi(this);
|
2013-07-24 16:41:12 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
m_pLineEditName->setText(m_MainWindow.appConfig().screenName());
|
|
|
|
|
m_pLineEditName->setValidator(
|
|
|
|
|
new validators::ScreenNameValidator(m_pLineEditName, label_ErrorMessage));
|
2013-07-24 16:41:12 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
connect(m_pButtonApply, SIGNAL(clicked()), this, SLOT(accept()));
|
|
|
|
|
connect(m_pLineEditName, SIGNAL(textEdited(QString)), this,
|
|
|
|
|
SLOT(onNameChanged()));
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
void SetupWizard::accept() {
|
|
|
|
|
AppConfig &appConfig = m_MainWindow.appConfig();
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
appConfig.setWizardHasRun();
|
|
|
|
|
appConfig.setScreenName(m_pLineEditName->text());
|
|
|
|
|
appConfig.saveSettings();
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
m_MainWindow.open();
|
|
|
|
|
QDialog::accept();
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
void SetupWizard::onNameChanged() {
|
|
|
|
|
m_pButtonApply->setEnabled(label_ErrorMessage->text().isEmpty());
|
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
|
|
|
}
|