diff --git a/CHANGES b/CHANGES index 712bdfeb1..42a0b8c51 100644 --- a/CHANGES +++ b/CHANGES @@ -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) # diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b823ccbe..6edc4e4cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( diff --git a/lang/tz_en.ts b/lang/tz_en.ts index 7e46eab3d..ba9b5a350 100644 --- a/lang/tz_en.ts +++ b/lang/tz_en.ts @@ -1285,7 +1285,7 @@ Kiev tz_names - + Kyiv diff --git a/lang/tz_uk.ts b/lang/tz_uk.ts new file mode 100644 index 000000000..6059079ca --- /dev/null +++ b/lang/tz_uk.ts @@ -0,0 +1,2617 @@ + + + + + QObject + + + Africa + tz_regions + + + + + America + tz_regions + + + + + Antarctica + tz_regions + + + + + Arctic + tz_regions + + + + + Asia + tz_regions + + + + + Atlantic + tz_regions + + + + + Australia + tz_regions + + + + + Europe + tz_regions + + + + + Indian + tz_regions + + + + + Pacific + tz_regions + + + + + Abidjan + tz_names + + + + + Accra + tz_names + + + + + Adak + tz_names + + + + + Addis Ababa + tz_names + + + + + Adelaide + tz_names + + + + + Aden + tz_names + + + + + Algiers + tz_names + + + + + Almaty + tz_names + + + + + Amman + tz_names + + + + + Amsterdam + tz_names + + + + + Anadyr + tz_names + + + + + Anchorage + tz_names + + + + + Andorra + tz_names + + + + + Anguilla + tz_names + + + + + Antananarivo + tz_names + + + + + Antigua + tz_names + + + + + Apia + tz_names + + + + + Aqtau + tz_names + + + + + Aqtobe + tz_names + + + + + Araguaina + tz_names + + + + + Argentina/Buenos Aires + tz_names + + + + + Argentina/Catamarca + tz_names + + + + + Argentina/Cordoba + tz_names + + + + + Argentina/Jujuy + tz_names + + + + + Argentina/La Rioja + tz_names + + + + + Argentina/Mendoza + tz_names + + + + + Argentina/Rio Gallegos + tz_names + + + + + Argentina/Salta + tz_names + + + + + Argentina/San Juan + tz_names + + + + + Argentina/San Luis + tz_names + + + + + Argentina/Tucuman + tz_names + + + + + Argentina/Ushuaia + tz_names + + + + + Aruba + tz_names + + + + + Ashgabat + tz_names + + + + + Asmara + tz_names + + + + + Astrakhan + tz_names + + + + + Asuncion + tz_names + + + + + Athens + tz_names + + + + + Atikokan + tz_names + + + + + Atyrau + tz_names + + + + + Auckland + tz_names + + + + + Azores + tz_names + + + + + Baghdad + tz_names + + + + + Bahia + tz_names + + + + + Bahia Banderas + tz_names + + + + + Bahrain + tz_names + + + + + Baku + tz_names + + + + + Bamako + tz_names + + + + + Bangkok + tz_names + + + + + Bangui + tz_names + + + + + Banjul + tz_names + + + + + Barbados + tz_names + + + + + Barnaul + tz_names + + + + + Beirut + tz_names + + + + + Belem + tz_names + + + + + Belgrade + tz_names + + + + + Belize + tz_names + + + + + Berlin + tz_names + + + + + Bermuda + tz_names + + + + + Bishkek + tz_names + + + + + Bissau + tz_names + + + + + Blanc-Sablon + tz_names + + + + + Blantyre + tz_names + + + + + Boa Vista + tz_names + + + + + Bogota + tz_names + + + + + Boise + tz_names + + + + + Bougainville + tz_names + + + + + Bratislava + tz_names + + + + + Brazzaville + tz_names + + + + + Brisbane + tz_names + + + + + Broken Hill + tz_names + + + + + Brunei + tz_names + + + + + Brussels + tz_names + + + + + Bucharest + tz_names + + + + + Budapest + tz_names + + + + + Bujumbura + tz_names + + + + + Busingen + tz_names + + + + + Cairo + tz_names + + + + + Cambridge Bay + tz_names + + + + + Campo Grande + tz_names + + + + + Canary + tz_names + + + + + Cancun + tz_names + + + + + Cape Verde + tz_names + + + + + Caracas + tz_names + + + + + Casablanca + tz_names + + + + + Casey + tz_names + + + + + Cayenne + tz_names + + + + + Cayman + tz_names + + + + + Ceuta + tz_names + + + + + Chagos + tz_names + + + + + Chatham + tz_names + + + + + Chicago + tz_names + + + + + Chihuahua + tz_names + + + + + Chisinau + tz_names + + + + + Chita + tz_names + + + + + Choibalsan + tz_names + + + + + Christmas + tz_names + + + + + Chuuk + tz_names + + + + + Cocos + tz_names + + + + + Colombo + tz_names + + + + + Comoro + tz_names + + + + + Conakry + tz_names + + + + + Copenhagen + tz_names + + + + + Costa Rica + tz_names + + + + + Creston + tz_names + + + + + Cuiaba + tz_names + + + + + Curacao + tz_names + + + + + Currie + tz_names + + + + + Dakar + tz_names + + + + + Damascus + tz_names + + + + + Danmarkshavn + tz_names + + + + + Dar es Salaam + tz_names + + + + + Darwin + tz_names + + + + + Davis + tz_names + + + + + Dawson + tz_names + + + + + Dawson Creek + tz_names + + + + + Denver + tz_names + + + + + Detroit + tz_names + + + + + Dhaka + tz_names + + + + + Dili + tz_names + + + + + Djibouti + tz_names + + + + + Dominica + tz_names + + + + + Douala + tz_names + + + + + Dubai + tz_names + + + + + Dublin + tz_names + + + + + DumontDUrville + tz_names + + + + + Dushanbe + tz_names + + + + + Easter + tz_names + + + + + Edmonton + tz_names + + + + + Efate + tz_names + + + + + Eirunepe + tz_names + + + + + El Aaiun + tz_names + + + + + El Salvador + tz_names + + + + + Enderbury + tz_names + + + + + Eucla + tz_names + + + + + Fakaofo + tz_names + + + + + Famagusta + tz_names + + + + + Faroe + tz_names + + + + + Fiji + tz_names + + + + + Fort Nelson + tz_names + + + + + Fortaleza + tz_names + + + + + Freetown + tz_names + + + + + Funafuti + tz_names + + + + + Gaborone + tz_names + + + + + Galapagos + tz_names + + + + + Gambier + tz_names + + + + + Gaza + tz_names + + + + + Gibraltar + tz_names + + + + + Glace Bay + tz_names + + + + + Godthab + tz_names + + + + + Goose Bay + tz_names + + + + + Grand Turk + tz_names + + + + + Grenada + tz_names + + + + + Guadalcanal + tz_names + + + + + Guadeloupe + tz_names + + + + + Guam + tz_names + + + + + Guatemala + tz_names + + + + + Guayaquil + tz_names + + + + + Guernsey + tz_names + + + + + Guyana + tz_names + + + + + Halifax + tz_names + + + + + Harare + tz_names + + + + + Havana + tz_names + + + + + Hebron + tz_names + + + + + Helsinki + tz_names + + + + + Hermosillo + tz_names + + + + + Ho Chi Minh + tz_names + + + + + Hobart + tz_names + + + + + Hong Kong + tz_names + + + + + Honolulu + tz_names + + + + + Hovd + tz_names + + + + + Indiana/Indianapolis + tz_names + + + + + Indiana/Knox + tz_names + + + + + Indiana/Marengo + tz_names + + + + + Indiana/Petersburg + tz_names + + + + + Indiana/Tell City + tz_names + + + + + Indiana/Vevay + tz_names + + + + + Indiana/Vincennes + tz_names + + + + + Indiana/Winamac + tz_names + + + + + Inuvik + tz_names + + + + + Iqaluit + tz_names + + + + + Irkutsk + tz_names + + + + + Isle of Man + tz_names + + + + + Istanbul + tz_names + + + + + Jakarta + tz_names + + + + + Jamaica + tz_names + + + + + Jayapura + tz_names + + + + + Jersey + tz_names + + + + + Jerusalem + tz_names + + + + + Johannesburg + tz_names + + + + + Juba + tz_names + + + + + Juneau + tz_names + + + + + Kabul + tz_names + + + + + Kaliningrad + tz_names + + + + + Kamchatka + tz_names + + + + + Kampala + tz_names + + + + + Karachi + tz_names + + + + + Kathmandu + tz_names + + + + + Kentucky/Louisville + tz_names + + + + + Kentucky/Monticello + tz_names + + + + + Kerguelen + tz_names + + + + + Khandyga + tz_names + + + + + Khartoum + tz_names + + + + + Kiev + tz_names + Київ + + + + Kigali + tz_names + + + + + Kinshasa + tz_names + + + + + Kiritimati + tz_names + + + + + Kirov + tz_names + + + + + Kolkata + tz_names + + + + + Kosrae + tz_names + + + + + Kralendijk + tz_names + + + + + Krasnoyarsk + tz_names + + + + + Kuala Lumpur + tz_names + + + + + Kuching + tz_names + + + + + Kuwait + tz_names + + + + + Kwajalein + tz_names + + + + + La Paz + tz_names + + + + + Lagos + tz_names + + + + + Libreville + tz_names + + + + + Lima + tz_names + + + + + Lindeman + tz_names + + + + + Lisbon + tz_names + + + + + Ljubljana + tz_names + + + + + Lome + tz_names + + + + + London + tz_names + + + + + Longyearbyen + tz_names + + + + + Lord Howe + tz_names + + + + + Los Angeles + tz_names + + + + + Lower Princes + tz_names + + + + + Luanda + tz_names + + + + + Lubumbashi + tz_names + + + + + Lusaka + tz_names + + + + + Luxembourg + tz_names + + + + + Macau + tz_names + + + + + Maceio + tz_names + + + + + Macquarie + tz_names + + + + + Madeira + tz_names + + + + + Madrid + tz_names + + + + + Magadan + tz_names + + + + + Mahe + tz_names + + + + + Majuro + tz_names + + + + + Makassar + tz_names + + + + + Malabo + tz_names + + + + + Maldives + tz_names + + + + + Malta + tz_names + + + + + Managua + tz_names + + + + + Manaus + tz_names + + + + + Manila + tz_names + + + + + Maputo + tz_names + + + + + Mariehamn + tz_names + + + + + Marigot + tz_names + + + + + Marquesas + tz_names + + + + + Martinique + tz_names + + + + + Maseru + tz_names + + + + + Matamoros + tz_names + + + + + Mauritius + tz_names + + + + + Mawson + tz_names + + + + + Mayotte + tz_names + + + + + Mazatlan + tz_names + + + + + Mbabane + tz_names + + + + + McMurdo + tz_names + + + + + Melbourne + tz_names + + + + + Menominee + tz_names + + + + + Merida + tz_names + + + + + Metlakatla + tz_names + + + + + Mexico City + tz_names + + + + + Midway + tz_names + + + + + Minsk + tz_names + + + + + Miquelon + tz_names + + + + + Mogadishu + tz_names + + + + + Monaco + tz_names + + + + + Moncton + tz_names + + + + + Monrovia + tz_names + + + + + Monterrey + tz_names + + + + + Montevideo + tz_names + + + + + Montserrat + tz_names + + + + + Moscow + tz_names + + + + + Muscat + tz_names + + + + + Nairobi + tz_names + + + + + Nassau + tz_names + + + + + Nauru + tz_names + + + + + Ndjamena + tz_names + + + + + New York + tz_names + + + + + Niamey + tz_names + + + + + Nicosia + tz_names + + + + + Nipigon + tz_names + + + + + Niue + tz_names + + + + + Nome + tz_names + + + + + Norfolk + tz_names + + + + + Noronha + tz_names + + + + + North Dakota/Beulah + tz_names + + + + + North Dakota/Center + tz_names + + + + + North Dakota/New Salem + tz_names + + + + + Nouakchott + tz_names + + + + + Noumea + tz_names + + + + + Novokuznetsk + tz_names + + + + + Novosibirsk + tz_names + + + + + Ojinaga + tz_names + + + + + Omsk + tz_names + + + + + Oral + tz_names + + + + + Oslo + tz_names + + + + + Ouagadougou + tz_names + + + + + Pago Pago + tz_names + + + + + Palau + tz_names + + + + + Palmer + tz_names + + + + + Panama + tz_names + + + + + Pangnirtung + tz_names + + + + + Paramaribo + tz_names + + + + + Paris + tz_names + + + + + Perth + tz_names + + + + + Phnom Penh + tz_names + + + + + Phoenix + tz_names + + + + + Pitcairn + tz_names + + + + + Podgorica + tz_names + + + + + Pohnpei + tz_names + + + + + Pontianak + tz_names + + + + + Port Moresby + tz_names + + + + + Port of Spain + tz_names + + + + + Port-au-Prince + tz_names + + + + + Porto Velho + tz_names + + + + + Porto-Novo + tz_names + + + + + Prague + tz_names + + + + + Puerto Rico + tz_names + + + + + Punta Arenas + tz_names + + + + + Pyongyang + tz_names + + + + + Qatar + tz_names + + + + + Qostanay + tz_names + + + + + Qyzylorda + tz_names + + + + + Rainy River + tz_names + + + + + Rankin Inlet + tz_names + + + + + Rarotonga + tz_names + + + + + Recife + tz_names + + + + + Regina + tz_names + + + + + Resolute + tz_names + + + + + Reunion + tz_names + + + + + Reykjavik + tz_names + + + + + Riga + tz_names + + + + + Rio Branco + tz_names + + + + + Riyadh + tz_names + + + + + Rome + tz_names + + + + + Rothera + tz_names + + + + + Saipan + tz_names + + + + + Sakhalin + tz_names + + + + + Samara + tz_names + + + + + Samarkand + tz_names + + + + + San Marino + tz_names + + + + + Santarem + tz_names + + + + + Santiago + tz_names + + + + + Santo Domingo + tz_names + + + + + Sao Paulo + tz_names + + + + + Sao Tome + tz_names + + + + + Sarajevo + tz_names + + + + + Saratov + tz_names + + + + + Scoresbysund + tz_names + + + + + Seoul + tz_names + + + + + Shanghai + tz_names + + + + + Simferopol + tz_names + + + + + Singapore + tz_names + + + + + Sitka + tz_names + + + + + Skopje + tz_names + + + + + Sofia + tz_names + + + + + South Georgia + tz_names + + + + + Srednekolymsk + tz_names + + + + + St Barthelemy + tz_names + + + + + St Helena + tz_names + + + + + St Johns + tz_names + + + + + St Kitts + tz_names + + + + + St Lucia + tz_names + + + + + St Thomas + tz_names + + + + + St Vincent + tz_names + + + + + Stanley + tz_names + + + + + Stockholm + tz_names + + + + + Swift Current + tz_names + + + + + Sydney + tz_names + + + + + Syowa + tz_names + + + + + Tahiti + tz_names + + + + + Taipei + tz_names + + + + + Tallinn + tz_names + + + + + Tarawa + tz_names + + + + + Tashkent + tz_names + + + + + Tbilisi + tz_names + + + + + Tegucigalpa + tz_names + + + + + Tehran + tz_names + + + + + Thimphu + tz_names + + + + + Thule + tz_names + + + + + Thunder Bay + tz_names + + + + + Tijuana + tz_names + + + + + Tirane + tz_names + + + + + Tokyo + tz_names + + + + + Tomsk + tz_names + + + + + Tongatapu + tz_names + + + + + Toronto + tz_names + + + + + Tortola + tz_names + + + + + Tripoli + tz_names + + + + + Troll + tz_names + + + + + Tunis + tz_names + + + + + Ulaanbaatar + tz_names + + + + + Ulyanovsk + tz_names + + + + + Urumqi + tz_names + + + + + Ust-Nera + tz_names + + + + + Uzhgorod + tz_names + + + + + Vaduz + tz_names + + + + + Vancouver + tz_names + + + + + Vatican + tz_names + + + + + Vienna + tz_names + + + + + Vientiane + tz_names + + + + + Vilnius + tz_names + + + + + Vladivostok + tz_names + + + + + Volgograd + tz_names + + + + + Vostok + tz_names + + + + + Wake + tz_names + + + + + Wallis + tz_names + + + + + Warsaw + tz_names + + + + + Whitehorse + tz_names + + + + + Windhoek + tz_names + + + + + Winnipeg + tz_names + + + + + Yakutat + tz_names + + + + + Yakutsk + tz_names + + + + + Yangon + tz_names + + + + + Yekaterinburg + tz_names + + + + + Yellowknife + tz_names + + + + + Yerevan + tz_names + + + + + Zagreb + tz_names + + + + + Zaporozhye + tz_names + + + + + Zurich + tz_names + + + + diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index 5d9b29c69..f70715aea 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -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. diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 527f92c85..1584b11fa 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -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"; } diff --git a/src/libcalamares/locale/Tests.cpp b/src/libcalamares/locale/Tests.cpp index 106a77b4c..b63eb9e18 100644 --- a/src/libcalamares/locale/Tests.cpp +++ b/src/libcalamares/locale/Tests.cpp @@ -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() ); } diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 05aeaf885..58695ee0e 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -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(); } diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 567b42241..3345e61f8 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -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(); } diff --git a/src/libcalamares/utils/Retranslator.cpp b/src/libcalamares/utils/Retranslator.cpp index 047f642e4..4c7c3b3f5 100644 --- a/src/libcalamares/utils/Retranslator.cpp +++ b/src/libcalamares/utils/Retranslator.cpp @@ -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,74 +75,85 @@ struct BrandingLoader : public TranslationLoader { } - bool tryLoad( QTranslator* translator ) override - { - if ( m_prefix.isEmpty() ) - { - return false; - } - QString brandingTranslationsDirPath( m_prefix ); - brandingTranslationsDirPath.truncate( m_prefix.lastIndexOf( QDir::separator() ) ); - QDir brandingTranslationsDir( brandingTranslationsDirPath ); - if ( brandingTranslationsDir.exists() ) - { - QString filenameBase( m_prefix ); - filenameBase.remove( 0, m_prefix.lastIndexOf( QDir::separator() ) + 1 ); - if ( translator->load( m_locale, filenameBase, "_", brandingTranslationsDir.absolutePath() ) ) - { - cDebug() << Logger::SubEntry << "Branding using locale:" << m_localeName; - return true; - } - else - { - cDebug() << Logger::SubEntry << "Branding using default, system locale not found:" << m_localeName; - // TODO: this loads something completely different - return translator->load( m_prefix + "en" ); - } - } - return false; - } + 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 - { - if ( translator->load( QString( ":/lang/calamares_" ) + m_localeName ) ) - { - cDebug() << Logger::SubEntry << "Calamares using locale:" << m_localeName; - return true; - } - else - { - cDebug() << Logger::SubEntry << "Calamares using default, system locale not found:" << m_localeName; - return translator->load( QString( ":/lang/calamares_en" ) ); - } - } + bool tryLoad( QTranslator* translator ) override; }; +/// @brief Loads timezone name translations struct TZLoader : public TranslationLoader { using TranslationLoader::TranslationLoader; - bool tryLoad( QTranslator* translator ) override + bool tryLoad( QTranslator* translator ) override; +}; + +TranslationLoader::~TranslationLoader() {} + +bool +BrandingLoader::tryLoad( QTranslator* translator ) +{ + if ( m_prefix.isEmpty() ) { - if ( translator->load( QString( ":/lang/tz_" ) + m_localeName ) ) + return false; + } + QString brandingTranslationsDirPath( m_prefix ); + brandingTranslationsDirPath.truncate( m_prefix.lastIndexOf( QDir::separator() ) ); + QDir brandingTranslationsDir( brandingTranslationsDirPath ); + if ( brandingTranslationsDir.exists() ) + { + QString filenameBase( m_prefix ); + filenameBase.remove( 0, m_prefix.lastIndexOf( QDir::separator() ) + 1 ); + if ( translator->load( m_locale, filenameBase, "_", brandingTranslationsDir.absolutePath() ) ) { - cDebug() << Logger::SubEntry << "Calamares Timezones using locale:" << m_localeName; + cDebug() << Logger::SubEntry << "Branding using locale:" << m_localeName; return true; } else { - cDebug() << Logger::SubEntry - << "Calamares Timezones using default, system locale not found:" << m_localeName; - return translator->load( QString( ":/lang/tz_en" ) ); + cDebug() << Logger::SubEntry << "Branding using default, system locale not found:" << m_localeName; + // TODO: this loads something completely different + return translator->load( m_prefix + "en" ); } } -}; + return false; +} + +bool +CalamaresLoader::tryLoad( QTranslator* translator ) +{ + if ( translator->load( QString( ":/lang/calamares_" ) + m_localeName ) ) + { + cDebug() << Logger::SubEntry << "Calamares using locale:" << m_localeName; + return true; + } + else + { + cDebug() << Logger::SubEntry << "Calamares using default, system locale not found:" << m_localeName; + return translator->load( QString( ":/lang/calamares_en" ) ); + } +} + +bool +TZLoader::tryLoad( QTranslator* translator ) +{ + if ( translator->load( QString( ":/lang/tz_" ) + m_localeName ) ) + { + cDebug() << Logger::SubEntry << "Calamares Timezones using locale:" << m_localeName; + return true; + } + else + { + 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 ); diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index edbced5fa..a5b6e5dce 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -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() ) diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 3723fd07f..30e8be846 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -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 > diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 9df60dec2..6147a508a 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -4,7 +4,7 @@ # === This file is part of Calamares - === # # Copyright 2014, Rohan Garg -# Copyright 2015 - 2019, Philip Müller +# Copyright 2015,2019, Philip Müller # Copyright 2017, Alf Gaida # Copyright 2019, Adriaan de Groot # @@ -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: diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 4e43fc177..c1df7c81c 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -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; diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index a96aaafa3..400af0841 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -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 ); diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index b4d9f99af..16f50abab 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -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 { diff --git a/src/modules/packagechooser/PackageChooserPage.h b/src/modules/packagechooser/PackageChooserPage.h index 79b9fa69c..b4ef2169b 100644 --- a/src/modules/packagechooser/PackageChooserPage.h +++ b/src/modules/packagechooser/PackageChooserPage.h @@ -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 diff --git a/src/modules/packagechooser/PackageChooserViewStep.cpp b/src/modules/packagechooser/PackageChooserViewStep.cpp index 6fb29a4f7..c933147ee 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.cpp +++ b/src/modules/packagechooser/PackageChooserViewStep.cpp @@ -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 diff --git a/src/modules/packagechooser/PackageChooserViewStep.h b/src/modules/packagechooser/PackageChooserViewStep.h index 499571c12..29e65ef82 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.h +++ b/src/modules/packagechooser/PackageChooserViewStep.h @@ -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 ) diff --git a/src/modules/packagechooser/packagechooser.conf b/src/modules/packagechooser/packagechooser.conf index 89458cadb..90611a64b 100644 --- a/src/modules/packagechooser/packagechooser.conf +++ b/src/modules/packagechooser/packagechooser.conf @@ -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.