[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:
parent
82223431fa
commit
04145f49f8
@ -209,38 +209,50 @@ getWidgetNavigation( CalamaresWindow*, Calamares::ViewManager* viewManager, QWid
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_QML
|
#ifdef WITH_QML
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
setDimension( QQuickWidget* w, Qt::Orientation o, int desiredWidth )
|
||||||
|
{
|
||||||
|
w->setSizePolicy( o == Qt::Orientation::Vertical ? QSizePolicy::MinimumExpanding : QSizePolicy::Expanding,
|
||||||
|
o == Qt::Orientation::Horizontal ? QSizePolicy::MinimumExpanding : QSizePolicy::Expanding );
|
||||||
|
if ( o == Qt::Orientation::Vertical )
|
||||||
|
{
|
||||||
|
w->setFixedWidth( desiredWidth );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 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
|
||||||
|
// (with *my* specific screen, style, etc. so YMMV).
|
||||||
|
//
|
||||||
|
// Bound between (16, 64) with a default of 48.
|
||||||
|
qreal minimumHeight = qBound( qreal( 16 ), w->rootObject() ? w->rootObject()->height() : 48, qreal( 64 ) );
|
||||||
|
w->setMinimumHeight( int( minimumHeight ) );
|
||||||
|
w->setFixedHeight( int( minimumHeight ) );
|
||||||
|
}
|
||||||
|
w->setResizeMode( QQuickWidget::SizeRootObjectToView );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int desiredWidth )
|
getQmlSidebar( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation o, int desiredWidth )
|
||||||
{
|
{
|
||||||
CalamaresUtils::registerQmlModels();
|
CalamaresUtils::registerQmlModels();
|
||||||
QQuickWidget* w = new QQuickWidget( parent );
|
QQuickWidget* w = new QQuickWidget( parent );
|
||||||
w->setFixedWidth( desiredWidth );
|
|
||||||
w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
|
||||||
w->setResizeMode( QQuickWidget::SizeRootObjectToView );
|
|
||||||
w->setSource( QUrl(
|
w->setSource( QUrl(
|
||||||
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
|
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
|
||||||
|
setDimension( w, o, desiredWidth );
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QWidget*
|
static QWidget*
|
||||||
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation, int )
|
getQmlNavigation( CalamaresWindow*, Calamares::ViewManager*, QWidget* parent, Qt::Orientation o, int desiredWidth )
|
||||||
{
|
{
|
||||||
CalamaresUtils::registerQmlModels();
|
CalamaresUtils::registerQmlModels();
|
||||||
QQuickWidget* w = new QQuickWidget( parent );
|
QQuickWidget* w = new QQuickWidget( parent );
|
||||||
w->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::MinimumExpanding );
|
|
||||||
w->setResizeMode( QQuickWidget::SizeRootObjectToView );
|
|
||||||
w->setSource( QUrl(
|
w->setSource( QUrl(
|
||||||
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) );
|
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) );
|
||||||
|
setDimension( w, o, desiredWidth );
|
||||||
// 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
|
|
||||||
// (with *my* specific screen, style, etc. so YMMV).
|
|
||||||
//
|
|
||||||
// Bound between (16, 64) with a default of 48.
|
|
||||||
qreal minimumHeight = qBound( qreal( 16 ), w->rootObject() ? w->rootObject()->height() : 48, qreal( 64 ) );
|
|
||||||
w->setMinimumHeight( int( minimumHeight ) );
|
|
||||||
w->setFixedHeight( int( minimumHeight ) );
|
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user