refactor: addNew PlatformInfo::isWindows()
This commit is contained in:
parent
8e83b16f5e
commit
5256f05963
7 changed files with 47 additions and 47 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QSysInfo>
|
||||||
|
|
||||||
namespace deskflow::platform {
|
namespace deskflow::platform {
|
||||||
|
|
||||||
|
|
@ -16,6 +17,15 @@ inline bool isWayland()
|
||||||
return qEnvironmentVariable("XDG_SESSION_TYPE") == QStringLiteral("wayland");
|
return qEnvironmentVariable("XDG_SESSION_TYPE") == QStringLiteral("wayland");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief isWindows
|
||||||
|
* @return Returns true if we are running on windows
|
||||||
|
*/
|
||||||
|
inline bool isWindows()
|
||||||
|
{
|
||||||
|
return QSysInfo::productType() == QStringLiteral("windows");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief isFlatpak
|
* @brief isFlatpak
|
||||||
* @return Returns true if we are running as flatpak
|
* @return Returns true if we are running as flatpak
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "base/LogOutputters.h"
|
#include "base/LogOutputters.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/ExitCodes.h"
|
#include "common/ExitCodes.h"
|
||||||
|
#include "common/PlatformInfo.h"
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "deskflow/DeskflowException.h"
|
#include "deskflow/DeskflowException.h"
|
||||||
#include "deskflow/ProtocolTypes.h"
|
#include "deskflow/ProtocolTypes.h"
|
||||||
|
|
@ -108,11 +109,7 @@ int App::run()
|
||||||
|
|
||||||
int App::daemonMainLoop(int, const char **)
|
int App::daemonMainLoop(int, const char **)
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
SystemLogger sysLogger(daemonName(), !deskflow::platform::isWindows());
|
||||||
SystemLogger sysLogger(daemonName(), false);
|
|
||||||
#else
|
|
||||||
SystemLogger sysLogger(daemonName(), true);
|
|
||||||
#endif
|
|
||||||
return mainLoop();
|
return mainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,21 +78,16 @@ void ClientApp::parseArgs()
|
||||||
|
|
||||||
const char *ClientApp::daemonName() const
|
const char *ClientApp::daemonName() const
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
if (deskflow::platform::isWindows())
|
||||||
return "Deskflow Client";
|
return "Deskflow Client";
|
||||||
#elif SYSAPI_UNIX
|
|
||||||
return "deskflow-client";
|
return "deskflow-client";
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ClientApp::daemonInfo() const
|
const char *ClientApp::daemonInfo() const
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
if (deskflow::platform::isWindows())
|
||||||
return "Allows another computer to share it's keyboard and mouse with this "
|
return "Allows another computer to share it's keyboard and mouse with this computer.";
|
||||||
"computer.";
|
|
||||||
#elif SYSAPI_UNIX
|
|
||||||
return "";
|
return "";
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deskflow::Screen *ClientApp::createScreen()
|
deskflow::Screen *ClientApp::createScreen()
|
||||||
|
|
|
||||||
|
|
@ -605,20 +605,16 @@ int ServerApp::start()
|
||||||
|
|
||||||
const char *ServerApp::daemonName() const
|
const char *ServerApp::daemonName() const
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
if (deskflow::platform::isWindows())
|
||||||
return "Deskflow Server";
|
return "Deskflow Server";
|
||||||
#elif SYSAPI_UNIX
|
|
||||||
return "deskflow-server";
|
return "deskflow-server";
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ServerApp::daemonInfo() const
|
const char *ServerApp::daemonInfo() const
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
if (deskflow::platform::isWindows())
|
||||||
return "Shares this computers mouse and keyboard with other computers.";
|
return "Shares this computers mouse and keyboard with other computers.";
|
||||||
#elif SYSAPI_UNIX
|
|
||||||
return "";
|
return "";
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApp::startNode()
|
void ServerApp::startNode()
|
||||||
|
|
|
||||||
|
|
@ -103,10 +103,10 @@ MainWindow::MainWindow()
|
||||||
m_actionMinimize->setIcon(QIcon::fromTheme(QStringLiteral("window-minimize-pip")));
|
m_actionMinimize->setIcon(QIcon::fromTheme(QStringLiteral("window-minimize-pip")));
|
||||||
m_actionRestore->setIcon(QIcon::fromTheme(QStringLiteral("window-restore-pip")));
|
m_actionRestore->setIcon(QIcon::fromTheme(QStringLiteral("window-restore-pip")));
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
if (!deskflow::platform::isWindows()) {
|
||||||
m_actionQuit->setShortcut(QKeySequence::Quit);
|
m_actionQuit->setShortcut(QKeySequence::Quit);
|
||||||
m_actionTrayQuit->setShortcut(QKeySequence::Quit);
|
m_actionTrayQuit->setShortcut(QKeySequence::Quit);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
m_actionQuit->setMenuRole(QAction::QuitRole);
|
m_actionQuit->setMenuRole(QAction::QuitRole);
|
||||||
m_actionQuit->setIcon(QIcon(QIcon::fromTheme("application-exit")));
|
m_actionQuit->setIcon(QIcon(QIcon::fromTheme("application-exit")));
|
||||||
|
|
@ -763,19 +763,20 @@ void MainWindow::setTrayIcon()
|
||||||
|
|
||||||
themeIcon.append(QStringLiteral("-symbolic"));
|
themeIcon.append(QStringLiteral("-symbolic"));
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
if (deskflow::platform::isWindows()) {
|
||||||
QSettings settings(
|
QSettings settings(
|
||||||
QStringLiteral("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"),
|
QStringLiteral("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"),
|
||||||
QSettings::NativeFormat
|
QSettings::NativeFormat
|
||||||
);
|
);
|
||||||
const QString theme = settings.value(QStringLiteral("SystemUsesLightTheme"), 1).toBool() ? QStringLiteral("light")
|
const QString theme = settings.value(QStringLiteral("SystemUsesLightTheme"), 1).toBool() ? QStringLiteral("light")
|
||||||
: QStringLiteral("dark");
|
: QStringLiteral("dark");
|
||||||
m_trayIcon->setIcon(QIcon(fallbackPath.arg(kAppId, theme, themeIcon)));
|
m_trayIcon->setIcon(QIcon(fallbackPath.arg(kAppId, theme, themeIcon)));
|
||||||
#else
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto icon = QIcon::fromTheme(themeIcon, QIcon(fallbackPath.arg(kAppId, iconMode(), themeIcon)));
|
auto icon = QIcon::fromTheme(themeIcon, QIcon(fallbackPath.arg(kAppId, iconMode(), themeIcon)));
|
||||||
icon.setIsMask(true);
|
icon.setIsMask(true);
|
||||||
m_trayIcon->setIcon(icon);
|
m_trayIcon->setIcon(icon);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::handleLogLine(const QString &line)
|
void MainWindow::handleLogLine(const QString &line)
|
||||||
|
|
@ -1071,11 +1072,11 @@ void MainWindow::updateText()
|
||||||
//: stop core shortcut
|
//: stop core shortcut
|
||||||
m_actionStopCore->setShortcut(QKeySequence(tr("Ctrl+T")));
|
m_actionStopCore->setShortcut(QKeySequence(tr("Ctrl+T")));
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
if (deskflow::platform::isWindows()) {
|
||||||
//: Quit shortcut
|
//: Quit shortcut
|
||||||
m_actionQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
m_actionQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
||||||
m_actionTrayQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
m_actionTrayQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// General controls
|
// General controls
|
||||||
m_btnFingerprint->setToolTip(tr("View local fingerprint"));
|
m_btnFingerprint->setToolTip(tr("View local fingerprint"));
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ServerConfigDialog.h"
|
#include "ServerConfigDialog.h"
|
||||||
|
#include "common/PlatformInfo.h"
|
||||||
#include "ui_ServerConfigDialog.h"
|
#include "ui_ServerConfigDialog.h"
|
||||||
|
|
||||||
#include "base/NetworkProtocol.h"
|
#include "base/NetworkProtocol.h"
|
||||||
|
|
@ -79,9 +80,9 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
|
||||||
|
|
||||||
ui->cbRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
|
ui->cbRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
if (!deskflow::platform::isWindows())
|
||||||
ui->cbWin32KeepForeground->setVisible(false);
|
ui->cbWin32KeepForeground->setVisible(false);
|
||||||
#endif
|
|
||||||
ui->cbWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
|
ui->cbWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
|
||||||
connect(ui->cbWin32KeepForeground, &QCheckBox::toggled, this, &ServerConfigDialog::toggleWin32Foreground);
|
connect(ui->cbWin32KeepForeground, &QCheckBox::toggled, this, &ServerConfigDialog::toggleWin32Foreground);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SettingsDialog.h"
|
#include "SettingsDialog.h"
|
||||||
|
#include "common/PlatformInfo.h"
|
||||||
#include "ui_SettingsDialog.h"
|
#include "ui_SettingsDialog.h"
|
||||||
|
|
||||||
#include "common/I18N.h"
|
#include "common/I18N.h"
|
||||||
|
|
@ -209,9 +210,8 @@ void SettingsDialog::loadFromConfig()
|
||||||
const auto processMode = Settings::value(Settings::Core::ProcessMode).value<Settings::ProcessMode>();
|
const auto processMode = Settings::value(Settings::Core::ProcessMode).value<Settings::ProcessMode>();
|
||||||
ui->groupService->setChecked(processMode == Settings::ProcessMode::Service);
|
ui->groupService->setChecked(processMode == Settings::ProcessMode::Service);
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
if (!deskflow::platform::isWindows())
|
||||||
ui->groupService->setVisible(false);
|
ui->groupService->setVisible(false);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (Settings::value(Settings::Gui::SymbolicTrayIcon).toBool())
|
if (Settings::value(Settings::Gui::SymbolicTrayIcon).toBool())
|
||||||
ui->rbIconMono->setChecked(true);
|
ui->rbIconMono->setChecked(true);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue