refactor: mainwindow move save config to a button shown only in server mode

This commit is contained in:
sithlord48
2025-03-14 12:03:24 -04:00
committed by Nick Bolton
parent ed1bf01306
commit f7b98465fa
3 changed files with 26 additions and 11 deletions

View File

@ -82,7 +82,6 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
m_actionQuit{new QAction(tr("&Quit"), this)},
m_actionTrayQuit{new QAction(tr("&Quit"), this)},
m_actionRestore{new QAction(tr("&Open Deskflow"), this)},
m_actionSave{new QAction(tr("Save configuration &as..."), this)},
m_actionSettings{new QAction(tr("Preferences"), this)},
m_actionStartCore{new QAction(tr("&Start"), this)},
m_actionStopCore{new QAction(tr("S&top"), this)},
@ -119,9 +118,6 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
m_actionSettings->setMenuRole(QAction::PreferencesRole);
m_actionSettings->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
m_actionSave->setShortcut(QKeySequence(tr("Ctrl+Alt+S")));
m_actionSave->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::DocumentSaveAs));
m_actionStartCore->setShortcut(QKeySequence(tr("Ctrl+S")));
m_actionStartCore->setIcon(QIcon::fromTheme(QStringLiteral("system-run")));
@ -309,7 +305,6 @@ void MainWindow::connectSlots()
connect(m_actionQuit, &QAction::triggered, this, &MainWindow::close);
connect(m_actionTrayQuit, &QAction::triggered, this, &MainWindow::close);
connect(m_actionRestore, &QAction::triggered, this, &MainWindow::showAndActivate);
connect(m_actionSave, &QAction::triggered, this, &MainWindow::saveConfig);
connect(m_actionSettings, &QAction::triggered, this, &MainWindow::openSettings);
connect(m_actionStartCore, &QAction::triggered, this, &MainWindow::startCore);
connect(m_actionStopCore, &QAction::triggered, this, &MainWindow::stopCore);
@ -335,6 +330,7 @@ void MainWindow::connectSlots()
connect(ui->lineHostname, &QLineEdit::returnPressed, ui->btnConnect, &QPushButton::click);
connect(ui->lineHostname, &QLineEdit::textChanged, &m_coreProcess, &deskflow::gui::CoreProcess::setAddress);
connect(ui->btnSaveServerConfig, &QPushButton::clicked, this, &MainWindow::saveServerConfig);
connect(ui->btnConfigureServer, &QPushButton::clicked, this, [this] { showConfigureServer(""); });
connect(ui->lblComputerName, &QLabel::linkActivated, this, &MainWindow::openSettings);
connect(m_btnFingerprint, &QToolButton::clicked, this, &MainWindow::showMyFingerprint);
@ -472,12 +468,12 @@ void MainWindow::clearSettings()
diagnostic::clearSettings(m_configScopes, true);
}
bool MainWindow::saveConfig()
bool MainWindow::saveServerConfig()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as..."));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save server configuration as..."));
if (!fileName.isEmpty() && !m_serverConfig.save(fileName)) {
QMessageBox::warning(this, tr("Save failed"), tr("Could not save configuration to file."));
QMessageBox::warning(this, tr("Save failed"), tr("Could not save server configuration to file."));
return true;
}

View File

@ -116,7 +116,7 @@ private:
void openSettings();
void startCore();
void stopCore();
bool saveConfig();
bool saveServerConfig();
void testFatalError() const;
void testCriticalError() const;
void resetCore();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>520</height>
<width>735</width>
<height>525</height>
</rect>
</property>
<property name="sizePolicy">
@ -233,6 +233,25 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSaveServerConfig">
<property name="toolTip">
<string>Export server configuration</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="QIcon::ThemeIcon::DocumentSaveAs"/>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">