Skip to content

Commit

Permalink
Move the list of all languages in another file.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Feb 5, 2020
1 parent 7a54f2a commit aa6c961
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 152 deletions.
6 changes: 4 additions & 2 deletions kiwix-desktop.pro
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ SOURCES += \
src/opdsrequestmanager.cpp \
src/localkiwixserver.cpp \
src/fullscreenwindow.cpp \
src/fullscreennotification.cpp
src/fullscreennotification.cpp \
src/static_content.cpp

HEADERS += \
src/mainwindow.h \
Expand Down Expand Up @@ -97,6 +98,7 @@ HEADERS += \
src/localkiwixserver.h \
src/fullscreenwindow.h \
src/fullscreennotification.h \
src/static_content.h \
src/menuproxystyle.h

FORMS += \
Expand Down Expand Up @@ -169,4 +171,4 @@ unix {
system(lrelease $$_PRO_FILE_)
}

RC_ICONS = resources/icons/kiwix/app_icon.ico
RC_ICONS = resources/icons/kiwix/app_icon.ico
154 changes: 5 additions & 149 deletions src/contentmanagerside.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QLocale>

#include "klistwidgetitem.h"
#include "static_content.h"

ContentManagerSide::ContentManagerSide(QWidget *parent) :
QWidget(parent),
Expand Down Expand Up @@ -32,153 +33,7 @@ ContentManagerSide::ContentManagerSide(QWidget *parent) :
mp_categorySelector->setHidden(true);
mp_ui->contentTypeButton->hide();

for (auto lang:
{
QLocale::AnyLanguage,
QLocale::Afar,
QLocale::Afrikaans,
QLocale::Akan,
QLocale::Amharic,
QLocale::Arabic,
QLocale::Assamese,
QLocale::Azerbaijani,
QLocale::Bashkir,
QLocale::Belarusian,
QLocale::Bulgarian,
QLocale::Bambara,
QLocale::Bengali,
QLocale::Tibetan,
QLocale::Breton,
QLocale::Bosnian,
QLocale::Catalan,
QLocale::Chechen,
QLocale::Corsican,
QLocale::Czech,
QLocale::Church,
QLocale::Chuvash,
QLocale::Welsh,
QLocale::Danish,
QLocale::German,
QLocale::Divehi,
QLocale::Dzongkha,
QLocale::Ewe,
QLocale::Greek,
QLocale::English,
QLocale::Spanish,
QLocale::Estonian,
QLocale::Basque,
QLocale::Persian,
QLocale::Fulah,
QLocale::Finnish,
QLocale::Faroese,
QLocale::French,
QLocale::WesternFrisian,
QLocale::Irish,
QLocale::Gaelic,
QLocale::Galician,
QLocale::Guarani,
QLocale::Gujarati,
QLocale::Manx,
QLocale::Hausa,
QLocale::Hebrew,
QLocale::Hindi,
QLocale::Croatian,
QLocale::Hungarian,
QLocale::Armenian,
QLocale::Interlingua,
QLocale::Indonesian,
QLocale::Igbo,
QLocale::Icelandic,
QLocale::Italian,
QLocale::Inuktitut,
QLocale::Japanese,
QLocale::Javanese,
QLocale::Georgian,
QLocale::Kikuyu,
QLocale::Kazakh,
QLocale::Greenlandic,
QLocale::Khmer,
QLocale::Kannada,
QLocale::Korean,
QLocale::Kashmiri,
QLocale::Kurdish,
QLocale::Cornish,
QLocale::Kirghiz,
QLocale::Luxembourgish,
QLocale::Ganda,
QLocale::Lingala,
QLocale::Lao,
QLocale::Lithuanian,
QLocale::Latvian,
QLocale::Malagasy,
QLocale::Maori,
QLocale::Maori,
QLocale::Macedonian,
QLocale::Malayalam,
QLocale::Mongolian,
QLocale::Marathi,
QLocale::Malay,
QLocale::Maltese,
QLocale::Burmese,
QLocale::Nepali,
QLocale::Dutch,
QLocale::NorwegianNynorsk,
QLocale::NorwegianBokmal,
QLocale::Nyanja,
QLocale::Occitan,
QLocale::Oromo,
QLocale::Oriya,
QLocale::Ossetic,
QLocale::Punjabi,
QLocale::Polish,
QLocale::Pashto,
QLocale::Portuguese,
QLocale::Quechua,
QLocale::Romansh,
QLocale::Rundi,
QLocale::Romanian,
QLocale::Russian,
QLocale::Kinyarwanda,
QLocale::Sanskrit,
QLocale::Sindhi,
QLocale::NorthernSami,
QLocale::Sango,
QLocale::Sinhala,
QLocale::Slovak,
QLocale::Slovenian,
QLocale::Shona,
QLocale::Somali,
QLocale::Albanian,
QLocale::Serbian,
QLocale::Swati,
QLocale::SouthernSotho,
QLocale::Swedish,
QLocale::Swahili,
QLocale::Tamil,
QLocale::Telugu,
QLocale::Tajik,
QLocale::Thai,
QLocale::Tigrinya,
QLocale::Turkmen,
QLocale::Filipino,
QLocale::Tswana,
QLocale::Tongan,
QLocale::Turkish,
QLocale::Tsonga,
QLocale::Tatar,
QLocale::Uighur,
QLocale::Ukrainian,
QLocale::Urdu,
QLocale::Uzbek,
QLocale::Venda,
QLocale::Vietnamese,
QLocale::Walloon,
QLocale::Wolof,
QLocale::Xhosa,
QLocale::Yoruba,
QLocale::Chinese,
QLocale::Zulu,
})
for(auto lang: S_LANGUAGES)
{
auto currentLang = QLocale().language();
if (lang == QLocale::AnyLanguage) {
Expand Down Expand Up @@ -248,12 +103,13 @@ void ContentManagerSide::setContentManager(ContentManager *contentManager)
this, [=]() {
auto item = mp_languageSelector->selectedItems().at(0);
if (!item) return;
auto lang = QLocale::Language(item->data(Qt::UserRole).toInt());
auto langId = item->data(Qt::UserRole).toInt();
auto lang = QLocale::Language(langId);
if (lang == QLocale::AnyLanguage) {
mp_contentManager->setCurrentLanguage("*");
return;
}
auto locale = QLocale(QLocale::Language(item->data(Qt::UserRole).toInt()));
auto locale = QLocale(lang);
mp_contentManager->setCurrentLanguage(locale.name().split("_").at(0));
});
connect(mp_categorySelector, &QListWidget::itemSelectionChanged,
Expand Down
5 changes: 4 additions & 1 deletion src/kiwixapp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "kiwixapp.h"
#include "static_content.h"
#include "zim/error.h"

#include <QLocale>
Expand Down Expand Up @@ -43,6 +44,8 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
m_appTranslator.load(QLocale(), "kiwix-desktop", "_", ":/i18n/");
installTranslator(&m_appTranslator);

initStaticContent();

auto icon = QIcon();
icon.addFile(":/icons/kiwix-app-icons-square.svg");
setWindowIcon(icon);
Expand Down Expand Up @@ -404,4 +407,4 @@ void KiwixApp::disableItemsOnLibraryPage(bool libraryDisplayed)
KiwixApp::instance()->getAction(KiwixApp::ZoomInAction)->setDisabled(libraryDisplayed);
KiwixApp::instance()->getAction(KiwixApp::ZoomOutAction)->setDisabled(libraryDisplayed);
KiwixApp::instance()->getAction(KiwixApp::ZoomResetAction)->setDisabled(libraryDisplayed);
}
}
155 changes: 155 additions & 0 deletions src/static_content.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@

