2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2019 Prince Gupta <jagannatharjun11@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If
25 * you modify file(s), you may extend this exception to your version of the
26 * file(s), but you are not obligated to do so. If you do not wish to do so,
27 * delete this exception statement from your version.
38 class UIThemeManager
: public QObject
41 Q_DISABLE_COPY_MOVE(UIThemeManager
)
44 static void initInstance();
45 static void freeInstance();
46 static UIThemeManager
*instance();
48 QString
getIconPath(const QString
&iconId
) const;
49 QIcon
getIcon(const QString
&iconId
, const QString
&fallback
= {}) const;
50 QIcon
getFlagIcon(const QString
&countryIsoCode
) const;
52 QColor
getColor(const QString
&id
, const QColor
&defaultColor
) const;
55 UIThemeManager(); // singleton class
56 QString
getIconPathFromResources(const QString
&iconId
, const QString
&fallback
= {}) const;
57 void loadColorsFromJSONConfig();
58 void applyPalette() const;
59 void applyStyleSheet() const;
61 static UIThemeManager
*m_instance
;
62 QHash
<QString
, QColor
> m_colors
;
63 mutable QHash
<QString
, QIcon
> m_iconCache
;
64 mutable QHash
<QString
, QIcon
> m_flagCache
;
65 const bool m_useCustomTheme
;
66 #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
67 const bool m_useSystemTheme
;