[calamares] Pass orientation into panel-creation
- Add function for mapping panel sides to an orientation (H/V) - Pass that into the creation functions This is prep-work for handling vertical navigation and horizontal progress reporting cleanly.
This commit is contained in:
parent
0f50085bb9
commit
82223431fa
@ -55,6 +55,19 @@ windowDimensionToPixels( const Calamares::Branding::WindowDimension& u )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Expected orientation of the panels, based on their side
|
||||||
|
*
|
||||||
|
* Panels on the left and right are expected to be "vertical" style,
|
||||||
|
* top and bottom should be "horizontal bars". This function maps
|
||||||
|
* the sides to expected orientation.
|
||||||
|
*/
|
||||||
|
static inline Qt::Orientation
|
||||||
|
orientation( const Calamares::Branding::PanelSide s )
|
||||||
|
{
|
||||||
|
using Side = Calamares::Branding::PanelSide;
|
||||||
|
return ( s == Side::Left || s == Side::Right ) ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Get a button-sized icon. */
|
/** @brief Get a button-sized icon. */
|
||||||
static inline QPixmap
|
static inline QPixmap
|
||||||
getButtonIcon( const QString& name )
|
getButtonIcon( const QString& name )
|
||||||
@ -73,7 +86,11 @@ setButtonIcon( QPushButton* button, const QString& name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getWidgetSidebar( CalamaresWindow* window, Calamares::ViewManager* viewManager, QWidget* parent, int desiredWidth )
|
getWidgetSidebar( CalamaresWindow* window,
|
||||||
|
Calamares::ViewManager* viewManager,
|
||||||
|
QWidget* parent,
|
||||||
|
Qt::Orientation,
|
||||||
|
int desiredWidth )
|
||||||
{
|
{
|
||||||
const Calamares::Branding* const branding = Calamares::Branding::instance();
|
const Calamares::Branding* const branding = Calamares::Branding::instance();
|
||||||
|
|
||||||
@ -130,7 +147,7 @@ getWidgetSidebar( CalamaresWindow* window, Calamares::ViewManager* viewManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getWidgetNavigation( CalamaresWindow*, Calamares::ViewManager* viewManager, QWidget* parent )
|
getWidgetNavigation( CalamaresWindow*, Calamares::ViewManager* viewManager, QWidget* parent, Qt::Orientation, int )
|
||||||
{
|
{
|
||||||
QWidget* navigation = new QWidget( parent );
|
QWidget* navigation = new QWidget( parent );
|
||||||
QBoxLayout* bottomLayout = new QHBoxLayout;
|
QBoxLayout* bottomLayout = new QHBoxLayout;
|
||||||
@ -193,7 +210,7 @@ getWidgetNavigation( CalamaresWindow*, Calamares::ViewManager* viewManager, QWid
|
|||||||
|
|
||||||
#ifdef WITH_QML
|
#ifdef WITH_QML
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, int desiredWidth )
|
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int desiredWidth )
|
||||||
{
|
{
|
||||||
CalamaresUtils::registerQmlModels();
|
CalamaresUtils::registerQmlModels();
|
||||||
QQuickWidget* w = new QQuickWidget( parent );
|
QQuickWidget* w = new QQuickWidget( parent );
|
||||||
@ -206,7 +223,7 @@ getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, int d
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent )
|
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int )
|
||||||
{
|
{
|
||||||
CalamaresUtils::registerQmlModels();
|
CalamaresUtils::registerQmlModels();
|
||||||
QQuickWidget* w = new QQuickWidget( parent );
|
QQuickWidget* w = new QQuickWidget( parent );
|
||||||
@ -232,12 +249,12 @@ getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent )
|
|||||||
// Calls to flavoredWidget() still refer to these *names*
|
// Calls to flavoredWidget() still refer to these *names*
|
||||||
// even if they are subsequently not used.
|
// even if they are subsequently not used.
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, int desiredWidth )
|
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int desiredWidth )
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent )
|
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int desiredWidth )
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -251,6 +268,7 @@ getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent )
|
|||||||
template < typename widgetMaker, typename... args >
|
template < typename widgetMaker, typename... args >
|
||||||
QWidget*
|
QWidget*
|
||||||
flavoredWidget( Calamares::Branding::PanelFlavor flavor,
|
flavoredWidget( Calamares::Branding::PanelFlavor flavor,
|
||||||
|
Qt::Orientation o,
|
||||||
CalamaresWindow* w,
|
CalamaresWindow* w,
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
widgetMaker widget,
|
widgetMaker widget,
|
||||||
@ -264,10 +282,10 @@ flavoredWidget( Calamares::Branding::PanelFlavor flavor,
|
|||||||
switch ( flavor )
|
switch ( flavor )
|
||||||
{
|
{
|
||||||
case Calamares::Branding::PanelFlavor::Widget:
|
case Calamares::Branding::PanelFlavor::Widget:
|
||||||
return widget( w, viewManager, parent, a... );
|
return widget( w, viewManager, parent, o, a... );
|
||||||
#ifdef WITH_QML
|
#ifdef WITH_QML
|
||||||
case Calamares::Branding::PanelFlavor::Qml:
|
case Calamares::Branding::PanelFlavor::Qml:
|
||||||
return qml( w, viewManager, parent, a... );
|
return qml( w, viewManager, parent, o, a... );
|
||||||
#endif
|
#endif
|
||||||
case Calamares::Branding::PanelFlavor::None:
|
case Calamares::Branding::PanelFlavor::None:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -369,13 +387,19 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
|||||||
|
|
||||||
QWidget* sideBox = flavoredWidget(
|
QWidget* sideBox = flavoredWidget(
|
||||||
branding->sidebarFlavor(),
|
branding->sidebarFlavor(),
|
||||||
|
::orientation( branding->sidebarSide() ),
|
||||||
this,
|
this,
|
||||||
baseWidget,
|
baseWidget,
|
||||||
::getWidgetSidebar,
|
::getWidgetSidebar,
|
||||||
::getQmlSidebar,
|
::getQmlSidebar,
|
||||||
qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) );
|
qBound( 100, CalamaresUtils::defaultFontHeight() * 12, w < windowPreferredWidth ? 100 : 190 ) );
|
||||||
QWidget* navigation
|
QWidget* navigation = flavoredWidget( branding->navigationFlavor(),
|
||||||
= flavoredWidget( branding->navigationFlavor(), this, baseWidget, ::getWidgetNavigation, ::getQmlNavigation );
|
::orientation( branding->sidebarSide() ),
|
||||||
|
this,
|
||||||
|
baseWidget,
|
||||||
|
::getWidgetNavigation,
|
||||||
|
::getQmlNavigation,
|
||||||
|
64 );
|
||||||
|
|
||||||
// Build up the contentsLayout (a VBox) top-to-bottom
|
// Build up the contentsLayout (a VBox) top-to-bottom
|
||||||
// .. note that the bottom is mirrored wrt. the top
|
// .. note that the bottom is mirrored wrt. the top
|
||||||
|
Loading…
Reference in New Issue
Block a user