2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2024 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
|
|
|
*/
|
|
|
|
|
|
2018-08-03 15:58:23 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
2024-07-02 19:07:06 +00:00
|
|
|
#include <QMutex>
|
2012-06-10 16:50:54 +00:00
|
|
|
#include <QProcess>
|
2025-01-12 06:48:23 +00:00
|
|
|
#include <QRegularExpression>
|
2024-07-02 19:07:06 +00:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QSystemTrayIcon>
|
2012-06-10 16:50:54 +00:00
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
|
|
#include "ServerConfig.h"
|
2024-11-27 22:11:28 +00:00
|
|
|
#include "VersionChecker.h"
|
2024-08-07 14:05:18 +00:00
|
|
|
#include "gui/core/ClientConnection.h"
|
|
|
|
|
#include "gui/core/CoreProcess.h"
|
|
|
|
|
#include "gui/core/ServerConnection.h"
|
2024-09-09 10:18:17 +00:00
|
|
|
#include "gui/core/WaylandWarnings.h"
|
2024-08-07 14:05:18 +00:00
|
|
|
#include "gui/tls/TlsUtility.h"
|
2014-11-24 11:59:24 +00:00
|
|
|
|
2025-01-02 21:31:32 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
#include "gui/OSXHelpers.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
class QAction;
|
|
|
|
|
class QMenu;
|
2025-02-19 22:23:48 +00:00
|
|
|
class QLabel;
|
2012-06-10 16:50:54 +00:00
|
|
|
class QLineEdit;
|
|
|
|
|
class QGroupBox;
|
|
|
|
|
class QPushButton;
|
|
|
|
|
class QTextEdit;
|
|
|
|
|
class QComboBox;
|
|
|
|
|
class QTabWidget;
|
2025-02-19 22:46:13 +00:00
|
|
|
class QToolButton;
|
2012-06-10 16:50:54 +00:00
|
|
|
class QCheckBox;
|
|
|
|
|
class QRadioButton;
|
2014-11-13 11:02:48 +00:00
|
|
|
class QMessageBox;
|
2014-11-13 12:09:11 +00:00
|
|
|
class QAbstractButton;
|
2025-01-03 05:00:10 +00:00
|
|
|
class QLocalServer;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
class DeskflowApplication;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2024-10-18 21:58:00 +00:00
|
|
|
namespace Ui {
|
|
|
|
|
class MainWindow;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-06 12:03:51 +00:00
|
|
|
namespace deskflow::gui::ipc {
|
|
|
|
|
class DaemonIpcClient;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-18 21:58:00 +00:00
|
|
|
class MainWindow : public QMainWindow
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2025-03-10 02:50:44 +00:00
|
|
|
using CoreMode = Settings::CoreMode;
|
2024-09-17 19:00:25 +00:00
|
|
|
using CoreProcess = deskflow::gui::CoreProcess;
|
2024-08-07 14:05:18 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
Q_OBJECT
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
friend class DeskflowApplication;
|
2024-07-02 19:07:06 +00:00
|
|
|
friend class SettingsDialog;
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
public:
|
2024-10-17 18:04:35 +00:00
|
|
|
enum class LogLevel
|
|
|
|
|
{
|
|
|
|
|
Error,
|
|
|
|
|
Info
|
|
|
|
|
};
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
public:
|
2025-03-15 03:03:59 +00:00
|
|
|
explicit MainWindow();
|
2024-07-22 16:48:02 +00:00
|
|
|
~MainWindow() override;
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2025-05-08 10:37:09 +00:00
|
|
|
[[nodiscard]] CoreMode coreMode() const
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2025-02-04 00:30:00 +00:00
|
|
|
return m_coreProcess.mode();
|
2024-10-17 18:04:35 +00:00
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
void open();
|
2024-10-17 18:04:35 +00:00
|
|
|
ServerConfig &serverConfig()
|
|
|
|
|
{
|
2025-02-04 00:30:00 +00:00
|
|
|
return m_serverConfig;
|
2024-10-17 18:04:35 +00:00
|
|
|
}
|
2025-05-08 10:38:55 +00:00
|
|
|
void autoAddScreen(const QString &name);
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2025-01-09 14:47:04 +00:00
|
|
|
void hide();
|
2025-01-02 21:31:32 +00:00
|
|
|
|
2025-02-04 01:22:17 +00:00
|
|
|
private:
|
2024-12-05 21:32:01 +00:00
|
|
|
void toggleLogVisible(bool visible);
|
2025-02-04 01:22:17 +00:00
|
|
|
|
2025-03-07 00:26:17 +00:00
|
|
|
void settingsChanged(const QString &key = QString());
|
2025-03-15 02:17:08 +00:00
|
|
|
void serverConfigSaving();
|
2025-02-04 01:22:17 +00:00
|
|
|
void coreProcessStarting();
|
|
|
|
|
void coreProcessError(CoreProcess::Error error);
|
|
|
|
|
void coreConnectionStateChanged(CoreProcess::ConnectionState state);
|
|
|
|
|
void coreProcessStateChanged(CoreProcess::ProcessState state);
|
|
|
|
|
void versionCheckerUpdateFound(const QString &version);
|
|
|
|
|
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
|
|
|
|
void serverConnectionConfigureClient(const QString &clientName);
|
2024-08-01 00:13:01 +00:00
|
|
|
|
2024-12-18 22:51:03 +00:00
|
|
|
void clearSettings();
|
|
|
|
|
void openAboutDialog();
|
|
|
|
|
void openHelpUrl() const;
|
2025-02-19 23:54:43 +00:00
|
|
|
void openGetNewVersionUrl() const;
|
2024-12-18 22:51:03 +00:00
|
|
|
void openSettings();
|
|
|
|
|
void startCore();
|
|
|
|
|
void stopCore();
|
2025-03-14 16:03:24 +00:00
|
|
|
bool saveServerConfig();
|
2024-12-18 23:49:10 +00:00
|
|
|
void resetCore();
|
2024-12-19 00:05:51 +00:00
|
|
|
|
2024-12-19 00:39:07 +00:00
|
|
|
void showMyFingerprint();
|
2025-02-14 11:40:00 +00:00
|
|
|
void updateSecurityIcon(bool visible);
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2025-02-23 21:28:53 +00:00
|
|
|
void coreModeToggled();
|
|
|
|
|
void updateModeControls(bool serverMode);
|
|
|
|
|
|
2024-10-18 21:58:00 +00:00
|
|
|
std::unique_ptr<Ui::MainWindow> ui;
|
|
|
|
|
|
2024-12-05 21:32:01 +00:00
|
|
|
void updateSize();
|
2024-07-02 19:07:06 +00:00
|
|
|
void createMenuBar();
|
2025-01-07 05:22:48 +00:00
|
|
|
void setupTrayIcon();
|
2024-07-26 22:53:52 +00:00
|
|
|
void applyConfig();
|
2024-08-10 00:48:27 +00:00
|
|
|
void setIcon();
|
2024-07-02 19:07:06 +00:00
|
|
|
void setStatus(const QString &status);
|
|
|
|
|
void updateFromLogLine(const QString &line);
|
2025-05-08 10:37:09 +00:00
|
|
|
[[nodiscard]] QString getIPAddresses() const;
|
2024-07-02 19:07:06 +00:00
|
|
|
void checkConnected(const QString &line);
|
|
|
|
|
void checkFingerprint(const QString &line);
|
2025-05-08 10:37:09 +00:00
|
|
|
[[nodiscard]] QString getTimeStamp() const;
|
2024-08-03 00:17:29 +00:00
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2024-07-02 19:07:06 +00:00
|
|
|
void secureSocket(bool secureSocket);
|
2024-08-07 14:05:18 +00:00
|
|
|
void connectSlots();
|
|
|
|
|
void handleLogLine(const QString &line);
|
2024-07-26 22:53:52 +00:00
|
|
|
void updateLocalFingerprint();
|
|
|
|
|
void updateScreenName();
|
2025-05-20 02:19:19 +00:00
|
|
|
void saveSettings() const;
|
2024-07-26 22:53:52 +00:00
|
|
|
void showConfigureServer(const QString &message);
|
2024-08-01 00:13:01 +00:00
|
|
|
void restoreWindow();
|
|
|
|
|
void setupControls();
|
2024-08-12 15:39:18 +00:00
|
|
|
void showFirstConnectedMessage();
|
2024-08-07 14:05:18 +00:00
|
|
|
void updateStatus();
|
2024-08-08 17:41:59 +00:00
|
|
|
void showAndActivate();
|
2025-01-12 06:48:23 +00:00
|
|
|
void showHostNameEditor();
|
|
|
|
|
void setHostName();
|
2025-04-18 12:56:37 +00:00
|
|
|
void daemonIpcClientConnectionFailed();
|
2025-04-19 17:26:41 +00:00
|
|
|
void toggleCanRunCore(bool enableButtons);
|
2025-05-08 10:38:55 +00:00
|
|
|
void remoteHostChanged(const QString &newRemoteHost);
|
2024-07-22 16:48:02 +00:00
|
|
|
|
2025-02-17 19:11:49 +00:00
|
|
|
/**
|
2025-03-28 03:43:04 +00:00
|
|
|
* @brief trustedFingerprintDatabase get the FingerprintDatabase for the trusted clients or trusted servers.
|
2025-02-17 19:11:49 +00:00
|
|
|
* @return The path to the trusted fingerprint file
|
|
|
|
|
*/
|
2025-05-20 02:19:19 +00:00
|
|
|
QString trustedFingerprintDatabase() const;
|
2025-02-17 19:11:49 +00:00
|
|
|
|
2025-02-09 02:42:19 +00:00
|
|
|
// Generate prints if they are missing
|
|
|
|
|
// Returns true if successful
|
|
|
|
|
bool regenerateLocalFingerprints();
|
|
|
|
|
|
2025-06-15 11:52:41 +00:00
|
|
|
void serverClientsChanged(const QStringList &clients);
|
|
|
|
|
|
2025-02-26 17:06:22 +00:00
|
|
|
inline static const auto m_guiSocketName = QStringLiteral("deskflow-gui");
|
|
|
|
|
inline static const auto m_nameRegEx = QRegularExpression(QStringLiteral("^[\\w\\-_\\.]{0,255}$"));
|
|
|
|
|
|
2025-02-04 00:30:00 +00:00
|
|
|
VersionChecker m_versionChecker;
|
|
|
|
|
bool m_secureSocket = false;
|
|
|
|
|
bool m_saveOnExit = true;
|
|
|
|
|
deskflow::gui::core::WaylandWarnings m_waylandWarnings;
|
|
|
|
|
ServerConfig m_serverConfig;
|
|
|
|
|
deskflow::gui::CoreProcess m_coreProcess;
|
|
|
|
|
deskflow::gui::ServerConnection m_serverConnection;
|
|
|
|
|
deskflow::gui::ClientConnection m_clientConnection;
|
|
|
|
|
deskflow::gui::TlsUtility m_tlsUtility;
|
2024-12-05 21:32:01 +00:00
|
|
|
QSize m_expandedSize = QSize();
|
2025-02-27 17:11:54 +00:00
|
|
|
QStringList m_checkedClients;
|
|
|
|
|
QStringList m_checkedServers;
|
2025-02-10 11:54:46 +00:00
|
|
|
QSystemTrayIcon *m_trayIcon = nullptr;
|
2025-01-03 05:00:10 +00:00
|
|
|
QLocalServer *m_guiDupeChecker = nullptr;
|
2025-02-06 12:03:51 +00:00
|
|
|
deskflow::gui::ipc::DaemonIpcClient *m_daemonIpcClient = nullptr;
|
2025-01-03 05:00:10 +00:00
|
|
|
|
2025-02-19 22:23:48 +00:00
|
|
|
QLabel *m_lblSecurityStatus = nullptr;
|
|
|
|
|
QLabel *m_lblStatus = nullptr;
|
2025-02-19 22:46:13 +00:00
|
|
|
QToolButton *m_btnFingerprint = nullptr;
|
2025-02-19 23:54:43 +00:00
|
|
|
QPushButton *m_btnUpdate = nullptr;
|
2025-02-19 22:23:48 +00:00
|
|
|
|
2024-12-18 22:51:03 +00:00
|
|
|
// Window Actions
|
|
|
|
|
QAction *m_actionAbout = nullptr;
|
|
|
|
|
QAction *m_actionClearSettings = nullptr;
|
2025-01-18 16:36:12 +00:00
|
|
|
QAction *m_actionReportBug = nullptr;
|
2024-12-18 22:51:03 +00:00
|
|
|
QAction *m_actionMinimize = nullptr;
|
|
|
|
|
QAction *m_actionQuit = nullptr;
|
2025-01-09 14:47:04 +00:00
|
|
|
QAction *m_actionTrayQuit = nullptr;
|
2024-12-18 22:51:03 +00:00
|
|
|
QAction *m_actionRestore = nullptr;
|
|
|
|
|
QAction *m_actionSettings = nullptr;
|
|
|
|
|
QAction *m_actionStartCore = nullptr;
|
2025-06-04 02:48:03 +00:00
|
|
|
QAction *m_actionRestartCore = nullptr;
|
2024-12-18 22:51:03 +00:00
|
|
|
QAction *m_actionStopCore = nullptr;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|