Debian Codegraph @

Nagstamon/qui/widgets/app.py

raw
1 # Nagstamon - Nagios status monitor for your desktop
2 # Copyright (C) 2008-2026 Henri Wahl <[email protected]> et al.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17
18 from platform import release
19 from os import sep
20 from sys import argv
21
22 from Nagstamon.config import (OS,
23 OS_WINDOWS,
24 RESOURCES)
25 from Nagstamon.qui.qt import (Qt,
26 QApplication,
27 QFontDatabase,
28 QT_VERSION_MAJOR)
29 from Nagstamon.qui.widgets.buttons import StandardDialogIconsProxyStyle
30
31 # since Qt6 HighDPI-awareness is default behaviour
32 if QT_VERSION_MAJOR < 6:
33 # enable HighDPI-awareness to avoid https://github.com/HenriWahl/Nagstamon/issues/618
34 try:
35 QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
36 except AttributeError:
37 pass
38 QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
39
40
41 # global application instance
42 app = QApplication(argv)
43
44 # set style for tooltips globally - to sad not all properties can be set here
45 app.setStyleSheet('''QToolTip { margin: 3px;
46 }''')
47
48 # proxy style helps to remove ugly icons in Linux Fusion style
49 app.setStyle(StandardDialogIconsProxyStyle())
50
51 # as long as Windows 11 + Qt6 looks that ugly it's better to choose another app style
52 # might be mitigated with sometimes, so commented out now
53 if OS == OS_WINDOWS and release() >= '11':
54 app.setStyle('fusion')
55
56 # add nagstamon.ttf with icons to fonts
57 QFontDatabase.addApplicationFont(f'{RESOURCES}{sep}nagstamon.ttf')