Merge pull request #211 from calamares/branding-style
Eliminate CalamaresStyle and get style constants from Branding instead.
This commit is contained in:
commit
19715c2ab1
@ -15,3 +15,8 @@ images:
|
||||
productIcon: "squid.png"
|
||||
|
||||
slideshow: "show.qml"
|
||||
|
||||
style:
|
||||
sidebarBackground: "#292F34"
|
||||
sidebarText: "#FFFFFF"
|
||||
sidebarTextSelect: "#292F34"
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "ViewManager.h"
|
||||
#include "progresstree/ProgressTreeView.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/CalamaresStyle.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/DebugWindow.h"
|
||||
#include "utils/Retranslator.h"
|
||||
@ -71,8 +70,10 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
{
|
||||
QPalette plt = sideBox->palette();
|
||||
sideBox->setAutoFillBackground( true );
|
||||
plt.setColor( sideBox->backgroundRole(), CalamaresStyle::SIDEBAR_BACKGROUND );
|
||||
plt.setColor( sideBox->foregroundRole(), CalamaresStyle::SIDEBAR_TEXT );
|
||||
plt.setColor( sideBox->backgroundRole(), Calamares::Branding::instance()->
|
||||
styleString( Calamares::Branding::SidebarBackground ) );
|
||||
plt.setColor( sideBox->foregroundRole(), Calamares::Branding::instance()->
|
||||
styleString( Calamares::Branding::SidebarText ) );
|
||||
sideBox->setPalette( plt );
|
||||
logoLabel->setPalette( plt );
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "ViewStepItem.h"
|
||||
#include "ProgressTreeModel.h"
|
||||
#include "ViewManager.h"
|
||||
#include "utils/CalamaresStyle.h"
|
||||
#include "Branding.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
|
||||
#include <QAbstractItemView>
|
||||
@ -82,8 +82,10 @@ ProgressTreeDelegate::paint( QPainter* painter,
|
||||
initStyleOption( &opt, index );
|
||||
opt.text.clear();
|
||||
|
||||
painter->setBrush( CalamaresStyle::SIDEBAR_BACKGROUND );
|
||||
painter->setPen( CalamaresStyle::SIDEBAR_TEXT );
|
||||
painter->setBrush( QColor( Calamares::Branding::instance()->
|
||||
styleString( Calamares::Branding::SidebarBackground ) ) );
|
||||
painter->setPen( QColor( Calamares::Branding::instance()->
|
||||
styleString( Calamares::Branding::SidebarText ) ) );
|
||||
|
||||
if ( isFirstLevel )
|
||||
paintCategory( painter, opt, index );
|
||||
@ -135,7 +137,8 @@ ProgressTreeDelegate::paintViewStep( QPainter* painter,
|
||||
|
||||
if ( isCurrent )
|
||||
{
|
||||
painter->setPen( CalamaresStyle::SIDEBAR_TEXT_SELECT );
|
||||
painter->setPen( Calamares::Branding::instance()->
|
||||
styleString( Calamares::Branding::SidebarTextSelect ) );
|
||||
painter->setBrush( APP->mainWindow()->palette().background() );
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "ProgressTreeDelegate.h"
|
||||
#include "ViewManager.h"
|
||||
#include "utils/CalamaresStyle.h"
|
||||
#include "Branding.h"
|
||||
|
||||
ProgressTreeView* ProgressTreeView::s_instance = nullptr;
|
||||
|
||||
@ -54,7 +54,8 @@ ProgressTreeView::ProgressTreeView( QWidget* parent )
|
||||
setItemDelegate( m_delegate );
|
||||
|
||||
QPalette plt = palette();
|
||||
plt.setColor( QPalette::Base, CalamaresStyle::SIDEBAR_BACKGROUND );
|
||||
plt.setColor( QPalette::Base, Calamares::Branding::instance()->
|
||||
styleString( Calamares::Branding::SidebarBackground ) );
|
||||
setPalette( plt );
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,13 @@ QStringList Branding::s_imageEntryStrings =
|
||||
"productIcon"
|
||||
};
|
||||
|
||||
QStringList Branding::s_styleEntryStrings =
|
||||
{
|
||||
"sidebarBackground",
|
||||
"sidebarText",
|
||||
"sidebarTextSelect"
|
||||
};
|
||||
|
||||
|
||||
Branding::Branding( const QString& brandingFilePath,
|
||||
QObject* parent )
|
||||
@ -147,6 +154,15 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
else
|
||||
bail( "Syntax error in slideshow sequence." );
|
||||
|
||||
if ( !doc[ "style" ].IsMap() )
|
||||
bail( "Syntax error in style map." );
|
||||
|
||||
QVariantMap style =
|
||||
CalamaresUtils::yamlMapToVariant( doc[ "style" ] ).toMap();
|
||||
m_style.clear();
|
||||
for ( auto it = style.constBegin(); it != style.constEnd(); ++it )
|
||||
m_style.insert( it.key(), it.value().toString() );
|
||||
|
||||
}
|
||||
catch ( YAML::Exception& e )
|
||||
{
|
||||
@ -192,6 +208,13 @@ Branding::string( Branding::StringEntry stringEntry ) const
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
Branding::styleString( Branding::StyleEntry styleEntry ) const
|
||||
{
|
||||
return m_style.value( s_styleEntryStrings.value( styleEntry ) );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
Branding::imagePath( Branding::ImageEntry imageEntry ) const
|
||||
{
|
||||
|
@ -53,6 +53,13 @@ public:
|
||||
ProductIcon
|
||||
};
|
||||
|
||||
enum StyleEntry : short
|
||||
{
|
||||
SidebarBackground,
|
||||
SidebarText,
|
||||
SidebarTextSelect
|
||||
};
|
||||
|
||||
static Branding* instance();
|
||||
|
||||
explicit Branding( const QString& brandingFilePath,
|
||||
@ -63,6 +70,7 @@ public:
|
||||
QString componentDirectory() 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;
|
||||
@ -79,6 +87,7 @@ private:
|
||||
|
||||
static QStringList s_stringEntryStrings;
|
||||
static QStringList s_imageEntryStrings;
|
||||
static QStringList s_styleEntryStrings;
|
||||
|
||||
void bail( const QString& message );
|
||||
|
||||
@ -86,6 +95,7 @@ private:
|
||||
QString m_componentName;
|
||||
QMap< QString, QString > m_strings;
|
||||
QMap< QString, QString > m_images;
|
||||
QMap< QString, QString > m_style;
|
||||
QString m_slideshowPath;
|
||||
};
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, 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 CALAMARESSTYLE_H
|
||||
#define CALAMARESSTYLE_H
|
||||
|
||||
#include "../UiDllMacro.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
|
||||
namespace CalamaresStyle {
|
||||
|
||||
static const QColor SIDEBAR_BACKGROUND = "#292F34";
|
||||
static const QColor SIDEBAR_TEXT = "#FFFFFF";
|
||||
static const QColor SIDEBAR_TEXT_SELECT = "#292F34";
|
||||
|
||||
} // namespace CalamaresStyle
|
||||
|
||||
#endif // CALAMARESSTYLE_H
|
Loading…
Reference in New Issue
Block a user