deskflow/src/lib/gui/MainWindow.cpp

1245 lines
40 KiB
C++
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2024 - 2026 Chris Rizzitello <sithord48@gmail.com>
* SPDX-FileCopyrightText: (C) 2012 - 2024 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
*/
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "Diagnostic.h"
#include "StyleUtils.h"
#include "dialogs/AboutDialog.h"
#include "dialogs/ClientConfigDialog.h"
2025-02-09 16:16:15 +00:00
#include "dialogs/FingerprintDialog.h"
#include "dialogs/ServerConfigDialog.h"
#include "dialogs/SettingsDialog.h"
#include "common/PlatformInfo.h"
#include "common/Settings.h"
#include "common/UrlConstants.h"
#include "common/VersionInfo.h"
#include "gui/Messages.h"
#include "gui/TlsUtility.h"
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
#include "gui/core/CoreProcess.h"
#include "gui/ipc/DaemonIpcClient.h"
#include "gui/widgets/LogDock.h"
#include "net/FingerprintDatabase.h"
#include "widgets/StatusBar.h"
2012-06-10 16:50:54 +00:00
#include <QCloseEvent>
#include <QDesktopServices>
#include <QFileDialog>
#include <QLocalServer>
#include <QLocalSocket>
2014-02-14 16:21:02 +00:00
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkInterface>
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
#include <QPushButton>
#include <QRegularExpression>
#include <QRegularExpressionValidator>
#include <QScreen>
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
#include <QScrollBar>
#include <memory>
2012-06-10 16:50:54 +00:00
#if defined(Q_OS_MACOS)
2012-06-10 16:50:54 +00:00
#include <ApplicationServices/ApplicationServices.h>
#endif
using namespace deskflow::gui;
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
MainWindow::MainWindow()
: ui{std::make_unique<Ui::MainWindow>()},
m_coreProcess(m_serverConfig),
m_serverConnection(this, m_serverConfig),
m_clientConnection(this),
m_trayIcon{new QSystemTrayIcon(this)},
m_guiDupeChecker{new QLocalServer(this)},
m_daemonIpcClient{new ipc::DaemonIpcClient(this)},
m_logDock{new LogDock(this)},
m_statusBar{new StatusBar(this)},
m_menuFile{new QMenu(this)},
m_menuEdit{new QMenu(this)},
m_menuView{new QMenu(this)},
m_menuHelp{new QMenu(this)},
m_actionAbout{new QAction(this)},
m_actionClearSettings{new QAction(this)},
m_actionReportBug{new QAction(this)},
m_actionMinimize{new QAction(this)},
m_actionQuit{new QAction(this)},
m_actionTrayQuit{new QAction(this)},
m_actionRestore{new QAction(this)},
m_actionSettings{new QAction(this)},
m_actionStartCore{new QAction(this)},
m_actionRestartCore{new QAction(this)},
m_actionStopCore{new QAction(this)},
m_networkMonitor{new NetworkMonitor(this)}
{
ui->setupUi(this);
setWindowIcon(QIcon::fromTheme(kRevFqdnName));
addDockWidget(Qt::BottomDockWidgetArea, m_logDock);
// Setup Actions
m_actionAbout->setMenuRole(QAction::AboutRole);
m_actionAbout->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::HelpAbout));
m_actionMinimize->setIcon(QIcon::fromTheme(QStringLiteral("window-minimize-pip")));
m_actionRestore->setIcon(QIcon::fromTheme(QStringLiteral("window-restore-pip")));
if (!deskflow::platform::isWindows()) {
m_actionQuit->setShortcut(QKeySequence::Quit);
m_actionTrayQuit->setShortcut(QKeySequence::Quit);
}
m_actionQuit->setIcon(QIcon::fromTheme("application-exit"));
m_actionQuit->setMenuRole(QAction::QuitRole);
m_actionTrayQuit->setIcon(QIcon::fromTheme("application-exit"));
m_actionTrayQuit->setMenuRole(QAction::NoRole);
m_actionClearSettings->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear-all")));
m_actionClearSettings->setMenuRole(QAction::NoRole);
m_actionSettings->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
m_actionSettings->setMenuRole(QAction::PreferencesRole);
m_actionStartCore->setIcon(QIcon::fromTheme(QStringLiteral("system-run")));
m_actionStartCore->setMenuRole(QAction::NoRole);
2025-06-04 02:48:03 +00:00
m_actionRestartCore->setVisible(false);
m_actionRestartCore->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
m_actionRestartCore->setMenuRole(QAction::NoRole);
2025-06-04 02:48:03 +00:00
m_actionStopCore->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::ProcessStop));
m_actionStopCore->setMenuRole(QAction::NoRole);
m_actionReportBug->setIcon(QIcon::fromTheme(QStringLiteral("tools-report-bug")));
m_actionReportBug->setMenuRole(QAction::NoRole);
// Setup the Instance Checking
// In case of a previous crash remove first
QLocalServer::removeServer(m_guiSocketName);
m_guiDupeChecker->listen(m_guiSocketName);
createMenuBar();
setupControls();
updateText();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
connectSlots();
setupTrayIcon();
updateScreenName();
qDebug().noquote() << "active settings path:" << Settings::settingsPath();
// Force generation of a certificate on the host
if (TlsUtility::isEnabled()) {
if (Settings::value(Settings::Security::KeySize).toInt() < 2048) {
QMessageBox::information(
this, kAppName,
tr("Your current TLS key is smaller than the minimum allowed size, A new key 2048-bit key will be generated.")
);
Settings::setValue(Settings::Security::KeySize, 2048);
}
if (!TlsUtility::isCertValid()) {
generateCertificate();
} else {
m_fingerprint = {QCryptographicHash::Sha256, TlsUtility::certFingerprint()};
}
}
applyConfig();
m_statusBar->setSecurityIcon(TlsUtility::isEnabled());
restoreWindow();
}
MainWindow::~MainWindow()
{
// Stop network monitoring
if (m_networkMonitor) {
m_networkMonitor->stopMonitoring();
}
m_guiDupeChecker->close();
m_coreProcess.cleanup();
}
void MainWindow::restoreWindow()
{
auto windowGeometry = Settings::value(Settings::Gui::WindowGeometry).toRect();
const auto totalGeometry = QGuiApplication::primaryScreen()->availableGeometry();
if (!windowGeometry.isValid()) {
adjustSize();
windowGeometry = geometry();
} else {
setGeometry(windowGeometry);
}
m_expandedSize = geometry().size();
if (!totalGeometry.contains(windowGeometry)) {
QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
move(screenGeometry.center() - rect().center());
}
if (!Settings::value(Settings::Gui::LogExpanded).toBool())
setFixedSize(size());
}
void MainWindow::setupControls()
{
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
secureSocket(false);
ui->btnConfigureServer->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
ui->btnConfigureClient->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
if (Settings::value(Settings::Core::LastVersion).toString() != kVersion) {
Settings::setValue(Settings::Core::LastVersion, kVersion);
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
if (!Settings::value(Settings::Gui::LogExpanded).toBool()) {
m_logDock->hide();
}
ui->serverOptions->setVisible(false);
ui->clientOptions->setVisible(false);
const auto coreMode = Settings::value(Settings::Core::CoreMode).value<Settings::CoreMode>();
ui->rbModeClient->setChecked(coreMode == Settings::CoreMode::Client);
ui->rbModeServer->setChecked(coreMode == Settings::CoreMode::Server);
ui->lineEditName->setValidator(new QRegularExpressionValidator(m_nameRegEx, this));
ui->lineEditName->setVisible(false);
ui->lineEditName->installEventFilter(this);
if (deskflow::platform::isMac()) {
ui->rbModeServer->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->rbModeClient->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->btnSaveServerConfig->setFixedWidth(ui->btnSaveServerConfig->height());
} else {
ui->btnSaveServerConfig->setIconSize(QSize(22, 22));
}
setStatusBar(m_statusBar);
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
//////////////////////////////////////////////////////////////////////////////
// Begin slots
//////////////////////////////////////////////////////////////////////////////
// remember: using queued connection allows the render loop to run before
// executing the slot. the default is to instantly call the slot when the
// signal is emitted from the thread that owns the receiver's object.
void MainWindow::connectSlots()
{
connect(Settings::instance(), &Settings::serverSettingsChanged, this, &MainWindow::serverConfigSaving);
connect(Settings::instance(), &Settings::settingsChanged, this, &MainWindow::settingsChanged);
connect(&m_coreProcess, &CoreProcess::error, this, &MainWindow::coreProcessError);
connect(&m_coreProcess, &CoreProcess::logLine, this, &MainWindow::handleLogLine);
connect(
&m_coreProcess, &CoreProcess::processStateChanged, this, &MainWindow::coreProcessStateChanged,
Qt::QueuedConnection
);
connect(&m_coreProcess, &CoreProcess::connectionStateChanged, this, &MainWindow::coreConnectionStateChanged);
connect(&m_coreProcess, &CoreProcess::secureSocket, this, &MainWindow::secureSocket);
connect(
&m_coreProcess, &CoreProcess::daemonIpcClientConnectionFailed, this, &MainWindow::daemonIpcClientConnectionFailed
);
connect(&m_coreProcess, &CoreProcess::securityLevelChanged, m_statusBar, &StatusBar::setSecurityLevel);
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
connect(m_actionAbout, &QAction::triggered, this, &MainWindow::openAboutDialog);
connect(m_actionClearSettings, &QAction::triggered, this, &MainWindow::clearSettings);
connect(m_actionReportBug, &QAction::triggered, this, &MainWindow::openHelpUrl);
connect(m_actionMinimize, &QAction::triggered, this, &MainWindow::hide);
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
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_actionSettings, &QAction::triggered, this, &MainWindow::openSettings);
connect(m_actionStartCore, &QAction::triggered, this, &MainWindow::startCore);
2025-06-04 02:48:03 +00:00
connect(m_actionRestartCore, &QAction::triggered, this, &MainWindow::resetCore);
connect(m_actionStopCore, &QAction::triggered, this, &MainWindow::stopCore);
// Mac os tray will only show a menu
if (!deskflow::platform::isMac())
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
connect(&m_serverConnection, &ServerConnection::configureClient, this, &MainWindow::serverConnectionConfigureClient);
connect(&m_serverConnection, &ServerConnection::clientsChanged, this, &MainWindow::serverClientsChanged);
connect(
&m_serverConnection, &ServerConnection::requestNewClientPrompt, this, &MainWindow::handleNewClientPromptRequest
);
connect(&m_clientConnection, &ClientConnection::requestShowError, this, &MainWindow::showClientError);
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);
connect(ui->lineHostname, &QLineEdit::textChanged, this, &MainWindow::remoteHostChanged);
connect(ui->btnSaveServerConfig, &QPushButton::clicked, this, &MainWindow::saveServerConfig);
connect(ui->btnConfigureServer, &QPushButton::clicked, this, [this] { showConfigureServer(""); });
connect(ui->btnConfigureClient, &QPushButton::clicked, this, [this] { showConfigureClient(); });
connect(ui->lblComputerName, &QLabel::linkActivated, this, &MainWindow::openSettings);
connect(ui->rbModeServer, &QRadioButton::toggled, this, &MainWindow::coreModeToggled);
connect(ui->rbModeClient, &QRadioButton::toggled, this, &MainWindow::coreModeToggled);
connect(m_logDock->toggleViewAction(), &QAction::toggled, this, &MainWindow::toggleLogVisible);
connect(m_statusBar, &StatusBar::requestShowMyFingerprints, this, &MainWindow::showMyFingerprint);
connect(m_statusBar, &StatusBar::requestUpdateVersion, this, &MainWindow::openGetNewVersionUrl);
connect(&m_versionChecker, &VersionChecker::updateFound, m_statusBar, &StatusBar::updateFound);
connect(m_guiDupeChecker, &QLocalServer::newConnection, this, &MainWindow::showAndActivate);
connect(ui->btnEditName, &QPushButton::clicked, this, &MainWindow::showHostNameEditor);
connect(ui->lineEditName, &QLineEdit::editingFinished, this, &MainWindow::setHostName);
connect(m_networkMonitor, &NetworkMonitor::ipAddressesChanged, this, &MainWindow::updateIpLabel);
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::toggleLogVisible(bool visible)
{
// When the main window is hidden e.g. close to tray / minimized), this also triggers the log visibility toggle,
// but we don't want to hide the log in this case since we would need to un-hide it when the window is shown again.
if (!isVisible() || isMinimized()) {
qDebug() << "not toggling log, window not visible";
return;
}
setFixedSize(16777215, 16777215);
Settings::setValue(Settings::Gui::LogExpanded, visible);
if (visible) {
if (m_logDock->isFloating()) {
adjustSize();
setFixedSize(size());
} else {
QTimer::singleShot(15, this, [&] { resize(m_expandedSize); });
}
} else {
if (!m_logDock->isFloating()) {
m_expandedSize = geometry().size();
}
m_logDock->hide();
if (!m_logDock->isFloating()) {
adjustSize();
}
setFixedSize(size());
}
Settings::setValue(Settings::Gui::WindowGeometry, geometry());
}
void MainWindow::settingsChanged(const QString &key)
{
if (key == Settings::Log::Level) {
m_coreProcess.applyLogLevel();
return;
}
if (key == Settings::Core::ComputerName)
updateScreenName();
if ((key == Settings::Security::Certificate) || (key == Settings::Security::KeySize) ||
(key == Settings::Security::TlsEnabled) || (key == Settings::Security::CheckPeers)) {
if (TlsUtility::isEnabled() && !TlsUtility::isCertValid()) {
qWarning() << tr("invalid certificate, generating a new one");
TlsUtility::generateCertificate();
}
updateSecurityIcon(m_statusBar->securityIconVisible());
return;
}
}
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
void MainWindow::serverConfigSaving()
{
m_serverConfig.commit();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if (reason != QSystemTrayIcon::Trigger)
return;
isVisible() ? hide() : showAndActivate();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::coreProcessError(CoreProcess::Error error)
{
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
if (error == CoreProcess::Error::AddressMissing) {
QMessageBox::warning(
this, tr("Address missing"), tr("Please enter the hostname or IP address of the other computer.")
);
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
} else if (error == CoreProcess::Error::StartFailed) {
show();
QMessageBox::warning(
this, tr("Core cannot be started"),
tr("The Core executable could not be successfully started, "
"although it does exist. "
"Please check if you have sufficient permissions to run this program.")
);
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
}
void MainWindow::startCore()
{
// Save current IP state when server starts
if (m_coreProcess.mode() == CoreMode::Server && Settings::value(Settings::Core::Interface).toString().isEmpty()) {
m_serverStartIPs = NetworkMonitor::validAddresses();
m_serverStartSuggestedIP = m_serverStartIPs.isEmpty() ? "" : m_serverStartIPs.first();
}
m_coreProcess.start();
2025-06-04 02:48:03 +00:00
m_actionStartCore->setVisible(false);
m_actionRestartCore->setVisible(true);
}
void MainWindow::stopCore()
{
qDebug() << "stopping core process";
m_coreProcess.stop();
2025-06-04 02:48:03 +00:00
m_actionStartCore->setVisible(true);
m_actionRestartCore->setVisible(false);
}
void MainWindow::clearSettings()
{
if (!messages::showClearSettings(this)) {
qDebug() << "clear settings cancelled";
return;
}
m_networkMonitor->stopMonitoring();
disconnect(&m_coreProcess, nullptr, this, nullptr);
disconnect(&m_serverConnection, nullptr, this, nullptr);
disconnect(&m_clientConnection, nullptr, this, nullptr);
disconnect(&m_versionChecker, nullptr, this, nullptr);
disconnect(m_guiDupeChecker, nullptr, this, nullptr);
disconnect(m_trayIcon, nullptr, this, nullptr);
disconnect(m_logDock->toggleViewAction(), nullptr, this, nullptr);
m_coreProcess.stop();
m_coreProcess.clearSettings();
m_saveOnExit = false;
diagnostic::clearSettings(true);
}
bool MainWindow::saveServerConfig()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save server configuration as..."));
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
if (!fileName.isEmpty() && !m_serverConfig.save(fileName)) {
QMessageBox::warning(this, tr("Save failed"), tr("Could not save server configuration to file."));
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
return true;
}
return false;
}
void MainWindow::openAboutDialog()
{
AboutDialog about(this);
about.exec();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::openHelpUrl() const
{
QDesktopServices::openUrl(QUrl(kUrlHelp));
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::openGetNewVersionUrl() const
{
QDesktopServices::openUrl(QUrl(kUrlDownload));
}
void MainWindow::openSettings()
{
auto dialog = SettingsDialog(this, m_serverConfig);
if (dialog.exec() == QDialog::Accepted) {
Settings::save();
applyConfig();
if (m_coreProcess.isStarted()) {
m_coreProcess.restart();
}
}
2012-06-10 16:50:54 +00:00
}
void MainWindow::resetCore()
{
m_coreProcess.restart();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::showMyFingerprint()
{
FingerprintDialog fingerprintDialog(this, m_fingerprint);
2025-02-09 16:16:15 +00:00
fingerprintDialog.exec();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::coreModeToggled(bool checked)
{
// this method is called when rbClient or rbServer toggles
// with both being in the same group one must be turned on if the other is turned off
// only react to toggle on to avoid calling everything twice when the user switches modes
if (!checked)
return;
Settings::CoreMode mode = Settings::CoreMode::None;
if (ui->rbModeServer->isChecked())
mode = Settings::CoreMode::Server;
if (ui->rbModeClient->isChecked())
mode = Settings::CoreMode::Client;
qDebug() << QStringLiteral("change mode to: %1").arg(QVariant::fromValue(mode).toString());
if (m_coreProcess.isStarted() && m_coreProcess.mode() != mode)
m_coreProcess.stop();
m_coreProcess.setMode(mode);
Settings::setValue(Settings::Core::CoreMode, mode);
Settings::save();
updateModeControls();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::updateModeControls()
{
const auto mode = m_coreProcess.mode();
const bool isServer = mode == Settings::CoreMode::Server;
const bool isClient = mode == Settings::CoreMode::Client;
ui->serverOptions->setVisible(isServer);
ui->lblIpAddresses->setVisible(isServer);
ui->clientOptions->setVisible(isClient);
ui->lblNoMode->setVisible(!isServer && !isClient);
toggleCanRunCore(canRunCore());
if (isServer) {
updateNetworkInfo();
m_networkMonitor->startMonitoring();
} else {
m_networkMonitor->stopMonitoring();
}
if (isServer || isClient)
updateModeControlLabels();
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
}
void MainWindow::updateModeControlLabels()
{
const bool isServer = m_coreProcess.mode() == CoreMode::Server;
const bool isStarted = m_coreProcess.isStarted();
QString startText;
QString stopText;
QIcon startIcon;
QIcon stopIcon;
if (isServer) {
startText = tr("Start");
stopText = tr("Stop");
startIcon = QIcon::fromTheme(QStringLiteral("system-run"));
stopIcon = QIcon::fromTheme(QIcon::ThemeIcon::ProcessStop);
} else {
startText = tr("Connect");
stopText = tr("Disconnect");
startIcon = QIcon::fromTheme(QStringLiteral("network-connect"));
stopIcon = QIcon::fromTheme(QStringLiteral("network-disconnect"));
}
m_actionStartCore->setText(startText);
m_actionStartCore->setIcon(startIcon);
m_actionStopCore->setText(stopText);
m_actionStopCore->setIcon(stopIcon);
if (isStarted) {
ui->btnToggleCore->setText(stopText);
ui->btnToggleCore->setIcon(stopIcon);
} else {
ui->btnToggleCore->setText(startText);
ui->btnToggleCore->setIcon(startIcon);
}
}
void MainWindow::updateSecurityIcon(bool visible)
{
m_statusBar->setSecurityIconVisible(visible);
if (!visible)
return;
m_statusBar->setSecurityIcon(TlsUtility::isEnabled());
}
void MainWindow::updateNetworkInfo()
{
updateIpLabel(NetworkMonitor::validAddresses());
}
void MainWindow::serverConnectionConfigureClient(const QString &clientName)
{
m_serverConnection.serverConfigDialogVisible(true);
ServerConfigDialog dialog(this, m_serverConfig);
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
if (dialog.addClient(clientName) && dialog.exec() == QDialog::Accepted) {
m_coreProcess.restart();
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
}
m_serverConnection.serverConfigDialogVisible(false);
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
}
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
//////////////////////////////////////////////////////////////////////////////
// End slots
//////////////////////////////////////////////////////////////////////////////
void MainWindow::open()
{
Settings::value(Settings::Gui::Autohide).toBool() ? hide() : showAndActivate();
// if a critical error was shown just before the main window (i.e. on app
// load), it will be hidden behind the main window. therefore we need to raise
// it up in front of the main window.
// HACK: because the `onShown` event happens just as the window is shown, the
// message box has a chance of being raised under the main window. to solve
// this we delay the error dialog raise by a split second. this seems a bit
// hacky and fragile, so maybe there's a better approach.
const auto kCriticalDialogDelay = 100;
QTimer::singleShot(kCriticalDialogDelay, this, &messages::raiseCriticalDialog);
if (!Settings::value(Settings::Gui::AutoUpdateCheck).isValid()) {
Settings::setValue(Settings::Gui::AutoUpdateCheck, messages::showUpdateCheckOption(this));
}
if (Settings::value(Settings::Gui::AutoUpdateCheck).toBool()) {
m_versionChecker.checkLatest();
} else {
qDebug() << "skipping check for new version, disabled";
}
if (Settings::value(Settings::Gui::AutoStartCore).toBool()) {
if (ui->rbModeClient->isChecked() && ui->lineHostname->text().isEmpty())
return;
2025-06-04 02:48:03 +00:00
startCore();
}
}
void MainWindow::createMenuBar()
{
m_menuFile->addAction(m_actionStartCore);
m_menuFile->addAction(m_actionRestartCore);
m_menuFile->addAction(m_actionStopCore);
m_menuFile->addSeparator();
m_menuFile->addAction(m_actionQuit);
m_menuEdit->addAction(m_actionSettings);
m_menuView->addAction(m_logDock->toggleViewAction());
m_menuHelp->addAction(m_actionAbout);
m_menuHelp->addAction(m_actionReportBug);
m_menuHelp->addSeparator();
m_menuHelp->addAction(m_actionClearSettings);
auto menuBar = new QMenuBar(this);
menuBar->addMenu(m_menuFile);
menuBar->addMenu(m_menuEdit);
menuBar->addMenu(m_menuView);
menuBar->addMenu(m_menuHelp);
setMenuBar(menuBar);
2012-06-10 16:50:54 +00:00
}
void MainWindow::setupTrayIcon()
{
auto trayMenu = new QMenu(this);
2025-06-04 02:48:03 +00:00
trayMenu->addActions(
{m_actionStartCore, m_actionRestartCore, m_actionStopCore, m_actionMinimize, m_actionRestore, m_actionTrayQuit}
);
trayMenu->insertSeparator(m_actionMinimize);
trayMenu->insertSeparator(m_actionTrayQuit);
m_trayIcon->setContextMenu(trayMenu);
setTrayIcon();
m_trayIcon->show();
}
void MainWindow::applyConfig()
{
if (Settings::value(Settings::Gui::ShowVersionInTitle).toBool()) {
setWindowTitle(QStringLiteral("%1 - %2").arg(kAppName, kDisplayVersion));
} else {
setWindowTitle(kAppName);
}
if (const auto host = Settings::value(Settings::Client::RemoteHost).toString(); !host.isEmpty())
ui->lineHostname->setText(host);
updateLocalFingerprint();
setTrayIcon();
if (const auto ip = Settings::value(Settings::Core::Interface).toString(); !ip.isEmpty()) {
m_serverStartIPs = {ip};
m_serverStartSuggestedIP = ip;
}
coreModeToggled(true);
}
void MainWindow::saveSettings() const
{
if (ui->rbModeClient->isChecked()) {
Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Client);
} else if (ui->rbModeServer->isChecked()) {
Settings::setValue(Settings::Core::CoreMode, Settings::CoreMode::Server);
}
if (!ui->lineHostname->text().isEmpty())
Settings::setValue(Settings::Client::RemoteHost, ui->lineHostname->text());
Settings::save();
2012-06-10 16:50:54 +00:00
}
void MainWindow::setTrayIcon()
{
2025-10-29 16:01:04 +00:00
static const auto fallbackPath = QStringLiteral(":/icons/%1-%2/apps/64/%3");
QString themeIcon = kRevFqdnName;
if (!Settings::value(Settings::Gui::SymbolicTrayIcon).toBool()) {
if (deskflow::platform::isMac())
m_trayIcon->setIcon(QIcon::fromTheme(themeIcon));
else
m_trayIcon->setIcon(QIcon(fallbackPath.arg(kAppId, QStringLiteral("dark"), themeIcon)));
return;
}
themeIcon.append(QStringLiteral("-symbolic"));
if (deskflow::platform::isWindows()) {
QSettings settings(
QStringLiteral("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"),
QSettings::NativeFormat
);
const QString theme = settings.value(QStringLiteral("SystemUsesLightTheme"), 1).toBool() ? QStringLiteral("light")
: QStringLiteral("dark");
m_trayIcon->setIcon(QIcon(fallbackPath.arg(kAppId, theme, themeIcon)));
return;
}
2025-10-29 16:01:04 +00:00
auto icon = QIcon::fromTheme(themeIcon, QIcon(fallbackPath.arg(kAppId, iconMode(), themeIcon)));
icon.setIsMask(true);
m_trayIcon->setIcon(icon);
}
void MainWindow::handleLogLine(const QString &line)
{
m_logDock->appendLine(line);
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
updateFromLogLine(line);
}
void MainWindow::updateFromLogLine(const QString &line)
{
checkConnected(line);
checkFingerprint(line);
}
void MainWindow::checkConnected(const QString &line)
{
if (ui->rbModeServer->isChecked()) {
m_serverConnection.handleLogLine(line);
} else {
m_clientConnection.handleLogLine(line);
}
}
void MainWindow::checkFingerprint(const QString &line)
{
static const auto tlsPeerMessage = QStringLiteral("peer fingerprint: ");
static const qsizetype msgLen = QString(tlsPeerMessage).length();
const qsizetype midStart = line.indexOf(tlsPeerMessage);
if (midStart == -1)
return;
const auto sha256Text = line.mid(midStart + msgLen).remove(':');
const Fingerprint sha256 = {QCryptographicHash::Sha256, QByteArray::fromHex(sha256Text.toLatin1())};
const bool isClient = m_coreProcess.mode() == CoreMode::Client;
if ((isClient && m_checkedServers.contains(sha256Text)) || (!isClient && m_checkedClients.contains(sha256Text))) {
qDebug("ignoring fingerprint, already handled");
return;
}
FingerprintDatabase db;
db.read(trustedFingerprintDatabase());
if (db.isTrusted(sha256)) {
qDebug("fingerprint is trusted");
return;
}
if (isClient) {
m_checkedServers.append(sha256Text);
m_coreProcess.stop();
} else {
m_checkedClients.append(sha256Text);
}
auto mode = isClient ? FingerprintDialogMode::Client : FingerprintDialogMode::Server;
FingerprintDialog fingerprintDialog(this, m_fingerprint, mode, sha256);
2025-02-09 16:16:15 +00:00
if (fingerprintDialog.exec() == QDialog::Accepted) {
db.addTrusted(sha256);
if (!db.write(trustedFingerprintDatabase())) {
qCritical().noquote() << "unable to write fingerprint to db:" << trustedFingerprintDatabase();
m_coreProcess.stop();
return;
}
if (isClient) {
m_checkedServers.removeAll(sha256Text);
m_coreProcess.start();
} else {
m_checkedClients.removeAll(sha256Text);
}
}
2012-06-10 16:50:54 +00:00
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if (Settings::value(Settings::Gui::CloseToTray).toBool() && event->spontaneous()) {
if (Settings::value(Settings::Gui::CloseReminder).toBool()) {
messages::showCloseReminder(this);
Settings::setValue(Settings::Gui::CloseReminder, false);
}
Settings::setValue(Settings::Gui::WindowGeometry, geometry());
qDebug() << "hiding to tray";
hide();
event->ignore();
return;
}
if (m_saveOnExit) {
Settings::setValue(Settings::Gui::WindowGeometry, geometry());
Settings::setValue(Settings::Gui::AutoStartCore, m_coreProcess.isStarted());
}
qDebug() << "quitting application";
// any connected dock view acitons will be triggered
// disconnect them before accepting the event
disconnect(m_logDock->toggleViewAction(), &QAction::toggled, nullptr, nullptr);
event->accept();
QApplication::quit();
}
void MainWindow::showFirstConnectedMessage()
{
if (Settings::value(Settings::Gui::ShownFirstConnectedMessage).toBool())
return;
Settings::setValue(Settings::Gui::ShownFirstConnectedMessage, true);
const auto isServer = m_coreProcess.mode() == CoreMode::Server;
const auto closeToTray = Settings::value(Settings::Gui::CloseToTray).toBool();
using ProcessMode = Settings::ProcessMode;
const auto enableService = Settings::value(Settings::Core::ProcessMode).value<ProcessMode>() == ProcessMode::Service;
messages::showFirstConnectedMessage(this, closeToTray, enableService, isServer);
}
void MainWindow::updateStatus()
{
using enum ProcessState;
const auto connection = m_coreProcess.connectionState();
const auto process = m_coreProcess.processState();
const bool isServer = (m_coreProcess.mode() == CoreMode::Server);
if (process == Stopped || process == Started) {
updateNetworkInfo();
ui->btnEditName->setVisible(process == Stopped);
}
m_statusBar->setStatus(connection, process, isServer);
}
void MainWindow::coreProcessStateChanged(ProcessState state)
{
using enum ProcessState;
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
updateStatus();
if (state == Started) {
qDebug() << "recording that core has started";
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";
messages::showFirstServerStartMessage(this);
Settings::setValue(Settings::Gui::ShownServerFirstStartMessage, true);
}
}
if (state == Started || state == Starting || state == RetryPending) {
disconnect(ui->btnToggleCore, &QPushButton::clicked, m_actionStartCore, &QAction::trigger);
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStopCore, &QAction::trigger, Qt::UniqueConnection);
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
ui->btnRestartCore->setEnabled(true);
2025-06-04 02:48:03 +00:00
m_actionStartCore->setVisible(false);
m_actionRestartCore->setVisible(true);
m_actionStopCore->setEnabled(true);
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
if (state == Starting) {
saveSettings();
}
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
} else {
disconnect(ui->btnToggleCore, &QPushButton::clicked, m_actionStopCore, &QAction::trigger);
connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStartCore, &QAction::trigger, Qt::UniqueConnection);
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
ui->btnRestartCore->setEnabled(false);
2025-06-04 02:48:03 +00:00
m_actionStartCore->setVisible(true);
m_actionRestartCore->setVisible(false);
m_actionStopCore->setEnabled(false);
}
updateModeControlLabels();
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
}
void MainWindow::coreConnectionStateChanged(ConnectionState state)
{
qDebug() << "core connection state changed: " << static_cast<int>(state);
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
updateStatus();
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
// always assume connection is not secure when connection changes
// to anything except connected. the only way the padlock shows is
// when the correct TLS version string is detected.
if (state != ConnectionState::Connected) {
Refactored core process management and IPC client (#7425) * Also ignore `command_pre` for Fedora itself * Improve warning message * Fixed layout issues on main window * Restore fusion theme for Windows dark mode * Further correct main window layout * Set CWD for launch on Windows to same dir as .env * Use signals for tray icon instead of callback * Reduce complexity for setting tray icon * Further reduce tray icon complexity * Reduce tray retry time * Fixed tray not showing on macOS * Refactor function names * Move tray icon to lib * Decouple server connection class * Move server connection to lib * Move client config to lib * Remove redundant forward declarations * Fixed some namespaces in the new lib * Move core process code to new class * Improve member names on new process class * Remove copy/pasta code * Move OSX helpers to lib * Add .mm to lib config * Fixed copyright * Improve reliability of log line handling * Fixed TLS certificate generate bugs * Remove client list * Refactor core process handling to fix various problems * Fixed process/connection status bugs * Fixed function signature issue on macOS * Fixed override warnings * Fixed string format warning * Save `wasStarted` state and use that instead * Use only filename in dialog * Use lambda for simple slot * Scroll to bottom if at bottome * Set value based on position before text added and set horizontal scroll too * Add 1px tollerance for Linux * Simplify start/stop mutex * Always stop service on restart * Increase scroll bottom threshold to 2 * Log warning instead of critical * Fixed long-standing dir CD-up hack * Remove include * Remove include * Fixed rogue dumbisense includes * Account for optional distro_like * Add QAction include to solve incomplete type * Remove rogue #pragma * Static cast log value * Solve event queue delete warning * Fixed integ test on Windows 10 * Reduce enum verbosity * Use static instance instead of global * Make function const * Use unique_ptr instead of new and delete, and made some functions const * Fixed smart pointer use * Fixed variable shadowing * Fixed wrong use of using * Fixed missing namespace using * Simplify TLS error handling * Improve UX around certificate errors and success * Decouple app config from core process through interface * First iteration of core process test * Mark dtor as override * Rename attach launch entry * Add TODO * Create proxy for process * Move IPC client to deps * Fixed warnings * Reorganize new GUI lib dir structure * Update includes to reflect new paths * Reorg GUI tests * Abstract IPC client * Refactor about screen * Fixed .ui warnings * Remove redundant include * Fixed typo * Fixed typos and add spelling * Fixed misleading function name * Improve comment * Improve code coverage for core process * Remove noisy log line * Make global const * Use default dtor * Use vector instead of new * Make ctor explicit * Make ctor explicit (2) * Use enum class * Fixed bad enum * Stub out core tool * Stub out dir operation * Extract byte functions * Add missing return path * Simplify byte/int functions * Fix truncation * Use ctor member assignment * Fixed segfault in process proxy * Fixed print warning * Make function const * Cleanup header * Fixed missing name * Update ChangeLog * Make more functions const
2024-08-07 14:05:18 +00:00
secureSocket(false);
} else if (isVisible()) {
showFirstConnectedMessage();
}
2012-06-10 16:50:54 +00:00
}
void MainWindow::updateLocalFingerprint()
{
m_statusBar->setBtnFingerprintVisible(TlsUtility::isEnabled() && !m_fingerprint.data.isEmpty());
}
void MainWindow::hide()
{
#ifdef Q_OS_MACOS
macOSNativeHide();
#else
QMainWindow::hide();
#endif
m_actionRestore->setVisible(true);
m_actionMinimize->setVisible(false);
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
if (e->type() == QEvent::PaletteChange) {
updateIconTheme();
setWindowIcon(QIcon::fromTheme(kRevFqdnName));
setTrayIcon();
} else if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
updateModeControlLabels();
updateNetworkInfo();
updateStatus();
serverClientsChanged(m_serverConnection.connectedClients());
updateText();
}
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj != ui->lineEditName || event->type() != QEvent::KeyPress)
return false;
if (const auto keyEvent = static_cast<QKeyEvent *>(event); keyEvent->key() != Qt::Key_Escape)
return false;
ui->lineEditName->hide();
ui->lblComputerName->show();
ui->btnEditName->show();
ui->lineEditName->setText(Settings::value(Settings::Core::ComputerName).toString());
toggleCanRunCore(canRunCore());
return true;
}
void MainWindow::updateText()
{
m_menuFile->setTitle(tr("&File"));
m_menuEdit->setTitle(tr("&Edit"));
m_menuView->setTitle(tr("&View"));
m_menuHelp->setTitle(tr("&Help"));
m_actionClearSettings->setText(tr("Clear settings"));
m_actionReportBug->setText(tr("Report a Bug"));
m_actionMinimize->setText(tr("&Minimize to tray"));
m_actionQuit->setText(tr("&Quit"));
m_actionTrayQuit->setText(tr("&Quit"));
//: %1 will be the replaced with the appname
m_actionRestore->setText(tr("&Open %1").arg(kAppName));
m_actionSettings->setText(tr("&Preferences"));
m_actionStartCore->setText(tr("&Start"));
m_actionRestartCore->setText(tr("Rest&art"));
m_actionStopCore->setText(tr("S&top"));
//: %1 will be the replaced with the appname
m_actionAbout->setText(tr("About %1...").arg(kAppName));
//: start / restart core shortcut
m_actionStartCore->setShortcut(QKeySequence(tr("Ctrl+S")));
m_actionRestartCore->setShortcut(QKeySequence(tr("Ctrl+S")));
//: stop core shortcut
m_actionStopCore->setShortcut(QKeySequence(tr("Ctrl+T")));
if (deskflow::platform::isWindows()) {
//: Quit shortcut
m_actionQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
m_actionTrayQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
}
}
void MainWindow::showConfigureServer(const QString &message)
{
ServerConfigDialog dialog(this, serverConfig());
dialog.message(message);
if ((dialog.exec() == QDialog::Accepted) && m_coreProcess.isStarted()) {
m_coreProcess.restart();
}
2012-06-10 16:50:54 +00:00
}
void MainWindow::showConfigureClient()
{
ClientConfigDialog dialog(this);
if ((dialog.exec() == QDialog::Accepted) && m_coreProcess.isStarted()) {
m_coreProcess.restart();
}
}
void MainWindow::secureSocket(bool secureSocket)
{
m_secureSocket = secureSocket;
updateSecurityIcon(m_statusBar->securityIconVisible());
}
void MainWindow::updateScreenName()
{
const auto screenName = Settings::value(Settings::Core::ComputerName).toString();
ui->lblComputerName->setText(screenName);
ui->lineEditName->setText(screenName);
m_serverConfig.updateServerName();
}
void MainWindow::showAndActivate()
{
const auto wasVisible = isVisible();
#ifdef Q_OS_MACOS
forceAppActive();
#endif
2024-12-22 21:30:52 +00:00
showNormal();
raise();
activateWindow();
m_actionRestore->setVisible(false);
m_actionMinimize->setVisible(true);
if (!wasVisible)
restoreWindow();
}
void MainWindow::showHostNameEditor()
{
ui->lineEditName->show();
ui->lblComputerName->hide();
ui->btnEditName->hide();
toggleCanRunCore(false);
ui->lineEditName->setFocus();
}
void MainWindow::setHostName()
{
ui->lineEditName->hide();
ui->lblComputerName->show();
ui->btnEditName->show();
toggleCanRunCore(canRunCore());
QString text = ui->lineEditName->text();
const auto screenName = Settings::value(Settings::Core::ComputerName).toString();
if (text == screenName)
return;
const bool isServer = ui->rbModeServer->isChecked();
bool existingScreen = false;
if (isServer)
existingScreen = serverConfig().screenExists(text);
if (!ui->lineEditName->hasAcceptableInput() || text.isEmpty() || existingScreen) {
blockSignals(true);
ui->lineEditName->setText(screenName);
blockSignals(false);
const auto title = tr("Invalid Screen Name");
QString body;
if (existingScreen) {
body = tr("Screen name already exists");
} else {
body =
tr("The name you have chosen is invalid.\n\n"
"Valid names:\n"
"• Use letters and numbers\n"
"• May also use _ or -\n"
"• Are between 1 and 255 characters");
}
QMessageBox::information(this, title, body);
return;
}
ui->lblComputerName->setText(ui->lineEditName->text());
Settings::setValue(Settings::Core::ComputerName, ui->lineEditName->text());
if (isServer)
serverConfig().updateServerName();
applyConfig();
}
QString MainWindow::trustedFingerprintDatabase() const
{
const bool isClient = m_coreProcess.mode() == CoreMode::Client;
return isClient ? Settings::tlsTrustedServersDb() : Settings::tlsTrustedClientsDb();
}
bool MainWindow::generateCertificate()
{
const auto certificate = Settings::value(Settings::Security::Certificate).toString();
if (!QFile::exists(certificate) && !TlsUtility::generateCertificate()) {
return false;
}
m_fingerprint = {QCryptographicHash::Sha256, TlsUtility::certFingerprint()};
updateLocalFingerprint();
return true;
}
void MainWindow::serverClientsChanged(const QStringList &clients)
{
if (m_coreProcess.mode() != CoreMode::Server || !m_coreProcess.isStarted())
return;
m_statusBar->setServerClients(clients);
}
void MainWindow::daemonIpcClientConnectionFailed()
{
if (deskflow::gui::messages::showDaemonOffline(this)) {
m_coreProcess.retryDaemon();
}
}
void MainWindow::toggleCanRunCore(bool enableButtons)
{
const bool isStarted = m_coreProcess.isStarted();
ui->btnToggleCore->setEnabled(enableButtons);
ui->btnRestartCore->setEnabled(enableButtons && isStarted);
m_actionStartCore->setEnabled(enableButtons);
m_actionStopCore->setEnabled(enableButtons && isStarted);
}
2025-05-08 10:38:55 +00:00
void MainWindow::remoteHostChanged(const QString &newRemoteHost)
{
m_coreProcess.setAddress(newRemoteHost);
toggleCanRunCore(!newRemoteHost.isEmpty() && ui->rbModeClient->isChecked());
if (newRemoteHost.isEmpty()) {
Settings::setValue(Settings::Client::RemoteHost);
} else {
Settings::setValue(Settings::Client::RemoteHost, newRemoteHost);
}
}
void MainWindow::showClientError(deskflow::client::ErrorType error, const QString &address)
{
if (!isVisible() || m_clientErrorVisible || error != deskflow::client::ErrorType::AlreadyConnected)
return;
m_clientErrorVisible = true;
showAndActivate();
QMessageBox::warning(
this, tr("%1 Connection Error").arg(kAppName),
tr("<p>Failed to connect to the server '%1'.</p>"
"<p>A Client with your name is already connected to the server.</p>"
"Please ensure that you're using a unique name and that only a "
"single instance of the client process is running.</p>")
.arg(address)
);
m_clientErrorVisible = false;
}
void MainWindow::handleNewClientPromptRequest(const QString &clientName, bool usePeerAuth)
{
showAndActivate();
bool result = deskflow::gui::messages::showNewClientPrompt(this, clientName, usePeerAuth);
m_serverConnection.handleNewClientResult(clientName, result);
}
void MainWindow::updateIpLabel(const QStringList &addresses)
{
if (m_coreProcess.mode() != CoreMode::Server) {
return;
}
static const auto colorText = QStringLiteral(R"(<span style="color:%1;">%2</span>)");
const bool serverStarted = m_coreProcess.isStarted();
const bool fixedIP = !Settings::value(Settings::Core::Interface).toString().isEmpty();
if (!fixedIP && addresses.isEmpty() && !serverStarted || (serverStarted && m_serverStartSuggestedIP.isEmpty())) {
ui->lblIpAddresses->setText(colorText.arg(palette().linkVisited().color().name(), tr("No IP Detected")));
ui->lblIpAddresses->setToolTip(tr("Unable to detect an IP address. Check your network connection is active."));
return;
}
QString labelText = fixedIP ? tr("Using IP: ") : tr("Suggested IP: ");
QString toolTipText = tr("<p>If connecting via the hostname fails, try %1</p>");
// Get all available IPs for tooltip
const bool filterIpList = (serverStarted || fixedIP);
const QRegularExpression ipListFilter(filterIpList ? QStringLiteral("(%1)").arg(m_serverStartIPs.join("|")) : "");
const QStringList ipList = addresses.filter(ipListFilter);
bool IPValid = true;
if (filterIpList && (m_serverStartSuggestedIP != m_currentIpAddress) || !ipList.contains(m_serverStartSuggestedIP)) {
IPValid = !ipList.isEmpty();
}
if (IPValid) {
m_currentIpAddress = ipList.first();
labelText.append(m_currentIpAddress);
} else {
labelText.append(colorText.arg(palette().linkVisited().color().name(), m_serverStartSuggestedIP));
toolTipText.append(tr("\nA bound IP is now invalid, you may need to restart the server."));
}
if (ipList.count() < 2 || fixedIP) {
toolTipText = toolTipText.arg(tr("the suggested IP."));
} else {
toolTipText = toolTipText.arg(tr("one of the following IPs:<br/>%1").arg(ipList.join("<br/>")));
}
ui->lblIpAddresses->setText(labelText);
ui->lblIpAddresses->setToolTip(toolTipText);
}
bool MainWindow::canRunCore() const
{
const auto mode = m_coreProcess.mode();
const bool isServer = mode == Settings::CoreMode::Server;
const bool isClient = mode == Settings::CoreMode::Client;
return ((isServer || isClient) && (isClient && !ui->lineHostname->text().isEmpty()) || isServer);
}