#include "static_content.h"
#include <QTranslator>


std::vector<QLocale::Language> S_LANGUAGES;

void initStaticContent() {
#define PUSH(value) S_LANGUAGES.push_back(value)
PUSH(QLocale::AnyLanguage);
PUSH(QLocale::Afar);
PUSH(QLocale::Afrikaans);
PUSH(QLocale::Akan);
PUSH(QLocale::Amharic);
PUSH(QLocale::Arabic);
PUSH(QLocale::Assamese);
PUSH(QLocale::Azerbaijani);
PUSH(QLocale::Bashkir);
PUSH(QLocale::Belarusian);
PUSH(QLocale::Bulgarian);
PUSH(QLocale::Bambara);
PUSH(QLocale::Bengali);
PUSH(QLocale::Tibetan);
PUSH(QLocale::Breton);
PUSH(QLocale::Bosnian);
PUSH(QLocale::Catalan);
PUSH(QLocale::Chechen);
PUSH(QLocale::Corsican);
PUSH(QLocale::Czech);
PUSH(QLocale::Church);
PUSH(QLocale::Chuvash);
PUSH(QLocale::Welsh);
PUSH(QLocale::Danish);
PUSH(QLocale::German);
PUSH(QLocale::Divehi);
PUSH(QLocale::Dzongkha);
PUSH(QLocale::Ewe);
PUSH(QLocale::Greek);
PUSH(QLocale::English);
PUSH(QLocale::Spanish);
PUSH(QLocale::Estonian);
PUSH(QLocale::Basque);
PUSH(QLocale::Persian);
PUSH(QLocale::Fulah);
PUSH(QLocale::Finnish);
PUSH(QLocale::Faroese);
PUSH(QLocale::French);
PUSH(QLocale::WesternFrisian);
PUSH(QLocale::Irish);
PUSH(QLocale::Gaelic);
PUSH(QLocale::Galician);
PUSH(QLocale::Guarani);
PUSH(QLocale::Gujarati);
PUSH(QLocale::Manx);
PUSH(QLocale::Hausa);
PUSH(QLocale::Hebrew);
PUSH(QLocale::Hindi);
PUSH(QLocale::Croatian);
PUSH(QLocale::Hungarian);
PUSH(QLocale::Armenian);
PUSH(QLocale::Interlingua);
PUSH(QLocale::Indonesian);
PUSH(QLocale::Igbo);
PUSH(QLocale::Icelandic);
PUSH(QLocale::Italian);
PUSH(QLocale::Inuktitut);
PUSH(QLocale::Japanese);
PUSH(QLocale::Javanese);
PUSH(QLocale::Georgian);
PUSH(QLocale::Kikuyu);
PUSH(QLocale::Kazakh);
PUSH(QLocale::Greenlandic);
PUSH(QLocale::Khmer);
PUSH(QLocale::Kannada);
PUSH(QLocale::Korean);
PUSH(QLocale::Kashmiri);
PUSH(QLocale::Kurdish);
PUSH(QLocale::Cornish);
PUSH(QLocale::Kirghiz);
PUSH(QLocale::Luxembourgish);
PUSH(QLocale::Ganda);
PUSH(QLocale::Lingala);
PUSH(QLocale::Lao);
PUSH(QLocale::Lithuanian);
PUSH(QLocale::Latvian);
PUSH(QLocale::Malagasy);
PUSH(QLocale::Maori);
PUSH(QLocale::Maori);
PUSH(QLocale::Macedonian);
PUSH(QLocale::Malayalam);
PUSH(QLocale::Mongolian);
PUSH(QLocale::Marathi);
PUSH(QLocale::Malay);
PUSH(QLocale::Maltese);
PUSH(QLocale::Burmese);
PUSH(QLocale::Nepali);
PUSH(QLocale::Dutch);
PUSH(QLocale::NorwegianNynorsk);
PUSH(QLocale::NorwegianBokmal);
PUSH(QLocale::Nyanja);
PUSH(QLocale::Occitan);
PUSH(QLocale::Oromo);
PUSH(QLocale::Oriya);
PUSH(QLocale::Ossetic);
PUSH(QLocale::Punjabi);
PUSH(QLocale::Polish);
PUSH(QLocale::Pashto);
PUSH(QLocale::Portuguese);
PUSH(QLocale::Quechua);
PUSH(QLocale::Romansh);
PUSH(QLocale::Rundi);
PUSH(QLocale::Romanian);
PUSH(QLocale::Russian);
PUSH(QLocale::Kinyarwanda);
PUSH(QLocale::Sanskrit);
PUSH(QLocale::Sindhi);
PUSH(QLocale::NorthernSami);
PUSH(QLocale::Sango);
PUSH(QLocale::Sinhala);
PUSH(QLocale::Slovak);
PUSH(QLocale::Slovenian);
PUSH(QLocale::Shona);
PUSH(QLocale::Somali);
PUSH(QLocale::Albanian);
PUSH(QLocale::Serbian);
PUSH(QLocale::Swati);
PUSH(QLocale::SouthernSotho);
PUSH(QLocale::Swedish);
PUSH(QLocale::Swahili);
PUSH(QLocale::Tamil);
PUSH(QLocale::Telugu);
PUSH(QLocale::Tajik);
PUSH(QLocale::Thai);
PUSH(QLocale::Tigrinya);
PUSH(QLocale::Turkmen);
PUSH(QLocale::Filipino);
PUSH(QLocale::Tswana);
PUSH(QLocale::Tongan);
PUSH(QLocale::Turkish);
PUSH(QLocale::Tsonga);
PUSH(QLocale::Tatar);
PUSH(QLocale::Uighur);
PUSH(QLocale::Ukrainian);
PUSH(QLocale::Urdu);
PUSH(QLocale::Uzbek);
PUSH(QLocale::Venda);
PUSH(QLocale::Vietnamese);
PUSH(QLocale::Walloon);
PUSH(QLocale::Wolof);
PUSH(QLocale::Xhosa);
PUSH(QLocale::Yoruba);
PUSH(QLocale::Chinese);
PUSH(QLocale::Zulu);
#undef PUSH
}
12 changes: 12 additions & 0 deletions src/static_content.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#ifndef STATICCONTENT_H
#define STATICCONTENT_H

#include <QLocale>
#include <vector>

extern std::vector<QLocale::Language> S_LANGUAGES;

void initStaticContent();

#endif //STATICCONTENT_H

0 comments on commit aa6c961

Please sign in to comment.