From 56afa458126d57d36c6af6a2ac832d57b2a0f49f Mon Sep 17 00:00:00 2001 From: demmm Date: Thu, 19 Mar 2015 11:26:22 -0400 Subject: [PATCH 1/7] start of trial to add sidebar style options use a new style section in branding.desc, doesn't build as is --- src/branding/default/branding.desc | 5 +++++ src/libcalamaresui/Branding.cpp | 16 ++++++++++++++++ src/libcalamaresui/Branding.h | 10 ++++++++++ src/libcalamaresui/utils/CalamaresStyle.h | 11 ++++++++--- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index d6913c1e9..518d8e30b 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -15,3 +15,8 @@ images: productIcon: "squid.png" slideshow: "show.qml" + +style: + sidebarBackground: #292F34 + sidebarText: #FFFFFF + sidebarTextSelect: #292F34 diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 997bb59b4..de13759b7 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -62,6 +62,13 @@ QStringList Branding::s_imageEntryStrings = "productIcon" }; +QStringList Branding::s_styleEntryStrings = +{ + "sidebarBackground", + "sidebarText", + "sidebarTextSelect" +}; + Branding::Branding( const QString& brandingFilePath, QObject* parent ) @@ -146,6 +153,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 ) diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index bddea1b70..2a2279945 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -52,6 +52,13 @@ public: ProductLogo, ProductIcon }; + + enum StyleEntry : short + { + SidebarBackground, + SidebarText, + SidebarTextSelect + }; static Branding* instance(); @@ -66,6 +73,7 @@ public: QString imagePath( Branding::ImageEntry imageEntry ) const; QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const; QString slideshowPath() const; + QString style( Branding::StyleEntry styleEntry ) const; /** * Creates a map called "branding" in the global storage, and inserts an @@ -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; }; diff --git a/src/libcalamaresui/utils/CalamaresStyle.h b/src/libcalamaresui/utils/CalamaresStyle.h index 8eb24a711..d0db3cf9b 100644 --- a/src/libcalamaresui/utils/CalamaresStyle.h +++ b/src/libcalamaresui/utils/CalamaresStyle.h @@ -23,12 +23,17 @@ #include +#include "Branding.h" + namespace CalamaresStyle { -static const QColor SIDEBAR_BACKGROUND = "#292F34"; -static const QColor SIDEBAR_TEXT = "#FFFFFF"; -static const QColor SIDEBAR_TEXT_SELECT = "#292F34"; +static const QColor SIDEBAR_BACKGROUND = QColor( Calamares::Branding::instance()-> + style( Calamares::Branding::SidebarBackground ) ); +static const QColor SIDEBAR_TEXT = QColor( Calamares::Branding::instance()-> + style( Calamares::Branding::SidebarText ) ); +static const QColor SIDEBAR_TEXT_SELECT = QColor( Calamares::Branding::instance()-> + style( Calamares::Branding::SidebarTextSelect ) ); } // namespace CalamaresStyle From b982d751afbcdf695b863b3bccf894efe13a1ef4 Mon Sep 17 00:00:00 2001 From: demmm Date: Thu, 19 Mar 2015 12:00:43 -0400 Subject: [PATCH 2/7] adding needed Branding.cpp section builds, but segfaults on running --- src/libcalamaresui/Branding.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index de13759b7..916fd84d1 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -236,6 +236,12 @@ Branding::slideshowPath() const return m_slideshowPath; } +QString +Branding::style( Branding::StyleEntry styleEntry ) const +{ + return m_style.value( s_styleEntryStrings.value( styleEntry ) ); +} + void Branding::setGlobals( GlobalStorage* globalStorage ) const From 9615691554c94bd797766851b8ad33d481b7e215 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 19 Mar 2015 17:57:41 +0100 Subject: [PATCH 3/7] CalamaresStyle is no more. Look for color constants in Branding. --- src/libcalamaresui/utils/CalamaresStyle.h | 40 ----------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/libcalamaresui/utils/CalamaresStyle.h diff --git a/src/libcalamaresui/utils/CalamaresStyle.h b/src/libcalamaresui/utils/CalamaresStyle.h deleted file mode 100644 index d0db3cf9b..000000000 --- a/src/libcalamaresui/utils/CalamaresStyle.h +++ /dev/null @@ -1,40 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * 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 . - */ - -#ifndef CALAMARESSTYLE_H -#define CALAMARESSTYLE_H - -#include "../UiDllMacro.h" - -#include - -#include "Branding.h" - - -namespace CalamaresStyle { - -static const QColor SIDEBAR_BACKGROUND = QColor( Calamares::Branding::instance()-> - style( Calamares::Branding::SidebarBackground ) ); -static const QColor SIDEBAR_TEXT = QColor( Calamares::Branding::instance()-> - style( Calamares::Branding::SidebarText ) ); -static const QColor SIDEBAR_TEXT_SELECT = QColor( Calamares::Branding::instance()-> - style( Calamares::Branding::SidebarTextSelect ) ); - -} // namespace CalamaresStyle - -#endif // CALAMARESSTYLE_H From cc5095781d8fdb0607576e6f31c4905416fc3601 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 19 Mar 2015 17:58:18 +0100 Subject: [PATCH 4/7] Branding::style is now ::styleString for clarity. --- src/libcalamaresui/Branding.cpp | 13 +++++++------ src/libcalamaresui/Branding.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 916fd84d1..8755b8abd 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -208,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 { @@ -236,12 +243,6 @@ Branding::slideshowPath() const return m_slideshowPath; } -QString -Branding::style( Branding::StyleEntry styleEntry ) const -{ - return m_style.value( s_styleEntryStrings.value( styleEntry ) ); -} - void Branding::setGlobals( GlobalStorage* globalStorage ) const diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 2a2279945..4ebaf3c1f 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -70,10 +70,10 @@ 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; - QString style( Branding::StyleEntry styleEntry ) const; /** * Creates a map called "branding" in the global storage, and inserts an From e5d4c02b4a48ffb305e5a826b7bfd8c595015558 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 19 Mar 2015 17:59:14 +0100 Subject: [PATCH 5/7] Use Branding styleStrings instead of CalamaresStyle constants. --- src/calamares/CalamaresWindow.cpp | 7 ++++--- src/calamares/progresstree/ProgressTreeDelegate.cpp | 11 +++++++---- src/calamares/progresstree/ProgressTreeView.cpp | 5 +++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index c0563bf45..63f28f9c2 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -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 ); } diff --git a/src/calamares/progresstree/ProgressTreeDelegate.cpp b/src/calamares/progresstree/ProgressTreeDelegate.cpp index 9270ecd6f..ccc8f9a58 100644 --- a/src/calamares/progresstree/ProgressTreeDelegate.cpp +++ b/src/calamares/progresstree/ProgressTreeDelegate.cpp @@ -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 @@ -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() ); } diff --git a/src/calamares/progresstree/ProgressTreeView.cpp b/src/calamares/progresstree/ProgressTreeView.cpp index 37b47cf0e..7fc44d146 100644 --- a/src/calamares/progresstree/ProgressTreeView.cpp +++ b/src/calamares/progresstree/ProgressTreeView.cpp @@ -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 ); } From 62f6f1d9cf6b7a80c7305c3286b22f0bc68f92c1 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 19 Mar 2015 17:59:38 +0100 Subject: [PATCH 6/7] Dress color codes, otherwise they are treated as YAML comments. --- src/branding/default/branding.desc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index 518d8e30b..cd73388ba 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -17,6 +17,6 @@ images: slideshow: "show.qml" style: - sidebarBackground: #292F34 - sidebarText: #FFFFFF - sidebarTextSelect: #292F34 + sidebarBackground: "#292F34" + sidebarText: "#FFFFFF" + sidebarTextSelect: "#292F34" From f2c7458ebe04e5faacc7869576cb4c4da5e8bd1d Mon Sep 17 00:00:00 2001 From: demmm Date: Thu, 19 Mar 2015 13:10:44 -0400 Subject: [PATCH 7/7] proper align --- src/branding/default/branding.desc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index cd73388ba..6852386f8 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -17,6 +17,6 @@ images: slideshow: "show.qml" style: - sidebarBackground: "#292F34" - sidebarText: "#FFFFFF" - sidebarTextSelect: "#292F34" + sidebarBackground: "#292F34" + sidebarText: "#FFFFFF" + sidebarTextSelect: "#292F34"