refactor: MainWindow conform to naming standards

This commit is contained in:
sithlord48
2025-02-03 19:30:00 -05:00
committed by Nick Bolton
parent 10c50c9740
commit b14de6f9e2
3 changed files with 169 additions and 175 deletions

View File

@ -58,13 +58,13 @@ using CoreProcessState = CoreProcess::ProcessState;
MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig) MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
: ui{std::make_unique<Ui::MainWindow>()}, : ui{std::make_unique<Ui::MainWindow>()},
m_ConfigScopes(configScopes), m_configScopes(configScopes),
m_AppConfig(appConfig), m_appConfig(appConfig),
m_ServerConfig(appConfig, *this), m_serverConfig(appConfig, *this),
m_CoreProcess(appConfig, m_ServerConfig), m_coreProcess(appConfig, m_serverConfig),
m_ServerConnection(this, appConfig, m_ServerConfig, m_ServerConfigDialogState), m_serverConnection(this, appConfig, m_serverConfig, m_serverConfigDialogState),
m_ClientConnection(this, appConfig), m_clientConnection(this, appConfig),
m_TlsUtility(appConfig), m_tlsUtility(appConfig),
m_trayIcon{new QSystemTrayIcon(this)}, m_trayIcon{new QSystemTrayIcon(this)},
m_guiDupeChecker{new QLocalServer(this)}, m_guiDupeChecker{new QLocalServer(this)},
m_actionAbout{new QAction(this)}, m_actionAbout{new QAction(this)},
@ -127,10 +127,10 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
#endif #endif
ui->btnToggleLog->setStyleSheet(QStringLiteral("background:rgba(0,0,0,0);")); ui->btnToggleLog->setStyleSheet(QStringLiteral("background:rgba(0,0,0,0);"));
if (m_AppConfig.logExpanded()) if (m_appConfig.logExpanded())
ui->btnToggleLog->click(); ui->btnToggleLog->click();
toggleLogVisible(m_AppConfig.logExpanded()); toggleLogVisible(m_appConfig.logExpanded());
// Setup the Instance Checking // Setup the Instance Checking
// In case of a previous crash remove first // In case of a previous crash remove first
@ -143,13 +143,13 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
setupTrayIcon(); setupTrayIcon();
m_ConfigScopes.signalReady(); m_configScopes.signalReady();
updateScreenName(); updateScreenName();
applyConfig(); applyConfig();
restoreWindow(); restoreWindow();
qDebug().noquote() << "active settings path:" << m_ConfigScopes.activeFilePath(); qDebug().noquote() << "active settings path:" << m_configScopes.activeFilePath();
updateSize(); updateSize();
} }
@ -157,18 +157,18 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
m_guiDupeChecker->close(); m_guiDupeChecker->close();
m_CoreProcess.cleanup(); m_coreProcess.cleanup();
} }
void MainWindow::restoreWindow() void MainWindow::restoreWindow()
{ {
const auto &windowSize = m_AppConfig.mainWindowSize(); const auto &windowSize = m_appConfig.mainWindowSize();
if (windowSize.has_value()) { if (windowSize.has_value()) {
qDebug() << "restoring main window size"; qDebug() << "restoring main window size";
m_expandedSize = windowSize.value(); m_expandedSize = windowSize.value();
} }
const auto &windowPosition = m_AppConfig.mainWindowPosition(); const auto &windowPosition = m_appConfig.mainWindowPosition();
if (windowPosition.has_value()) { if (windowPosition.has_value()) {
int x = 0; int x = 0;
int y = 0; int y = 0;
@ -201,16 +201,16 @@ void MainWindow::setupControls()
secureSocket(false); secureSocket(false);
ui->m_pLabelUpdate->setStyleSheet(kStyleNoticeLabel); ui->lblUpdate->setStyleSheet(kStyleNoticeLabel);
ui->m_pLabelUpdate->hide(); ui->lblUpdate->hide();
ui->m_pLabelNotice->setStyleSheet(kStyleNoticeLabel); ui->lblNotice->setStyleSheet(kStyleNoticeLabel);
ui->m_pLabelNotice->hide(); ui->lblNotice->hide();
ui->m_pLabelIpAddresses->setText(tr("This computer's IP addresses: %1").arg(getIPAddresses())); ui->lblIpAddresses->setText(tr("This computer's IP addresses: %1").arg(getIPAddresses()));
if (m_AppConfig.lastVersion() != kVersion) { if (m_appConfig.lastVersion() != kVersion) {
m_AppConfig.setLastVersion(kVersion); m_appConfig.setLastVersion(kVersion);
} }
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
@ -238,28 +238,28 @@ void MainWindow::connectSlots()
connect(this, &MainWindow::shown, this, &MainWindow::onShown, Qt::QueuedConnection); connect(this, &MainWindow::shown, this, &MainWindow::onShown, Qt::QueuedConnection);
connect(&m_ConfigScopes, &ConfigScopes::saving, this, &MainWindow::onConfigScopesSaving, Qt::DirectConnection); connect(&m_configScopes, &ConfigScopes::saving, this, &MainWindow::onConfigScopesSaving, Qt::DirectConnection);
connect(&m_AppConfig, &AppConfig::tlsChanged, this, &MainWindow::onAppConfigTlsChanged); connect(&m_appConfig, &AppConfig::tlsChanged, this, &MainWindow::onAppConfigTlsChanged);
connect(&m_AppConfig, &AppConfig::screenNameChanged, this, &MainWindow::onAppConfigScreenNameChanged); connect(&m_appConfig, &AppConfig::screenNameChanged, this, &MainWindow::onAppConfigScreenNameChanged);
connect(&m_AppConfig, &AppConfig::invertConnectionChanged, this, &MainWindow::onAppConfigInvertConnection); connect(&m_appConfig, &AppConfig::invertConnectionChanged, this, &MainWindow::onAppConfigInvertConnection);
connect(&m_CoreProcess, &CoreProcess::starting, this, &MainWindow::onCoreProcessStarting, Qt::DirectConnection); connect(&m_coreProcess, &CoreProcess::starting, this, &MainWindow::onCoreProcessStarting, Qt::DirectConnection);
connect(&m_CoreProcess, &CoreProcess::error, this, &MainWindow::onCoreProcessError); connect(&m_coreProcess, &CoreProcess::error, this, &MainWindow::onCoreProcessError);
connect( connect(
&m_CoreProcess, &CoreProcess::logLine, this, // &m_coreProcess, &CoreProcess::logLine, this, //
[this](const QString &line) { handleLogLine(line); } [this](const QString &line) { handleLogLine(line); }
); );
connect(&m_CoreProcess, &CoreProcess::processStateChanged, this, &MainWindow::onCoreProcessStateChanged); connect(&m_coreProcess, &CoreProcess::processStateChanged, this, &MainWindow::onCoreProcessStateChanged);
connect(&m_CoreProcess, &CoreProcess::connectionStateChanged, this, &MainWindow::onCoreConnectionStateChanged); connect(&m_coreProcess, &CoreProcess::connectionStateChanged, this, &MainWindow::onCoreConnectionStateChanged);
connect(&m_CoreProcess, &CoreProcess::secureSocket, this, &MainWindow::onCoreProcessSecureSocket); connect(&m_coreProcess, &CoreProcess::secureSocket, this, &MainWindow::onCoreProcessSecureSocket);
connect(m_actionAbout, &QAction::triggered, this, &MainWindow::openAboutDialog); connect(m_actionAbout, &QAction::triggered, this, &MainWindow::openAboutDialog);
connect(m_actionClearSettings, &QAction::triggered, this, &MainWindow::clearSettings); connect(m_actionClearSettings, &QAction::triggered, this, &MainWindow::clearSettings);
@ -276,7 +276,7 @@ void MainWindow::connectSlots()
connect(m_actionTestFatalError, &QAction::triggered, this, &MainWindow::testFatalError); connect(m_actionTestFatalError, &QAction::triggered, this, &MainWindow::testFatalError);
connect(m_actionTestCriticalError, &QAction::triggered, this, &MainWindow::testCriticalError); connect(m_actionTestCriticalError, &QAction::triggered, this, &MainWindow::testCriticalError);
connect(&m_VersionChecker, &VersionChecker::updateFound, this, &MainWindow::onVersionCheckerUpdateFound); connect(&m_versionChecker, &VersionChecker::updateFound, this, &MainWindow::onVersionCheckerUpdateFound);
// Mac os tray will only show a menu // Mac os tray will only show a menu
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
@ -284,11 +284,11 @@ void MainWindow::connectSlots()
#endif #endif
connect( connect(
&m_ServerConnection, &ServerConnection::configureClient, this, &MainWindow::onServerConnectionConfigureClient &m_serverConnection, &ServerConnection::configureClient, this, &MainWindow::onServerConnectionConfigureClient
); );
connect(&m_ServerConnection, &ServerConnection::messageShowing, this, &MainWindow::showAndActivate); connect(&m_serverConnection, &ServerConnection::messageShowing, this, &MainWindow::showAndActivate);
connect(&m_ClientConnection, &ClientConnection::messageShowing, this, &MainWindow::showAndActivate); connect(&m_clientConnection, &ClientConnection::messageShowing, this, &MainWindow::showAndActivate);
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStartCore, &QAction::trigger, Qt::UniqueConnection); connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStartCore, &QAction::trigger, Qt::UniqueConnection);
connect(ui->btnApplySettings, &QPushButton::clicked, this, &MainWindow::resetCore); connect(ui->btnApplySettings, &QPushButton::clicked, this, &MainWindow::resetCore);
@ -296,10 +296,10 @@ void MainWindow::connectSlots()
connect(ui->btnConnectToClient, &QPushButton::clicked, this, &MainWindow::resetCore); connect(ui->btnConnectToClient, &QPushButton::clicked, this, &MainWindow::resetCore);
connect(ui->lineHostname, &QLineEdit::returnPressed, ui->btnConnect, &QPushButton::click); connect(ui->lineHostname, &QLineEdit::returnPressed, ui->btnConnect, &QPushButton::click);
connect(ui->lineHostname, &QLineEdit::textChanged, &m_CoreProcess, &deskflow::gui::CoreProcess::setAddress); connect(ui->lineHostname, &QLineEdit::textChanged, &m_coreProcess, &deskflow::gui::CoreProcess::setAddress);
connect(ui->lineClientIp, &QLineEdit::returnPressed, ui->btnConnectToClient, &QPushButton::click); connect(ui->lineClientIp, &QLineEdit::returnPressed, ui->btnConnectToClient, &QPushButton::click);
connect(ui->lineClientIp, &QLineEdit::textChanged, &m_CoreProcess, &deskflow::gui::CoreProcess::setAddress); connect(ui->lineClientIp, &QLineEdit::textChanged, &m_coreProcess, &deskflow::gui::CoreProcess::setAddress);
connect(ui->btnConfigureServer, &QPushButton::clicked, this, [this] { showConfigureServer(""); }); connect(ui->btnConfigureServer, &QPushButton::clicked, this, [this] { showConfigureServer(""); });
connect(ui->lblComputerName, &QLabel::linkActivated, this, &MainWindow::openSettings); connect(ui->lblComputerName, &QLabel::linkActivated, this, &MainWindow::openSettings);
@ -318,12 +318,12 @@ void MainWindow::toggleLogVisible(bool visible)
if (visible) { if (visible) {
ui->btnToggleLog->setArrowType(Qt::DownArrow); ui->btnToggleLog->setArrowType(Qt::DownArrow);
ui->textLog->setVisible(true); ui->textLog->setVisible(true);
m_AppConfig.setLogExpanded(true); m_appConfig.setLogExpanded(true);
} else { } else {
ui->btnToggleLog->setArrowType(Qt::RightArrow); ui->btnToggleLog->setArrowType(Qt::RightArrow);
m_expandedSize = size(); m_expandedSize = size();
ui->textLog->setVisible(false); ui->textLog->setVisible(false);
m_AppConfig.setLogExpanded(false); m_appConfig.setLogExpanded(false);
} }
// 1 ms delay is to make sure we have left the function before calling updateSize // 1 ms delay is to make sure we have left the function before calling updateSize
QTimer::singleShot(1, this, &MainWindow::updateSize); QTimer::singleShot(1, this, &MainWindow::updateSize);
@ -344,13 +344,13 @@ void MainWindow::onShown()
void MainWindow::onConfigScopesSaving() void MainWindow::onConfigScopesSaving()
{ {
m_ServerConfig.commit(); m_serverConfig.commit();
} }
void MainWindow::onAppConfigTlsChanged() void MainWindow::onAppConfigTlsChanged()
{ {
if (m_TlsUtility.isEnabled()) { if (m_tlsUtility.isEnabled()) {
m_TlsUtility.generateCertificate(); m_tlsUtility.generateCertificate();
} }
} }
@ -366,8 +366,8 @@ void MainWindow::onVersionCheckerUpdateFound(const QString &version)
const auto link = QString(kLinkDownload).arg(kUrlDownload, kColorWhite); const auto link = QString(kLinkDownload).arg(kUrlDownload, kColorWhite);
const auto text = tr("A new version is available (v%1). %2").arg(version, link); const auto text = tr("A new version is available (v%1). %2").arg(version, link);
ui->m_pLabelUpdate->show(); ui->lblUpdate->show();
ui->m_pLabelUpdate->setText(text); ui->lblUpdate->setText(text);
} }
void MainWindow::onAppConfigScreenNameChanged() void MainWindow::onAppConfigScreenNameChanged()
@ -399,14 +399,14 @@ void MainWindow::onCoreProcessError(CoreProcess::Error error)
void MainWindow::startCore() void MainWindow::startCore()
{ {
m_ClientConnection.setShowMessage(); m_clientConnection.setShowMessage();
m_CoreProcess.start(); m_coreProcess.start();
} }
void MainWindow::stopCore() void MainWindow::stopCore()
{ {
qDebug() << "stopping core process"; qDebug() << "stopping core process";
m_CoreProcess.stop(); m_coreProcess.stop();
} }
void MainWindow::testFatalError() const void MainWindow::testFatalError() const
@ -426,17 +426,17 @@ void MainWindow::clearSettings()
return; return;
} }
m_CoreProcess.stop(); m_coreProcess.stop();
m_SaveOnExit = false; m_saveOnExit = false;
diagnostic::clearSettings(m_ConfigScopes, true); diagnostic::clearSettings(m_configScopes, true);
} }
bool MainWindow::saveConfig() bool MainWindow::saveConfig()
{ {
QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as...")); QString fileName = QFileDialog::getSaveFileName(this, tr("Save configuration as..."));
if (!fileName.isEmpty() && !m_ServerConfig.save(fileName)) { 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 configuration to file."));
return true; return true;
} }
@ -457,23 +457,23 @@ void MainWindow::openHelpUrl() const
void MainWindow::openSettings() void MainWindow::openSettings()
{ {
auto dialog = SettingsDialog(this, m_AppConfig, m_ServerConfig, m_CoreProcess); auto dialog = SettingsDialog(this, m_appConfig, m_serverConfig, m_coreProcess);
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted) {
m_ConfigScopes.save(); m_configScopes.save();
applyConfig(); applyConfig();
if (m_CoreProcess.isStarted()) { if (m_coreProcess.isStarted()) {
m_CoreProcess.restart(); m_coreProcess.restart();
} }
} }
} }
void MainWindow::resetCore() void MainWindow::resetCore()
{ {
m_ClientConnection.setShowMessage(); m_clientConnection.setShowMessage();
m_CoreProcess.restart(); m_coreProcess.restart();
} }
void MainWindow::updateSize() void MainWindow::updateSize()
@ -499,24 +499,24 @@ void MainWindow::setModeServer()
{ {
enableServer(true); enableServer(true);
enableClient(false); enableClient(false);
m_ConfigScopes.save(); m_configScopes.save();
} }
void MainWindow::setModeClient() void MainWindow::setModeClient()
{ {
enableClient(true); enableClient(true);
enableServer(false); enableServer(false);
m_ConfigScopes.save(); m_configScopes.save();
} }
void MainWindow::onServerConnectionConfigureClient(const QString &clientName) void MainWindow::onServerConnectionConfigureClient(const QString &clientName)
{ {
m_ServerConfigDialogState.setVisible(true); m_serverConfigDialogState.setVisible(true);
ServerConfigDialog dialog(this, m_ServerConfig, m_AppConfig); ServerConfigDialog dialog(this, m_serverConfig, m_appConfig);
if (dialog.addClient(clientName) && dialog.exec() == QDialog::Accepted) { if (dialog.addClient(clientName) && dialog.exec() == QDialog::Accepted) {
m_CoreProcess.restart(); m_coreProcess.restart();
} }
m_ServerConfigDialogState.setVisible(false); m_serverConfigDialogState.setVisible(false);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -525,22 +525,22 @@ void MainWindow::onServerConnectionConfigureClient(const QString &clientName)
void MainWindow::open() void MainWindow::open()
{ {
if (!m_AppConfig.enableUpdateCheck().has_value()) { if (!m_appConfig.enableUpdateCheck().has_value()) {
m_AppConfig.setEnableUpdateCheck(messages::showUpdateCheckOption(this)); m_appConfig.setEnableUpdateCheck(messages::showUpdateCheckOption(this));
m_ConfigScopes.save(); m_configScopes.save();
} }
if (m_AppConfig.enableUpdateCheck().value()) { if (m_appConfig.enableUpdateCheck().value()) {
m_VersionChecker.checkLatest(); m_versionChecker.checkLatest();
} else { } else {
qDebug() << "update check disabled"; qDebug() << "update check disabled";
} }
if (m_AppConfig.startedBefore()) { if (m_appConfig.startedBefore()) {
m_CoreProcess.start(); m_coreProcess.start();
} }
if (m_AppConfig.autoHide()) { if (m_appConfig.autoHide()) {
hide(); hide();
} else { } else {
showAndActivate(); showAndActivate();
@ -550,14 +550,14 @@ void MainWindow::open()
void MainWindow::onCoreProcessStarting() void MainWindow::onCoreProcessStarting()
{ {
if (deskflow::platform::isWayland()) { if (deskflow::platform::isWayland()) {
m_WaylandWarnings.showOnce(this, m_CoreProcess.mode()); m_waylandWarnings.showOnce(this, m_coreProcess.mode());
} }
saveSettings(); saveSettings();
} }
void MainWindow::setStatus(const QString &status) void MainWindow::setStatus(const QString &status)
{ {
ui->m_pStatusLabel->setText(status); ui->lblStatus->setText(status);
} }
void MainWindow::createMenuBar() void MainWindow::createMenuBar()
@ -609,23 +609,23 @@ void MainWindow::setupTrayIcon()
void MainWindow::applyConfig() void MainWindow::applyConfig()
{ {
enableServer(m_AppConfig.serverGroupChecked()); enableServer(m_appConfig.serverGroupChecked());
enableClient(m_AppConfig.clientGroupChecked()); enableClient(m_appConfig.clientGroupChecked());
ui->lineHostname->setText(m_AppConfig.serverHostname()); ui->lineHostname->setText(m_appConfig.serverHostname());
ui->lineClientIp->setText(m_ServerConfig.getClientAddress()); ui->lineClientIp->setText(m_serverConfig.getClientAddress());
updateLocalFingerprint(); updateLocalFingerprint();
setIcon(); setIcon();
} }
void MainWindow::saveSettings() void MainWindow::saveSettings()
{ {
m_AppConfig.setServerGroupChecked(ui->rbModeServer->isChecked()); m_appConfig.setServerGroupChecked(ui->rbModeServer->isChecked());
m_AppConfig.setClientGroupChecked(ui->rbModeClient->isChecked()); m_appConfig.setClientGroupChecked(ui->rbModeClient->isChecked());
m_AppConfig.setServerHostname(ui->lineHostname->text()); m_appConfig.setServerHostname(ui->lineHostname->text());
m_ServerConfig.setClientAddress(ui->lineClientIp->text()); m_serverConfig.setClientAddress(ui->lineClientIp->text());
m_ConfigScopes.save(); m_configScopes.save();
} }
void MainWindow::setIcon() void MainWindow::setIcon()
@ -640,7 +640,7 @@ void MainWindow::setIcon()
} }
m_trayIcon->setIcon(QIcon(iconString)); m_trayIcon->setIcon(QIcon(iconString));
#else #else
if (m_AppConfig.colorfulTrayIcon()) { if (m_appConfig.colorfulTrayIcon()) {
m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow"))); m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow")));
} else { } else {
m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow-symbolic"))); m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow-symbolic")));
@ -679,10 +679,10 @@ void MainWindow::updateFromLogLine(const QString &line)
void MainWindow::checkConnected(const QString &line) void MainWindow::checkConnected(const QString &line)
{ {
if (ui->rbModeServer->isChecked()) { if (ui->rbModeServer->isChecked()) {
m_ServerConnection.handleLogLine(line); m_serverConnection.handleLogLine(line);
ui->m_pLabelServerState->updateServerState(line); ui->labelServerState->updateServerState(line);
} else { } else {
m_ClientConnection.handleLogLine(line); m_clientConnection.handleLogLine(line);
ui->m_pLabelClientState->updateClientState(line); ui->m_pLabelClientState->updateClientState(line);
} }
} }
@ -703,7 +703,7 @@ void MainWindow::checkFingerprint(const QString &line)
static bool messageBoxAlreadyShown = false; static bool messageBoxAlreadyShown = false;
if (!messageBoxAlreadyShown) { if (!messageBoxAlreadyShown) {
m_CoreProcess.stop(); m_coreProcess.stop();
messageBoxAlreadyShown = true; messageBoxAlreadyShown = true;
QMessageBox::StandardButton fingerprintReply = QMessageBox::information( QMessageBox::StandardButton fingerprintReply = QMessageBox::information(
@ -723,7 +723,7 @@ void MainWindow::checkFingerprint(const QString &line)
if (fingerprintReply == QMessageBox::Yes) { if (fingerprintReply == QMessageBox::Yes) {
// start core process again after trusting fingerprint. // start core process again after trusting fingerprint.
TlsFingerprint::trustedServers().trust(fingerprint); TlsFingerprint::trustedServers().trust(fingerprint);
m_CoreProcess.start(); m_coreProcess.start();
} }
messageBoxAlreadyShown = false; messageBoxAlreadyShown = false;
@ -743,10 +743,10 @@ void MainWindow::showEvent(QShowEvent *event)
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
if (m_AppConfig.closeToTray() && event->spontaneous()) { if (m_appConfig.closeToTray() && event->spontaneous()) {
if (m_AppConfig.showCloseReminder()) { if (m_appConfig.showCloseReminder()) {
messages::showCloseReminder(this); messages::showCloseReminder(this);
m_AppConfig.setShowCloseReminder(false); m_appConfig.setShowCloseReminder(false);
} }
qDebug() << "hiding to tray"; qDebug() << "hiding to tray";
hide(); hide();
@ -754,10 +754,10 @@ void MainWindow::closeEvent(QCloseEvent *event)
return; return;
} }
if (m_SaveOnExit) { if (m_saveOnExit) {
m_AppConfig.setMainWindowPosition(pos()); m_appConfig.setMainWindowPosition(pos());
m_AppConfig.setMainWindowSize(size()); m_appConfig.setMainWindowSize(size());
m_ConfigScopes.save(); m_configScopes.save();
} }
qDebug() << "quitting application"; qDebug() << "quitting application";
event->accept(); event->accept();
@ -766,15 +766,15 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::showFirstConnectedMessage() void MainWindow::showFirstConnectedMessage()
{ {
if (m_AppConfig.startedBefore()) { if (m_appConfig.startedBefore()) {
return; return;
} }
m_AppConfig.setStartedBefore(true); m_appConfig.setStartedBefore(true);
m_ConfigScopes.save(); m_configScopes.save();
const auto isServer = m_CoreProcess.mode() == CoreMode::Server; const auto isServer = m_coreProcess.mode() == CoreMode::Server;
messages::showFirstConnectedMessage(this, m_AppConfig.closeToTray(), m_AppConfig.enableService(), isServer); messages::showFirstConnectedMessage(this, m_appConfig.closeToTray(), m_appConfig.enableService(), isServer);
} }
void MainWindow::onCoreProcessSecureSocket(bool enabled) void MainWindow::onCoreProcessSecureSocket(bool enabled)
@ -784,8 +784,8 @@ void MainWindow::onCoreProcessSecureSocket(bool enabled)
void MainWindow::updateStatus() void MainWindow::updateStatus()
{ {
const auto connection = m_CoreProcess.connectionState(); const auto connection = m_coreProcess.connectionState();
const auto process = m_CoreProcess.processState(); const auto process = m_coreProcess.processState();
ui->lblConnectionSecurityStatus->setVisible(false); ui->lblConnectionSecurityStatus->setVisible(false);
switch (process) { switch (process) {
@ -812,7 +812,7 @@ void MainWindow::updateStatus()
using enum CoreConnectionState; using enum CoreConnectionState;
case Listening: { case Listening: {
if (m_CoreProcess.mode() == CoreMode::Server) { if (m_coreProcess.mode() == CoreMode::Server) {
setStatus(tr("%1 is waiting for clients").arg(kAppName)); setStatus(tr("%1 is waiting for clients").arg(kAppName));
} }
@ -825,8 +825,8 @@ void MainWindow::updateStatus()
case Connected: { case Connected: {
ui->lblConnectionSecurityStatus->setVisible(true); ui->lblConnectionSecurityStatus->setVisible(true);
if (m_SecureSocket) { if (m_secureSocket) {
setStatus(tr("%1 is connected (with %2)").arg(kAppName, m_CoreProcess.secureSocketVersion())); setStatus(tr("%1 is connected (with %2)").arg(kAppName, m_coreProcess.secureSocketVersion()));
} else { } else {
setStatus(tr("%1 is connected (without TLS encryption)").arg(kAppName)); setStatus(tr("%1 is connected (without TLS encryption)").arg(kAppName));
} }
@ -847,8 +847,8 @@ void MainWindow::onCoreProcessStateChanged(CoreProcessState state)
if (state == CoreProcessState::Started) { if (state == CoreProcessState::Started) {
qDebug() << "recording that core has started"; qDebug() << "recording that core has started";
m_AppConfig.setStartedBefore(true); m_appConfig.setStartedBefore(true);
m_ConfigScopes.save(); m_configScopes.save();
} }
if (state == CoreProcessState::Started || state == CoreProcessState::Starting || if (state == CoreProcessState::Started || state == CoreProcessState::Starting ||
@ -934,7 +934,7 @@ void MainWindow::updateLocalFingerprint()
qFatal() << "failed to check if fingerprint exists"; qFatal() << "failed to check if fingerprint exists";
} }
if (m_AppConfig.tlsEnabled() && fingerprintExists) { if (m_appConfig.tlsEnabled() && fingerprintExists) {
ui->lblMyFingerprint->setVisible(true); ui->lblMyFingerprint->setVisible(true);
} else { } else {
ui->lblMyFingerprint->setVisible(false); ui->lblMyFingerprint->setVisible(false);
@ -944,11 +944,11 @@ void MainWindow::updateLocalFingerprint()
void MainWindow::autoAddScreen(const QString name) void MainWindow::autoAddScreen(const QString name)
{ {
int r = m_ServerConfig.autoAddScreen(name); int r = m_serverConfig.autoAddScreen(name);
if (r != kAutoAddScreenOk) { if (r != kAutoAddScreenOk) {
switch (r) { switch (r) {
case kAutoAddScreenManualServer: case kAutoAddScreenManualServer:
showConfigureServer(tr("Please add the server (%1) to the grid.").arg(m_AppConfig.screenName())); showConfigureServer(tr("Please add the server (%1) to the grid.").arg(m_appConfig.screenName()));
break; break;
case kAutoAddScreenManualClient: case kAutoAddScreenManualClient:
@ -973,16 +973,16 @@ void MainWindow::hide()
void MainWindow::showConfigureServer(const QString &message) void MainWindow::showConfigureServer(const QString &message)
{ {
ServerConfigDialog dialog(this, serverConfig(), m_AppConfig); ServerConfigDialog dialog(this, serverConfig(), m_appConfig);
dialog.message(message); dialog.message(message);
if ((dialog.exec() == QDialog::Accepted) && m_CoreProcess.isStarted()) { if ((dialog.exec() == QDialog::Accepted) && m_coreProcess.isStarted()) {
m_CoreProcess.restart(); m_coreProcess.restart();
} }
} }
void MainWindow::secureSocket(bool secureSocket) void MainWindow::secureSocket(bool secureSocket)
{ {
m_SecureSocket = secureSocket; m_secureSocket = secureSocket;
const auto txt = secureSocket ? tr("Secure Connection") : tr("Insecure Connection"); const auto txt = secureSocket ? tr("Secure Connection") : tr("Insecure Connection");
ui->lblConnectionSecurityStatus->setToolTip(txt); ui->lblConnectionSecurityStatus->setToolTip(txt);
@ -995,34 +995,34 @@ void MainWindow::updateScreenName()
{ {
ui->lblComputerName->setText(tr("This computer's name: %1 " ui->lblComputerName->setText(tr("This computer's name: %1 "
R"((<a href="#" style="color: %2">change</a>))") R"((<a href="#" style="color: %2">change</a>))")
.arg(m_AppConfig.screenName(), kColorSecondary)); .arg(m_appConfig.screenName(), kColorSecondary));
m_ServerConfig.updateServerName(); m_serverConfig.updateServerName();
} }
void MainWindow::enableServer(bool enable) void MainWindow::enableServer(bool enable)
{ {
QString serverStr = enable ? QStringLiteral("server enabled") : QStringLiteral("server disabled"); QString serverStr = enable ? QStringLiteral("server enabled") : QStringLiteral("server disabled");
qDebug() << serverStr; qDebug() << serverStr;
m_AppConfig.setServerGroupChecked(enable); m_appConfig.setServerGroupChecked(enable);
ui->rbModeServer->setChecked(enable); ui->rbModeServer->setChecked(enable);
ui->m_pWidgetServer->setEnabled(enable); ui->widgetServer->setEnabled(enable);
ui->m_pWidgetServerInput->setVisible(m_AppConfig.invertConnection()); ui->widgetServerInput->setVisible(m_appConfig.invertConnection());
if (enable) { if (enable) {
ui->btnToggleCore->setEnabled(true); ui->btnToggleCore->setEnabled(true);
m_actionStartCore->setEnabled(true); m_actionStartCore->setEnabled(true);
if (m_CoreProcess.isStarted() && m_CoreProcess.mode() != CoreProcess::Mode::Server) if (m_coreProcess.isStarted() && m_coreProcess.mode() != CoreProcess::Mode::Server)
m_CoreProcess.stop(); m_coreProcess.stop();
m_CoreProcess.setMode(CoreProcess::Mode::Server); m_coreProcess.setMode(CoreProcess::Mode::Server);
// The server can run without any clients configured, and this is actually // 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 // what you'll want to do the first time since you'll be prompted when an
// unrecognized client tries to connect. // unrecognized client tries to connect.
if (!m_AppConfig.startedBefore() && !m_CoreProcess.isStarted()) { if (!m_appConfig.startedBefore() && !m_coreProcess.isStarted()) {
qDebug() << "auto-starting core server for first time"; qDebug() << "auto-starting core server for first time";
m_CoreProcess.start(); m_coreProcess.start();
messages::showFirstServerStartMessage(this); messages::showFirstServerStartMessage(this);
} }
} }
@ -1032,17 +1032,17 @@ void MainWindow::enableClient(bool enable)
{ {
QString clientStr = enable ? QStringLiteral("client enabled") : QStringLiteral("client disabled"); QString clientStr = enable ? QStringLiteral("client enabled") : QStringLiteral("client disabled");
qDebug() << clientStr; qDebug() << clientStr;
m_AppConfig.setClientGroupChecked(enable); m_appConfig.setClientGroupChecked(enable);
ui->rbModeClient->setChecked(enable); ui->rbModeClient->setChecked(enable);
ui->m_pWidgetClientInput->setEnabled(enable); ui->widgetClientInput->setEnabled(enable);
ui->m_pWidgetClientInput->setVisible(!m_AppConfig.invertConnection()); ui->widgetClientInput->setVisible(!m_appConfig.invertConnection());
if (enable) { if (enable) {
ui->btnToggleCore->setEnabled(true); ui->btnToggleCore->setEnabled(true);
m_actionStartCore->setEnabled(true); m_actionStartCore->setEnabled(true);
if (m_CoreProcess.isStarted() && m_CoreProcess.mode() != CoreProcess::Mode::Client) if (m_coreProcess.isStarted() && m_coreProcess.mode() != CoreProcess::Mode::Client)
m_CoreProcess.stop(); m_coreProcess.stop();
m_CoreProcess.setMode(CoreProcess::Mode::Client); m_coreProcess.setMode(CoreProcess::Mode::Client);
} }
} }

View File

@ -76,13 +76,13 @@ public:
CoreMode coreMode() const CoreMode coreMode() const
{ {
return m_CoreProcess.mode(); return m_coreProcess.mode();
} }
QString address() const; QString address() const;
void open(); void open();
ServerConfig &serverConfig() ServerConfig &serverConfig()
{ {
return m_ServerConfig; return m_serverConfig;
} }
void autoAddScreen(const QString name); void autoAddScreen(const QString name);
@ -131,11 +131,11 @@ private:
void updateSize(); void updateSize();
AppConfig &appConfig() AppConfig &appConfig()
{ {
return m_AppConfig; return m_appConfig;
} }
AppConfig const &appConfig() const AppConfig const &appConfig() const
{ {
return m_AppConfig; return m_appConfig;
} }
void createMenuBar(); void createMenuBar();
void setupTrayIcon(); void setupTrayIcon();
@ -169,21 +169,21 @@ private:
void updateStatus(); void updateStatus();
void showAndActivate(); void showAndActivate();
VersionChecker m_VersionChecker; VersionChecker m_versionChecker;
QSystemTrayIcon *m_trayIcon = nullptr; QSystemTrayIcon *m_trayIcon = nullptr;
QAbstractButton *m_pCancelButton = nullptr; QAbstractButton *m_btnCancel = nullptr;
bool m_SecureSocket = false; bool m_secureSocket = false;
deskflow::gui::config::ServerConfigDialogState m_ServerConfigDialogState; deskflow::gui::config::ServerConfigDialogState m_serverConfigDialogState;
bool m_SaveOnExit = true; bool m_saveOnExit = true;
deskflow::gui::core::WaylandWarnings m_WaylandWarnings; deskflow::gui::core::WaylandWarnings m_waylandWarnings;
deskflow::gui::ConfigScopes &m_ConfigScopes; deskflow::gui::ConfigScopes &m_configScopes;
AppConfig &m_AppConfig; AppConfig &m_appConfig;
ServerConfig m_ServerConfig; ServerConfig m_serverConfig;
deskflow::gui::CoreProcess m_CoreProcess; deskflow::gui::CoreProcess m_coreProcess;
deskflow::gui::ServerConnection m_ServerConnection; deskflow::gui::ServerConnection m_serverConnection;
deskflow::gui::ClientConnection m_ClientConnection; deskflow::gui::ClientConnection m_clientConnection;
deskflow::gui::TlsUtility m_TlsUtility; deskflow::gui::TlsUtility m_tlsUtility;
QSize m_expandedSize = QSize(); QSize m_expandedSize = QSize();
QLocalServer *m_guiDupeChecker = nullptr; QLocalServer *m_guiDupeChecker = nullptr;

View File

@ -19,13 +19,13 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Deskflow</string> <string>Deskflow</string>
</property> </property>
<widget class="QWidget" name="m_pWidgetTopLevel"> <widget class="QWidget" name="topLevelWidget">
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="_2">
<property name="spacing"> <property name="spacing">
<number>10</number> <number>10</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="m_layoutName"> <layout class="QHBoxLayout" name="layoutName">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetMinAndMaxSize</enum> <enum>QLayout::SizeConstraint::SetMinAndMaxSize</enum>
</property> </property>
@ -56,7 +56,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QLabel" name="m_pLabelUpdate"> <widget class="QLabel" name="lblUpdate">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -64,7 +64,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">m_pLabelUpdate</string> <string notr="true">lblUpdate</string>
</property> </property>
<property name="openExternalLinks"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
@ -74,7 +74,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QLabel" name="m_pLabelIpAddresses"> <widget class="QLabel" name="lblIpAddresses">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -106,7 +106,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QWidget" name="m_pWidgetModes" native="true"> <widget class="QWidget" name="widgetModes" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -130,7 +130,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QGroupBox" name="m_pGroupServer"> <widget class="QGroupBox" name="groupServer">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -142,7 +142,7 @@
<number>15</number> <number>15</number>
</property> </property>
<item alignment="Qt::AlignmentFlag::AlignTop"> <item alignment="Qt::AlignmentFlag::AlignTop">
<widget class="QWidget" name="m_pWidgetServerRadio" native="true"> <widget class="QWidget" name="widgetServerRadio" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -186,7 +186,7 @@
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignmentFlag::AlignTop"> <item alignment="Qt::AlignmentFlag::AlignTop">
<widget class="QWidget" name="m_pWidgetServer" native="true"> <widget class="QWidget" name="widgetServer" native="true">
<layout class="QVBoxLayout" name="m_pLayoutServer"> <layout class="QVBoxLayout" name="m_pLayoutServer">
<property name="spacing"> <property name="spacing">
<number>15</number> <number>15</number>
@ -204,7 +204,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QWidget" name="m_pWidgetServerInput" native="true"> <widget class="QWidget" name="widgetServerInput" native="true">
<layout class="QVBoxLayout" name="m_pLayoutServerInverse"> <layout class="QVBoxLayout" name="m_pLayoutServerInverse">
<property name="spacing"> <property name="spacing">
<number>15</number> <number>15</number>
@ -222,7 +222,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="m_pLabelClientIp"> <widget class="QLabel" name="lblClientIp">
<property name="text"> <property name="text">
<string>Client IP address or hostname:</string> <string>Client IP address or hostname:</string>
</property> </property>
@ -252,7 +252,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="deskflow::gui::widgets::ServerStateLabel" name="m_pLabelServerState"> <widget class="deskflow::gui::widgets::ServerStateLabel" name="labelServerState">
<property name="text"> <property name="text">
<string>No clients connected</string> <string>No clients connected</string>
</property> </property>
@ -305,7 +305,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="m_pGroupClient"> <widget class="QGroupBox" name="groupClient">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -317,7 +317,7 @@
<number>15</number> <number>15</number>
</property> </property>
<item alignment="Qt::AlignmentFlag::AlignTop"> <item alignment="Qt::AlignmentFlag::AlignTop">
<widget class="QWidget" name="m_pWidgetClientRadio" native="true"> <widget class="QWidget" name="widgetClientRadio" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -361,7 +361,7 @@
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignmentFlag::AlignTop"> <item alignment="Qt::AlignmentFlag::AlignTop">
<widget class="QWidget" name="m_pWidgetClientInput" native="true"> <widget class="QWidget" name="widgetClientInput" native="true">
<layout class="QVBoxLayout" name="m_pLayoutClient"> <layout class="QVBoxLayout" name="m_pLayoutClient">
<property name="spacing"> <property name="spacing">
<number>15</number> <number>15</number>
@ -448,17 +448,14 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum> <enum>QFrame::Shadow::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="_3">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="_4">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetMinAndMaxSize</enum> <enum>QLayout::SizeConstraint::SetMinAndMaxSize</enum>
</property> </property>
<item> <item>
<widget class="QToolButton" name="btnToggleLog"> <widget class="QToolButton" name="btnToggleLog">
<property name="text">
<string>...</string>
</property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -496,9 +493,6 @@
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
</property> </property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="lineWrapMode"> <property name="lineWrapMode">
<enum>QPlainTextEdit::LineWrapMode::NoWrap</enum> <enum>QPlainTextEdit::LineWrapMode::NoWrap</enum>
</property> </property>
@ -514,7 +508,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="m_pLayoutActions"> <layout class="QHBoxLayout" name="layoutActions">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
@ -544,7 +538,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="m_pStatusLabel"> <widget class="QLabel" name="lblStatus">
<property name="text"> <property name="text">
<string>Ready</string> <string>Ready</string>
</property> </property>
@ -564,12 +558,12 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QLabel" name="m_pLabelNotice"> <widget class="QLabel" name="lblNotice">
<property name="autoFillBackground"> <property name="autoFillBackground">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">m_pLabelNotice</string> <string notr="true">lblNotice</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set> <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>