calamares/src/libcalamaresui/Branding.h
Andrius Štikonas 9f0ca042fe Port away from most cases of Q_FOREACH to C++11 ranged for loop.
In order to avoid deep copies, Qt containers over which we iterate must be const
The remaining unported cases require qAsConst (Qt 5.7) or std::as_const (C++17)
2016-09-01 16:46:14 +01:00

112 lines
2.9 KiB
C++

/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BRANDING_H
#define BRANDING_H
#include "UiDllMacro.h"
#include "Typedefs.h"
#include <QObject>
#include <QStringList>
#include <QMap>
namespace Calamares
{
class GlobalStorage;
class UIDLLEXPORT Branding : public QObject
{
Q_OBJECT
public:
enum StringEntry : short
{
ProductName,
Version,
ShortVersion,
VersionedName,
ShortVersionedName,
ShortProductName,
BootloaderEntryName,
ProductUrl,
SupportUrl,
KnownIssuesUrl,
ReleaseNotesUrl
};
enum ImageEntry : short
{
ProductLogo,
ProductIcon,
ProductWelcome
};
enum StyleEntry : short
{
SidebarBackground,
SidebarText,
SidebarTextSelect
};
static Branding* instance();
explicit Branding( const QString& brandingFilePath,
QObject* parent = nullptr );
QString descriptorPath() const;
QString componentName() const;
QString componentDirectory() const;
QString translationsPathPrefix() const;
QString string( Branding::StringEntry stringEntry ) const;
QString styleString( Branding::StyleEntry styleEntry ) const;
QString imagePath( Branding::ImageEntry imageEntry ) const;
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
QString slideshowPath() const;
/**
* Creates a map called "branding" in the global storage, and inserts an
* entry for each of the branding strings. This makes the branding
* information accessible to the Python modules.
*/
void setGlobals( GlobalStorage* globalStorage ) const;
private:
static Branding* s_instance;
static const QStringList s_stringEntryStrings;
static const QStringList s_imageEntryStrings;
static const QStringList s_styleEntryStrings;
void bail( const QString& message );
QString m_descriptorPath;
QString m_componentName;
QMap< QString, QString > m_strings;
QMap< QString, QString > m_images;
QMap< QString, QString > m_style;
QString m_slideshowPath;
QString m_translationsPathPrefix;
};
}
#endif // BRANDING_H