2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2023 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2019 Prince Gupta <jagannatharjun11@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * In addition, as a special exception, the copyright holders give permission to
22 * link this program with the OpenSSL project's "OpenSSL" library (or with
23 * modified versions of it that use the same license as the "OpenSSL" library),
24 * and distribute the linked executables. You must obey the GNU General Public
25 * License in all respects for all of the code used other than "OpenSSL". If
26 * you modify file(s), you may extend this exception to your version of the
27 * file(s), but you are not obligated to do so. If you do not wish to do so,
28 * delete this exception statement from your version.
36 #include <QCoreApplication>
41 #include "base/path.h"
42 #include "uithemecommon.h"
52 Q_DECLARE_TR_FUNCTIONS(UIThemeSource
)
55 virtual ~UIThemeSource() = default;
57 virtual QColor
getColor(const QString
&colorId
, ColorMode colorMode
) const = 0;
58 virtual Path
getIconPath(const QString
&iconId
, ColorMode colorMode
) const = 0;
59 virtual QByteArray
readStyleSheet() = 0;
62 class DefaultThemeSource final
: public UIThemeSource
64 Q_DECLARE_TR_FUNCTIONS(DefaultThemeSource
)
69 QByteArray
readStyleSheet() override
;
70 QColor
getColor(const QString
&colorId
, ColorMode colorMode
) const override
;
71 Path
getIconPath(const QString
&iconId
, ColorMode colorMode
) const override
;
76 const Path m_defaultPath
;
77 const Path m_userPath
;
78 QHash
<QString
, UIThemeColor
> m_colors
;
81 class CustomThemeSource
: public UIThemeSource
83 Q_DECLARE_TR_FUNCTIONS(CustomThemeSource
)
86 QColor
getColor(const QString
&colorId
, ColorMode colorMode
) const override
;
87 Path
getIconPath(const QString
&iconId
, ColorMode colorMode
) const override
;
88 QByteArray
readStyleSheet() override
;
91 explicit CustomThemeSource(const Path
&themeRootPath
);
93 DefaultThemeSource
*defaultThemeSource() const;
96 Path
themeRootPath() const;
99 const std::unique_ptr
<DefaultThemeSource
> m_defaultThemeSource
= std::make_unique
<DefaultThemeSource
>();
100 Path m_themeRootPath
;
101 QHash
<QString
, QColor
> m_colors
;
102 QHash
<QString
, QColor
> m_darkModeColors
;
105 class QRCThemeSource final
: public CustomThemeSource
111 class FolderThemeSource
: public CustomThemeSource
114 explicit FolderThemeSource(const Path
&folderPath
);
116 QByteArray
readStyleSheet() override
;