Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
LanguageManager.h
1/*
2 * LanguageManager.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2021-2023 - adazem009
6 * Copyright (C) 2022 - Roker2
7 *
8 * Open-Typer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * Open-Typer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef LANGUAGEMANAGER_H
23#define LANGUAGEMANAGER_H
24
25#include <QObject>
26#include <QLocale>
27#include <QVector>
28#include <QTranslator>
29#include <QCoreApplication>
30#include <QLibraryInfo>
31#include "../ILanguageManager.h"
32
33extern QTranslator *translator_app;
34extern QTranslator *translator_qt;
35
49class Q_DECL_EXPORT LanguageManager : public ILanguageManager
50{
51 Q_OBJECT
52 Q_PROPERTY(QString languageStr READ languageStr NOTIFY languageStrChanged)
53 using LanguageCountry = std::pair<QLocale::Language, QLocale::Country>;
54
55 public:
56 static std::shared_ptr<LanguageManager> instance();
57 void init(void);
58 Q_INVOKABLE void setLanguage(int index) override;
59 Q_INVOKABLE QStringList getBoxItems() override;
60 QLocale getLocale(int index) override;
61
62 QString languageStr(void) override;
63
64 private:
65 static std::shared_ptr<LanguageManager> m_instance;
66 static const QList<LanguageCountry> supportedLanguagesList;
67 static const QString boxLangItemTemplate;
68 bool initComplete = false;
69 int m_index = -1;
70};
71
72#endif // LANGUAGEMANAGER_H
Definition ILanguageManager.h:28
The LanguageManager class provides a list of supported languages.
Definition LanguageManager.h:50