[merge] with upstream

This commit is contained in:
Philip Müller 2020-01-08 14:35:47 +01:00
commit d47544e1e3
20 changed files with 2831 additions and 68 deletions

11
CHANGES
View File

@ -6,20 +6,25 @@ website will have to do for older versions.
# 3.2.18 (unreleased) #
This release contains contributions from (alphabetically by first name):
- No other contributors this time around.
- Bill Auger
## Core ##
- Timezone support code has migrated into the core of Calamares. This
means that modules now have easier access to timezone information.
Translations for timezones have also been enabled, so it is **possible**
at least to translate the displayed zones in the *welcome* 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 ##
- The *license* module has seen a significant change to its looks.
Actions are now labeled more clearly, and the URL (or filename)
for each license is displayed.
- The *welcome* module now supports translations for timezone and
- The *locale* module now supports translations for timezone and
location names (e.g. "Berlin" is "Berlijn" in Dutch).
- *Packagechooser* is a little more careful with displaying
default and empty package names. (thanks to Bill Auger)
# 3.2.17.1 (2019-12-02) #

View File

@ -220,6 +220,8 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
# The path prefix is only relevant for CMake 3.16 and later, fixes #1286
set( CMAKE_AUTOMOC_PATH_PREFIX OFF )
set( CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h" )
set( CALAMARES_AUTOUIC_OPTIONS --include utils/moc-warnings.h )
else()
@ -322,6 +324,10 @@ set_package_properties(
)
if ( PYTHONLIBS_FOUND )
# Since Boost provides CMake config files (starting with Boost 1.70.
# or so) the mess that is the Calamares find code picks the wrong
# bits. Suppress those CMake config files, as suggested by @jmrcpn
set(Boost_NO_BOOST_CMAKE ON)
include( BoostPython3 )
find_boost_python3( ${BOOSTPYTHON_VERSION} ${PYTHONLIBS_VERSION_STRING} CALAMARES_BOOST_PYTHON3_FOUND )
set_package_properties(

View File

@ -1285,7 +1285,7 @@
<location filename="../src/libcalamares/locale/ZoneData_p.cxxtr" line="253"/>
<source>Kiev</source>
<comment>tz_names</comment>
<translation type="unfinished"></translation>
<translation>Kyiv</translation>
</message>
<message>
<location filename="../src/libcalamares/locale/ZoneData_p.cxxtr" line="254"/>

2617
lang/tz_uk.ts Normal file

File diff suppressed because it is too large Load Diff

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

@ -39,6 +39,7 @@
#include <QDesktopWidget>
#include <QDir>
#include <QFileInfo>
#include <QScreen>
#include <QTimer>
@ -342,6 +343,42 @@ CalamaresApplication::initModuleManager()
m_moduleManager->init();
}
/** @brief centers the widget @p w on (a) screen
*
* This tries to duplicate the (deprecated) qApp->desktop()->availableGeometry()
* placement by iterating over screens and putting Calamares in the first
* one where it fits; this is *generally* the primary screen.
*
* With debugging, it would look something like this (2 screens attached,
* primary at +1080+240 because I have a very strange X setup). Before
* being mapped, the Calamares window is at +0+0 but does have a size.
* The first screen's geometry includes the offset from the origin in
* screen coordinates.
*
* Proposed window size: 1024 520
* Window QRect(0,0 1024x520)
* Screen QRect(1080,240 2560x1440)
* Moving QPoint(1848,700)
* Screen QRect(0,0 1080x1920)
*
*/
static void
centerWindowOnScreen( QWidget* w )
{
QList< QScreen* > screens = qApp->screens();
QPoint windowCenter = w->rect().center();
QSize windowSize = w->rect().size();
for ( const auto* screen : screens )
{
QSize screenSize = screen->availableGeometry().size();
if ( ( screenSize.width() >= windowSize.width() ) && ( screenSize.height() >= windowSize.height() ) )
{
w->move( screen->availableGeometry().center() - windowCenter );
break;
}
}
}
void
CalamaresApplication::initView()
@ -357,6 +394,10 @@ CalamaresApplication::initView()
QTimer::singleShot( 0, m_moduleManager, &Calamares::ModuleManager::loadModules );
if ( Calamares::Branding::instance() && Calamares::Branding::instance()->windowPlacementCentered() )
{
centerWindowOnScreen( m_mainwindow );
}
cDebug() << "STARTUP: CalamaresWindow created; loadModules started";
}

View File

@ -215,12 +215,12 @@ LocaleTests::testSimpleZones()
QVERIFY( n.tr().isEmpty() );
}
{
TZRegion r0( "xAmsterdam" );
TZZone r0( "xAmsterdam" );
QCOMPARE( r0.tr(), QStringLiteral( "xAmsterdam" ) );
TZRegion r1( r0 );
TZZone r1( r0 );
QCOMPARE( r0.tr(), QStringLiteral( "xAmsterdam" ) );
QCOMPARE( r1.tr(), QStringLiteral( "xAmsterdam" ) );
TZRegion r2( std::move( r0 ) );
TZZone r2( std::move( r0 ) );
QCOMPARE( r2.tr(), QStringLiteral( "xAmsterdam" ) );
QCOMPARE( r0.tr(), QString() );
}

