2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2016-09-07 14:24:00 +00:00
|
|
|
* Copyright (C) 2012-2016 Symless Ltd.
|
2012-06-10 16:50:54 +00:00
|
|
|
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
2015-07-29 21:34:21 +00:00
|
|
|
*
|
2012-06-10 16:50:54 +00:00
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2015-05-03 02:33:52 +00:00
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
2015-07-29 21:34:21 +00:00
|
|
|
*
|
2012-06-10 16:50:54 +00:00
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
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-09 14:23:14 +00:00
|
|
|
#include "TrayIcon.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
|
|
|
|
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;
|
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-07-23 19:17:40 +00:00
|
|
|
void setVisible(bool visible) override;
|
2024-10-17 18:04:35 +00:00
|
|
|
CoreMode coreMode() const
|
|
|
|
|
{
|
|
|
|
|
return m_CoreProcess.mode();
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
QString address() const;
|
|
|
|
|
void open();
|
2024-10-17 18:04:35 +00:00
|
|
|
ServerConfig &serverConfig()
|
|
|
|
|
{
|
|
|
|
|
return m_ServerConfig;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
void autoAddScreen(const QString name);
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-26 22:53:52 +00:00
|
|
|
signals:
|
|
|
|
|
void created();
|
|
|
|
|
void shown();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void onAppAboutToQuit();
|
|
|
|
|
|
|
|
|
|
private slots:
|
2024-08-08 20:54:32 +00:00
|
|
|
//
|
|
|
|
|
// Manual slots
|
|
|
|
|
//
|
2024-07-26 22:53:52 +00:00
|
|
|
void onCreated();
|
|
|
|
|
void onShown();
|
2024-08-03 00:17:29 +00:00
|
|
|
void onConfigScopesSaving();
|
2024-07-26 22:53:52 +00:00
|
|
|
void onAppConfigTlsChanged();
|
|
|
|
|
void onAppConfigScreenNameChanged();
|
|
|
|
|
void onAppConfigInvertConnection();
|
2024-08-07 14:05:18 +00:00
|
|
|
void onCoreProcessStarting();
|
|
|
|
|
void onCoreProcessError(CoreProcess::Error error);
|
|
|
|
|
void onCoreConnectionStateChanged(CoreProcess::ConnectionState state);
|
|
|
|
|
void onCoreProcessStateChanged(CoreProcess::ProcessState state);
|
|
|
|
|
void onCoreProcessSecureSocket(bool enabled);
|
2024-07-26 22:53:52 +00:00
|
|
|
void onVersionCheckerUpdateFound(const QString &version);
|
2024-08-07 14:05:18 +00:00
|
|
|
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
2024-08-01 00:13:01 +00:00
|
|
|
void onWindowSaveTimerTimeout();
|
2024-08-07 14:05:18 +00:00
|
|
|
void onServerConnectionConfigureClient(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-08-08 20:54:32 +00:00
|
|
|
//
|
|
|
|
|
// Auto-connect slots
|
|
|
|
|
//
|
2024-07-26 22:53:52 +00:00
|
|
|
void on_m_pLabelFingerprint_linkActivated(const QString &link);
|
2024-07-02 19:07:06 +00:00
|
|
|
void on_m_pRadioGroupServer_clicked(bool);
|
|
|
|
|
void on_m_pRadioGroupClient_clicked(bool);
|
2016-12-28 11:50:32 +00:00
|
|
|
|
2024-07-26 22:53:52 +00:00
|
|
|
private:
|
2024-10-18 21:58:00 +00:00
|
|
|
std::unique_ptr<Ui::MainWindow> ui;
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
AppConfig &appConfig()
|
|
|
|
|
{
|
|
|
|
|
return m_AppConfig;
|
|
|
|
|
}
|
|
|
|
|
AppConfig const &appConfig() const
|
|
|
|
|
{
|
|
|
|
|
return m_AppConfig;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
void createMenuBar();
|
|
|
|
|
void createStatusBar();
|
|
|
|
|
void createTrayIcon();
|
2024-07-26 22:53:52 +00:00
|
|
|
void applyConfig();
|
2024-08-03 00:17:29 +00:00
|
|
|
void applyCloseToTray() const;
|
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 saveWindow();
|
|
|
|
|
void setupControls();
|
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
|
void moveEvent(QMoveEvent *event) override;
|
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
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
VersionChecker m_VersionChecker;
|
2024-09-17 19:00:25 +00:00
|
|
|
deskflow::gui::TrayIcon m_TrayIcon;
|
2024-07-22 16:48:02 +00:00
|
|
|
QMenuBar *m_pMenuBar = nullptr;
|
|
|
|
|
QMenu *m_pMenuFile = nullptr;
|
|
|
|
|
QMenu *m_pMenuEdit = nullptr;
|
|
|
|
|
QMenu *m_pMenuWindow = nullptr;
|
|
|
|
|
QMenu *m_pMenuHelp = nullptr;
|
|
|
|
|
QAbstractButton *m_pCancelButton = nullptr;
|
|
|
|
|
bool m_SecureSocket = false;
|
2024-08-01 00:13:01 +00:00
|
|
|
bool m_SaveWindow = false;
|
2024-08-09 18:20:10 +00:00
|
|
|
bool m_Quitting = false;
|
2024-09-17 19:00:25 +00:00
|
|
|
deskflow::gui::config::ServerConfigDialogState m_ServerConfigDialogState;
|
2024-08-10 23:58:24 +00:00
|
|
|
bool m_SaveOnExit = true;
|
2024-09-17 19:00:25 +00:00
|
|
|
deskflow::gui::core::WaylandWarnings m_WaylandWarnings;
|
2019-08-02 12:11:47 +00:00
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
deskflow::gui::ConfigScopes &m_ConfigScopes;
|
2024-07-26 22:53:52 +00:00
|
|
|
AppConfig &m_AppConfig;
|
|
|
|
|
ServerConfig m_ServerConfig;
|
2024-09-17 19:00:25 +00:00
|
|
|
deskflow::gui::CoreProcess m_CoreProcess;
|
|
|
|
|
deskflow::gui::ServerConnection m_ServerConnection;
|
|
|
|
|
deskflow::gui::ClientConnection m_ClientConnection;
|
|
|
|
|
deskflow::gui::TlsUtility m_TlsUtility;
|
2024-08-01 00:13:01 +00:00
|
|
|
QTimer m_WindowSaveTimer;
|
2024-12-18 22:51:03 +00:00
|
|
|
|
|
|
|
|
// Window Actions
|
|
|
|
|
QAction *m_actionAbout = nullptr;
|
|
|
|
|
QAction *m_actionClearSettings = nullptr;
|
|
|
|
|
QAction *m_actionHelp = nullptr;
|
|
|
|
|
QAction *m_actionMinimize = nullptr;
|
|
|
|
|
QAction *m_actionQuit = nullptr;
|
|
|
|
|
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
|
|
|
};
|