refactor: Add deskflow::platform::isMac

This commit is contained in:
sithlord48
2025-11-05 16:34:53 -05:00
committed by Chris Rizzitello
parent 5256f05963
commit f89e857223
4 changed files with 28 additions and 20 deletions

View File

@ -10,6 +10,7 @@
#include "common/Constants.h"
#include "common/ExitCodes.h"
#include "common/I18N.h"
#include "common/PlatformInfo.h"
#include "common/UrlConstants.h"
#include "gui/Diagnostic.h"
#include "gui/Logger.h"
@ -118,12 +119,9 @@ int main(int argc, char *argv[])
return s_exitDuplicate;
}
#if !defined(Q_OS_MAC)
// causes dark mode to be used on some DE's
if (qEnvironmentVariable("XDG_CURRENT_DESKTOP") != QLatin1String("KDE")) {
if (!deskflow::platform::isMac() && qEnvironmentVariable("XDG_CURRENT_DESKTOP") != QLatin1String("KDE")) {
QApplication::setStyle("fusion");
}
#endif
// Sets the fallback icon path and fallback theme
updateIconTheme();

View File

@ -26,6 +26,15 @@ inline bool isWindows()
return QSysInfo::productType() == QStringLiteral("windows");
}
/**
* @brief isMac
* @return Returns true if we are running on mac os
*/
inline bool isMac()
{
return QSysInfo::productType() == QStringLiteral("macos");
}
/**
* @brief isFlatpak
* @return Returns true if we are running as flatpak

View File

@ -222,13 +222,13 @@ void MainWindow::setupControls()
ui->lineEditName->setValidator(new QRegularExpressionValidator(m_nameRegEx, this));
ui->lineEditName->setVisible(false);
#if defined(Q_OS_MAC)
ui->rbModeServer->setAttribute(Qt::WA_MacShowFocusRect, 0);
ui->rbModeClient->setAttribute(Qt::WA_MacShowFocusRect, 0);
ui->btnSaveServerConfig->setFixedWidth(ui->btnSaveServerConfig->height());
#else
ui->btnSaveServerConfig->setIconSize(QSize(22, 22));
#endif
if (deskflow::platform::isMac()) {
ui->rbModeServer->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->rbModeClient->setAttribute(Qt::WA_MacShowFocusRect, false);
ui->btnSaveServerConfig->setFixedWidth(ui->btnSaveServerConfig->height());
} else {
ui->btnSaveServerConfig->setIconSize(QSize(22, 22));
}
static const auto btnHeight = ui->statusBar->height() - 2;
static const auto btnSize = QSize(btnHeight, btnHeight);
@ -295,10 +295,9 @@ void MainWindow::connectSlots()
connect(&m_versionChecker, &VersionChecker::updateFound, this, &MainWindow::versionCheckerUpdateFound);
// Mac os tray will only show a menu
#ifndef Q_OS_MAC
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
#endif
// Mac os tray will only show a menu
if (!deskflow::platform::isMac())
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
connect(&m_serverConnection, &ServerConnection::configureClient, this, &MainWindow::serverConnectionConfigureClient);
connect(&m_serverConnection, &ServerConnection::clientsChanged, this, &MainWindow::serverClientsChanged);

View File

@ -5,6 +5,7 @@
*/
#include "LogWidget.h"
#include "common/PlatformInfo.h"
#include <gui/Logger.h>
@ -19,11 +20,12 @@ LogWidget::LogWidget(QWidget *parent) : QWidget{parent}, m_textLog{new QPlainTex
// setup the log font
m_textLog->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
#ifdef Q_OS_MAC
auto f = m_textLog->font();
f.setPixelSize(12);
m_textLog->setFont(f);
#endif
if (deskflow::platform::isMac()) {
auto f = m_textLog->font();
f.setPixelSize(12);
m_textLog->setFont(f);
}
auto layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_textLog);