refactor: Use the Settings::Gui::AutoStartCore to control if the Gui should start the core when starting up
removes Settings::Core::StartedBefore
This commit is contained in:
committed by
Chris Rizzitello
parent
df78f0757e
commit
e5513101a6
@ -73,7 +73,6 @@ This section contains general options it will begin with `[core]`
|
||||
| preventSleep | `true` or `false` | Prevent sleep when Deskflow is active [default: false] |
|
||||
| processMode | `1` or `0` | The mode we use to start the process Service or Desktop |
|
||||
| screenName | string | Name used to identify the screen [default: machine's hostname] |
|
||||
| startedBefore | `true` or `false `| Have we started client or server before. Used in logic when deciding to show some dialogs.
|
||||
| updateUrl | URL | The URL to use when checking for a new version number, it should return a version [default: https://api.deskflow.org/version]|
|
||||
| useHooks | `true` or `false` | If Windows uses hooks or not [default: true] |
|
||||
| language | 639 language | The language to display the GUI in [default: en] |
|
||||
@ -106,6 +105,7 @@ This section contains options used by the GUI it will begin with `[gui]`
|
||||
| showGenericClientFailureDialog | `true` or `false` | When `true` client connection errors will not show popup error messages [default: true] |
|
||||
| shownFirstConnectedMessage | `true` or `false` | When `true` GUI has shown the user the message for connecting the first time [default: false] |
|
||||
| shownServerFirstStartMessage | `true` or `false` | When `true` GUI has shown the user the Deskflow server is now running message [default: false] |
|
||||
| startCoreWithGui | `true` or `false` | When true the Core will be started with the GUI. It is set to the Core's state on exit. |
|
||||
|
||||
### Log
|
||||
|
||||
|
||||
@ -49,7 +49,6 @@ public:
|
||||
inline static const auto PreventSleep = QStringLiteral("core/preventSleep");
|
||||
inline static const auto ProcessMode = QStringLiteral("core/processMode");
|
||||
inline static const auto ScreenName = QStringLiteral("core/screenName");
|
||||
inline static const auto StartedBefore = QStringLiteral("core/startedBefore");
|
||||
inline static const auto UpdateUrl = QStringLiteral("core/updateUrl");
|
||||
inline static const auto Display = QStringLiteral("core/display");
|
||||
inline static const auto UseHooks = QStringLiteral("core/useHooks");
|
||||
@ -66,6 +65,7 @@ public:
|
||||
struct Gui
|
||||
{
|
||||
inline static const auto Autohide = QStringLiteral("gui/autoHide");
|
||||
inline static const auto AutoStartCore = QStringLiteral("gui/startCoreWithGui");
|
||||
inline static const auto AutoUpdateCheck = QStringLiteral("gui/enableUpdateCheck");
|
||||
inline static const auto CloseReminder = QStringLiteral("gui/closeReminder");
|
||||
inline static const auto CloseToTray = QStringLiteral("gui/closeToTray");
|
||||
@ -192,7 +192,6 @@ private:
|
||||
, Settings::Core::PreventSleep
|
||||
, Settings::Core::ProcessMode
|
||||
, Settings::Core::ScreenName
|
||||
, Settings::Core::StartedBefore
|
||||
, Settings::Core::UpdateUrl
|
||||
, Settings::Core::Display
|
||||
, Settings::Core::UseHooks
|
||||
@ -206,6 +205,7 @@ private:
|
||||
, Settings::Log::ToFile
|
||||
, Settings::Log::GuiDebug
|
||||
, Settings::Gui::Autohide
|
||||
, Settings::Gui::AutoStartCore
|
||||
, Settings::Gui::AutoUpdateCheck
|
||||
, Settings::Gui::CloseReminder
|
||||
, Settings::Gui::CloseToTray
|
||||
@ -226,9 +226,9 @@ private:
|
||||
// When checking the default values this list contains the ones that default to false.
|
||||
inline static const QStringList m_defaultFalseValues = {
|
||||
Settings::Gui::Autohide
|
||||
, Settings::Gui::AutoStartCore
|
||||
, Settings::Gui::ShownFirstConnectedMessage
|
||||
, Settings::Gui::ShownServerFirstStartMessage
|
||||
, Settings::Core::StartedBefore
|
||||
, Settings::Core::PreventSleep
|
||||
, Settings::Core::UseWlClipboard
|
||||
, Settings::Server::ExternalConfig
|
||||
|
||||
@ -306,7 +306,12 @@ void MainWindow::connectSlots()
|
||||
|
||||
connect(&m_clientConnection, &ClientConnection::requestShowError, this, &MainWindow::showClientError);
|
||||
|
||||
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStartCore, &QAction::trigger, Qt::UniqueConnection);
|
||||
if (Settings::value(Settings::Gui::AutoStartCore).toBool()) {
|
||||
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStopCore, &QAction::trigger, Qt::UniqueConnection);
|
||||
} else {
|
||||
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStartCore, &QAction::trigger, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
connect(ui->btnRestartCore, &QPushButton::clicked, this, &MainWindow::resetCore);
|
||||
|
||||
connect(ui->lineHostname, &QLineEdit::returnPressed, ui->btnRestartCore, &QPushButton::click);
|
||||
@ -526,15 +531,6 @@ void MainWindow::updateModeControls(bool serverMode)
|
||||
if (m_coreProcess.isStarted() && m_coreProcess.mode() != expectedCoreMode)
|
||||
m_coreProcess.stop();
|
||||
m_coreProcess.setMode(expectedCoreMode);
|
||||
if (serverMode) {
|
||||
// The server can run without any clients configured, and this is actually
|
||||
// what you'll want to do the first time since you'll be prompted when an
|
||||
// unrecognized client tries to connect.
|
||||
const auto startedBefore = Settings::value(Settings::Core::StartedBefore).toBool();
|
||||
if (!startedBefore && !m_coreProcess.isStarted()) {
|
||||
m_coreProcess.start();
|
||||
}
|
||||
}
|
||||
updateModeControlLabels();
|
||||
|
||||
toggleCanRunCore((!serverMode && !ui->lineHostname->text().isEmpty()) || serverMode);
|
||||
@ -671,7 +667,7 @@ void MainWindow::open()
|
||||
qDebug() << "update check disabled";
|
||||
}
|
||||
|
||||
if (Settings::value(Settings::Core::StartedBefore).toBool()) {
|
||||
if (Settings::value(Settings::Gui::AutoStartCore).toBool()) {
|
||||
if (ui->rbModeClient->isChecked() && ui->lineHostname->text().isEmpty())
|
||||
return;
|
||||
startCore();
|
||||
@ -867,6 +863,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
if (m_saveOnExit) {
|
||||
Settings::setValue(Settings::Gui::WindowGeometry, geometry());
|
||||
Settings::setValue(Settings::Gui::AutoStartCore, m_coreProcess.isStarted());
|
||||
}
|
||||
qDebug() << "quitting application";
|
||||
|
||||
@ -958,7 +955,7 @@ void MainWindow::coreProcessStateChanged(CoreProcessState state)
|
||||
|
||||
if (state == CoreProcessState::Started) {
|
||||
qDebug() << "recording that core has started";
|
||||
Settings::setValue(Settings::Core::StartedBefore, true);
|
||||
Settings::setValue(Settings::Gui::AutoStartCore, true);
|
||||
if (m_coreProcess.mode() == CoreMode::Server &&
|
||||
!Settings::value(Settings::Gui::ShownServerFirstStartMessage).toBool()) {
|
||||
qDebug() << "starting core server for first time";
|
||||
|
||||
Reference in New Issue
Block a user