[libcalamaresui] Add a setting for window placement

This commit is contained in:
Adriaan de Groot 2020-01-07 00:27:11 +01:00
parent 1625bb1dae
commit 17d09342e9
3 changed files with 25 additions and 1 deletions

View File

@ -35,6 +35,12 @@ windowExpanding: normal
# in CalamaresUtilsGui, 800x520.
windowSize: 800px,520px
# Placement of Calamares window. Either "center" or "free".
# Whether "center" actually works does depend on the window
# manager in use (and only makes sense if you're not using
# *windowExpanding* set to "fullscreen").
windowPlacement: center
# These are strings shown to the user in the user interface.
# There is no provision for translating them -- since they
# are names, the string is included as-is.

View File

@ -410,6 +410,9 @@ Branding::initSimpleSettings( const YAML::Node& doc )
{ QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen },
{ QStringLiteral( "noexpand" ), WindowExpansion::Fixed }
};
static const NamedEnumTable< WindowPlacement > placementNames {
{ QStringLiteral( "free" ), WindowPlacement::Free }, { QStringLiteral( "center" ), WindowPlacement::Center }
};
bool ok = false;
m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false );
@ -420,6 +423,12 @@ Branding::initSimpleSettings( const YAML::Node& doc )
cWarning() << "Branding module-setting *windowExpanding* interpreted as"
<< expansionNames.find( m_windowExpansion, ok );
}
m_windowPlacement = placementNames.find( getString( doc, "windowPlacement" ), ok );
if ( !ok )
{
cWarning() << "Branding module-setting *windowPlacement* interpreted as"
<< placementNames.find( m_windowPlacement, ok );
}
QString windowSize = getString( doc, "windowSize" );
if ( !windowSize.isEmpty() )

View File

@ -108,6 +108,13 @@ public:
{
}
};
/** @brief Placement of main window.
*/
enum class WindowPlacement
{
Center,
Free
};
static Branding* instance();
@ -162,6 +169,7 @@ public:
{
return QPair< WindowDimension, WindowDimension >( m_windowWidth, m_windowHeight );
}
bool windowPlacementCentered() const { return m_windowPlacement == WindowPlacement::Center; }
/**
* Creates a map called "branding" in the global storage, and inserts an
@ -193,9 +201,10 @@ private:
bool m_welcomeStyleCalamares;
bool m_welcomeExpandingLogo;
WindowExpansion m_windowExpansion;
WindowExpansion m_windowExpansion;
WindowDimension m_windowHeight, m_windowWidth;
WindowPlacement m_windowPlacement;
};
template < typename U >