[calamares] Use branding-settings for initial window-size
This commit is contained in:
parent
32ab377e43
commit
f6c69db9ff
@ -35,6 +35,18 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
windowDimensionToPixels( const Calamares::Branding::WindowDimension& u )
|
||||||
|
{
|
||||||
|
if ( !u.isValid() )
|
||||||
|
return 0;
|
||||||
|
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Pixies )
|
||||||
|
return u.value();
|
||||||
|
if ( u.unit() == Calamares::Branding::WindowDimensionUnit::Fonties )
|
||||||
|
return u.value() * CalamaresUtils::defaultFontHeight();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
CalamaresWindow::CalamaresWindow( QWidget* parent )
|
CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_debugWindow( nullptr )
|
, m_debugWindow( nullptr )
|
||||||
@ -45,24 +57,24 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
|||||||
.arg( *Calamares::Branding::ProductName ) );
|
.arg( *Calamares::Branding::ProductName ) );
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const Calamares::Branding* const branding = Calamares::Branding::instance();
|
||||||
|
|
||||||
using CalamaresUtils::windowMinimumHeight;
|
using CalamaresUtils::windowMinimumHeight;
|
||||||
using CalamaresUtils::windowMinimumWidth;
|
using CalamaresUtils::windowMinimumWidth;
|
||||||
using CalamaresUtils::windowPreferredHeight;
|
using CalamaresUtils::windowPreferredHeight;
|
||||||
using CalamaresUtils::windowPreferredWidth;
|
using CalamaresUtils::windowPreferredWidth;
|
||||||
|
|
||||||
QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
|
QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
|
||||||
|
|
||||||
cDebug() << "Available size" << availableSize;
|
|
||||||
|
|
||||||
if ( ( availableSize.width() < windowPreferredWidth ) || ( availableSize.height() < windowPreferredHeight ) )
|
|
||||||
cDebug() << " Small screen detected.";
|
|
||||||
QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ),
|
QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ),
|
||||||
qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) );
|
qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) );
|
||||||
setMinimumSize( minimumSize );
|
setMinimumSize( minimumSize );
|
||||||
|
|
||||||
|
cDebug() << "Available desktop" << availableSize << "minimum size" << minimumSize;
|
||||||
|
|
||||||
int w = qBound( minimumSize.width(), CalamaresUtils::defaultFontHeight() * 60, availableSize.width() );
|
auto brandingSizes = branding->windowSize();
|
||||||
int h = qBound( minimumSize.height(), CalamaresUtils::defaultFontHeight() * 36, availableSize.height() );
|
|
||||||
|
int w = qBound( minimumSize.width(), windowDimensionToPixels( brandingSizes.first ), availableSize.width() );
|
||||||
|
int h = qBound( minimumSize.height(), windowDimensionToPixels( brandingSizes.second ), availableSize.height() );
|
||||||
|
|
||||||
cDebug() << " Proposed window size:" << w << h;
|
cDebug() << " Proposed window size:" << w << h;
|
||||||
resize( w, h );
|
resize( w, h );
|
||||||
@ -85,18 +97,14 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
|||||||
{
|
{
|
||||||
QPalette plt = sideBox->palette();
|
QPalette plt = sideBox->palette();
|
||||||
sideBox->setAutoFillBackground( true );
|
sideBox->setAutoFillBackground( true );
|
||||||
plt.setColor( sideBox->backgroundRole(), Calamares::Branding::instance()->
|
plt.setColor( sideBox->backgroundRole(),branding->styleString( Calamares::Branding::SidebarBackground ) );
|
||||||
styleString( Calamares::Branding::SidebarBackground ) );
|
plt.setColor( sideBox->foregroundRole(), branding->styleString( Calamares::Branding::SidebarText ) );
|
||||||
plt.setColor( sideBox->foregroundRole(), Calamares::Branding::instance()->
|
|
||||||
styleString( Calamares::Branding::SidebarText ) );
|
|
||||||
sideBox->setPalette( plt );
|
sideBox->setPalette( plt );
|
||||||
logoLabel->setPalette( plt );
|
logoLabel->setPalette( plt );
|
||||||
}
|
}
|
||||||
logoLabel->setAlignment( Qt::AlignCenter );
|
logoLabel->setAlignment( Qt::AlignCenter );
|
||||||
logoLabel->setFixedSize( 80, 80 );
|
logoLabel->setFixedSize( 80, 80 );
|
||||||
logoLabel->setPixmap( Calamares::Branding::instance()->
|
logoLabel->setPixmap( branding->image( Calamares::Branding::ProductLogo, logoLabel->size() ) );
|
||||||
image( Calamares::Branding::ProductLogo,
|
|
||||||
logoLabel->size() ) );
|
|
||||||
logoLayout->addWidget( logoLabel );
|
logoLayout->addWidget( logoLabel );
|
||||||
logoLayout->addStretch();
|
logoLayout->addStretch();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user