mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 02:45:44 -05:00
[libcalamares] Add convenience accessor for translations
- Which translations are available is a global property of Calamares itself, not of the plugins, so getting the model of available translations should live there. Move the relevant code (which is simple) from the Welcome module.
This commit is contained in:
parent
76b45a2740
commit
1857952431
3 changed files with 22 additions and 2 deletions
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "LabelModel.h"
|
||||
|
||||
#include "CalamaresVersion.h" // For the list of translations
|
||||
|
||||
namespace CalamaresUtils::Locale
|
||||
{
|
||||
|
||||
|
@ -104,4 +106,10 @@ LabelModel::find( const QLocale& locale ) const
|
|||
} );
|
||||
}
|
||||
|
||||
LabelModel* const availableTranslations()
|
||||
{
|
||||
static LabelModel model( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') );
|
||||
return &model;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace CalamaresUtils {}
|
|||
namespace CalamaresUtils::Locale
|
||||
{
|
||||
|
||||
DLLEXPORT class LabelModel : public QAbstractListModel
|
||||
class DLLEXPORT LabelModel : public QAbstractListModel
|
||||
{
|
||||
public:
|
||||
enum
|
||||
|
@ -65,5 +65,17 @@ private:
|
|||
QVector< Label > m_locales;
|
||||
} ;
|
||||
|
||||
/** @brief Returns a model with all available translations.
|
||||
*
|
||||
* The translations are set when Calamares is compiled; the list
|
||||
* is provided by CMake via the CALAMARES_TRANSLATION_LANGUAGES
|
||||
* #define.
|
||||
*
|
||||
* This model is a singleton and can be shared.
|
||||
*
|
||||
* NOTE: While the model is not typed const, it should be. Do not modify.
|
||||
*/
|
||||
DLLEXPORT LabelModel* const availableTranslations();
|
||||
|
||||
} // namespace
|
||||
#endif
|
||||
|
|
|
@ -131,7 +131,7 @@ WelcomePage::initLanguages()
|
|||
ui->languageWidget->clear();
|
||||
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
|
||||
|
||||
m_languages = new CalamaresUtils::Locale::LabelModel( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') );
|
||||
m_languages = CalamaresUtils::Locale::availableTranslations();
|
||||
ui->languageWidget->setModel( m_languages );
|
||||
ui->languageWidget->setItemDelegate( new LocaleTwoColumnDelegate( ui->languageWidget ) );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue