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>
|
2018-05-22 11:47:14 +02:00
|
|
|
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
|
|
|
* Copyright 2018, Raul Rodrigo Segura (raurodse)
|
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"
|
|
|
|
|
2019-01-14 12:06:04 +01:00
|
|
|
#include "utils/NamedSuffix.h"
|
|
|
|
|
2014-10-10 18:18:35 +02:00
|
|
|
#include <QObject>
|
2014-10-16 16:14:48 +02:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QMap>
|
2014-10-10 18:18:35 +02:00
|
|
|
|
2019-01-11 17:35:06 +01:00
|
|
|
namespace YAML
|
|
|
|
{
|
|
|
|
class Node;
|
|
|
|
}
|
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
|
|
|
};
|
2019-01-11 17:35:06 +01: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
|
|
|
|
2019-01-11 17:35:06 +01:00
|
|
|
/** @brief Setting for how much the main window may expand. */
|
|
|
|
enum class WindowExpansion { Normal, Fullscreen, Fixed } ;
|
2019-01-14 12:06:04 +01:00
|
|
|
/** @brief Setting for the main window size.
|
|
|
|
*
|
|
|
|
* The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which
|
|
|
|
* we suffix as "em", e.g. "600px" or "32em".
|
|
|
|
*/
|
|
|
|
enum class WindowDimensionUnit { None, Pixies, Fonties };
|
|
|
|
class WindowDimension : public NamedSuffix<WindowDimensionUnit, WindowDimensionUnit::None>
|
|
|
|
{
|
|
|
|
public:
|
2019-04-11 14:26:16 +02:00
|
|
|
static const NamedEnumTable< WindowDimensionUnit >& suffixes();
|
2019-01-14 12:06:04 +01:00
|
|
|
bool isValid() const;
|
2019-04-11 14:26:16 +02:00
|
|
|
|
|
|
|
using NamedSuffix::NamedSuffix;
|
|
|
|
WindowDimension( const QString& s ) : NamedSuffix( suffixes(), s ) {}
|
2019-01-14 12:06:04 +01:00
|
|
|
} ;
|
2019-01-11 17:35:06 +01: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; }
|
2019-04-23 22:41:22 +02:00
|
|
|
|
2018-05-22 11:21:20 +02:00
|
|
|
/** @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;
|
2019-05-21 13:21:47 +02:00
|
|
|
/** @brief Stylesheet to apply for this branding. May be empty.
|
|
|
|
*
|
|
|
|
* The file is loaded every time this function is called, so
|
|
|
|
* it may be quite expensive -- although normally it will be
|
|
|
|
* called only once, on startup. (Or from the debug window)
|
|
|
|
*/
|
|
|
|
QString stylesheet() 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; }
|
2019-01-14 14:17:39 +01:00
|
|
|
bool windowMaximize() const { return m_windowExpansion == WindowExpansion::Fullscreen; }
|
2019-01-14 14:25:01 +01:00
|
|
|
bool windowExpands() const { return m_windowExpansion != WindowExpansion::Fixed; }
|
2019-01-14 12:06:04 +01:00
|
|
|
QPair< WindowDimension, WindowDimension > windowSize() const
|
|
|
|
{
|
|
|
|
return QPair< WindowDimension, WindowDimension >( m_windowWidth, m_windowHeight );
|
|
|
|
}
|
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
|
|
|
|
2019-04-11 12:35:38 +02:00
|
|
|
[[noreturn]] void bail( const QString& message );
|
2014-10-16 16:14:48 +02:00
|
|
|
|
2019-05-21 13:21:47 +02:00
|
|
|
QString m_descriptorPath; // Path to descriptor (e.g. "/etc/calamares/default/branding.desc")
|
|
|
|
QString m_componentName; // Matches last part of full path to containing directory
|
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
|
|
|
|
2019-01-11 17:35:06 +01:00
|
|
|
/** @brief Initialize the simple settings below */
|
|
|
|
void initSimpleSettings( const YAML::Node& doc );
|
|
|
|
|
2017-06-12 21:25:05 +02:00
|
|
|
bool m_welcomeStyleCalamares;
|
2017-07-04 10:30:08 +02:00
|
|
|
bool m_welcomeExpandingLogo;
|
2019-01-11 17:35:06 +01:00
|
|
|
WindowExpansion m_windowExpansion;
|
2019-01-14 12:06:04 +01:00
|
|
|
|
|
|
|
WindowDimension m_windowHeight, m_windowWidth;
|
|
|
|
|
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
|