Initial upload of HyprArch releng configuration

This commit is contained in:
2026-03-03 20:31:33 +00:00
commit 7df61351c0
634 changed files with 36355 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
/** @file GlobalStorage management for Locale settings
*
* The *localeConf* key in Global Storage is semi-structured,
* and there are multiple modules that write to it (and some that
* read from it). Functions in this file provide access to
* that semi-structured data.
*/
#ifndef LOCALE_GLOBAL_H
#define LOCALE_GLOBAL_H
#include "DllMacro.h"
#include <QMap>
#include <QString>
#include <QVariantMap>
namespace Calamares
{
class GlobalStorage;
namespace Locale
{
/** @brief Selector for methods that insert multiple values.
*
* When inserting, use @c Overwrite to remove all keys not in the collection
* of values being inserted; use @c Merge to preserve whatever is
* already in Global Storage but not mentioned in the collection.
*/
enum class InsertMode
{
Overwrite,
Merge
};
/** @brief Insert the given @p values into the *localeConf* map in @p gs
*
* @param gs The Global Storage to write to
* @param values The collection of keys and values to write to @p gs
* @param mode Indicates whether the *localeConf* key is cleared first
*
* The keys in the collection @p values should be first-level keys
* in *localeConf*, e.g. "LANG" or "LC_TIME". No effort is made to
* enforce this.
*/
DLLEXPORT void insertGS( Calamares::GlobalStorage& gs, const QVariantMap& values, InsertMode mode = InsertMode::Merge );
/** @brief Insert the given @p values into the *localeConf* map in @p gs
*
* Alternate way of providing the keys and values.
*/
DLLEXPORT void
insertGS( Calamares::GlobalStorage& gs, const QMap< QString, QString >& values, InsertMode mode = InsertMode::Merge );
/** @brief Write a single @p key and @p value to the *localeConf* map
*/
DLLEXPORT void insertGS( Calamares::GlobalStorage& gs, const QString& key, const QString& value );
/** @brief Remove a single @p key from the *localeConf* map
*/
DLLEXPORT void removeGS( Calamares::GlobalStorage& gs, const QString& key );
/** @brief Remove the *localeConf* map from Global Storage
*/
DLLEXPORT void clearGS( Calamares::GlobalStorage& gs );
/** @brief Gets a value from the *localeConf* map in @p gs
*
* If the key is not set (or doesn't exist), returns QString().
*/
DLLEXPORT QString readGS( Calamares::GlobalStorage& gs, const QString& key );
} // namespace Locale
} // namespace Calamares
#endif

View File

@@ -0,0 +1,47 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
#ifndef LOCALE_LOOKUP_H
#define LOCALE_LOOKUP_H
#include "DllMacro.h"
#include <QLocale>
#include <QPair>
namespace Calamares
{
namespace Locale
{
/* All the functions in this file do lookups of locale data
* based on CLDR tables; these are lookups that you can't (easily)
* do with just QLocale (e.g. from 2-letter country code to a likely
* locale).
*/
/// @brief Map a 2-letter code to a Country, or AnyCountry if not found
DLLEXPORT QLocale::Country countryForCode( const QString& code );
/** @brief Map a Country to a Language, or AnyLanguage if not found
*
* This is a *likely* language for the given country, based on the
* CLDR tables. For instance, this maps Belgium to Dutch.
*/
DLLEXPORT QLocale::Language languageForCountry( QLocale::Country country );
/// @brief Map a 2-letter code to a Language, or AnyLanguage if not found
DLLEXPORT QLocale::Language languageForCountry( const QString& code );
/// @brief Get both Country and Language for a 2-letter code
DLLEXPORT QPair< QLocale::Country, QLocale::Language > countryData( const QString& code );
/// @brief Get a likely locale for a 2-letter country code
DLLEXPORT QLocale countryLocale( const QString& code );
} // namespace Locale
} // namespace Calamares
#endif

View File

