Deskflow
1.26.0.418
Keyboard and mouse sharing utility
Toggle main menu visibility
Loading...
Searching...
No Matches
StyleUtils.h
Go to the documentation of this file.
1
/*
2
* Deskflow -- mouse and keyboard sharing utility
3
* SPDX-FileCopyrightText: (C) 2024 Synergy App Ltd
4
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
5
*/
6
7
#pragma once
8
9
#include <QDir>
10
#include <QFileInfoList>
11
#include <QFontDatabase>
12
#include <QIcon>
13
#include <QPalette>
14
#include <QStyleHints>
15
16
#include "common/Constants.h"
17
18
namespace
deskflow::gui
{
19
26
inline
bool
isDarkMode
()
27
{
28
const
QPalette defaultPalette;
29
const
auto
text = defaultPalette.color(QPalette::WindowText);
30
const
auto
window = defaultPalette.color(QPalette::Window);
31
return
text.lightness() > window.lightness();
32
}
33
37
inline
QString
iconMode
()
38
{
39
return
isDarkMode
() ? QStringLiteral(
"dark"
) : QStringLiteral(
"light"
);
40
}
41
42
inline
void
updateIconTheme
()
43
{
44
// Sets the fallback icon path and fallback theme
45
const
auto
themeName = QStringLiteral(
"%1-%2"
).arg(kAppId,
iconMode
());
46
if
(QIcon::themeName().isEmpty() || QIcon::themeName().startsWith(kAppId))
47
QIcon::setThemeName(themeName);
48
else
49
QIcon::setFallbackThemeName(themeName);
50
QIcon::setFallbackSearchPaths({QStringLiteral(
":/icons/%1"
).arg(themeName)});
51
}
52
}
// namespace deskflow::gui
53
54
inline
QFont
fixedFont
()
55
{
56
#if defined(Q_OS_WIN)
57
QFont f({
"Hack"
,
"Liberation Mono"
,
"Monospace"
,
"Andale Mono"
});
58
f.setStyleHint(QFont::Monospace);
59
#else
60
QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont);
61
#endif
62
63
#if defined(Q_OS_MACOS)
64
f.setPointSize(12);
65
#endif
66
return
f;
67
}
fixedFont
QFont fixedFont()
Definition
StyleUtils.h:54
deskflow::gui
Definition
CoreProcess.cpp:30
deskflow::gui::iconMode
QString iconMode()
get a string for the iconMode
Definition
StyleUtils.h:37
deskflow::gui::updateIconTheme
void updateIconTheme()
Definition
StyleUtils.h:42
deskflow::gui::isDarkMode
bool isDarkMode()
Detects dark mode in a universal manner (all Qt versions). Until better platform support is added,...
Definition
StyleUtils.h:26
src
lib
gui
StyleUtils.h
Generated by
1.18.0