Merge branch 'issue-1293'

FIXES #1293
This commit is contained in:
Adriaan de Groot 2020-01-07 01:14:28 +01:00
commit 3877151bd8
5 changed files with 43 additions and 1 deletions

View File

@ -13,6 +13,9 @@ This release contains contributions from (alphabetically by first name):
means that modules now have easier access to timezone information. means that modules now have easier access to timezone information.
Translations for timezones have also been enabled, so it is **possible** Translations for timezones have also been enabled, so it is **possible**
at least to translate the displayed zones in the *locale* module. at least to translate the displayed zones in the *locale* module.
- Branding can now specify whether to (try to) display the Calamares window
in the middle of the desktop or not. The *windowPlacement* key in
`branding.desc` specifies *center* or *free* placement.
## Modules ## ## Modules ##
- The *license* module has seen a significant change to its looks. - The *license* module has seen a significant change to its looks.

View File

@ -35,6 +35,12 @@ windowExpanding: normal
# in CalamaresUtilsGui, 800x520. # in CalamaresUtilsGui, 800x520.
windowSize: 800px,520px 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. # These are strings shown to the user in the user interface.
# There is no provision for translating them -- since they # There is no provision for translating them -- since they
# are names, the string is included as-is. # are names, the string is included as-is.

View File

@ -39,6 +39,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QScreen>
#include <QTimer> #include <QTimer>
@ -357,6 +358,20 @@ CalamaresApplication::initView()
QTimer::singleShot( 0, m_moduleManager, &Calamares::ModuleManager::loadModules ); QTimer::singleShot( 0, m_moduleManager, &Calamares::ModuleManager::loadModules );
if ( Calamares::Branding::instance() && Calamares::Branding::instance()->windowPlacementCentered() )
{
QList< QScreen* > screens = qApp->screens();
QPoint windowCenter = m_mainwindow->rect().center();
for ( const auto* screen : screens )
{
QPoint screenCenter = screen->availableGeometry().center();
if ( ( screenCenter.x() >= windowCenter.x() ) && ( screenCenter.y() >= windowCenter.y() ) )
{
m_mainwindow->move( screenCenter - windowCenter );
break;
}
}
}
cDebug() << "STARTUP: CalamaresWindow created; loadModules started"; cDebug() << "STARTUP: CalamaresWindow created; loadModules started";
} }

View File

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

View File

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