@@ -0,0 +1,237 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
/** @file Timezone data and models to go with it
*
* The TimeZoneData class holds information from zone.tab, about
* TZ names and locations (latitude and longitude) for geographic
* lookups.
*
* The RegionModel lists the regions of the world (about 12) and
* ZonesModel lists all the timezones; the RegionalZonesModel provides
* a way to restrict the view of timezones to those of a specific region.
*
*/
#ifndef LOCALE_TIMEZONE_H
#define LOCALE_TIMEZONE_H
#include "DllMacro.h"
#include "locale/TranslatableString.h"
#include <QAbstractListModel>
#include <QObject>
#include <QSortFilterProxyModel>
#include <QVariant>
namespace Calamares
{
namespace Locale
{
class Private;
class RegionalZonesModel;
class ZonesModel;
class DLLEXPORT TimeZoneData : public QObject, TranslatableString
{
friend class RegionalZonesModel;
friend class ZonesModel;
Q_OBJECT
Q_PROPERTY( QString region READ region CONSTANT )
Q_PROPERTY( QString zone READ zone CONSTANT )
Q_PROPERTY( QString name READ translated CONSTANT )
Q_PROPERTY( QString countryCode READ country CONSTANT )
public:
TimeZoneData( const QString& region,
const QString& zone,
const QString& country,
double latitude,
double longitude );
TimeZoneData( const TimeZoneData& ) = delete;
TimeZoneData( TimeZoneData&& ) = delete;
///@brief Returns a translated, human-readable form of region/zone (e.g. "America/New York")
QString translated() const override;
///@brief Returns the region key (e.g. "Europe") with no translation and no human-readable tweaks
QString region() const { return m_region; }
///@brief Returns the zone key (e.g. "New_York") with no translation and no human-readable tweaks
QString zone() const { return key(); }
QString country() const { return m_country; }
double latitude() const { return m_latitude; }
double longitude() const { return m_longitude; }
private:
QString m_region;
QString m_country;
double m_latitude;
double m_longitude;
};
/** @brief The list of timezone regions
*
* The regions are a short list of global areas (Africa, America, India ..)
* which contain zones.
*/
class DLLEXPORT RegionsModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles
{
NameRole = Qt::DisplayRole,
KeyRole = Qt::UserRole // So that currentData() will get the key
};
RegionsModel( QObject* parent = nullptr );
~RegionsModel() override;
int rowCount( const QModelIndex& parent ) const override;
QVariant data( const QModelIndex& index, int role ) const override;
QHash< int, QByteArray > roleNames() const override;
public Q_SLOTS:
/** @brief Provides a human-readable version of the region
*
* Returns @p region unchanged if there is no such region
* or no translation for the region's name.
*/
QString translated( const QString& region ) const;
private:
Private* m_private;
};
class DLLEXPORT ZonesModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Roles
{
NameRole = Qt::DisplayRole,
KeyRole = Qt::UserRole, // So that currentData() will get the key
RegionRole = Qt::UserRole + 1
};
ZonesModel( QObject* parent = nullptr );
~ZonesModel() override;
int rowCount( const QModelIndex& parent ) const override;
QVariant data( const QModelIndex& index, int role ) const override;
QHash< int, QByteArray > roleNames() const override;
/** @brief Iterator for the underlying list of zones
*
* Iterates over all the zones in the model. Operator * may return
* a @c nullptr when the iterator is not valid. Typical usage:
*
* ```
* for( auto it = model.begin(); it; ++it )
* {
* const auto* zonedata = *it;
* ...
* }
*/
class Iterator
{
friend class ZonesModel;
Iterator( const Private* m )
: m_index( 0 )
, m_p( m )
{
}
public:
operator bool() const;
void operator++() { ++m_index; }
const TimeZoneData* operator*() const;
int index() const { return m_index; }
private:
int m_index;
const Private* m_p;
};
Iterator begin() const { return Iterator( m_private ); }
/** @brief Look up TZ data based on an arbitrary distance function
*
* This is a generic method that can define distance in whatever
* coordinate system is wanted; returns the zone with the smallest
* distance. The @p distanceFunc must return "the distance" for
* each zone. It would be polite to return something non-negative.
*
* Note: not a slot, because the parameter isn't moc-able.
*/
const TimeZoneData* find( const std::function< double( const TimeZoneData* ) >& distanceFunc ) const;
public Q_SLOTS:
/** @brief Look up TZ data based on its name.
*
* Returns @c nullptr if not found.
*/
const TimeZoneData* find( const QString& region, const QString& zone ) const;
/** @brief Look up TZ data based on the location.
*
* Returns the nearest zone to the given lat and lon. This is a
* convenience function for calling find(), below, with a standard
* distance function based on the distance between the given
* location (lat and lon) and each zone's given location.
*/
const TimeZoneData* find( double latitude, double longitude ) const;
/** @brief Look up TZ data based on the location.
*
* Returns the nearest zone, or New York. This is non-const for QML
* purposes, but the object should be considered const anyway.
*/
QObject* lookup( double latitude, double longitude ) const;
private:
Private* m_private;
};
class DLLEXPORT RegionalZonesModel : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY( QString region READ region WRITE setRegion NOTIFY regionChanged )
public:
RegionalZonesModel( ZonesModel* source, QObject* parent = nullptr );
~RegionalZonesModel() override;
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const override;
QString region() const { return m_region; }
public Q_SLOTS:
void setRegion( const QString& r );
signals:
void regionChanged( const QString& );
private:
Private* m_private;
QString m_region;
};
} // namespace Locale
} // namespace Calamares
#endif // LOCALE_TIMEZONE_H

