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>
|
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-09 13:03:48 +00:00
|
|
|
#include "common/ipc.h"
|
2024-08-07 14:05:18 +00:00
|
|
|
#include "gui/config/AppConfig.h"
|
|
|
|
|
#include "gui/config/ConfigScopes.h"
|
2024-08-10 23:58:24 +00:00
|
|
|
#include "gui/config/ServerConfigDialogState.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;
|
|
|
|
|
class QLineEdit;
|
|
|
|
|
class QGroupBox;
|
|
|
|
|
class QPushButton;
|
|
|
|
|
class QTextEdit;
|
|
|
|
|
class QComboBox;
|
|
|
|
|
class QTabWidget;
|
|
|
|
|
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
|
|
|
class SetupWizard;
|
|
|
|
|
|
2024-10-18 21:58:00 +00:00
|
|
|
namespace Ui {
|
|
|
|
|
class MainWindow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2024-09-17 19:00:25 +00:00
|
|
|
using CoreMode = deskflow::gui::CoreProcess::Mode;
|
|
|
|
|
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 SetupWizard;
|
|
|
|
|
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:
|
2024-10-17 18:04:35 +00:00
|
|
|
explicit MainWindow(deskflow::gui::ConfigScopes &configScopes, AppConfig &appConfig);
|
2024-07-22 16:48:02 +00:00
|
|
|
~MainWindow() override;
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
CoreMode coreMode() const
|
|
|
|
|
{
|
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
|
|
|
QString address() const;
|
|
|
|
|
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
|
|
|
}
|
2024-07-02 19:07:06 +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
|
|
|
|
2024-07-26 22:53:52 +00:00
|
|
|
signals:
|
|
|
|
|
void shown();
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
void firstShown();
|
|
|
|
|
|
|
|
|
|
void configScopesSaving();
|
|
|
|
|
void appConfigTlsChanged();
|
|
|
|
|
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;
|
|
|
|
|
void openSettings();
|
|
|
|
|
void startCore();
|
|
|
|
|
void stopCore();
|
|
|
|
|
bool saveConfig();
|
|
|
|
|
void testFatalError() const;
|
|
|
|
|
void testCriticalError() const;
|
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();
|
2024-12-19 00:47:50 +00:00
|
|
|
void setModeServer();
|
|
|
|
|
void setModeClient();
|
2025-02-14 11:40:00 +00:00
|
|
|
void updateSecurityIcon(bool visible);
|
2016-12-28 11:50:32 +00:00
|
|
|
|
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-10-17 18:04:35 +00:00
|
|
|
AppConfig &appConfig()
|
|
|
|
|
{
|
2025-02-04 00:30:00 +00:00
|
|
|
return m_appConfig;
|
2024-10-17 18:04:35 +00:00
|
|
|
}
|
|
|
|
|
AppConfig const &appConfig() const
|
|
|
|
|
{
|
2025-02-04 00:30:00 +00:00
|
|
|
return m_appConfig;
|
2024-10-17 18:04:35 +00:00
|
|
|
}
|
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
|
|
|
bool checkForApp(int which, QString &app);
|
|
|
|
|
void setStatus(const QString &status);
|
2024-07-18 07:04:39 +00:00
|
|
|
void sendIpcMessage(IpcMessageType type, const char *buffer, bool showErrors);
|
2024-07-02 19:07:06 +00:00
|
|
|
void updateFromLogLine(const QString &line);
|
2024-07-26 22:53:52 +00:00
|
|
|
QString getIPAddresses() const;
|
2024-07-02 19:07:06 +00:00
|
|
|
void enableServer(bool enable);
|
|
|
|
|
void enableClient(bool enable);
|
|
|
|
|
void checkConnected(const QString &line);
|
|
|
|
|
void checkFingerprint(const QString &line);
|
2024-07-26 22:53:52 +00:00
|
|
|
QString getTimeStamp() const;
|
2024-07-22 16:48:02 +00:00
|
|
|
void showEvent(QShowEvent *) override;
|
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);
|
|
|
|
|
void windowStateChanged();
|
2024-08-07 14:05:18 +00:00
|
|
|
void connectSlots();
|
2024-07-22 16:48:02 +00:00
|
|
|
void updateWindowTitle();
|
2024-08-07 14:05:18 +00:00
|
|
|
void handleLogLine(const QString &line);
|
2024-07-26 22:53:52 +00:00
|
|
|
void updateLocalFingerprint();
|
|
|
|
|
void updateScreenName();
|
|
|
|
|
void saveSettings();
|
|
|
|
|
QString configFilename();
|
|
|
|
|
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();
|
2024-07-22 16:48:02 +00:00
|
|
|
|
2025-02-08 19:10:39 +00:00
|
|
|
QString getTlsPath();
|
2025-02-17 19:14:26 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief localFingerprintDb
|
|
|
|
|
* @return The path to the local fingerprint file
|
|
|
|
|
*/
|
|
|
|
|
QString localFingerprintDb();
|
2025-02-08 19:10:39 +00:00
|
|
|
|
2025-02-17 19:11:49 +00:00
|
|
|
/**
|
|
|
|
|
* @brief trustedFingerprintDb get the fingerprintDb for the trusted clients or trusted servers.
|
|
|
|
|
* @return The path to the trusted fingerprint file
|
|
|
|
|
*/
|
|
|
|
|
QString trustedFingerprintDb();
|
|
|
|
|
|
2025-02-09 02:42:19 +00:00
|
|
|
// Generate prints if they are missing
|
|
|
|
|
// Returns true if successful
|
|
|
|
|
bool regenerateLocalFingerprints();
|
|
|
|
|
|
2025-02-04 00:30:00 +00:00
|
|
|
VersionChecker m_versionChecker;
|
|
|
|
|
bool m_secureSocket = false;
|
|
|
|
|
deskflow::gui::config::ServerConfigDialogState m_serverConfigDialogState;
|
|
|
|
|
bool m_saveOnExit = true;
|
|
|
|
|
deskflow::gui::core::WaylandWarnings m_waylandWarnings;
|
|
|
|
|
|
|
|
|
|
deskflow::gui::ConfigScopes &m_configScopes;
|
|
|
|
|
AppConfig &m_appConfig;
|
|
|
|
|
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();
|
2024-12-18 22:51:03 +00:00
|
|
|
|
2025-02-10 11:54:46 +00:00
|
|
|
QSystemTrayIcon *m_trayIcon = nullptr;
|
2025-01-03 05:00:10 +00:00
|
|
|
QLocalServer *m_guiDupeChecker = nullptr;
|
|
|
|
|
inline static const auto m_guiSocketName = QStringLiteral("deskflow-gui");
|
|
|
|
|
|
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_actionSave = nullptr;
|
|
|
|
|
QAction *m_actionSettings = nullptr;
|
|
|
|
|
QAction *m_actionStartCore = nullptr;
|
|
|
|
|
QAction *m_actionStopCore = nullptr;
|
|
|
|
|
QAction *m_actionTestCriticalError = nullptr;
|
|
|
|
|
QAction *m_actionTestFatalError = nullptr;
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|