2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2014-10-10 18:18:35 +02:00
|
|
|
*
|
2015-05-07 16:10:04 +02:00
|
|
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
2017-06-12 21:25:05 +02:00
|
|
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
2014-10-10 18:18:35 +02:00
|
|
|
*
|
|
|
|
* 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>
|
2014-10-16 16:14:48 +02:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QMap>
|
2014-10-10 18:18:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace Calamares
|
|
|
|
{
|
|
|
|
|
2014-11-16 04:19:53 +01:00
|
|
|
class GlobalStorage;
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
class UIDLLEXPORT Branding : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-07-04 00:07:18 +02:00
|
|
|
/**
|
|
|
|
* Descriptive strings in the configuration file. use
|
|
|
|
* e.g. *Branding::ProductName to get the string value for
|
|
|
|
* the product name.
|
|
|
|
*/
|
2014-10-16 16:57:52 +02:00
|
|
|
enum StringEntry : short
|
|
|
|
{
|
|
|
|
ProductName,
|
|
|
|
Version,
|
|
|
|
ShortVersion,
|
|
|
|
VersionedName,
|
2014-11-16 05:14:57 +01:00
|
|
|
ShortVersionedName,
|
2014-11-19 16:50:15 +01:00
|
|
|
ShortProductName,
|
2015-04-01 18:03:17 +02:00
|
|
|
BootloaderEntryName,
|
|
|
|
ProductUrl,
|
2015-04-01 19:00:52 +02:00
|
|
|
SupportUrl,
|
|
|
|
KnownIssuesUrl,
|
|
|
|
ReleaseNotesUrl
|
2014-10-16 16:57:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ImageEntry : short
|
|
|
|
{
|
|
|
|
ProductLogo,
|
2015-06-20 00:18:14 +02:00
|
|
|
ProductIcon,
|
|
|
|
ProductWelcome
|
2014-10-16 16:57:52 +02:00
|
|
|
};
|
2018-05-22 11:21:20 +02:00
|
|
|
|
2015-03-19 16:26:22 +01:00
|
|
|
enum StyleEntry : short
|
|
|
|
{
|
|
|
|
SidebarBackground,
|
|
|
|
SidebarText,
|
2016-01-07 04:02:56 +01:00
|
|
|
SidebarTextSelect,
|
|
|
|
SidebarTextHighlight
|
2015-03-19 16:26:22 +01:00
|
|
|
};
|
2014-10-16 16:14:48 +02:00
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
static Branding* instance();
|
|
|
|
|
|
|
|
explicit Branding( const QString& brandingFilePath,
|
2015-02-26 01:57:19 +01:00
|
|
|
QObject* parent = nullptr );
|
2014-10-10 18:18:35 +02:00
|
|
|
|
2018-05-22 11:21:20 +02:00
|
|
|
/** @brief Complete path of the branding descriptor file. */
|
|
|
|
QString descriptorPath() const { return m_descriptorPath; }
|
|
|
|
/** @brief The component name found in the descriptor file.
|
|
|
|
*
|
|
|
|
* The component name always matches the last directory name in the path.
|
|
|
|
*/
|
|
|
|
QString componentName() const { return m_componentName; }
|
|
|
|
/** @brief The directory holding all of the branding assets. */
|
2014-10-10 18:18:35 +02:00
|
|
|
QString componentDirectory() const;
|
2018-05-22 11:21:20 +02:00
|
|
|
/** @brief The directory where branding translations live.
|
|
|
|
*
|
|
|
|
* This is componentDir + "/lang".
|
|
|
|
*/
|
|
|
|
QString translationsDirectory() const { return m_translationsPathPrefix; }
|
|
|
|
/** @brief Path to the slideshow QML file, if any. */
|
|
|
|
QString slideshowPath() const { return m_slideshowPath; }
|
2014-10-10 18:18:35 +02:00
|
|
|
|
2014-10-16 16:14:48 +02:00
|
|
|
QString string( Branding::StringEntry stringEntry ) const;
|
2015-03-19 17:58:18 +01:00
|
|
|
QString styleString( Branding::StyleEntry styleEntry ) const;
|
2014-10-16 16:57:52 +02:00
|
|
|
QString imagePath( Branding::ImageEntry imageEntry ) const;
|
|
|
|
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
|
2014-10-10 18:18:35 +02:00
|
|
|
|
2017-07-04 10:30:08 +02:00
|
|
|
bool welcomeStyleCalamares() const { return m_welcomeStyleCalamares; }
|
|
|
|
bool welcomeExpandingLogo() const { return m_welcomeExpandingLogo; }
|
2017-06-12 21:25:05 +02:00
|
|
|
|
2014-11-16 04:19:53 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
private:
|
|
|
|
static Branding* s_instance;
|
|
|
|
|
2016-09-01 14:21:05 +02:00
|
|
|
static const QStringList s_stringEntryStrings;
|
|
|
|
static const QStringList s_imageEntryStrings;
|
|
|
|
static const QStringList s_styleEntryStrings;
|
2014-10-16 16:14:48 +02:00
|
|
|
|
|
|
|
void bail( const QString& message );
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
QString m_descriptorPath;
|
|
|
|
QString m_componentName;
|
2014-10-16 16:14:48 +02:00
|
|
|
QMap< QString, QString > m_strings;
|
|
|
|
QMap< QString, QString > m_images;
|
2015-03-19 16:26:22 +01:00
|
|
|
QMap< QString, QString > m_style;
|
2015-01-23 14:02:40 +01:00
|
|
|
QString m_slideshowPath;
|
2015-05-07 16:10:04 +02:00
|
|
|
QString m_translationsPathPrefix;
|
2017-06-12 21:25:05 +02:00
|
|
|
|
|
|
|
bool m_welcomeStyleCalamares;
|
2017-07-04 10:30:08 +02:00
|
|
|
bool m_welcomeExpandingLogo;
|
2014-10-10 18:18:35 +02:00
|
|
|
};
|
|
|
|
|
2017-07-04 00:07:18 +02:00
|
|
|
template<typename U> inline QString operator*(U e) { return Branding::instance()->string( e ); }
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // BRANDING_H
|