KTextAddons

languagetoolcombobox.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "languagetoolcombobox.h"
8#include "languageinfo.h"
9#include <KLocalizedString>
10using namespace TextGrammarCheck;
11LanguageToolComboBox::LanguageToolComboBox(QWidget *parent)
12 : QComboBox(parent)
13{
14 fillComboBox();
15}
16
17LanguageToolComboBox::~LanguageToolComboBox() = default;
18
19void LanguageToolComboBox::fillComboBox(const QVector<LanguageInfo> &info)
20{
21 clear();
22 for (int i = 0; i < info.count(); ++i) {
23 const LanguageInfo infoLang = info.at(i);
24 addItem(infoLang.name(), infoLang.code());
25 }
26}
27
28void LanguageToolComboBox::fillComboBox()
29{
30 addItem(i18n("Asturian"), QStringLiteral("ast"));
31 addItem(i18n("English"), QStringLiteral("en"));
32 addItem(i18n("English (Australian)"), QStringLiteral("en-AU"));
33 addItem(i18n("English (Canadian)"), QStringLiteral("en-CA"));
34 addItem(i18n("Belarusian"), QStringLiteral("be"));
35 addItem(i18n("Breton"), QStringLiteral("br"));
36 addItem(i18n("Catalan"), QStringLiteral("ca"));
37 addItem(i18n("Chinese"), QStringLiteral("zh"));
38 addItem(i18n("Danish"), QStringLiteral("da"));
39 addItem(i18n("Dutch"), QStringLiteral("nl"));
40 addItem(i18n("Esperanto"), QStringLiteral("eo"));
41 addItem(i18n("French"), QStringLiteral("fr"));
42 addItem(i18n("Galician"), QStringLiteral("gl"));
43 addItem(i18n("German"), QStringLiteral("de"));
44 addItem(i18n("Greek"), QStringLiteral("el"));
45 addItem(i18n("Italian"), QStringLiteral("it"));
46 addItem(i18n("Japanese"), QStringLiteral("ja"));
47 addItem(i18n("Khmer"), QStringLiteral("km"));
48 addItem(i18n("Persian"), QStringLiteral("fa"));
49 addItem(i18n("Polish"), QStringLiteral("pl"));
50 addItem(i18n("Portuguese"), QStringLiteral("pt"));
51 addItem(i18n("Romanian"), QStringLiteral("ro"));
52 addItem(i18n("Russian"), QStringLiteral("ru"));
53 addItem(i18n("Slovak"), QStringLiteral("sk"));
54 addItem(i18n("Slovenian"), QStringLiteral("sl"));
55 addItem(i18n("Spanish"), QStringLiteral("es"));
56 addItem(i18n("Swedish"), QStringLiteral("sv"));
57 addItem(i18n("Tagalog"), QStringLiteral("tl"));
58 addItem(i18n("Tamil"), QStringLiteral("ta"));
59 addItem(i18n("Ukrainian"), QStringLiteral("uk-UA"));
60}
61
62void LanguageToolComboBox::setLanguage(const QString &str)
63{
64 const int pos = findData(str);
65 if (pos != -1) {
67 }
68}
69
70QString LanguageToolComboBox::language() const
71{
72 return currentData().toString();
73}
74
75#include "moc_languagetoolcombobox.cpp"
QString i18n(const char *text, const TYPE &arg...)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
void clear()
void setCurrentIndex(int index)
int findData(const QVariant &data, int role, Qt::MatchFlags flags) const const
const_reference at(qsizetype i) const const
qsizetype count() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.