From 57e6864902329c25565c0a856536079bd5d5e341 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 1 Apr 2020 11:13:41 +0200 Subject: [PATCH] [libcalamaresui] Add panel flavor - rename enum to more general PanelFlavor - introduce branding settings for navigation (e.g. for switching the navigation buttons off, or using QML) --- src/branding/default/branding.desc | 8 +++++++- src/calamares/CalamaresWindow.cpp | 6 +++--- src/libcalamaresui/Branding.cpp | 16 +++++++++++----- src/libcalamaresui/Branding.h | 11 +++++++---- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index e7b9d9898..365af30e9 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -44,9 +44,15 @@ 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 +# - "qml", use calamares-sidebar.qml from branding folder sidebar: widget +# Kind of navigation (button panel on the bottom). +# - "widget" or unset, use traditional navigation +# - "none", hide it entirely +# - "qml", use calamares-navigation.qml from branding folder +navigation: widget + # 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/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index f2ff42aa8..f05bdc7d4 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -191,15 +191,15 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) QWidget* sideBox = nullptr; switch ( branding->sidebarFlavor() ) { - case Calamares::Branding::SidebarFlavor::Widget: + case Calamares::Branding::PanelFlavor::Widget: sideBox = getWidgetSidebar( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); break; - case Calamares::Branding::SidebarFlavor::Qml: + case Calamares::Branding::PanelFlavor::Qml: sideBox = getQmlSidebar( qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) ); break; - case Calamares::Branding::SidebarFlavor::None: + case Calamares::Branding::PanelFlavor::None: sideBox = nullptr; } if ( sideBox ) diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index a1634520b..25fab307e 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -419,11 +419,11 @@ Branding::initSimpleSettings( const YAML::Node& doc ) { QStringLiteral( "free" ), WindowPlacement::Free }, { QStringLiteral( "center" ), WindowPlacement::Center } }; - static const NamedEnumTable< SidebarFlavor > sidebarFlavorNames { - { QStringLiteral( "widget" ), SidebarFlavor::Widget }, - { QStringLiteral( "none" ), SidebarFlavor::None }, - { QStringLiteral( "hidden" ), SidebarFlavor::None }, - { QStringLiteral( "qml" ), SidebarFlavor::Qml } + static const NamedEnumTable< PanelFlavor > sidebarFlavorNames { + { QStringLiteral( "widget" ), PanelFlavor::Widget }, + { QStringLiteral( "none" ), PanelFlavor::None }, + { QStringLiteral( "hidden" ), PanelFlavor::None }, + { QStringLiteral( "qml" ), PanelFlavor::Qml } }; // clang-format on // *INDENT-ON* @@ -449,6 +449,12 @@ Branding::initSimpleSettings( const YAML::Node& doc ) cWarning() << "Branding module-setting *sidebar* interpreted as" << sidebarFlavorNames.find( m_sidebarFlavor, ok ); } + m_navigationFlavor = sidebarFlavorNames.find( getString( doc, "navigation" ), ok); + if ( !ok ) + { + cWarning() << "Branding module-setting *navigation* interpreted as" + << sidebarFlavorNames.find( m_navigationFlavor, ok ); + } QString windowSize = getString( doc, "windowSize" ); if ( !windowSize.isEmpty() ) diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 88f658473..b7ba637d6 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -124,13 +124,13 @@ public: }; Q_ENUM( WindowPlacement ) ///@brief What kind of sidebar to use in the main window - enum class SidebarFlavor + enum class PanelFlavor { None, Widget, Qml }; - Q_ENUM( SidebarFlavor ) + Q_ENUM( PanelFlavor ) static Branding* instance(); @@ -185,7 +185,9 @@ public: bool windowPlacementCentered() const { return m_windowPlacement == WindowPlacement::Center; } ///@brief Which sidebar flavor is configured - SidebarFlavor sidebarFlavor() const { return m_sidebarFlavor; } + PanelFlavor sidebarFlavor() const { return m_sidebarFlavor; } + ///@brief Which navigation flavor is configured + PanelFlavor navigationFlavor() const { return m_navigationFlavor; } /** * Creates a map called "branding" in the global storage, and inserts an @@ -227,7 +229,8 @@ private: WindowDimension m_windowHeight, m_windowWidth; WindowPlacement m_windowPlacement; - SidebarFlavor m_sidebarFlavor = SidebarFlavor::Widget; + PanelFlavor m_sidebarFlavor = PanelFlavor::Widget; + PanelFlavor m_navigationFlavor = PanelFlavor::Widget; }; template < typename U >