View File

@ -171,7 +171,6 @@ TZRegion::fromFile( const char* fileName )
}
QString region = timezoneParts.first().trimmed();
;
if ( region.isEmpty() )
{
continue;
@ -243,7 +242,7 @@ CStringListModel::CStringListModel( CStringPairList l )
CStringListModel::~CStringListModel() {}
int
CStringListModel::rowCount( const QModelIndex& parent ) const
CStringListModel::rowCount( const QModelIndex& ) const
{
return m_list.count();
}

View File

@ -48,7 +48,7 @@ class CStringPair
{
public:
/// @brief An empty pair
CStringPair() {};
CStringPair() {}
/// @brief Given an identifier, create the pair
explicit CStringPair( const char* s1 );
CStringPair( CStringPair&& t );
@ -88,7 +88,8 @@ class TZRegion : public CStringPair
{
public:
using CStringPair::CStringPair;
virtual ~TZRegion();
virtual ~TZRegion() override;
TZRegion( const TZRegion& ) = delete;
QString tr() const override;
QString region() const { return key(); }

View File

@ -58,7 +58,7 @@ struct TranslationLoader
{
}
virtual ~TranslationLoader() {};
virtual ~TranslationLoader();
/// @brief Loads @p translator with the specific translations of this type
virtual bool tryLoad( QTranslator* translator ) = 0;
@ -66,6 +66,7 @@ struct TranslationLoader
QString m_localeName;
};
/// @brief Loads translations for branding
struct BrandingLoader : public TranslationLoader
{
BrandingLoader( const QLocale& locale, const QString& prefix )
@ -74,7 +75,29 @@ struct BrandingLoader : public TranslationLoader
{
}
bool tryLoad( QTranslator* translator ) override
bool tryLoad( QTranslator* translator ) override;
QString m_prefix;
};
/// @brief Loads regular Calamares translations (program text)
struct CalamaresLoader : public TranslationLoader
{
using TranslationLoader::TranslationLoader;
bool tryLoad( QTranslator* translator ) override;
};
/// @brief Loads timezone name translations
struct TZLoader : public TranslationLoader
{
using TranslationLoader::TranslationLoader;
bool tryLoad( QTranslator* translator ) override;
};
TranslationLoader::~TranslationLoader() {}
bool
BrandingLoader::tryLoad( QTranslator* translator )
{
if ( m_prefix.isEmpty() )
{
@ -102,14 +125,8 @@ struct BrandingLoader : public TranslationLoader
return false;
}
QString m_prefix;
};
struct CalamaresLoader : public TranslationLoader
{
using TranslationLoader::TranslationLoader;
bool tryLoad( QTranslator* translator ) override
bool
CalamaresLoader::tryLoad( QTranslator* translator )
{
if ( translator->load( QString( ":/lang/calamares_" ) + m_localeName ) )
{
@ -122,12 +139,9 @@ struct CalamaresLoader : public TranslationLoader
return translator->load( QString( ":/lang/calamares_en" ) );
}
}
};
struct TZLoader : public TranslationLoader
{
using TranslationLoader::TranslationLoader;
bool tryLoad( QTranslator* translator ) override
bool
TZLoader::tryLoad( QTranslator* translator )
{
if ( translator->load( QString( ":/lang/tz_" ) + m_localeName ) )
{
@ -136,12 +150,10 @@ struct TZLoader : public TranslationLoader
}
else
{
cDebug() << Logger::SubEntry
<< "Calamares Timezones using default, system locale not found:" << m_localeName;
cDebug() << Logger::SubEntry << "Calamares Timezones using default, system locale not found:" << m_localeName;
return translator->load( QString( ":/lang/tz_en" ) );
}
}
};
static void
loadSingletonTranslator( TranslationLoader&& loader, QTranslator*& translator_p )
@ -167,7 +179,7 @@ static QTranslator* s_tztranslator = nullptr;
static QString s_translatorLocaleName;
void
installTranslator( const QLocale& locale, const QString& brandingTranslationsPrefix, QObject* parent )
installTranslator( const QLocale& locale, const QString& brandingTranslationsPrefix, QObject* )
{
loadSingletonTranslator( BrandingLoader( locale, brandingTranslationsPrefix ), s_brandingTranslator );
loadSingletonTranslator( TZLoader( locale ), s_tztranslator );

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 >

View File

@ -4,7 +4,7 @@
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# Copyright 2014, Rohan Garg <rohan@kde.org>
# Copyright 2015 - 2019, Philip Müller <philm@manjaro.org>
# Copyright 2015,2019, Philip Müller <philm@manjaro.org>
# Copyright 2017, Alf Gaida <agaida@sidution.org>
# Copyright 2019, Adriaan de Groot <groot@kde.org>
#
@ -102,10 +102,16 @@ def write_mkinitcpio_lines(hooks, modules, files, root_mount_point):
mkinitcpio_file.write("\n".join(mklins) + "\n")
def detect_plymouth():
"""
Checks existence (runnability) of plymouth in the target system.
@return True if plymouth exists in the target, False otherwise
"""
# Used to only check existence of path /usr/bin/plymouth in target
isPlymouth = target_env_call(["sh", "-c", "which plymouth"])
debug("which plymouth exit code: {!s}".format(isPlymouth))
return isPlymouth
return isPlymouth == 0
def modify_mkinitcpio_conf(partitions, root_mount_point):
"""
@ -127,7 +133,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
unencrypted_separate_boot = False
# It is important that the plymouth hook comes before any encrypt hook
if detect_plymouth() == 0:
if detect_plymouth():
hooks.append("plymouth")
for partition in partitions:

View File

@ -41,9 +41,9 @@
LocalePage::LocalePage( QWidget* parent )
: QWidget( parent )
, m_blockTzWidgetSet( false )
, m_regionList( CalamaresUtils::Locale::TZRegion::fromZoneTab() )
, m_regionModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >( m_regionList ) )
, m_blockTzWidgetSet( false )
{
QBoxLayout* mainLayout = new QVBoxLayout;

View File

@ -271,7 +271,14 @@ TimeZoneWidget::paintEvent( QPaintEvent* )
painter.drawImage( point.x() - pin.width() / 2, point.y() - pin.height() / 2, pin );
// Draw text and box
const int textWidth = fontMetrics.horizontalAdvance( m_currentLocation ? m_currentLocation->tr() : QString() );
// .. the lambda manages deprecations: the old one works in Qt 5.9 and Qt 5.10,
// while the new one avoids deprecation messages in Qt 5.13 and later.
#if QT_VERSION >= QT_VERSION_CHECK( 5, 11, 0 )
auto textwidth = [&]( const QString& s ) { return fontMetrics.horizontalAdvance( s ); };
#else
auto textwidth = [&]( const QString& s ) { return fontMetrics.width( s ); };
#endif
const int textWidth = textwidth( m_currentLocation ? m_currentLocation->tr() : QString() );
const int textHeight = fontMetrics.height();
QRect rect = QRect( point.x() - textWidth / 2 - 5, point.y() - textHeight - 8, textWidth + 10, textHeight - 2 );

View File

@ -53,7 +53,6 @@ PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent
}
ui->products->setMinimumWidth( 10 * CalamaresUtils::defaultFontHeight() );
}
/** @brief size the given @p pixmap to @p size
@ -140,6 +139,16 @@ PackageChooserPage::setModel( QAbstractItemModel* model )
&PackageChooserPage::updateLabels );
}
void
PackageChooserPage::setSelection( const QModelIndex& index )
{
if ( index.isValid() )
{
ui->products->selectionModel()->select( index, QItemSelectionModel::Select );
currentChanged( index );
}
}
bool
PackageChooserPage::hasSelection() const
{

View File

@ -35,10 +35,13 @@ class PackageChooserPage : public QWidget
public:
explicit PackageChooserPage( PackageChooserMode mode, QWidget* parent = nullptr );
/// @brief Sets the data model for the listview
void setModel( QAbstractItemModel* model );
/// @brief Sets the introductory (no-package-selected) texts
void setIntroduction( const PackageItem& item );
/// @brief Selects a listview item
void setSelection( const QModelIndex& index );
/// @brief Is anything selected?
bool hasSelection() const;
/** @brief Get the list of selected ids

View File

@ -144,6 +144,14 @@ PackageChooserViewStep::isAtEnd() const
return true;
}
void
PackageChooserViewStep::onActivate()
{
if ( !m_widget->hasSelection() )
{
m_widget->setSelection( m_defaultIdx );
}
}
void
PackageChooserViewStep::onLeave()
@ -198,6 +206,9 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
}
}
QString default_item_id = CalamaresUtils::getString( configurationMap, "default" );
m_defaultIdx = QModelIndex();
bool first_time = !m_model;
if ( configurationMap.contains( "items" ) )
{
@ -208,6 +219,22 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
{
hookupModel();
}
// find default item
if ( first_time && m_model && !default_item_id.isEmpty() )
{
for ( int item_n = 0; item_n < m_model->packageCount(); ++item_n )
{
QModelIndex item_idx = m_model->index( item_n, 0 );
QVariant item_id = m_model->data( item_idx, PackageListModel::IdRole );
if ( item_id.toString() == default_item_id )
{
m_defaultIdx = item_idx;
break;
}
}
}
}
void

View File

@ -50,6 +50,7 @@ public:
bool isAtBeginning() const override;
bool isAtEnd() const override;
void onActivate() override;
void onLeave() override;
Calamares::JobList jobs() const override;
@ -67,6 +68,7 @@ private:
PackageChooserMode m_mode;
QString m_id;
CalamaresUtils::Locale::TranslatedString* m_stepName; // As it appears in the sidebar
QModelIndex m_defaultIdx;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )

View File

@ -33,6 +33,10 @@ labels:
step: "Office Suite"
step[de]: "Office-Paket"
# (Optional) 'id' of pre-selected list-view item.
# Pre-selects one of the items below.
# default: kde
# Items to display in the chooser. In general, this should be a
# pretty short list to avoid overwhelming the UI. This is a list
# of objects, and the items are displayed in list order.