libcalamares: move all locale-related things into namespace Calamares::Locale
The locale bits were spread over Calamares::Locale and CalamaresUtils::Locale.
This commit is contained in:
parent
766c28ca82
commit
47cbcbd348
@ -281,7 +281,7 @@ _gettext_languages()
|
|||||||
Calamares::GlobalStorage* gs
|
Calamares::GlobalStorage* gs
|
||||||
= jq ? jq->globalStorage() : CalamaresPython::GlobalStoragePythonWrapper::globalStorageInstance();
|
= jq ? jq->globalStorage() : CalamaresPython::GlobalStoragePythonWrapper::globalStorageInstance();
|
||||||
|
|
||||||
QString lang = CalamaresUtils::Locale::readGS( *gs, QStringLiteral( "LANG" ) );
|
QString lang = Calamares::Locale::readGS( *gs, QStringLiteral( "LANG" ) );
|
||||||
if ( !lang.isEmpty() )
|
if ( !lang.isEmpty() )
|
||||||
{
|
{
|
||||||
languages.append( lang );
|
languages.append( lang );
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
// *INDENT-OFF*
|
// *INDENT-OFF*
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
|
|
||||||
struct CountryData
|
struct CountryData
|
||||||
{
|
{
|
||||||
QLocale::Language l;
|
QLocale::Language l;
|
||||||
@ -253,5 +252,4 @@ static const CountryData country_data_table[] = {
|
|||||||
|
|
||||||
static_assert( (sizeof(country_data_table) / sizeof(CountryData)) == country_data_size, "Table size mismatch for CountryData" );
|
static_assert( (sizeof(country_data_table) / sizeof(CountryData)) == country_data_size, "Table size mismatch for CountryData" );
|
||||||
|
|
||||||
|
|
||||||
// END Generated from CLDR data
|
// END Generated from CLDR data
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
@ -88,4 +88,4 @@ readGS( Calamares::GlobalStorage& gs, const QString& key )
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
@ -28,10 +28,7 @@
|
|||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
class GlobalStorage;
|
class GlobalStorage;
|
||||||
} // namespace Calamares
|
|
||||||
|
|
||||||
namespace CalamaresUtils
|
|
||||||
{
|
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -81,6 +78,6 @@ DLLEXPORT void clearGS( Calamares::GlobalStorage& gs );
|
|||||||
DLLEXPORT QString readGS( Calamares::GlobalStorage& gs, const QString& key );
|
DLLEXPORT QString readGS( Calamares::GlobalStorage& gs, const QString& key );
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -137,7 +137,6 @@ LocaleTests::testInterlingue()
|
|||||||
QCOMPARE( QLocale( "bork" ).language(), QLocale::C );
|
QCOMPARE( QLocale( "bork" ).language(), QLocale::C );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const QStringList&
|
static const QStringList&
|
||||||
someLanguages()
|
someLanguages()
|
||||||
{
|
{
|
||||||
@ -145,7 +144,6 @@ someLanguages()
|
|||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @brief Check consistency of test data
|
/** @brief Check consistency of test data
|
||||||
* Check that all the languages used in testing, are actually enabled
|
* Check that all the languages used in testing, are actually enabled
|
||||||
* in Calamares translations.
|
* in Calamares translations.
|
||||||
@ -166,11 +164,11 @@ LocaleTests::testTranslatableLanguages()
|
|||||||
void
|
void
|
||||||
LocaleTests::testTranslatableConfig1()
|
LocaleTests::testTranslatableConfig1()
|
||||||
{
|
{
|
||||||
CalamaresUtils::Locale::TranslatedString ts0;
|
Calamares::Locale::TranslatedString ts0;
|
||||||
QVERIFY( ts0.isEmpty() );
|
QVERIFY( ts0.isEmpty() );
|
||||||
QCOMPARE( ts0.count(), 1 ); // the empty string
|
QCOMPARE( ts0.count(), 1 ); // the empty string
|
||||||
|
|
||||||
CalamaresUtils::Locale::TranslatedString ts1( "Hello" );
|
Calamares::Locale::TranslatedString ts1( "Hello" );
|
||||||
QCOMPARE( ts1.count(), 1 );
|
QCOMPARE( ts1.count(), 1 );
|
||||||
QVERIFY( !ts1.isEmpty() );
|
QVERIFY( !ts1.isEmpty() );
|
||||||
|
|
||||||
@ -179,7 +177,7 @@ LocaleTests::testTranslatableConfig1()
|
|||||||
|
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert( "description", "description (no language)" );
|
map.insert( "description", "description (no language)" );
|
||||||
CalamaresUtils::Locale::TranslatedString ts2( map, "description" );
|
Calamares::Locale::TranslatedString ts2( map, "description" );
|
||||||
QCOMPARE( ts2.count(), 1 );
|
QCOMPARE( ts2.count(), 1 );
|
||||||
QVERIFY( !ts2.isEmpty() );
|
QVERIFY( !ts2.isEmpty() );
|
||||||
|
|
||||||
@ -205,7 +203,7 @@ LocaleTests::testTranslatableConfig2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If there's no untranslated string in the map, it is considered empty
|
// If there's no untranslated string in the map, it is considered empty
|
||||||
CalamaresUtils::Locale::TranslatedString ts0( map, "description" );
|
Calamares::Locale::TranslatedString ts0( map, "description" );
|
||||||
QVERIFY( ts0.isEmpty() ); // Because no untranslated string
|
QVERIFY( ts0.isEmpty() ); // Because no untranslated string
|
||||||
QCOMPARE( ts0.count(),
|
QCOMPARE( ts0.count(),
|
||||||
someLanguages().count() + 1 ); // But there are entries for the translations, plus an empty string
|
someLanguages().count() + 1 ); // But there are entries for the translations, plus an empty string
|
||||||
@ -214,7 +212,7 @@ LocaleTests::testTranslatableConfig2()
|
|||||||
map.insert( QString( "description" ), "description (no language)" );
|
map.insert( QString( "description" ), "description (no language)" );
|
||||||
map.insert( QString( "name" ), "name (no language)" );
|
map.insert( QString( "name" ), "name (no language)" );
|
||||||
|
|
||||||
CalamaresUtils::Locale::TranslatedString ts1( map, "description" );
|
Calamares::Locale::TranslatedString ts1( map, "description" );
|
||||||
// The +1 is because "" is always also inserted
|
// The +1 is because "" is always also inserted
|
||||||
QCOMPARE( ts1.count(), someLanguages().count() + 1 );
|
QCOMPARE( ts1.count(), someLanguages().count() + 1 );
|
||||||
QVERIFY( !ts1.isEmpty() );
|
QVERIFY( !ts1.isEmpty() );
|
||||||
@ -237,13 +235,13 @@ LocaleTests::testTranslatableConfig2()
|
|||||||
QCOMPARE( ts1.get( QLocale( QLocale::Language::Serbian, QLocale::Script::LatinScript, QLocale::Country::Serbia ) ),
|
QCOMPARE( ts1.get( QLocale( QLocale::Language::Serbian, QLocale::Script::LatinScript, QLocale::Country::Serbia ) ),
|
||||||
QStringLiteral( "description (language sr@latin)" ) );
|
QStringLiteral( "description (language sr@latin)" ) );
|
||||||
|
|
||||||
CalamaresUtils::Locale::TranslatedString ts2( map, "name" );
|
Calamares::Locale::TranslatedString ts2( map, "name" );
|
||||||
// We skipped dutch this time
|
// We skipped dutch this time
|
||||||
QCOMPARE( ts2.count(), someLanguages().count() );
|
QCOMPARE( ts2.count(), someLanguages().count() );
|
||||||
QVERIFY( !ts2.isEmpty() );
|
QVERIFY( !ts2.isEmpty() );
|
||||||
|
|
||||||
// This key doesn't exist
|
// This key doesn't exist
|
||||||
CalamaresUtils::Locale::TranslatedString ts3( map, "front" );
|
Calamares::Locale::TranslatedString ts3( map, "front" );
|
||||||
QVERIFY( ts3.isEmpty() );
|
QVERIFY( ts3.isEmpty() );
|
||||||
QCOMPARE( ts3.count(), 1 ); // The empty string
|
QCOMPARE( ts3.count(), 1 ); // The empty string
|
||||||
}
|
}
|
||||||
@ -251,7 +249,7 @@ LocaleTests::testTranslatableConfig2()
|
|||||||
void
|
void
|
||||||
LocaleTests::testTranslatableConfigContext()
|
LocaleTests::testTranslatableConfigContext()
|
||||||
{
|
{
|
||||||
using TS = CalamaresUtils::Locale::TranslatedString;
|
using TS = Calamares::Locale::TranslatedString;
|
||||||
|
|
||||||
const QString original( "Quit" );
|
const QString original( "Quit" );
|
||||||
TS quitUntranslated( original );
|
TS quitUntranslated( original );
|
||||||
@ -273,11 +271,10 @@ LocaleTests::testTranslatableConfigContext()
|
|||||||
QCOMPARE( tr( "Quit" ), QStringLiteral( "Ophouden" ) );
|
QCOMPARE( tr( "Quit" ), QStringLiteral( "Ophouden" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocaleTests::testRegions()
|
LocaleTests::testRegions()
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
RegionsModel regions;
|
RegionsModel regions;
|
||||||
|
|
||||||
QVERIFY( regions.rowCount( QModelIndex() ) > 3 ); // Africa, America, Asia
|
QVERIFY( regions.rowCount( QModelIndex() ) > 3 ); // Africa, America, Asia
|
||||||
@ -295,7 +292,6 @@ LocaleTests::testRegions()
|
|||||||
QVERIFY( !names.contains( "UTC" ) );
|
QVERIFY( !names.contains( "UTC" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
displayedNames( QAbstractItemModel& model, QStringList& names )
|
displayedNames( QAbstractItemModel& model, QStringList& names )
|
||||||
{
|
{
|
||||||
@ -312,7 +308,7 @@ displayedNames( QAbstractItemModel& model, QStringList& names )
|
|||||||
void
|
void
|
||||||
LocaleTests::testSimpleZones()
|
LocaleTests::testSimpleZones()
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
ZonesModel zones;
|
ZonesModel zones;
|
||||||
|
|
||||||
QVERIFY( zones.rowCount( QModelIndex() ) > 24 );
|
QVERIFY( zones.rowCount( QModelIndex() ) > 24 );
|
||||||
@ -338,7 +334,7 @@ LocaleTests::testSimpleZones()
|
|||||||
void
|
void
|
||||||
LocaleTests::testComplexZones()
|
LocaleTests::testComplexZones()
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
ZonesModel zones;
|
ZonesModel zones;
|
||||||
RegionalZonesModel europe( &zones );
|
RegionalZonesModel europe( &zones );
|
||||||
|
|
||||||
@ -377,7 +373,7 @@ LocaleTests::testComplexZones()
|
|||||||
void
|
void
|
||||||
LocaleTests::testTZLookup()
|
LocaleTests::testTZLookup()
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
ZonesModel zones;
|
ZonesModel zones;
|
||||||
|
|
||||||
QVERIFY( zones.find( "America", "New_York" ) );
|
QVERIFY( zones.find( "America", "New_York" ) );
|
||||||
@ -391,7 +387,7 @@ LocaleTests::testTZLookup()
|
|||||||
void
|
void
|
||||||
LocaleTests::testTZIterator()
|
LocaleTests::testTZIterator()
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
const ZonesModel zones;
|
const ZonesModel zones;
|
||||||
|
|
||||||
QVERIFY( zones.find( "Europe", "Rome" ) );
|
QVERIFY( zones.find( "Europe", "Rome" ) );
|
||||||
@ -437,7 +433,7 @@ LocaleTests::testLocationLookup_data()
|
|||||||
void
|
void
|
||||||
LocaleTests::testLocationLookup()
|
LocaleTests::testLocationLookup()
|
||||||
{
|
{
|
||||||
const CalamaresUtils::Locale::ZonesModel zones;
|
const Calamares::Locale::ZonesModel zones;
|
||||||
|
|
||||||
QFETCH( double, latitude );
|
QFETCH( double, latitude );
|
||||||
QFETCH( double, longitude );
|
QFETCH( double, longitude );
|
||||||
@ -456,7 +452,7 @@ LocaleTests::testLocationLookup2()
|
|||||||
// Spot patch
|
// Spot patch
|
||||||
// "ZA -3230+02259 Africa/Johannesburg\n";
|
// "ZA -3230+02259 Africa/Johannesburg\n";
|
||||||
|
|
||||||
const CalamaresUtils::Locale::ZonesModel zones;
|
const Calamares::Locale::ZonesModel zones;
|
||||||
const auto* zone = zones.find( -26.15, 28.00 );
|
const auto* zone = zones.find( -26.15, 28.00 );
|
||||||
QCOMPARE( zone->zone(), QString( "Johannesburg" ) );
|
QCOMPARE( zone->zone(), QString( "Johannesburg" ) );
|
||||||
// The TZ data sources use minutes-and-seconds notation,
|
// The TZ data sources use minutes-and-seconds notation,
|
||||||
@ -490,7 +486,7 @@ LocaleTests::testGSUpdates()
|
|||||||
|
|
||||||
// Insert one
|
// Insert one
|
||||||
{
|
{
|
||||||
CalamaresUtils::Locale::insertGS( gs, "LANG", "en_US" );
|
Calamares::Locale::insertGS( gs, "LANG", "en_US" );
|
||||||
auto map = gs.value( gsKey ).toMap();
|
auto map = gs.value( gsKey ).toMap();
|
||||||
QCOMPARE( map.count(), 1 );
|
QCOMPARE( map.count(), 1 );
|
||||||
QCOMPARE( map.value( "LANG" ).toString(), QString( "en_US" ) );
|
QCOMPARE( map.value( "LANG" ).toString(), QString( "en_US" ) );
|
||||||
@ -498,7 +494,7 @@ LocaleTests::testGSUpdates()
|
|||||||
|
|
||||||
// Overwrite one
|
// Overwrite one
|
||||||
{
|
{
|
||||||
CalamaresUtils::Locale::insertGS( gs, "LANG", "nl_BE" );
|
Calamares::Locale::insertGS( gs, "LANG", "nl_BE" );
|
||||||
auto map = gs.value( gsKey ).toMap();
|
auto map = gs.value( gsKey ).toMap();
|
||||||
QCOMPARE( map.count(), 1 );
|
QCOMPARE( map.count(), 1 );
|
||||||
QCOMPARE( map.value( "LANG" ).toString(), QString( "nl_BE" ) );
|
QCOMPARE( map.value( "LANG" ).toString(), QString( "nl_BE" ) );
|
||||||
@ -506,7 +502,7 @@ LocaleTests::testGSUpdates()
|
|||||||
|
|
||||||
// Insert a second value
|
// Insert a second value
|
||||||
{
|
{
|
||||||
CalamaresUtils::Locale::insertGS( gs, "LC_TIME", "UTC" );
|
Calamares::Locale::insertGS( gs, "LC_TIME", "UTC" );
|
||||||
auto map = gs.value( gsKey ).toMap();
|
auto map = gs.value( gsKey ).toMap();
|
||||||
QCOMPARE( map.count(), 2 );
|
QCOMPARE( map.count(), 2 );
|
||||||
QCOMPARE( map.value( "LANG" ).toString(), QString( "nl_BE" ) );
|
QCOMPARE( map.value( "LANG" ).toString(), QString( "nl_BE" ) );
|
||||||
@ -520,7 +516,7 @@ LocaleTests::testGSUpdates()
|
|||||||
kv.insert( "LC_CURRENCY", "rbl" );
|
kv.insert( "LC_CURRENCY", "rbl" );
|
||||||
|
|
||||||
// Overwrite one, add one
|
// Overwrite one, add one
|
||||||
CalamaresUtils::Locale::insertGS( gs, kv, CalamaresUtils::Locale::InsertMode::Merge );
|
Calamares::Locale::insertGS( gs, kv, Calamares::Locale::InsertMode::Merge );
|
||||||
auto map = gs.value( gsKey ).toMap();
|
auto map = gs.value( gsKey ).toMap();
|
||||||
QCOMPARE( map.count(), 3 );
|
QCOMPARE( map.count(), 3 );
|
||||||
QCOMPARE( map.value( "LANG" ).toString(), QString( "en_SU" ) );
|
QCOMPARE( map.value( "LANG" ).toString(), QString( "en_SU" ) );
|
||||||
@ -535,7 +531,7 @@ LocaleTests::testGSUpdates()
|
|||||||
kv.insert( "LC_CURRENCY", "peso" );
|
kv.insert( "LC_CURRENCY", "peso" );
|
||||||
|
|
||||||
// Overwrite one, add one
|
// Overwrite one, add one
|
||||||
CalamaresUtils::Locale::insertGS( gs, kv, CalamaresUtils::Locale::InsertMode::Overwrite );
|
Calamares::Locale::insertGS( gs, kv, Calamares::Locale::InsertMode::Overwrite );
|
||||||
auto map = gs.value( gsKey ).toMap();
|
auto map = gs.value( gsKey ).toMap();
|
||||||
QCOMPARE( map.count(), 2 ); // the rest were cleared
|
QCOMPARE( map.count(), 2 ); // the rest were cleared
|
||||||
QCOMPARE( map.value( "LANG" ).toString(), QString( "en_US" ) );
|
QCOMPARE( map.value( "LANG" ).toString(), QString( "en_US" ) );
|
||||||
@ -545,7 +541,6 @@ LocaleTests::testGSUpdates()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN( LocaleTests )
|
QTEST_GUILESS_MAIN( LocaleTests )
|
||||||
|
|
||||||
#include "utils/moc-warnings.h"
|
#include "utils/moc-warnings.h"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
static const char TZ_DATA_FILE[] = "/usr/share/zoneinfo/zone.tab";
|
static const char TZ_DATA_FILE[] = "/usr/share/zoneinfo/zone.tab";
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
@ -61,7 +61,6 @@ getRightGeoLocation( QString str )
|
|||||||
return sign * num;
|
return sign * num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TimeZoneData::TimeZoneData( const QString& region,
|
TimeZoneData::TimeZoneData( const QString& region,
|
||||||
const QString& zone,
|
const QString& zone,
|
||||||
const QString& country,
|
const QString& country,
|
||||||
@ -83,7 +82,6 @@ TimeZoneData::tr() const
|
|||||||
return QObject::tr( m_human, "tz_names" );
|
return QObject::tr( m_human, "tz_names" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class RegionData : public TranslatableString
|
class RegionData : public TranslatableString
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -384,9 +382,8 @@ find( double startingDistance,
|
|||||||
const TimeZoneData*
|
const TimeZoneData*
|
||||||
ZonesModel::find( const std::function< double( const TimeZoneData* ) >& distanceFunc ) const
|
ZonesModel::find( const std::function< double( const TimeZoneData* ) >& distanceFunc ) const
|
||||||
{
|
{
|
||||||
const auto* officialZone = CalamaresUtils::Locale::find( 1000000.0, m_private->m_zones, distanceFunc );
|
const auto* officialZone = Calamares::Locale::find( 1000000.0, m_private->m_zones, distanceFunc );
|
||||||
const auto* altZone
|
const auto* altZone = Calamares::Locale::find( distanceFunc( officialZone ), m_private->m_altZones, distanceFunc );
|
||||||
= CalamaresUtils::Locale::find( distanceFunc( officialZone ), m_private->m_altZones, distanceFunc );
|
|
||||||
|
|
||||||
// If nothing was closer than the official zone already was, altZone is
|
// If nothing was closer than the official zone already was, altZone is
|
||||||
// nullptr; but if there is a spot-patch, then we need to re-find
|
// nullptr; but if there is a spot-patch, then we need to re-find
|
||||||
@ -444,7 +441,6 @@ ZonesModel::lookup( double latitude, double longitude ) const
|
|||||||
return const_cast< QObject* >( reinterpret_cast< const QObject* >( p ) );
|
return const_cast< QObject* >( reinterpret_cast< const QObject* >( p ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZonesModel::Iterator::operator bool() const
|
ZonesModel::Iterator::operator bool() const
|
||||||
{
|
{
|
||||||
return 0 <= m_index && m_index < m_p->m_zones.count();
|
return 0 <= m_index && m_index < m_p->m_zones.count();
|
||||||
@ -460,7 +456,7 @@ ZonesModel::Iterator::operator*() const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionalZonesModel::RegionalZonesModel( CalamaresUtils::Locale::ZonesModel* source, QObject* parent )
|
RegionalZonesModel::RegionalZonesModel( Calamares::Locale::ZonesModel* source, QObject* parent )
|
||||||
: QSortFilterProxyModel( parent )
|
: QSortFilterProxyModel( parent )
|
||||||
, m_private( privateInstance() )
|
, m_private( privateInstance() )
|
||||||
{
|
{
|
||||||
@ -497,9 +493,8 @@ RegionalZonesModel::filterAcceptsRow( int sourceRow, const QModelIndex& ) const
|
|||||||
return ( zone->m_region == m_region );
|
return ( zone->m_region == m_region );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
|
||||||
#include "utils/moc-warnings.h"
|
#include "utils/moc-warnings.h"
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
@ -76,7 +76,6 @@ private:
|
|||||||
double m_longitude;
|
double m_longitude;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** @brief The list of timezone regions
|
/** @brief The list of timezone regions
|
||||||
*
|
*
|
||||||
* The regions are a short list of global areas (Africa, America, India ..)
|
* The regions are a short list of global areas (Africa, America, India ..)
|
||||||
@ -229,8 +228,7 @@ private:
|
|||||||
QString m_region;
|
QString m_region;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
|
||||||
#endif // LOCALE_TIMEZONE_H
|
#endif // LOCALE_TIMEZONE_H
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QRegularExpressionMatch>
|
#include <QRegularExpressionMatch>
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
@ -114,6 +114,5 @@ TranslatedString::get( const QLocale& locale ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
@ -99,6 +99,6 @@ private:
|
|||||||
const char* m_context = nullptr;
|
const char* m_context = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "TranslatableString.h"
|
#include "TranslatableString.h"
|
||||||
|
|
||||||
|
|
||||||
/** @brief Massage an identifier into a human-readable form
|
/** @brief Massage an identifier into a human-readable form
|
||||||
*
|
*
|
||||||
* Makes a copy of @p s, caller must free() it.
|
* Makes a copy of @p s, caller must free() it.
|
||||||
@ -37,7 +36,7 @@ munge( const char* s )
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
@ -69,11 +68,10 @@ TranslatableString::TranslatableString( const QString& s )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TranslatableString::~TranslatableString()
|
TranslatableString::~TranslatableString()
|
||||||
{
|
{
|
||||||
free( m_human );
|
free( m_human );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
@ -53,6 +53,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace Calamares
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
struct TranslationSpecialCase
|
struct TranslationSpecialCase
|
||||||
{
|
{
|
||||||
const char* id; // The Calamares ID for the translation
|
const char* id; // The Calamares ID for the translation
|
||||||
@ -127,6 +130,7 @@ specialCaseSystemLanguage()
|
|||||||
{ return ( s.language == language ) && lookup_region( region, s.regions ); } );
|
{ return ( s.language == language ) && lookup_region( region, s.regions ); } );
|
||||||
return ( it != std::cend( special_cases ) ) ? QString::fromLatin1( it->id ) : QString();
|
return ( it != std::cend( special_cases ) ) ? QString::fromLatin1( it->id ) : QString();
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Translation( const Id& localeId, LabelFormat format = LabelFormat::IfNeededWithCountry, QObject* parent = nullptr );
|
Translation( const Id& localeId, LabelFormat format = LabelFormat::IfNeededWithCountry, QObject* parent = nullptr );
|
||||||
|
|
||||||
|
|
||||||
/** @brief Define a sorting order.
|
/** @brief Define a sorting order.
|
||||||
*
|
*
|
||||||
* Locales are sorted by their id, which means the ISO 2-letter code + country.
|
* Locales are sorted by their id, which means the ISO 2-letter code + country.
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
|
@ -629,7 +629,7 @@ Config::guessLocaleKeyboardLayout()
|
|||||||
|
|
||||||
// Try to preselect a layout, depending on language and locale
|
// Try to preselect a layout, depending on language and locale
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
QString lang = CalamaresUtils::Locale::readGS( *gs, QStringLiteral( "LANG" ) );
|
QString lang = Calamares::Locale::readGS( *gs, QStringLiteral( "LANG" ) );
|
||||||
|
|
||||||
cDebug() << "Got locale language" << lang;
|
cDebug() << "Got locale language" << lang;
|
||||||
if ( !lang.isEmpty() )
|
if ( !lang.isEmpty() )
|
||||||
|
@ -147,7 +147,7 @@ loadLocales( const QString& localeGenPath )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
updateGSLocation( Calamares::GlobalStorage* gs, const CalamaresUtils::Locale::TimeZoneData* location )
|
updateGSLocation( Calamares::GlobalStorage* gs, const Calamares::Locale::TimeZoneData* location )
|
||||||
{
|
{
|
||||||
const QString regionKey = QStringLiteral( "locationRegion" );
|
const QString regionKey = QStringLiteral( "locationRegion" );
|
||||||
const QString zoneKey = QStringLiteral( "locationZone" );
|
const QString zoneKey = QStringLiteral( "locationZone" );
|
||||||
@ -176,14 +176,14 @@ updateGSLocation( Calamares::GlobalStorage* gs, const CalamaresUtils::Locale::Ti
|
|||||||
static void
|
static void
|
||||||
updateGSLocale( Calamares::GlobalStorage* gs, const LocaleConfiguration& locale )
|
updateGSLocale( Calamares::GlobalStorage* gs, const LocaleConfiguration& locale )
|
||||||
{
|
{
|
||||||
CalamaresUtils::Locale::insertGS( *gs, locale.toMap(), CalamaresUtils::Locale::InsertMode::Overwrite );
|
Calamares::Locale::insertGS( *gs, locale.toMap(), Calamares::Locale::InsertMode::Overwrite );
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::Config( QObject* parent )
|
Config::Config( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_regionModel( std::make_unique< CalamaresUtils::Locale::RegionsModel >() )
|
, m_regionModel( std::make_unique< Calamares::Locale::RegionsModel >() )
|
||||||
, m_zonesModel( std::make_unique< CalamaresUtils::Locale::ZonesModel >() )
|
, m_zonesModel( std::make_unique< Calamares::Locale::ZonesModel >() )
|
||||||
, m_regionalZonesModel( std::make_unique< CalamaresUtils::Locale::RegionalZonesModel >( m_zonesModel.get() ) )
|
, m_regionalZonesModel( std::make_unique< Calamares::Locale::RegionalZonesModel >( m_zonesModel.get() ) )
|
||||||
{
|
{
|
||||||
// Slightly unusual: connect to our *own* signals. Wherever the language
|
// Slightly unusual: connect to our *own* signals. Wherever the language
|
||||||
// or the location is changed, these signals are emitted, so hook up to
|
// or the location is changed, these signals are emitted, so hook up to
|
||||||
@ -255,7 +255,7 @@ Config::setCurrentLocation( const QString& regionzone )
|
|||||||
void
|
void
|
||||||
Config::setCurrentLocation( const QString& regionName, const QString& zoneName )
|
Config::setCurrentLocation( const QString& regionName, const QString& zoneName )
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
auto* zone = m_zonesModel->find( regionName, zoneName );
|
auto* zone = m_zonesModel->find( regionName, zoneName );
|
||||||
if ( zone )
|
if ( zone )
|
||||||
{
|
{
|
||||||
@ -269,7 +269,7 @@ Config::setCurrentLocation( const QString& regionName, const QString& zoneName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setCurrentLocation( const CalamaresUtils::Locale::TimeZoneData* location )
|
Config::setCurrentLocation( const Calamares::Locale::TimeZoneData* location )
|
||||||
{
|
{
|
||||||
const bool updateLocation = ( location != m_currentLocation );
|
const bool updateLocation = ( location != m_currentLocation );
|
||||||
if ( updateLocation )
|
if ( updateLocation )
|
||||||
@ -315,7 +315,7 @@ Config::automaticLocaleConfiguration() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto* gs = Calamares::JobQueue::instance()->globalStorage();
|
auto* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
QString lang = CalamaresUtils::Locale::readGS( *gs, QStringLiteral( "LANG" ) );
|
QString lang = Calamares::Locale::readGS( *gs, QStringLiteral( "LANG" ) );
|
||||||
if ( lang.isEmpty() )
|
if ( lang.isEmpty() )
|
||||||
{
|
{
|
||||||
lang = QLocale().name();
|
lang = QLocale().name();
|
||||||
|
@ -26,12 +26,12 @@ class Config : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( const QStringList& supportedLocales READ supportedLocales CONSTANT FINAL )
|
Q_PROPERTY( const QStringList& supportedLocales READ supportedLocales CONSTANT FINAL )
|
||||||
Q_PROPERTY( CalamaresUtils::Locale::RegionsModel* regionModel READ regionModel CONSTANT FINAL )
|
Q_PROPERTY( Calamares::Locale::RegionsModel* regionModel READ regionModel CONSTANT FINAL )
|
||||||
Q_PROPERTY( CalamaresUtils::Locale::ZonesModel* zonesModel READ zonesModel CONSTANT FINAL )
|
Q_PROPERTY( Calamares::Locale::ZonesModel* zonesModel READ zonesModel CONSTANT FINAL )
|
||||||
Q_PROPERTY( QAbstractItemModel* regionalZonesModel READ regionalZonesModel CONSTANT FINAL )
|
Q_PROPERTY( QAbstractItemModel* regionalZonesModel READ regionalZonesModel CONSTANT FINAL )
|
||||||
|
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
CalamaresUtils::Locale::TimeZoneData* currentLocation READ currentLocation_c NOTIFY currentLocationChanged )
|
Calamares::Locale::TimeZoneData* currentLocation READ currentLocation_c NOTIFY currentLocationChanged )
|
||||||
|
|
||||||
// Status are complete, human-readable, messages
|
// Status are complete, human-readable, messages
|
||||||
Q_PROPERTY( QString currentLocationStatus READ currentLocationStatus NOTIFY currentLanguageStatusChanged )
|
Q_PROPERTY( QString currentLocationStatus READ currentLocationStatus NOTIFY currentLanguageStatusChanged )
|
||||||
@ -76,22 +76,22 @@ public:
|
|||||||
// A long list of locale codes (e.g. en_US.UTF-8)
|
// A long list of locale codes (e.g. en_US.UTF-8)
|
||||||
const QStringList& supportedLocales() const { return m_localeGenLines; }
|
const QStringList& supportedLocales() const { return m_localeGenLines; }
|
||||||
// All the regions (Africa, America, ...)
|
// All the regions (Africa, America, ...)
|
||||||
CalamaresUtils::Locale::RegionsModel* regionModel() const { return m_regionModel.get(); }
|
Calamares::Locale::RegionsModel* regionModel() const { return m_regionModel.get(); }
|
||||||
// All of the timezones in the world, according to zone.tab
|
// All of the timezones in the world, according to zone.tab
|
||||||
CalamaresUtils::Locale::ZonesModel* zonesModel() const { return m_zonesModel.get(); }
|
Calamares::Locale::ZonesModel* zonesModel() const { return m_zonesModel.get(); }
|
||||||
// This model can be filtered by region
|
// This model can be filtered by region
|
||||||
CalamaresUtils::Locale::RegionalZonesModel* regionalZonesModel() const { return m_regionalZonesModel.get(); }
|
Calamares::Locale::RegionalZonesModel* regionalZonesModel() const { return m_regionalZonesModel.get(); }
|
||||||
|
|
||||||
const CalamaresUtils::Locale::TimeZoneData* currentLocation() const { return m_currentLocation; }
|
const Calamares::Locale::TimeZoneData* currentLocation() const { return m_currentLocation; }
|
||||||
|
|
||||||
|
|
||||||
/// Special case, set location from starting timezone if not already set
|
/// Special case, set location from starting timezone if not already set
|
||||||
void setCurrentLocation();
|
void setCurrentLocation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CalamaresUtils::Locale::TimeZoneData* currentLocation_c() const
|
Calamares::Locale::TimeZoneData* currentLocation_c() const
|
||||||
{
|
{
|
||||||
return const_cast< CalamaresUtils::Locale::TimeZoneData* >( m_currentLocation );
|
return const_cast< Calamares::Locale::TimeZoneData* >( m_currentLocation );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
@ -119,7 +119,7 @@ public Q_SLOTS:
|
|||||||
/** @brief Sets a location by pointer to zone data.
|
/** @brief Sets a location by pointer to zone data.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void setCurrentLocation( const CalamaresUtils::Locale::TimeZoneData* tz );
|
void setCurrentLocation( const Calamares::Locale::TimeZoneData* tz );
|
||||||
|
|
||||||
QString currentLanguageCode() const { return localeConfiguration().language(); }
|
QString currentLanguageCode() const { return localeConfiguration().language(); }
|
||||||
QString currentLCCode() const { return localeConfiguration().lc_numeric; }
|
QString currentLCCode() const { return localeConfiguration().lc_numeric; }
|
||||||
@ -127,7 +127,7 @@ public Q_SLOTS:
|
|||||||
QString currentTimezoneCode() const;
|
QString currentTimezoneCode() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentLocationChanged( const CalamaresUtils::Locale::TimeZoneData* location ) const;
|
void currentLocationChanged( const Calamares::Locale::TimeZoneData* location ) const;
|
||||||
void currentLocationStatusChanged( const QString& ) const;
|
void currentLocationStatusChanged( const QString& ) const;
|
||||||
void currentLanguageStatusChanged( const QString& ) const;
|
void currentLanguageStatusChanged( const QString& ) const;
|
||||||
void currentLCStatusChanged( const QString& ) const;
|
void currentLCStatusChanged( const QString& ) const;
|
||||||
@ -142,11 +142,11 @@ private:
|
|||||||
QStringList m_localeGenLines;
|
QStringList m_localeGenLines;
|
||||||
|
|
||||||
/// The regions (America, Asia, Europe ..)
|
/// The regions (America, Asia, Europe ..)
|
||||||
std::unique_ptr< CalamaresUtils::Locale::RegionsModel > m_regionModel;
|
std::unique_ptr< Calamares::Locale::RegionsModel > m_regionModel;
|
||||||
std::unique_ptr< CalamaresUtils::Locale::ZonesModel > m_zonesModel;
|
std::unique_ptr< Calamares::Locale::ZonesModel > m_zonesModel;
|
||||||
std::unique_ptr< CalamaresUtils::Locale::RegionalZonesModel > m_regionalZonesModel;
|
std::unique_ptr< Calamares::Locale::RegionalZonesModel > m_regionalZonesModel;
|
||||||
|
|
||||||
const CalamaresUtils::Locale::TimeZoneData* m_currentLocation = nullptr;
|
const Calamares::Locale::TimeZoneData* m_currentLocation = nullptr;
|
||||||
|
|
||||||
/** @brief Specific locale configurations
|
/** @brief Specific locale configurations
|
||||||
*
|
*
|
||||||
|
@ -109,7 +109,7 @@ LocalePage::LocalePage( Config* config, QWidget* parent )
|
|||||||
connect( m_tzWidget,
|
connect( m_tzWidget,
|
||||||
&TimeZoneWidget::locationChanged,
|
&TimeZoneWidget::locationChanged,
|
||||||
config,
|
config,
|
||||||
QOverload< const CalamaresUtils::Locale::TimeZoneData* >::of( &Config::setCurrentLocation ) );
|
QOverload< const Calamares::Locale::TimeZoneData* >::of( &Config::setCurrentLocation ) );
|
||||||
|
|
||||||
connect( m_regionCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::regionChanged );
|
connect( m_regionCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::regionChanged );
|
||||||
connect( m_zoneCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::zoneChanged );
|
connect( m_zoneCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::zoneChanged );
|
||||||
@ -147,7 +147,7 @@ LocalePage::onActivate()
|
|||||||
void
|
void
|
||||||
LocalePage::regionChanged( int currentIndex )
|
LocalePage::regionChanged( int currentIndex )
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
|
|
||||||
QString selectedRegion = m_regionCombo->itemData( currentIndex ).toString();
|
QString selectedRegion = m_regionCombo->itemData( currentIndex ).toString();
|
||||||
{
|
{
|
||||||
@ -168,7 +168,7 @@ LocalePage::zoneChanged( int currentIndex )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalePage::locationChanged( const CalamaresUtils::Locale::TimeZoneData* location )
|
LocalePage::locationChanged( const Calamares::Locale::TimeZoneData* location )
|
||||||
{
|
{
|
||||||
if ( !location )
|
if ( !location )
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ private:
|
|||||||
|
|
||||||
void regionChanged( int currentIndex );
|
void regionChanged( int currentIndex );
|
||||||
void zoneChanged( int currentIndex );
|
void zoneChanged( int currentIndex );
|
||||||
void locationChanged( const CalamaresUtils::Locale::TimeZoneData* location );
|
void locationChanged( const Calamares::Locale::TimeZoneData* location );
|
||||||
void changeLocale();
|
void changeLocale();
|
||||||
void changeFormats();
|
void changeFormats();
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ LocaleTests::testTZSanity()
|
|||||||
QVERIFY( QFile( "/usr/share/zoneinfo/zone.tab" ).exists() );
|
QVERIFY( QFile( "/usr/share/zoneinfo/zone.tab" ).exists() );
|
||||||
|
|
||||||
// Contains a sensible number of total zones
|
// Contains a sensible number of total zones
|
||||||
const CalamaresUtils::Locale::ZonesModel zones;
|
const Calamares::Locale::ZonesModel zones;
|
||||||
QVERIFY( zones.rowCount( QModelIndex() ) > 100 );
|
QVERIFY( zones.rowCount( QModelIndex() ) > 100 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ LocaleTests::testTZImages()
|
|||||||
// Check zones are uniquely-claimed
|
// Check zones are uniquely-claimed
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
const ZonesModel m;
|
const ZonesModel m;
|
||||||
|
|
||||||
int overlapcount = 0;
|
int overlapcount = 0;
|
||||||
@ -223,9 +223,9 @@ operator<( const QPoint& l, const QPoint& r )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
listAll( const QPoint& p, const CalamaresUtils::Locale::ZonesModel& zones )
|
listAll( const QPoint& p, const Calamares::Locale::ZonesModel& zones )
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
for ( auto it = zones.begin(); it; ++it )
|
for ( auto it = zones.begin(); it; ++it )
|
||||||
{
|
{
|
||||||
const auto* zone = *it;
|
const auto* zone = *it;
|
||||||
@ -244,7 +244,7 @@ listAll( const QPoint& p, const CalamaresUtils::Locale::ZonesModel& zones )
|
|||||||
void
|
void
|
||||||
LocaleTests::testTZLocations()
|
LocaleTests::testTZLocations()
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace Calamares::Locale;
|
||||||
ZonesModel zones;
|
ZonesModel zones;
|
||||||
|
|
||||||
QVERIFY( zones.rowCount( QModelIndex() ) > 100 );
|
QVERIFY( zones.rowCount( QModelIndex() ) > 100 );
|
||||||
@ -273,7 +273,7 @@ LocaleTests::testTZLocations()
|
|||||||
void
|
void
|
||||||
LocaleTests::testSpecificLocations()
|
LocaleTests::testSpecificLocations()
|
||||||
{
|
{
|
||||||
CalamaresUtils::Locale::ZonesModel zones;
|
Calamares::Locale::ZonesModel zones;
|
||||||
const auto* gibraltar = zones.find( "Europe", "Gibraltar" );
|
const auto* gibraltar = zones.find( "Europe", "Gibraltar" );
|
||||||
const auto* ceuta = zones.find( "Africa", "Ceuta" );
|
const auto* ceuta = zones.find( "Africa", "Ceuta" );
|
||||||
QVERIFY( gibraltar );
|
QVERIFY( gibraltar );
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QPoint
|
static QPoint
|
||||||
getLocationPosition( const CalamaresUtils::Locale::TimeZoneData* l )
|
getLocationPosition( const Calamares::Locale::TimeZoneData* l )
|
||||||
{
|
{
|
||||||
return TimeZoneImageList::getLocationPosition( l->longitude(), l->latitude() );
|
return TimeZoneImageList::getLocationPosition( l->longitude(), l->latitude() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TimeZoneWidget::TimeZoneWidget( const CalamaresUtils::Locale::ZonesModel* zones, QWidget* parent )
|
TimeZoneWidget::TimeZoneWidget( const Calamares::Locale::ZonesModel* zones, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, timeZoneImages( TimeZoneImageList::fromQRC() )
|
, timeZoneImages( TimeZoneImageList::fromQRC() )
|
||||||
, m_zonesData( zones )
|
, m_zonesData( zones )
|
||||||
@ -185,7 +185,7 @@ TimeZoneWidget::mousePressEvent( QMouseEvent* event )
|
|||||||
|
|
||||||
int mX = event->pos().x();
|
int mX = event->pos().x();
|
||||||
int mY = event->pos().y();
|
int mY = event->pos().y();
|
||||||
auto distance = [ & ]( const CalamaresUtils::Locale::TimeZoneData* zone )
|
auto distance = [ & ]( const Calamares::Locale::TimeZoneData* zone )
|
||||||
{
|
{
|
||||||
QPoint locPos = TimeZoneImageList::getLocationPosition( zone->longitude(), zone->latitude() );
|
QPoint locPos = TimeZoneImageList::getLocationPosition( zone->longitude(), zone->latitude() );
|
||||||
return double( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) );
|
return double( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) );
|
||||||
|
@ -43,9 +43,9 @@ class TimeZoneWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
using TimeZoneData = CalamaresUtils::Locale::TimeZoneData;
|
using TimeZoneData = Calamares::Locale::TimeZoneData;
|
||||||
|
|
||||||
explicit TimeZoneWidget( const CalamaresUtils::Locale::ZonesModel* zones, QWidget* parent = nullptr );
|
explicit TimeZoneWidget( const Calamares::Locale::ZonesModel* zones, QWidget* parent = nullptr );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/** @brief Sets a location by pointer
|
/** @brief Sets a location by pointer
|
||||||
@ -63,7 +63,7 @@ private:
|
|||||||
QImage background, pin, currentZoneImage;
|
QImage background, pin, currentZoneImage;
|
||||||
TimeZoneImageList timeZoneImages;
|
TimeZoneImageList timeZoneImages;
|
||||||
|
|
||||||
const CalamaresUtils::Locale::ZonesModel* m_zonesData;
|
const Calamares::Locale::ZonesModel* m_zonesData;
|
||||||
const TimeZoneData* m_currentLocation = nullptr; // Not owned by me
|
const TimeZoneData* m_currentLocation = nullptr; // Not owned by me
|
||||||
|
|
||||||
void paintEvent( QPaintEvent* event ) override;
|
void paintEvent( QPaintEvent* event ) override;
|
||||||
|
@ -127,11 +127,11 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
|
|
||||||
if ( label.contains( "sidebar" ) )
|
if ( label.contains( "sidebar" ) )
|
||||||
{
|
{
|
||||||
m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar", className );
|
m_sidebarLabel = new Calamares::Locale::TranslatedString( label, "sidebar", className );
|
||||||
}
|
}
|
||||||
if ( label.contains( "title" ) )
|
if ( label.contains( "title" ) )
|
||||||
{
|
{
|
||||||
m_titleLabel = new CalamaresUtils::Locale::TranslatedString( label, "title", className );
|
m_titleLabel = new Calamares::Locale::TranslatedString( label, "title", className );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lastly, load the groups data
|
// Lastly, load the groups data
|
||||||
|
@ -90,8 +90,8 @@ private Q_SLOTS:
|
|||||||
void loadingDone();
|
void loadingDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CalamaresUtils::Locale::TranslatedString* m_sidebarLabel = nullptr; // As it appears in the sidebar
|
Calamares::Locale::TranslatedString* m_sidebarLabel = nullptr; // As it appears in the sidebar
|
||||||
CalamaresUtils::Locale::TranslatedString* m_titleLabel = nullptr;
|
Calamares::Locale::TranslatedString* m_titleLabel = nullptr;
|
||||||
PackageModel* m_model = nullptr;
|
PackageModel* m_model = nullptr;
|
||||||
LoaderQueue* m_queue = nullptr;
|
LoaderQueue* m_queue = nullptr;
|
||||||
Status m_status = Status::Ok;
|
Status m_status = Status::Ok;
|
||||||
|
@ -31,7 +31,7 @@ NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
|
|
||||||
if ( qmlLabel.contains( "notes" ) )
|
if ( qmlLabel.contains( "notes" ) )
|
||||||
{
|
{
|
||||||
m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" );
|
m_notesName = new Calamares::Locale::TranslatedString( qmlLabel, "notes" );
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last
|
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CalamaresUtils::Locale::TranslatedString* m_notesName; // As it appears in the sidebar
|
Calamares::Locale::TranslatedString* m_notesName; // As it appears in the sidebar
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( NotesQmlViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( NotesQmlViewStepFactory )
|
||||||
|
@ -114,9 +114,9 @@ Config::introductionPackage() const
|
|||||||
= QT_TR_NOOP( "Please pick a product from the list. The selected product will be installed." );
|
= QT_TR_NOOP( "Please pick a product from the list. The selected product will be installed." );
|
||||||
defaultIntroduction = new PackageItem( QString(), name, description );
|
defaultIntroduction = new PackageItem( QString(), name, description );
|
||||||
defaultIntroduction->screenshot = QPixmap( QStringLiteral( ":/images/no-selection.png" ) );
|
defaultIntroduction->screenshot = QPixmap( QStringLiteral( ":/images/no-selection.png" ) );
|
||||||
defaultIntroduction->name = CalamaresUtils::Locale::TranslatedString( name, metaObject()->className() );
|
defaultIntroduction->name = Calamares::Locale::TranslatedString( name, metaObject()->className() );
|
||||||
defaultIntroduction->description
|
defaultIntroduction->description
|
||||||
= CalamaresUtils::Locale::TranslatedString( description, metaObject()->className() );
|
= Calamares::Locale::TranslatedString( description, metaObject()->className() );
|
||||||
}
|
}
|
||||||
return *defaultIntroduction;
|
return *defaultIntroduction;
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
{
|
{
|
||||||
if ( labels.contains( "step" ) )
|
if ( labels.contains( "step" ) )
|
||||||
{
|
{
|
||||||
m_stepName = new CalamaresUtils::Locale::TranslatedString( labels, "step" );
|
m_stepName = new Calamares::Locale::TranslatedString( labels, "step" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ private:
|
|||||||
* Reading the property will return an empty QString.
|
* Reading the property will return an empty QString.
|
||||||
*/
|
*/
|
||||||
std::optional< QString > m_packageChoice;
|
std::optional< QString > m_packageChoice;
|
||||||
CalamaresUtils::Locale::TranslatedString* m_stepName; // As it appears in the sidebar
|
Calamares::Locale::TranslatedString* m_stepName; // As it appears in the sidebar
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ PackageItem::PackageItem( const QString& a_id,
|
|||||||
|
|
||||||
PackageItem::PackageItem( const QVariantMap& item_map )
|
PackageItem::PackageItem( const QVariantMap& item_map )
|
||||||
: id( CalamaresUtils::getString( item_map, "id" ) )
|
: id( CalamaresUtils::getString( item_map, "id" ) )
|
||||||
, name( CalamaresUtils::Locale::TranslatedString( item_map, "name" ) )
|
, name( Calamares::Locale::TranslatedString( item_map, "name" ) )
|
||||||
, description( CalamaresUtils::Locale::TranslatedString( item_map, "description" ) )
|
, description( Calamares::Locale::TranslatedString( item_map, "description" ) )
|
||||||
, screenshot( loadScreenshot( CalamaresUtils::getString( item_map, "screenshot" ) ) )
|
, screenshot( loadScreenshot( CalamaresUtils::getString( item_map, "screenshot" ) ) )
|
||||||
, packageNames( CalamaresUtils::getStringList( item_map, "packages" ) )
|
, packageNames( CalamaresUtils::getStringList( item_map, "packages" ) )
|
||||||
, netinstallData( getSubMap( item_map, "netinstall" ) )
|
, netinstallData( getSubMap( item_map, "netinstall" ) )
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
struct PackageItem
|
struct PackageItem
|
||||||
{
|
{
|
||||||
QString id;
|
QString id;
|
||||||
CalamaresUtils::Locale::TranslatedString name;
|
Calamares::Locale::TranslatedString name;
|
||||||
CalamaresUtils::Locale::TranslatedString description;
|
Calamares::Locale::TranslatedString description;
|
||||||
QPixmap screenshot;
|
QPixmap screenshot;
|
||||||
QStringList packageNames;
|
QStringList packageNames;
|
||||||
QVariantMap netinstallData;
|
QVariantMap netinstallData;
|
||||||
|
@ -85,7 +85,7 @@ ShellProcessJob::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
{
|
{
|
||||||
if ( labels.contains( "name" ) )
|
if ( labels.contains( "name" ) )
|
||||||
{
|
{
|
||||||
m_name = std::make_unique< CalamaresUtils::Locale::TranslatedString >( labels, "name" );
|
m_name = std::make_unique< Calamares::Locale::TranslatedString >( labels, "name" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr< CalamaresUtils::CommandList > m_commands;
|
std::unique_ptr< CalamaresUtils::CommandList > m_commands;
|
||||||
std::unique_ptr< CalamaresUtils::Locale::TranslatedString > m_name;
|
std::unique_ptr< Calamares::Locale::TranslatedString > m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( ShellProcessJobFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( ShellProcessJobFactory )
|
||||||
|
@ -204,7 +204,7 @@ Config::setLocaleIndex( int index )
|
|||||||
branding ? branding->translationsDirectory() : QString() );
|
branding ? branding->translationsDirectory() : QString() );
|
||||||
if ( Calamares::JobQueue::instance() && Calamares::JobQueue::instance()->globalStorage() )
|
if ( Calamares::JobQueue::instance() && Calamares::JobQueue::instance()->globalStorage() )
|
||||||
{
|
{
|
||||||
CalamaresUtils::Locale::insertGS( *Calamares::JobQueue::instance()->globalStorage(),
|
Calamares::Locale::insertGS( *Calamares::JobQueue::instance()->globalStorage(),
|
||||||
QStringLiteral( "LANG" ),
|
QStringLiteral( "LANG" ),
|
||||||
CalamaresUtils::translatorLocaleName().name );
|
CalamaresUtils::translatorLocaleName().name );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user