From 80f49bed1daa580e6894a2870454ad50dd4beeca Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 17:59:06 -0500 Subject: [PATCH] [libcalamaresui] Add a sidebar flavor setting --- src/branding/default/branding.desc | 6 ++++++ src/libcalamaresui/Branding.cpp | 19 ++++++++++++++++++- src/libcalamaresui/Branding.h | 11 +++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index af1d39ca4..c3c0796cd 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -41,6 +41,12 @@ windowSize: 800px,520px # *windowExpanding* set to "fullscreen"). windowPlacement: center +# Kind of sidebar (panel on the left, showing progress). +# - "widget" or unset, use traditional sidebar (logo, items) +# - "none", hide it entirely +# - "qml", use sidebar.qml from branding folder +sidebar: none + # These are strings shown to the user in the user interface. # There is no provision for translating them -- since they # are names, the string is included as-is. diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index 9bdccfa51..34ba23436 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -89,6 +89,7 @@ const QStringList Branding::s_styleEntryStrings = // clang-format on // *INDENT-ON* + const NamedEnumTable< Branding::WindowDimensionUnit >& Branding::WindowDimension::suffixes() { @@ -407,14 +408,24 @@ getString( const YAML::Node& doc, const char* key ) void Branding::initSimpleSettings( const YAML::Node& doc ) { + // *INDENT-OFF* + // clang-format off static const NamedEnumTable< WindowExpansion > expansionNames { { QStringLiteral( "normal" ), WindowExpansion::Normal }, { QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen }, { QStringLiteral( "noexpand" ), WindowExpansion::Fixed } }; static const NamedEnumTable< WindowPlacement > placementNames { - { QStringLiteral( "free" ), WindowPlacement::Free }, { QStringLiteral( "center" ), WindowPlacement::Center } + { QStringLiteral( "free" ), WindowPlacement::Free }, + { QStringLiteral( "center" ), WindowPlacement::Center } }; + static const NamedEnumTable< SidebarFlavor > sidebarFlavorNames { + { QStringLiteral( "widget" ), SidebarFlavor::Widget }, + { QStringLiteral( "none" ), SidebarFlavor::None }, + { QStringLiteral( "qml" ), SidebarFlavor::Qml } + }; + // clang-format on + // *INDENT-ON* bool ok = false; m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false ); @@ -431,6 +442,12 @@ Branding::initSimpleSettings( const YAML::Node& doc ) cWarning() << "Branding module-setting *windowPlacement* interpreted as" << placementNames.find( m_windowPlacement, ok ); } + m_sidebarFlavor = sidebarFlavorNames.find( getString( doc, "sidebar" ), ok ); + if ( !ok ) + { + cWarning() << "Branding module-setting *sidebar* interpreted as" + << sidebarFlavorNames.find( m_sidebarFlavor, ok ); + } QString windowSize = getString( doc, "windowSize" ); if ( !windowSize.isEmpty() ) diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 3dfcd0586..6bc85875c 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -122,6 +122,15 @@ public: Center, Free }; + Q_ENUM( WindowPlacement ) + ///@brief What kind of sidebar to use in the main window + enum class SidebarFlavor + { + None, + Widget, + Qml + }; + Q_ENUM( SidebarFlavor ) static Branding* instance(); @@ -214,6 +223,8 @@ private: WindowExpansion m_windowExpansion; WindowDimension m_windowHeight, m_windowWidth; WindowPlacement m_windowPlacement; + + SidebarFlavor m_sidebarFlavor = SidebarFlavor::Widget; }; template < typename U >