From 8a9e85db71cce9fade23fd17deaafe671cea8d2a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 04:53:22 -0400 Subject: [PATCH 01/10] Branding: shuffle around a bit, expand documentation --- src/branding/default/branding.desc | 63 ++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index f8cc88295..fc0a16f7e 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -7,6 +7,12 @@ --- componentName: default + +### WELCOME / OVERALL WORDING +# +# These settings affect some overall phrasing and looks, +# which are most visible in the welcome page. + # This selects between different welcome texts. When false, uses # the traditional "Welcome to the %1 installer.", and when true, # uses "Welcome to the Calamares installer for %1." This allows @@ -20,6 +26,12 @@ welcomeStyleCalamares: false # may have surprising effects on HiDPI monitors). welcomeExpandingLogo: true +### WINDOW CONFIGURATION +# +# The settings here affect the placement of the Calamares +# window through hints to the window manager and initial +# sizing of the Calamares window. + # Size and expansion policy for Calamares. # - "normal" or unset, expand as needed, use *windowSize* # - "fullscreen", start as large as possible, ignore *windowSize* @@ -41,6 +53,14 @@ windowSize: 800px,520px # *windowExpanding* set to "fullscreen"). windowPlacement: center +### PANELS CONFIGURATION +# +# Calamares has a main content area, and two panels (navigation +# and progress / sidebar). The panels can be controlled individually, +# or switched off. If both panels are switched off, the layout of +# the main content area loses its margins, on the assumption that +# you're doing something special. + # Kind of sidebar (panel on the left, showing progress). # - "widget" or unset, use traditional sidebar (logo, items) # - "none", hide it entirely @@ -66,6 +86,12 @@ sidebar: widget # except the default is *bottom*. navigation: widget + +### STRINGS, IMAGES AND COLORS +# +# This section contains the "branding proper" of names +# and images, rather than global-look settings. + # 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. @@ -139,9 +165,28 @@ images: # productWallpaper: "wallpaper.png" productWelcome: "languages.png" +# Colors for text and background components. +# +# - sidebarBackground is the background of the sidebar +# - sidebarText is the (foreground) text color +# - sidebarTextHighlight sets the background of the selected (current) step. +# Optional, and defaults to the application palette. +# - sidebarSelect is the text color of the selected step. +# +# These colors can **also** be set through the stylesheet, if the +# branding component also ships a stylesheet.qss. Then they are +# the corresponding CSS attributes of #sidebarApp. +style: + sidebarBackground: "#292F34" + sidebarText: "#FFFFFF" + sidebarTextSelect: "#292F34" + sidebarTextHighlight: "#D35400" + +### SLIDESHOW +# # The slideshow is displayed during execution steps (e.g. when the # installer is actually writing to disk and doing other slow things). -# + # The slideshow can be a QML file (recommended) which can display # arbitrary things -- text, images, animations, or even play a game -- # during the execution step. The QML **is** abruptly stopped when the @@ -171,19 +216,3 @@ slideshow: "show.qml" slideshowAPI: 2 -# Colors for text and background components. -# -# - sidebarBackground is the background of the sidebar -# - sidebarText is the (foreground) text color -# - sidebarTextHighlight sets the background of the selected (current) step. -# Optional, and defaults to the application palette. -# - sidebarSelect is the text color of the selected step. -# -# These colors can **also** be set through the stylesheet, if the -# branding component also ships a stylesheet.qss. Then they are -# the corresponding CSS attributes of #sidebarApp. -style: - sidebarBackground: "#292F34" - sidebarText: "#FFFFFF" - sidebarTextSelect: "#292F34" - sidebarTextHighlight: "#D35400" From bfbb0f1c49ae6bd6f311fbf684aa7577517a9ee7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 04:59:19 -0400 Subject: [PATCH 02/10] [libcalamaresui] Mark some TODO for 3.3, in passing --- src/libcalamaresui/utils/CalamaresUtilsGui.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.h b/src/libcalamaresui/utils/CalamaresUtilsGui.h index 961ed5bc7..251741fad 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.h +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.h @@ -87,6 +87,7 @@ UIDLLEXPORT QPixmap defaultPixmap( ImageType type, ImageMode mode = CalamaresUtils::Original, const QSize& size = QSize( 0, 0 ) ); +// TODO:3.3:This has only one consumer, move to ImageRegistry, make static /** * @brief createRoundedImage returns a rounded version of a pixmap. * @param avatar the input pixmap. @@ -103,6 +104,7 @@ UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size */ UIDLLEXPORT void unmarginLayout( QLayout* layout ); +// TODO:3.3:This has only one consumer, move to LicensePage, make static /** * @brief clearLayout recursively walks the QLayout tree and deletes all the child * widgets and layouts. @@ -113,7 +115,7 @@ UIDLLEXPORT void clearLayout( QLayout* layout ); UIDLLEXPORT void setDefaultFontSize( int points ); UIDLLEXPORT int defaultFontSize(); // in points UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific -UIDLLEXPORT QFont defaultFont(); +UIDLLEXPORT QFont defaultFont(); // TODO:3.3:This has one consumer, move to BlankViewStep UIDLLEXPORT QFont largeFont(); UIDLLEXPORT QSize defaultIconSize(); From 4a6ee39f8bc8f64c740dbb4e92ea6ec58ade5df1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 11:08:31 +0200 Subject: [PATCH 03/10] [libcalamaresui] Blanket unmargin the content area --- src/libcalamaresui/ViewManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index c78680418..e72c434f8 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -71,6 +71,7 @@ ViewManager::ViewManager( QObject* parent ) Q_ASSERT( !s_instance ); QBoxLayout* mainLayout = new QVBoxLayout; + mainLayout->setContentsMargins( 0, 0, 0, 0 ); m_widget->setObjectName( "viewManager" ); m_widget->setLayout( mainLayout ); From 347a25d13d264efc71fc74059a5e4e607badf9f1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 20:48:06 +0200 Subject: [PATCH 04/10] [libcalamaresui] Avoid nullptr deref - there's a check already there, and probably this means things are hopelessly broken anyway, but let's not crash here. --- src/libcalamaresui/ViewManager.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index e72c434f8..40e621ae8 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -128,15 +128,19 @@ ViewManager::insertViewStep( int before, ViewStep* step ) { cError() << "ViewStep" << step->moduleInstanceKey() << "has no widget."; } - - QLayout* layout = step->widget()->layout(); - if ( layout ) + else { - layout->setContentsMargins( 0, 0, 0, 0 ); + // step->adjustMargins() "some magic" + QLayout* layout = step->widget()->layout(); + if ( layout ) + { + layout->setContentsMargins( 0, 0, 0, 0 ); + } + + m_stack->insertWidget( before, step->widget() ); + m_stack->setCurrentIndex( 0 ); + step->widget()->setFocus(); } - m_stack->insertWidget( before, step->widget() ); - m_stack->setCurrentIndex( 0 ); - step->widget()->setFocus(); emit endInsertRows(); } From 748d76df4f0f9c4b34f491f1d75234cbc1d8896f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 21:15:37 +0200 Subject: [PATCH 05/10] [libcalamaresui] Add support for steps with own margins --- src/libcalamaresui/viewpages/ViewStep.cpp | 13 ++++++++ src/libcalamaresui/viewpages/ViewStep.h | 40 +++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/libcalamaresui/viewpages/ViewStep.cpp b/src/libcalamaresui/viewpages/ViewStep.cpp index 82f8688dc..64979836f 100644 --- a/src/libcalamaresui/viewpages/ViewStep.cpp +++ b/src/libcalamaresui/viewpages/ViewStep.cpp @@ -19,6 +19,9 @@ #include "ViewStep.h" +#include +#include + namespace Calamares { @@ -85,4 +88,14 @@ ViewStep::checkRequirements() return RequirementsList(); } +QSize +ViewStep::widgetMargins( Qt::Orientations panelSides ) +{ + Q_UNUSED( panelSides ); + + // Application's default style + const auto* s = QApplication::style(); + return QSize( s->pixelMetric( QStyle::PM_LayoutLeftMargin ), s->pixelMetric( QStyle::PM_LayoutTopMargin ) ); +} + } // namespace Calamares diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index 707bc0b3b..59f307af2 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -52,27 +52,61 @@ public: explicit ViewStep( QObject* parent = nullptr ); virtual ~ViewStep() override; + /** @brief Human-readable name of the step + * + * This (translated) string is shown in the sidebar (progress) + * and during installation. There is no default. + */ virtual QString prettyName() const = 0; - /** + /** @brief Describe what this step will do during install + * * Optional. May return a non-empty string describing what this * step is going to do (should be translated). This is also used * in the summary page to describe what is going to be done. * Return an empty string to provide no description. + * + * The default implementation returns an empty string, so nothing + * will be displayed for this step when a summary is shown. */ virtual QString prettyStatus() const; - /** + /** @brief Return a long description what this step will do during install + * * Optional. May return a widget which will be inserted in the summary * page. The caller takes ownership of the widget. Return nullptr to * provide no widget. In general, this is only used for complicated * steps where prettyStatus() is not sufficient. + * + * The default implementation returns nullptr, so nothing + * will be displayed for this step when a summary is shown. */ virtual QWidget* createSummaryWidget() const; - //TODO: we might want to make this a QSharedPointer + /** @brief Get (or create) the widget for this view step + * + * While a view step **may** create the widget when it is loaded, + * it is recommended to wait with widget creation until the + * widget is actually asked for: a view step **may** be used + * without a UI. + */ virtual QWidget* widget() = 0; + /** @brief Get margins for this widget + * + * This is called by the layout manager to find the desired + * margins (width is used for left and right margin, height is + * used for top and bottom margins) for the widget. The + * @p panelSides indicates where there are panels in the overall + * layout: horizontally and / or vertically adjacent (or none!) + * to the view step's widget. + * + * Should return a size based also on QStyle metrics for layout. + * The default implementation just returns the default layout metrics + * (often 11 pixels on a side). + */ + virtual QSize widgetMargins( Qt::Orientations panelSides ); + /** * @brief Multi-page support, go next * From 1648f311fe18570ebafe89b25791b9c8655cf9f1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 21:26:22 +0200 Subject: [PATCH 06/10] [libcalamaresui] apidox touch-up --- src/libcalamaresui/ViewManager.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index cfff5abd9..73d1a0121 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -100,10 +100,11 @@ public: int currentStepIndex() const; /** - * @ brief Called when "Cancel" is clicked; asks for confirmation. + * @brief Called when "Cancel" is clicked; asks for confirmation. * Other means of closing Calamares also call this method, e.g. alt-F4. - * At the end of installation, no confirmation is asked. Returns true - * if the user confirms closing the window. + * At the end of installation, no confirmation is asked. + * + * @return @c true if the user confirms closing the window. */ bool confirmCancelInstallation(); From d7ed450dbfb334f24506915d5ee6a44de6965797 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 21:41:06 +0200 Subject: [PATCH 07/10] [libcalamaresui] Give ViewManager data about side-panels --- src/libcalamaresui/ViewManager.cpp | 1 + src/libcalamaresui/ViewManager.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 40e621ae8..45baa2f59 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -67,6 +67,7 @@ ViewManager::ViewManager( QObject* parent ) : QAbstractListModel( parent ) , m_currentStep( -1 ) , m_widget( new QWidget() ) + , m_panelSides( Qt::Horizontal | Qt::Vertical ) { Q_ASSERT( !s_instance ); diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 73d1a0121..0fb1cbb45 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -54,6 +54,9 @@ class UIDLLEXPORT ViewManager : public QAbstractListModel Q_PROPERTY( bool quitVisible READ quitVisible NOTIFY quitVisibleChanged FINAL ) + ///@brief Sides on which the ViewManager has side-panels + Q_PROPERTY( Qt::Orientations panelSides MEMBER m_panelSides ) + public: /** * @brief instance access to the ViewManager singleton. @@ -245,6 +248,8 @@ private: QString m_quitTooltip; bool m_quitVisible = true; + Qt::Orientations m_panelSides; + public: /** @section Model * From d952faf909bc423eb29df7e38e266460d1b9f0ff Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 22:12:59 +0200 Subject: [PATCH 08/10] [libcalamaresui] Set margins based on viewstep suggestion --- src/libcalamaresui/ViewManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 45baa2f59..a39fc141f 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -131,11 +131,11 @@ ViewManager::insertViewStep( int before, ViewStep* step ) } else { - // step->adjustMargins() "some magic" QLayout* layout = step->widget()->layout(); if ( layout ) { - layout->setContentsMargins( 0, 0, 0, 0 ); + const auto margins = step->widgetMargins( m_panelSides ); + layout->setContentsMargins( margins.width(), margins.height(), margins.width(), margins.height() ); } m_stack->insertWidget( before, step->widget() ); From 68aecf6a26c3f2664e0974261c4dce714f184d4d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 24 Jun 2020 23:41:20 +0200 Subject: [PATCH 09/10] [libcalamaresui] Special margins for QML view steps If there are no surrounding panels, drop the margin around the QML on the assumption it needs to be full screen under special circumstances. --- src/libcalamaresui/viewpages/QmlViewStep.cpp | 16 ++++++++++++++++ src/libcalamaresui/viewpages/QmlViewStep.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/libcalamaresui/viewpages/QmlViewStep.cpp b/src/libcalamaresui/viewpages/QmlViewStep.cpp index 2234c230a..6318e47d8 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.cpp +++ b/src/libcalamaresui/viewpages/QmlViewStep.cpp @@ -151,6 +151,22 @@ QmlViewStep::widget() return m_widget; } +QSize +QmlViewStep::widgetMargins( Qt::Orientations panelSides ) +{ + // If any panels around it, use the standard, but if all the + // panels are hidden, like on full-screen with subsumed navigation, + // then no margins. + if ( panelSides ) + { + return ViewStep::widgetMargins( panelSides ); + } + else + { + return QSize( 0, 0 ); + } +} + void QmlViewStep::loadComplete() { diff --git a/src/libcalamaresui/viewpages/QmlViewStep.h b/src/libcalamaresui/viewpages/QmlViewStep.h index cad6bb395..e1f4caf28 100644 --- a/src/libcalamaresui/viewpages/QmlViewStep.h +++ b/src/libcalamaresui/viewpages/QmlViewStep.h @@ -55,6 +55,7 @@ public: virtual QString prettyName() const override; virtual QWidget* widget() override; + virtual QSize widgetMargins( Qt::Orientations panelSides ) override; virtual bool isNextEnabled() const override; virtual bool isBackEnabled() const override; From 8ced67680d2632a24f52a375ded2f5cf95e49b82 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 25 Jun 2020 00:00:13 +0200 Subject: [PATCH 10/10] [calamares] Allow get/set of panel-sides - Add access to the panel-sides membe of the view manager, and calculate which sides are populated by panels (if any). - Pass the calculated panel-sides to the view manager before it starts adding viewpages, so they get consistent margins. --- src/calamares/CalamaresWindow.cpp | 24 +++++++++++++++++------- src/libcalamaresui/ViewManager.h | 5 ++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index a3775c44e..28b9df626 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -111,12 +111,12 @@ CalamaresWindow::getWidgetSidebar( QWidget* parent, int desiredWidth ) sideLayout->addWidget( debugWindowBtn ); debugWindowBtn->setFlat( true ); debugWindowBtn->setCheckable( true ); - connect( debugWindowBtn, &QPushButton::clicked, this, [ = ]( bool checked ) { + connect( debugWindowBtn, &QPushButton::clicked, this, [=]( bool checked ) { if ( checked ) { m_debugWindow = new Calamares::DebugWindow(); m_debugWindow->show(); - connect( m_debugWindow.data(), &Calamares::DebugWindow::closed, this, [ = ]() { + connect( m_debugWindow.data(), &Calamares::DebugWindow::closed, this, [=]() { m_debugWindow->deleteLater(); debugWindowBtn->setChecked( false ); } ); @@ -167,7 +167,7 @@ CalamaresWindow::getWidgetNavigation( QWidget* parent ) connect( back, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::back ); connect( m_viewManager, &Calamares::ViewManager::backEnabledChanged, back, &QPushButton::setEnabled ); connect( m_viewManager, &Calamares::ViewManager::backLabelChanged, back, &QPushButton::setText ); - connect( m_viewManager, &Calamares::ViewManager::backIconChanged, this, [ = ]( QString n ) { + connect( m_viewManager, &Calamares::ViewManager::backIconChanged, this, [=]( QString n ) { setButtonIcon( back, n ); } ); bottomLayout->addWidget( back ); @@ -179,7 +179,7 @@ CalamaresWindow::getWidgetNavigation( QWidget* parent ) connect( next, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::next ); connect( m_viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled ); connect( m_viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText ); - connect( m_viewManager, &Calamares::ViewManager::nextIconChanged, this, [ = ]( QString n ) { + connect( m_viewManager, &Calamares::ViewManager::nextIconChanged, this, [=]( QString n ) { setButtonIcon( next, n ); } ); bottomLayout->addWidget( next ); @@ -191,7 +191,7 @@ CalamaresWindow::getWidgetNavigation( QWidget* parent ) connect( quit, &QPushButton::clicked, m_viewManager, &Calamares::ViewManager::quit ); connect( m_viewManager, &Calamares::ViewManager::quitEnabledChanged, quit, &QPushButton::setEnabled ); connect( m_viewManager, &Calamares::ViewManager::quitLabelChanged, quit, &QPushButton::setText ); - connect( m_viewManager, &Calamares::ViewManager::quitIconChanged, this, [ = ]( QString n ) { + connect( m_viewManager, &Calamares::ViewManager::quitIconChanged, this, [=]( QString n ) { setButtonIcon( quit, n ); } ); connect( m_viewManager, &Calamares::ViewManager::quitTooltipChanged, quit, &QPushButton::setToolTip ); @@ -237,11 +237,13 @@ CalamaresWindow::getQmlNavigation( QWidget* parent ) } #else // Bogus to keep the linker happy -QWidget * CalamaresWindow::getQmlSidebar(QWidget* , int ) +QWidget* +CalamaresWindow::getQmlSidebar( QWidget*, int ) { return nullptr; } -QWidget * CalamaresWindow::getQmlNavigation(QWidget* ) +QWidget* +CalamaresWindow::getQmlNavigation( QWidget* ) { return nullptr; } @@ -401,6 +403,14 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) insertIf( mainLayout, PanelSide::Right, navigation, branding->navigationSide() ); insertIf( mainLayout, PanelSide::Right, sideBox, branding->sidebarSide() ); + // layout->count() returns number of things in it; above we have put + // at **least** the central widget, which comes from the view manager, + // both vertically and horizontally -- so if there's a panel along + // either axis, the count in that axis will be > 1. + m_viewManager->setPanelSides( + ( contentsLayout->count() > 1 ? Qt::Orientations( Qt::Horizontal ) : Qt::Orientations() ) + | ( mainLayout->count() > 1 ? Qt::Orientations( Qt::Vertical ) : Qt::Orientations() ) ); + CalamaresUtils::unmarginLayout( mainLayout ); CalamaresUtils::unmarginLayout( contentsLayout ); baseWidget->setLayout( mainLayout ); diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 0fb1cbb45..683b335d1 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -55,7 +55,7 @@ class UIDLLEXPORT ViewManager : public QAbstractListModel Q_PROPERTY( bool quitVisible READ quitVisible NOTIFY quitVisibleChanged FINAL ) ///@brief Sides on which the ViewManager has side-panels - Q_PROPERTY( Qt::Orientations panelSides MEMBER m_panelSides ) + Q_PROPERTY( Qt::Orientations panelSides READ panelSides WRITE setPanelSides MEMBER m_panelSides ) public: /** @@ -111,6 +111,9 @@ public: */ bool confirmCancelInstallation(); + Qt::Orientations panelSides() const { return m_panelSides; } + void setPanelSides( Qt::Orientations panelSides ) { m_panelSides = panelSides; } + public Q_SLOTS: /** * @brief next moves forward to the next page of the current ViewStep (if any),