View File

@@ -0,0 +1,104 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
/** @file Run-time translation of strings from configuration files
*
* The TranslatedString class provides a way of doing run-time
* lookups of human-readable strings, from data provided in
* the configuration files (*.conf) for Calamares. This acts
* like "normal" translation through tr() calls, as far as the
* user-visible part goes.
*/
#ifndef LOCALE_TRANSLATABLECONFIGURATION_H
#define LOCALE_TRANSLATABLECONFIGURATION_H
#include "DllMacro.h"
#include <QLocale>
#include <QMap>
#include <QVariant>
namespace Calamares
{
namespace Locale
{
/** @brief A human-readable string from a configuration file
*
* The configuration files can contain human-readable strings,
* but those need their own translations and are not supported
* by QObject::tr or anything else.
*/
class DLLEXPORT TranslatedString
{
public:
/** @brief Get all the translations connected to @p key
*
* Gets map[key] as the "untranslated" form, and then all the
* keys of the form <key>[lang] are taken as the translation
* for <lang> of the untranslated form.
*
* If @p context is not a nullptr, then that is taken as an
* indication to **also** use the regular QObject::tr() translation
* mechanism for these strings. It is recommended to pass in
* metaObject()->className() as context (from a QObject based class)
* to give the TranslatedString the same context as other calls
* to tr() within that class.
*
* The @p context, if any, should point to static data; it is
* **not** owned by the TranslatedString.
*/
TranslatedString( const QVariantMap& map, const QString& key, const char* context = nullptr );
/** @brief Not-actually-translated string.
*/
TranslatedString( const QString& string );
/** @brief Proxy for calling QObject::tr()
*
* This is like the two constructors above, with an empty map an a
* non-null context. It will end up calling tr() with that context.
*
* The @p context, if any, should point to static data; it is
* **not** owned by the TranslatedString.
*/
TranslatedString( const QString& key, const char* context );
/// @brief Empty string
TranslatedString()
: TranslatedString( QString() )
{
}
/** @brief How many strings (translations) are there?
*
* This is always at least 1 (for the untranslated string),
* but may be more than 1 even when isEmpty() is true --
* if there is no untranslated version, for instance.
*/
int count() const { return m_strings.count(); }
/** @brief Consider this string empty?
*
* Only the state of the untranslated string is considered,
* so count() may be more than 1 even while the string is empty.
*/
bool isEmpty() const { return m_strings[ QString() ].isEmpty(); }
/// @brief Gets the string in the current locale
QString get() const;
/// @brief Gets the string from the given locale
QString get( const QLocale& ) const;
private:
// Maps locale name to human-readable string, "" is English
QMap< QString, QString > m_strings;
const char* m_context = nullptr;
};
} // namespace Locale
} // namespace Calamares
#endif

