refactor: addNew PlatformInfo::isWindows()

This commit is contained in:
sithlord48
2025-11-05 15:55:51 -05:00
committed by Chris Rizzitello
parent 8e83b16f5e
commit 5256f05963
7 changed files with 47 additions and 47 deletions

View File

@ -8,6 +8,7 @@
#pragma once
#include <QFileInfo>
#include <QSysInfo>
namespace deskflow::platform {
@ -16,6 +17,15 @@ inline bool isWayland()
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
* @return Returns true if we are running as flatpak

View File

@ -14,6 +14,7 @@
#include "base/LogOutputters.h"
#include "common/Constants.h"
#include "common/ExitCodes.h"
#include "common/PlatformInfo.h"
#include "common/Settings.h"
#include "deskflow/DeskflowException.h"
#include "deskflow/ProtocolTypes.h"
@ -108,11 +109,7 @@ int App::run()
int App::daemonMainLoop(int, const char **)
{
#if SYSAPI_WIN32
SystemLogger sysLogger(daemonName(), false);
#else
SystemLogger sysLogger(daemonName(), true);
#endif
SystemLogger sysLogger(daemonName(), !deskflow::platform::isWindows());
return mainLoop();
}

View File

@ -78,21 +78,16 @@ void ClientApp::parseArgs()
const char *ClientApp::daemonName() const
{
#if SYSAPI_WIN32
return "Deskflow Client";
#elif SYSAPI_UNIX
if (deskflow::platform::isWindows())
return "Deskflow Client";
return "deskflow-client";
#endif
}
const char *ClientApp::daemonInfo() const
{
#if SYSAPI_WIN32
return "Allows another computer to share it's keyboard and mouse with this "
"computer.";
#elif SYSAPI_UNIX
if (deskflow::platform::isWindows())
return "Allows another computer to share it's keyboard and mouse with this computer.";
return "";
#endif
}
deskflow::Screen *ClientApp::createScreen()

View File

@ -605,20 +605,16 @@ int ServerApp::start()
const char *ServerApp::daemonName() const
{
#if SYSAPI_WIN32
return "Deskflow Server";
#elif SYSAPI_UNIX
if (deskflow::platform::isWindows())
return "Deskflow Server";
return "deskflow-server";
#endif
}
const char *ServerApp::daemonInfo() const
{
#if SYSAPI_WIN32
return "Shares this computers mouse and keyboard with other computers.";
#elif SYSAPI_UNIX
if (deskflow::platform::isWindows())
return "Shares this computers mouse and keyboard with other computers.";
return "";
#endif
}
void ServerApp::startNode()

View File

@ -103,10 +103,10 @@ MainWindow::MainWindow()
m_actionMinimize->setIcon(QIcon::fromTheme(QStringLiteral("window-minimize-pip")));
m_actionRestore->setIcon(QIcon::fromTheme(QStringLiteral("window-restore-pip")));
#ifndef Q_OS_WIN
m_actionQuit->setShortcut(QKeySequence::Quit);
m_actionTrayQuit->setShortcut(QKeySequence::Quit);
#endif
if (!deskflow::platform::isWindows()) {
m_actionQuit->setShortcut(QKeySequence::Quit);
m_actionTrayQuit->setShortcut(QKeySequence::Quit);
}
m_actionQuit->setMenuRole(QAction::QuitRole);
m_actionQuit->setIcon(QIcon(QIcon::fromTheme("application-exit")));
@ -763,19 +763,20 @@ void MainWindow::setTrayIcon()
themeIcon.append(QStringLiteral("-symbolic"));
#ifdef Q_OS_WIN
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)));
#else
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;
}
auto icon = QIcon::fromTheme(themeIcon, QIcon(fallbackPath.arg(kAppId, iconMode(), themeIcon)));
icon.setIsMask(true);
m_trayIcon->setIcon(icon);
#endif
}
void MainWindow::handleLogLine(const QString &line)
@ -1071,11 +1072,11 @@ void MainWindow::updateText()
//: stop core shortcut
m_actionStopCore->setShortcut(QKeySequence(tr("Ctrl+T")));
#ifdef Q_OS_WIN
//: Quit shortcut
m_actionQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
m_actionTrayQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
#endif
if (deskflow::platform::isWindows()) {
//: Quit shortcut
m_actionQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
m_actionTrayQuit->setShortcut(QKeySequence(tr("Ctrl+Q")));
}
// General controls
m_btnFingerprint->setToolTip(tr("View local fingerprint"));

View File

@ -7,6 +7,7 @@
*/
#include "ServerConfigDialog.h"
#include "common/PlatformInfo.h"
#include "ui_ServerConfigDialog.h"
#include "base/NetworkProtocol.h"
@ -79,9 +80,9 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
ui->cbRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
#ifndef Q_OS_WIN
ui->cbWin32KeepForeground->setVisible(false);
#endif
if (!deskflow::platform::isWindows())
ui->cbWin32KeepForeground->setVisible(false);
ui->cbWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
connect(ui->cbWin32KeepForeground, &QCheckBox::toggled, this, &ServerConfigDialog::toggleWin32Foreground);

View File

@ -7,6 +7,7 @@
*/
#include "SettingsDialog.h"
#include "common/PlatformInfo.h"
#include "ui_SettingsDialog.h"
#include "common/I18N.h"
@ -209,9 +210,8 @@ void SettingsDialog::loadFromConfig()
const auto processMode = Settings::value(Settings::Core::ProcessMode).value<Settings::ProcessMode>();
ui->groupService->setChecked(processMode == Settings::ProcessMode::Service);
#ifndef Q_OS_WIN
ui->groupService->setVisible(false);
#endif
if (!deskflow::platform::isWindows())
ui->groupService->setVisible(false);
if (Settings::value(Settings::Gui::SymbolicTrayIcon).toBool())
ui->rbIconMono->setChecked(true);