From 8ced67680d2632a24f52a375ded2f5cf95e49b82 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 25 Jun 2020 00:00:13 +0200 Subject: [PATCH] [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),