View File

@@ -0,0 +1,58 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
#ifndef LOCALE_TRANSLATABLESTRING_H
#define LOCALE_TRANSLATABLESTRING_H
#include <QString>
namespace Calamares
{
namespace Locale
{
/** @brief A pair of strings, one human-readable, one a key
*
* Given an identifier-like string (e.g. "New_York"), makes
* a human-readable version of that and keeps a copy of the
* identifier itself.
*
* This explicitly uses const char* instead of just being
* QPair<QString, QString> because the human-readable part
* may need to be translated through tr(), and that takes a char*
* C-style strings.
*/
class TranslatableString
{
public:
/// @brief An empty pair
TranslatableString() {}
/// @brief Given an identifier, create the pair
explicit TranslatableString( const char* s1 );
explicit TranslatableString( const QString& s );
TranslatableString( TranslatableString&& t );
TranslatableString( const TranslatableString& );
virtual ~TranslatableString();
/// @brief Give the localized human-readable form
virtual QString translated() const = 0;
QString key() const { return m_key; }
bool operator==( const TranslatableString& other ) const { return m_key == other.m_key; }
bool operator<( const TranslatableString& other ) const { return m_key < other.m_key; }
protected:
char* m_human = nullptr;
QString m_key;
};
} // namespace Locale
} // namespace Calamares
#endif

View File

@@ -0,0 +1,145 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
* SPDX-FileCopyrightText: 2017-2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
#ifndef LOCALE_TRANSLATION_H
#define LOCALE_TRANSLATION_H
#include "utils/Logger.h"
#include <QLocale>
#include <QObject>
#include <QString>
///@brief Define to 1 if the Qt version being used supports Interlingue fully
#if QT_VERSION < QT_VERSION_CHECK( 6, 7, 0 )
#define CALAMARES_QT_SUPPORT_INTERLINGUE 0
#else
#define CALAMARES_QT_SUPPORT_INTERLINGUE 1
#endif
namespace Calamares
{
namespace Locale
{
/**
* @brief Consistent locale (language + country) naming.
*
* Support class to turn locale names (as used by Calamares's
* translation system) into QLocales, and also into consistent
* human-readable text labels.
*
* This handles special-cases in Calamares translations:
* - `sr@latin` is the name which Qt recognizes as `sr@latn`,
* Serbian written with Latin characters (not Cyrillic).
* - `ca@valencia` is the Catalan dialect spoken in Valencia.
* There is no Qt code for it.
*
* (There are more special cases, not documented here)
*/
class DLLEXPORT Translation : public QObject
{
Q_OBJECT
public:
/** @brief Formatting option for label -- add (country) to label. */
enum class LabelFormat
{
AlwaysWithCountry,
IfNeededWithCountry
};
struct Id
{
QString name;
};
/** @brief Empty locale. This uses the system-default locale. */
Translation( QObject* parent = nullptr );
/** @brief Construct from a locale name.
*
* The @p localeName should be one that Qt recognizes, e.g. en_US or ar_EY.
* The @p format determines whether the country name is always present
* in the label (human-readable form) or only if needed for disambiguation.
*/
Translation( const Id& localeId, LabelFormat format = LabelFormat::IfNeededWithCountry, QObject* parent = nullptr );
/** @brief Define a sorting order.
*
* Locales are sorted by their id, which means the ISO 2-letter code + country.
*/
bool operator<( const Translation& other ) const { return m_localeId < other.m_localeId; }
/** @brief Is this locale English?
*
* en_US and en (American English) is defined as English. The Queen's
* English -- proper English -- is relegated to non-English status.
*/
bool isEnglish() const { return m_localeId == QLatin1String( "en_US" ) || m_localeId == QLatin1String( "en" ); }
/** @brief Get the human-readable name for this locale. */
QString label() const { return m_label; }
/** @brief Get the *English* human-readable name for this locale. */
QString englishLabel() const { return m_englishLabel; }
/** @brief Get the Qt locale. */
QLocale locale() const { return m_locale; }
/** @brief Gets the Calamares internal name (code) of the locale.
*
* This is a strongly-typed return to avoid it ending up all over
* the place as a QString.
*/
Id id() const { return { m_localeId }; }
/// @brief Convenience accessor to the language part of the locale
QLocale::Language language() const { return m_locale.language(); }
/// @brief Convenience accessor to the country part (if any) of the locale
QLocale::Country country() const
{
#if QT_VERSION < QT_VERSION_CHECK( 6, 6, 0 )
return m_locale.country();
#else
return m_locale.territory();
#endif
}
/** @brief Get a Qt locale for the given @p localeName
*
* This obeys special cases as described in the class documentation.
*/
static QLocale getLocale( const Id& localeId );
private:
QLocale m_locale;
QString m_localeId; // the locale identifier, e.g. "en_GB"
QString m_label; // the native name of the locale
QString m_englishLabel;
};
static inline QDebug&
operator<<( QDebug& s, const Translation::Id& id )
{
return s << id.name;
}
static inline bool
operator==( const Translation::Id& lhs, const Translation::Id& rhs )
{
return lhs.name == rhs.name;
}
} // namespace Locale
} // namespace Calamares
#endif

