2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-02-25 00:28:21 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
2024-07-22 16:48:02 +00:00
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
#include "SettingsDialog.h"
|
2025-11-05 20:55:51 +00:00
|
|
|
#include "common/PlatformInfo.h"
|
2024-11-07 04:28:57 +00:00
|
|
|
#include "ui_SettingsDialog.h"
|
2015-02-12 16:49:18 +00:00
|
|
|
|
2025-10-18 05:39:59 +00:00
|
|
|
#include "common/I18N.h"
|
2025-03-05 03:29:28 +00:00
|
|
|
#include "common/Settings.h"
|
2025-03-19 21:47:24 +00:00
|
|
|
#include "gui/Messages.h"
|
2025-11-22 17:49:09 +00:00
|
|
|
#include "gui/TlsUtility.h"
|
2024-10-01 13:30:24 +00:00
|
|
|
|
2025-10-18 05:39:59 +00:00
|
|
|
#include <QComboBox>
|
2024-07-02 19:07:06 +00:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QMessageBox>
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
using namespace deskflow::gui;
|
2024-07-26 22:53:52 +00:00
|
|
|
|
2025-03-10 03:07:01 +00:00
|
|
|
SettingsDialog::SettingsDialog(QWidget *parent, const IServerConfig &serverConfig, const CoreProcess &coreProcess)
|
2024-12-05 13:52:05 +00:00
|
|
|
: QDialog(parent),
|
2024-11-07 04:28:57 +00:00
|
|
|
ui{std::make_unique<Ui::SettingsDialog>()},
|
2024-08-08 17:41:59 +00:00
|
|
|
m_serverConfig(serverConfig),
|
2025-11-22 17:35:41 +00:00
|
|
|
m_coreProcess(coreProcess)
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2024-07-26 22:53:52 +00:00
|
|
|
|
2024-11-07 04:28:57 +00:00
|
|
|
ui->setupUi(this);
|
2024-07-02 19:07:06 +00:00
|
|
|
|
2025-10-18 05:39:59 +00:00
|
|
|
// set up the language combo
|
|
|
|
|
I18N::reDetectLanguages();
|
|
|
|
|
ui->comboLanguage->addItems(I18N::detectedLanguages());
|
|
|
|
|
ui->comboLanguage->setCurrentText(I18N::currentLanguage());
|
|
|
|
|
|
2025-10-27 22:03:48 +00:00
|
|
|
updateText();
|
2025-08-25 14:07:42 +00:00
|
|
|
|
2025-06-10 13:05:44 +00:00
|
|
|
ui->comboTlsKeyLength->setItemIcon(0, QIcon::fromTheme(QStringLiteral("security-medium")));
|
|
|
|
|
ui->comboTlsKeyLength->setItemIcon(1, QIcon::fromTheme(QIcon::ThemeIcon::SecurityHigh));
|
2025-03-19 13:53:22 +00:00
|
|
|
ui->lblTlsCertInfo->setFixedSize(28, 28);
|
2025-01-18 16:56:27 +00:00
|
|
|
|
2025-10-29 18:31:18 +00:00
|
|
|
ui->rbIconMono->setIcon(QIcon::fromTheme(QStringLiteral("%1-symbolic").arg(kRevFqdnName)));
|
|
|
|
|
ui->rbIconColorful->setIcon(QIcon::fromTheme(kRevFqdnName));
|
|
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
// force the first tab, since qt creator sets the active tab as the last one
|
|
|
|
|
// the developer was looking at, and it's easy to accidentally save that.
|
2025-02-27 03:16:54 +00:00
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
2024-08-01 00:13:01 +00:00
|
|
|
|
2024-08-08 10:38:34 +00:00
|
|
|
loadFromConfig();
|
|
|
|
|
|
2024-12-05 13:52:05 +00:00
|
|
|
adjustSize();
|
2024-12-24 04:11:47 +00:00
|
|
|
QApplication::processEvents();
|
2024-12-05 13:52:05 +00:00
|
|
|
setFixedHeight(height());
|
|
|
|
|
setWindowFlags((windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMinMaxButtonsHint);
|
2024-08-08 17:41:59 +00:00
|
|
|
|
2025-02-25 00:54:25 +00:00
|
|
|
initConnections();
|
2024-08-08 17:41:59 +00:00
|
|
|
}
|
|
|
|
|
|
2025-10-27 22:03:48 +00:00
|
|
|
void SettingsDialog::changeEvent(QEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QDialog::changeEvent(e);
|
|
|
|
|
if (e->type() == QEvent::LanguageChange) {
|
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
|
updateText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-20 02:19:19 +00:00
|
|
|
void SettingsDialog::initConnections() const
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2025-02-25 00:54:25 +00:00
|
|
|
connect(this, &SettingsDialog::shown, this, &SettingsDialog::showReadOnlyMessage, Qt::QueuedConnection);
|
2024-08-08 17:41:59 +00:00
|
|
|
|
2025-02-25 00:54:25 +00:00
|
|
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept);
|
2025-03-15 03:24:22 +00:00
|
|
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
2024-08-08 17:41:59 +00:00
|
|
|
|
2025-02-27 04:26:34 +00:00
|
|
|
connect(ui->groupSecurity, &QGroupBox::toggled, this, &SettingsDialog::updateTlsControlsEnabled);
|
2025-04-02 21:32:07 +00:00
|
|
|
connect(ui->groupService, &QGroupBox::toggled, this, &SettingsDialog::updateControls);
|
2025-02-27 03:16:54 +00:00
|
|
|
connect(ui->btnTlsRegenCert, &QPushButton::clicked, this, &SettingsDialog::regenCertificates);
|
2025-03-19 13:53:22 +00:00
|
|
|
connect(ui->comboTlsKeyLength, &QComboBox::currentIndexChanged, this, &SettingsDialog::updateRequestedKeySize);
|
2025-02-27 03:16:54 +00:00
|
|
|
connect(ui->btnTlsCertPath, &QPushButton::clicked, this, &SettingsDialog::browseCertificatePath);
|
|
|
|
|
connect(ui->btnBrowseLog, &QPushButton::clicked, this, &SettingsDialog::browseLogPath);
|
|
|
|
|
connect(ui->cbLogToFile, &QCheckBox::toggled, this, &SettingsDialog::setLogToFile);
|
2025-08-25 14:07:42 +00:00
|
|
|
connect(ui->comboLogLevel, &QComboBox::currentIndexChanged, this, &SettingsDialog::logLevelChanged);
|
2025-10-18 05:39:59 +00:00
|
|
|
connect(ui->comboLanguage, &QComboBox::currentTextChanged, I18N::instance(), &I18N::setLanguage);
|
2025-02-25 00:54:25 +00:00
|
|
|
}
|
2024-08-12 15:39:18 +00:00
|
|
|
|
2025-02-25 00:54:25 +00:00
|
|
|
void SettingsDialog::regenCertificates()
|
|
|
|
|
{
|
2025-11-22 17:35:41 +00:00
|
|
|
if (TlsUtility::generateCertificate()) {
|
2025-02-25 00:54:25 +00:00
|
|
|
QMessageBox::information(this, tr("TLS Certificate Regenerated"), tr("TLS certificate regenerated successfully."));
|
2025-03-19 13:53:22 +00:00
|
|
|
const auto certificate = Settings::value(Settings::Security::Certificate).toString();
|
|
|
|
|
updateKeyLengthOnFile(certificate);
|
2024-08-12 15:39:18 +00:00
|
|
|
}
|
2024-08-08 10:38:34 +00:00
|
|
|
}
|
|
|
|
|
|
2025-02-25 00:54:25 +00:00
|
|
|
void SettingsDialog::browseCertificatePath()
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2024-08-08 17:41:59 +00:00
|
|
|
QString fileName = QFileDialog::getSaveFileName(
|
2025-02-27 03:16:54 +00:00
|
|
|
this, tr("Select a TLS certificate to use..."), ui->lineTlsCertPath->text(), "Cert (*.pem)", nullptr,
|
2024-10-17 18:04:35 +00:00
|
|
|
QFileDialog::DontConfirmOverwrite
|
|
|
|
|
);
|
2024-08-08 17:41:59 +00:00
|
|
|
|
|
|
|
|
if (!fileName.isEmpty()) {
|
2025-02-27 03:16:54 +00:00
|
|
|
ui->lineTlsCertPath->setText(fileName);
|
2024-08-08 17:41:59 +00:00
|
|
|
|
|
|
|
|
if (QFile(fileName).exists()) {
|
|
|
|
|
updateKeyLengthOnFile(fileName);
|
|
|
|
|
} else {
|
|
|
|
|
qDebug("no tls certificate file at: %s", qUtf8Printable(fileName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-25 00:54:25 +00:00
|
|
|
void SettingsDialog::browseLogPath()
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2025-02-27 03:16:54 +00:00
|
|
|
QString fileName =
|
|
|
|
|
QFileDialog::getSaveFileName(this, tr("Save log file to..."), ui->lineLogFilename->text(), "Logs (*.log *.txt)");
|
2025-02-25 00:54:25 +00:00
|
|
|
|
|
|
|
|
if (!fileName.isEmpty()) {
|
2025-02-27 03:16:54 +00:00
|
|
|
ui->lineLogFilename->setText(fileName);
|
2024-08-08 17:41:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-25 00:54:25 +00:00
|
|
|
void SettingsDialog::setLogToFile(bool logToFile)
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2025-02-27 03:16:54 +00:00
|
|
|
ui->widgetLogFilename->setEnabled(logToFile);
|
2024-08-08 17:41:59 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::showEvent(QShowEvent *event)
|
|
|
|
|
{
|
2024-08-12 15:39:18 +00:00
|
|
|
QDialog::showEvent(event);
|
2024-10-21 04:08:10 +00:00
|
|
|
Q_EMIT shown();
|
2024-08-12 15:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::showReadOnlyMessage()
|
|
|
|
|
{
|
2025-03-10 03:07:01 +00:00
|
|
|
if (Settings::isWritable())
|
2025-02-25 00:54:25 +00:00
|
|
|
return;
|
2025-03-10 03:07:01 +00:00
|
|
|
messages::showReadOnlySettings(this, Settings::settingsFile());
|
2024-08-12 15:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
2025-10-27 22:03:48 +00:00
|
|
|
void SettingsDialog::updateText()
|
|
|
|
|
{
|
|
|
|
|
// Set Tooltip for the logLevel Items
|
|
|
|
|
ui->comboLogLevel->setItemData(0, tr("Required messages"), Qt::ToolTipRole);
|
|
|
|
|
ui->comboLogLevel->setItemData(1, tr("Non-fatal errors"), Qt::ToolTipRole);
|
|
|
|
|
ui->comboLogLevel->setItemData(2, tr("General warnings"), Qt::ToolTipRole);
|
|
|
|
|
ui->comboLogLevel->setItemData(3, tr("Notable events"), Qt::ToolTipRole);
|
|
|
|
|
ui->comboLogLevel->setItemData(4, tr("General events [Default]"), Qt::ToolTipRole);
|
|
|
|
|
ui->comboLogLevel->setItemData(5, tr("Debug entries"), Qt::ToolTipRole);
|
|
|
|
|
ui->comboLogLevel->setItemData(6, tr("More debug output"), Qt::ToolTipRole);
|
|
|
|
|
ui->comboLogLevel->setItemData(7, tr("Verbose debug output"), Qt::ToolTipRole);
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::accept()
|
|
|
|
|
{
|
2025-03-09 00:25:57 +00:00
|
|
|
Settings::setValue(Settings::Core::Port, ui->sbPort->value());
|
2025-03-08 21:58:53 +00:00
|
|
|
Settings::setValue(Settings::Core::Interface, ui->lineInterface->text());
|
2025-03-09 01:13:26 +00:00
|
|
|
Settings::setValue(Settings::Log::Level, ui->comboLogLevel->currentIndex());
|
2025-03-09 00:34:50 +00:00
|
|
|
Settings::setValue(Settings::Log::ToFile, ui->cbLogToFile->isChecked());
|
2025-03-09 01:56:29 +00:00
|
|
|
Settings::setValue(Settings::Log::File, ui->lineLogFilename->text());
|
2025-04-02 22:00:06 +00:00
|
|
|
Settings::setValue(Settings::Daemon::Elevate, ui->cbElevateDaemon->isChecked());
|
2025-03-05 03:29:28 +00:00
|
|
|
Settings::setValue(Settings::Gui::Autohide, ui->cbAutoHide->isChecked());
|
2025-03-05 04:25:38 +00:00
|
|
|
Settings::setValue(Settings::Gui::AutoUpdateCheck, ui->cbAutoUpdate->isChecked());
|
2025-03-07 03:07:14 +00:00
|
|
|
Settings::setValue(Settings::Core::PreventSleep, ui->cbPreventSleep->isChecked());
|
2025-03-07 00:04:55 +00:00
|
|
|
Settings::setValue(Settings::Security::Certificate, ui->lineTlsCertPath->text());
|
2025-03-06 23:32:14 +00:00
|
|
|
Settings::setValue(Settings::Security::KeySize, ui->comboTlsKeyLength->currentText().toInt());
|
2025-03-06 23:08:08 +00:00
|
|
|
Settings::setValue(Settings::Security::TlsEnabled, ui->groupSecurity->isChecked());
|
2025-03-08 21:51:41 +00:00
|
|
|
Settings::setValue(Settings::Client::LanguageSync, ui->cbLanguageSync->isChecked());
|
2025-03-08 21:35:02 +00:00
|
|
|
Settings::setValue(Settings::Client::InvertScrollDirection, ui->cbScrollDirection->isChecked());
|
2025-03-05 04:45:14 +00:00
|
|
|
Settings::setValue(Settings::Gui::CloseToTray, ui->cbCloseToTray->isChecked());
|
2025-10-29 18:31:18 +00:00
|
|
|
Settings::setValue(Settings::Gui::SymbolicTrayIcon, ui->rbIconMono->isChecked());
|
2025-03-07 00:42:16 +00:00
|
|
|
Settings::setValue(Settings::Security::CheckPeers, ui->cbRequireClientCert->isChecked());
|
2025-09-27 12:24:14 +00:00
|
|
|
Settings::setValue(Settings::Client::ScrollSpeed, ui->sbScrollSpeed->value());
|
2025-10-18 05:39:59 +00:00
|
|
|
Settings::setValue(Settings::Core::Language, ui->comboLanguage->currentText());
|
2025-11-04 16:27:52 +00:00
|
|
|
Settings::setValue(Settings::Log::GuiDebug, ui->cbGuiDebug->isChecked());
|
2025-11-20 13:59:36 +00:00
|
|
|
Settings::setValue(Settings::Core::UseWlClipboard, ui->cbUseWlClipboard->isChecked());
|
2024-07-02 19:07:06 +00:00
|
|
|
|
2025-03-09 04:30:12 +00:00
|
|
|
Settings::ProcessMode mode;
|
2025-04-02 21:32:07 +00:00
|
|
|
if (ui->groupService->isChecked())
|
2025-03-09 04:30:12 +00:00
|
|
|
mode = Settings::ProcessMode::Service;
|
|
|
|
|
else
|
|
|
|
|
mode = Settings::ProcessMode::Desktop;
|
|
|
|
|
Settings::setValue(Settings::Core::ProcessMode, mode);
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
QDialog::accept();
|
2020-02-28 11:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::loadFromConfig()
|
|
|
|
|
{
|
2025-03-09 00:25:57 +00:00
|
|
|
ui->sbPort->setValue(Settings::value(Settings::Core::Port).toInt());
|
2025-03-08 21:58:53 +00:00
|
|
|
ui->lineInterface->setText(Settings::value(Settings::Core::Interface).toString());
|
2025-03-09 01:13:26 +00:00
|
|
|
ui->comboLogLevel->setCurrentIndex(Settings::value(Settings::Log::Level).toInt());
|
2025-03-09 00:34:50 +00:00
|
|
|
ui->cbLogToFile->setChecked(Settings::value(Settings::Log::ToFile).toBool());
|
2025-03-09 01:56:29 +00:00
|
|
|
ui->lineLogFilename->setText(Settings::value(Settings::Log::File).toString());
|
2025-03-05 03:29:28 +00:00
|
|
|
ui->cbAutoHide->setChecked(Settings::value(Settings::Gui::Autohide).toBool());
|
2025-03-07 03:07:14 +00:00
|
|
|
ui->cbPreventSleep->setChecked(Settings::value(Settings::Core::PreventSleep).toBool());
|
2025-03-08 21:51:41 +00:00
|
|
|
ui->cbLanguageSync->setChecked(Settings::value(Settings::Client::LanguageSync).toBool());
|
2025-03-08 21:35:02 +00:00
|
|
|
ui->cbScrollDirection->setChecked(Settings::value(Settings::Client::InvertScrollDirection).toBool());
|
2025-03-05 04:45:14 +00:00
|
|
|
ui->cbCloseToTray->setChecked(Settings::value(Settings::Gui::CloseToTray).toBool());
|
2025-04-02 22:00:06 +00:00
|
|
|
ui->cbElevateDaemon->setChecked(Settings::value(Settings::Daemon::Elevate).toBool());
|
2025-03-30 10:32:17 +00:00
|
|
|
ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::AutoUpdateCheck).toBool());
|
2025-09-27 12:24:14 +00:00
|
|
|
ui->sbScrollSpeed->setValue(Settings::value(Settings::Client::ScrollSpeed).toInt());
|
2025-11-04 16:27:52 +00:00
|
|
|
ui->cbGuiDebug->setChecked(Settings::value(Settings::Log::GuiDebug).toBool());
|
2025-11-20 13:59:36 +00:00
|
|
|
ui->cbUseWlClipboard->setChecked(Settings::value(Settings::Core::UseWlClipboard).toBool());
|
2024-11-13 15:42:08 +00:00
|
|
|
|
2025-03-09 04:42:52 +00:00
|
|
|
const auto processMode = Settings::value(Settings::Core::ProcessMode).value<Settings::ProcessMode>();
|
2025-04-02 21:32:07 +00:00
|
|
|
ui->groupService->setChecked(processMode == Settings::ProcessMode::Service);
|
2025-03-09 04:42:52 +00:00
|
|
|
|
2025-11-05 20:55:51 +00:00
|
|
|
if (!deskflow::platform::isWindows())
|
|
|
|
|
ui->groupService->setVisible(false);
|
2025-10-18 19:16:49 +00:00
|
|
|
|
2025-10-29 18:31:18 +00:00
|
|
|
if (Settings::value(Settings::Gui::SymbolicTrayIcon).toBool())
|
|
|
|
|
ui->rbIconMono->setChecked(true);
|
|
|
|
|
else
|
|
|
|
|
ui->rbIconColorful->setChecked(true);
|
|
|
|
|
|
2025-09-27 12:09:56 +00:00
|
|
|
ui->lblDebugWarning->setVisible(Settings::value(Settings::Log::Level).toInt() > 4);
|
|
|
|
|
|
2025-02-25 00:13:03 +00:00
|
|
|
qDebug() << "load from config done";
|
2025-08-20 02:51:50 +00:00
|
|
|
updateControls();
|
2012-06-10 16:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::updateTlsControls()
|
|
|
|
|
{
|
2025-03-07 00:04:55 +00:00
|
|
|
const auto certificate = Settings::value(Settings::Security::Certificate).toString();
|
|
|
|
|
if (QFile(certificate).exists()) {
|
|
|
|
|
updateKeyLengthOnFile(certificate);
|
2024-07-02 19:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-19 13:53:22 +00:00
|
|
|
ui->comboTlsKeyLength->setCurrentText(Settings::value(Settings::Security::KeySize).toString());
|
|
|
|
|
|
2025-03-07 00:04:55 +00:00
|
|
|
ui->lineTlsCertPath->setText(certificate);
|
2025-03-07 00:42:16 +00:00
|
|
|
ui->cbRequireClientCert->setChecked(Settings::value(Settings::Security::CheckPeers).toBool());
|
2025-11-22 13:32:00 +00:00
|
|
|
ui->groupSecurity->setChecked(TlsUtility::isEnabled());
|
2025-02-25 00:13:03 +00:00
|
|
|
|
2025-08-20 02:28:18 +00:00
|
|
|
ui->groupSecurity->setEnabled(Settings::isWritable());
|
|
|
|
|
|
|
|
|
|
updateTlsControlsEnabled();
|
2024-07-22 16:48:02 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::updateTlsControlsEnabled()
|
|
|
|
|
{
|
2025-03-10 03:07:01 +00:00
|
|
|
const auto writable = Settings::isWritable();
|
2025-02-27 04:26:34 +00:00
|
|
|
const auto tlsChecked = ui->groupSecurity->isChecked();
|
2024-08-09 08:08:29 +00:00
|
|
|
|
2025-08-20 02:54:58 +00:00
|
|
|
auto enabled = writable && tlsChecked;
|
2025-02-27 03:16:54 +00:00
|
|
|
ui->lblTlsKeyLength->setEnabled(enabled);
|
|
|
|
|
ui->comboTlsKeyLength->setEnabled(enabled);
|
|
|
|
|
ui->lblTlsCert->setEnabled(enabled);
|
2025-02-25 00:13:03 +00:00
|
|
|
ui->widgetTlsCert->setEnabled(enabled);
|
2025-02-27 03:16:54 +00:00
|
|
|
ui->btnTlsRegenCert->setEnabled(enabled);
|
2025-08-20 02:54:58 +00:00
|
|
|
ui->cbRequireClientCert->setEnabled(enabled && !isClientMode());
|
2022-06-01 12:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
bool SettingsDialog::isClientMode() const
|
|
|
|
|
{
|
2025-03-10 02:50:44 +00:00
|
|
|
return m_coreProcess.mode() == Settings::CoreMode::Client;
|
2020-07-28 12:00:20 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::updateKeyLengthOnFile(const QString &path)
|
|
|
|
|
{
|
2024-08-07 14:05:18 +00:00
|
|
|
if (!QFile(path).exists()) {
|
|
|
|
|
qFatal("tls certificate file not found: %s", qUtf8Printable(path));
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-22 15:29:47 +00:00
|
|
|
auto length = TlsUtility::getCertKeyLength(path);
|
2025-04-27 16:52:11 +00:00
|
|
|
auto labelIcon = QPixmap(QIcon::fromTheme(QIcon::ThemeIcon::SecurityLow).pixmap(24, 24));
|
2025-03-19 13:53:22 +00:00
|
|
|
if (length == 2048)
|
|
|
|
|
labelIcon = QPixmap(QIcon::fromTheme(QStringLiteral("security-medium")).pixmap(24, 24));
|
|
|
|
|
if (length == 4096)
|
|
|
|
|
labelIcon = QPixmap(QIcon::fromTheme(QIcon::ThemeIcon::SecurityHigh).pixmap(24, 24));
|
|
|
|
|
|
|
|
|
|
ui->lblTlsCertInfo->setPixmap(labelIcon);
|
|
|
|
|
ui->lblTlsCertInfo->setToolTip(QStringLiteral("Key length: %1 bits").arg(QString::number(length)));
|
2020-07-27 16:21:46 +00:00
|
|
|
}
|
2021-02-01 19:21:46 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void SettingsDialog::updateControls()
|
|
|
|
|
{
|
2025-03-10 03:07:01 +00:00
|
|
|
const bool writable = Settings::isWritable();
|
2025-04-02 21:32:07 +00:00
|
|
|
const bool serviceChecked = ui->groupService->isChecked();
|
2025-02-27 03:16:54 +00:00
|
|
|
const bool logToFile = ui->cbLogToFile->isChecked();
|
|
|
|
|
|
2025-05-12 15:32:24 +00:00
|
|
|
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(writable);
|
|
|
|
|
|
2025-02-27 03:16:54 +00:00
|
|
|
ui->sbPort->setEnabled(writable);
|
|
|
|
|
ui->lineInterface->setEnabled(writable);
|
|
|
|
|
ui->comboLogLevel->setEnabled(writable);
|
|
|
|
|
ui->cbLogToFile->setEnabled(writable);
|
|
|
|
|
ui->cbAutoHide->setEnabled(writable);
|
|
|
|
|
ui->cbAutoUpdate->setEnabled(writable);
|
|
|
|
|
ui->cbPreventSleep->setEnabled(writable);
|
|
|
|
|
ui->lineTlsCertPath->setEnabled(writable);
|
|
|
|
|
ui->comboTlsKeyLength->setEnabled(writable);
|
|
|
|
|
ui->cbCloseToTray->setEnabled(writable);
|
|
|
|
|
|
2025-10-09 13:56:34 +00:00
|
|
|
// Portable mode only ever applies to Windows.
|
|
|
|
|
// Daemon options should only be available on Windows when *not* in portable mode.
|
|
|
|
|
if (!Settings::isPortableMode()) {
|
2025-04-02 21:32:07 +00:00
|
|
|
ui->groupService->setEnabled(writable);
|
2025-04-02 22:00:06 +00:00
|
|
|
ui->cbElevateDaemon->setEnabled(writable && serviceChecked);
|
2025-03-31 19:22:58 +00:00
|
|
|
} else if (ui->groupService->isVisibleTo(ui->tabAdvanced)) {
|
|
|
|
|
ui->groupService->setVisible(false);
|
|
|
|
|
}
|
2025-02-27 03:16:54 +00:00
|
|
|
|
2025-11-16 13:08:28 +00:00
|
|
|
// wl-clipboard support only works on wayland.
|
|
|
|
|
// options should only be available when we are *not* running on wayland.
|
|
|
|
|
if (deskflow::platform::isWayland()) {
|
|
|
|
|
ui->cbUseWlClipboard->setEnabled(writable);
|
|
|
|
|
} else if (ui->widgetWlClipboard->isVisibleTo(ui->tabAdvanced)) {
|
|
|
|
|
ui->widgetWlClipboard->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-20 03:15:35 +00:00
|
|
|
ui->groupClientOptions->setEnabled(writable && isClientMode());
|
2025-02-27 03:16:54 +00:00
|
|
|
|
|
|
|
|
ui->widgetLogFilename->setEnabled(writable && logToFile);
|
2024-07-22 16:48:02 +00:00
|
|
|
|
|
|
|
|
updateTlsControls();
|
2021-02-04 17:10:27 +00:00
|
|
|
}
|
2024-11-07 04:28:57 +00:00
|
|
|
|
2025-05-20 02:19:19 +00:00
|
|
|
void SettingsDialog::updateRequestedKeySize() const
|
2025-03-19 13:53:22 +00:00
|
|
|
{
|
|
|
|
|
if (ui->comboTlsKeyLength->currentText() == Settings::value(Settings::Security::KeySize).toString())
|
|
|
|
|
return;
|
|
|
|
|
Settings::setValue(Settings::Security::KeySize, ui->comboTlsKeyLength->currentText());
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 14:07:42 +00:00
|
|
|
void SettingsDialog::logLevelChanged()
|
|
|
|
|
{
|
|
|
|
|
ui->lblDebugWarning->setVisible(ui->comboLogLevel->currentIndex() > 4);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 04:28:57 +00:00
|
|
|
SettingsDialog::~SettingsDialog() = default;
|