[calamares] Factor out size-setting for QML panels

- Either orientation needs to have the same generic size-setting
  code, for both navigation and progress panels.
This commit is contained in:
Adriaan de Groot 2021-03-05 16:58:51 +01:00
parent 82223431fa
commit 04145f49f8

View File

@ -209,29 +209,18 @@ getWidgetNavigation( CalamaresWindow*, Calamares::ViewManager* viewManager, QWid
} }
#ifdef WITH_QML #ifdef WITH_QML
static QWidget*
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int desiredWidth ) static inline void
setDimension( QQuickWidget* w, Qt::Orientation o, int desiredWidth )
{ {
CalamaresUtils::registerQmlModels(); w->setSizePolicy( o == Qt::Orientation::Vertical ? QSizePolicy::MinimumExpanding : QSizePolicy::Expanding,
QQuickWidget* w = new QQuickWidget( parent ); o == Qt::Orientation::Horizontal ? QSizePolicy::MinimumExpanding : QSizePolicy::Expanding );
if ( o == Qt::Orientation::Vertical )
{
w->setFixedWidth( desiredWidth ); w->setFixedWidth( desiredWidth );
w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); }
w->setResizeMode( QQuickWidget::SizeRootObjectToView ); else
w->setSource( QUrl( {
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
return w;
}
static QWidget*
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int )
{
CalamaresUtils::registerQmlModels();
QQuickWidget* w = new QQuickWidget( parent );
w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::MinimumExpanding );
w->setResizeMode( QQuickWidget::SizeRootObjectToView );
w->setSource( QUrl(
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) );
// If the QML itself sets a height, use that, otherwise go to 48 pixels // If the QML itself sets a height, use that, otherwise go to 48 pixels
// which seems to match what the widget navigation would use for height // which seems to match what the widget navigation would use for height
// (with *my* specific screen, style, etc. so YMMV). // (with *my* specific screen, style, etc. so YMMV).
@ -240,7 +229,30 @@ getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt
qreal minimumHeight = qBound( qreal( 16 ), w->rootObject() ? w->rootObject()->height() : 48, qreal( 64 ) ); qreal minimumHeight = qBound( qreal( 16 ), w->rootObject() ? w->rootObject()->height() : 48, qreal( 64 ) );
w->setMinimumHeight( int( minimumHeight ) ); w->setMinimumHeight( int( minimumHeight ) );
w->setFixedHeight( int( minimumHeight ) ); w->setFixedHeight( int( minimumHeight ) );
}
w->setResizeMode( QQuickWidget::SizeRootObjectToView );
}
static QWidget*
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation o, int desiredWidth )
{
CalamaresUtils::registerQmlModels();
QQuickWidget* w = new QQuickWidget( parent );
w->setSource( QUrl(
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
setDimension( w, o, desiredWidth );
return w;
}
static QWidget*
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation o, int desiredWidth )
{
CalamaresUtils::registerQmlModels();
QQuickWidget* w = new QQuickWidget( parent );
w->setSource( QUrl(
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) );
setDimension( w, o, desiredWidth );
return w; return w;
} }
#else #else