View File

@@ -0,0 +1,94 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2019 Camilo Higuita <milo.h@aol.com>
* SPDX-FileCopyrightText: 2019-2020 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
#ifndef LOCALE_TRANSLATIONSMODEL_H
#define LOCALE_TRANSLATIONSMODEL_H
#include "DllMacro.h"
#include "Translation.h"
#include <QAbstractListModel>
#include <QVector>
namespace Calamares
{
namespace Locale
{
class DLLEXPORT TranslationsModel : public QAbstractListModel
{
Q_OBJECT
public:
enum
{
LabelRole = Qt::DisplayRole,
EnglishLabelRole = Qt::UserRole + 1
};
TranslationsModel( const QStringList& locales, QObject* parent = nullptr );
~TranslationsModel() override;
int rowCount( const QModelIndex& parent ) const override;
QVariant data( const QModelIndex& index, int role ) const override;
QHash< int, QByteArray > roleNames() const override;
/** @brief Gets locale information for entry #n
*
* This is the backing data for the model; if @p row is out-of-range,
* returns a reference to en_US.
*/
const Translation& locale( int row ) const;
/// @brief Returns all of the locale Ids (e.g. en_US) put into this model.
const QStringList& localeIds() const { return m_localeIds; }
/** @brief Searches for an item that matches @p predicate
*
* Returns the row number of the first match, or -1 if there isn't one.
*/
int find( std::function< bool( const QLocale& ) > predicate ) const;
int find( std::function< bool( const Translation& ) > predicate ) const;
/// @brief Looks for an item using the same locale, -1 if there isn't one
int find( const QLocale& ) const;
/// @brief Looks for an item that best matches the 2-letter country code
int find( const QString& countryCode ) const;
/// @brief Looks up a translation Id
int find( const Translation::Id& id ) const;
private:
QVector< Translation* > m_locales;
QStringList m_localeIds;
};
/** @brief Returns a model with all available translations.
*
* The translations are set when Calamares is compiled; the list
* of names used can be queried with avalableLanguages().
*
* This model is a singleton and can be shared.
*
* NOTE: While the model is not typed const, it should be. Do not modify.
*/
DLLEXPORT TranslationsModel* availableTranslations();
/** @brief The list of names (e.g. en, pt_BR) of available translations.
*
* The translations are set when Calamares is compiled.
* At CMake-time, the list CALAMARES_TRANSLATION_LANGUAGES
* is used to create the table.
*/
DLLEXPORT const QStringList& availableLanguages();
} // namespace Locale
} // namespace Calamares
#endif