source: calamares/trunk/fuentes/src/libcalamaresui/Branding.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 3.4 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
4 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares 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.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef BRANDING_H
21#define BRANDING_H
22
23#include "UiDllMacro.h"
24#include "Typedefs.h"
25
26#include <QObject>
27#include <QStringList>
28#include <QMap>
29
30
31namespace Calamares
32{
33
34class GlobalStorage;
35
36class UIDLLEXPORT Branding : public QObject
37{
38    Q_OBJECT
39public:
40    /**
41     * Descriptive strings in the configuration file. use
42     * e.g. *Branding::ProductName to get the string value for
43     * the product name.
44     */
45    enum StringEntry : short
46    {
47        ProductName,
48        Version,
49        ShortVersion,
50        VersionedName,
51        ShortVersionedName,
52        ShortProductName,
53        BootloaderEntryName,
54        ProductUrl,
55        SupportUrl,
56        KnownIssuesUrl,
57        ReleaseNotesUrl
58    };
59
60    enum ImageEntry : short
61    {
62        ProductLogo,
63        ProductIcon,
64        ProductWelcome
65    };
66   
67    enum StyleEntry : short
68    {
69        SidebarBackground,
70        SidebarText,
71        SidebarTextSelect,
72        SidebarTextHighlight
73    };
74
75    static Branding* instance();
76
77    explicit Branding( const QString& brandingFilePath,
78                       QObject* parent = nullptr );
79
80    QString descriptorPath() const;
81    QString componentName() const;
82    QString componentDirectory() const;
83    QString translationsPathPrefix() const;
84
85    QString string( Branding::StringEntry stringEntry ) const;
86    QString styleString( Branding::StyleEntry styleEntry ) const;
87    QString imagePath( Branding::ImageEntry imageEntry ) const;
88    QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
89    QString slideshowPath() const;
90
91    bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; }
92    bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; }
93
94    /**
95     * Creates a map called "branding" in the global storage, and inserts an
96     * entry for each of the branding strings. This makes the branding
97     * information accessible to the Python modules.
98     */
99    void setGlobals( GlobalStorage* globalStorage ) const;
100
101private:
102    static Branding* s_instance;
103
104    static const QStringList s_stringEntryStrings;
105    static const QStringList s_imageEntryStrings;
106    static const QStringList s_styleEntryStrings;
107
108    void bail( const QString& message );
109
110    QString m_descriptorPath;
111    QString m_componentName;
112    QMap< QString, QString > m_strings;
113    QMap< QString, QString > m_images;
114    QMap< QString, QString > m_style;
115    QString m_slideshowPath;
116    QString m_translationsPathPrefix;
117
118    bool m_welcomeStyleCalamares;
119    bool m_welcomeExpandingLogo;
120};
121
122template<typename U> inline QString operator*(U e) { return Branding::instance()->string( e ); }
123
124}
125
126#endif // BRANDING_H
Note: See TracBrowser for help on using the repository browser.