1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
/*
* This file is part of system-settings
*
* Copyright (C) 2013 Canonical Ltd.
*
* Contact: William Hua <william.hua@canonical.com>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LANGUAGE_PLUGIN_H
#define LANGUAGE_PLUGIN_H
#include <QtCore>
#include "subset-model.h"
#include "sessionservice.h"
#include "accountsservice.h"
extern "C"
{
#include <act/act-user.h>
#include <act/act-user-manager.h>
}
typedef void *gpointer;
typedef char gchar;
class KeyboardLayout;
class LanguagePlugin : public QObject
{
private:
Q_OBJECT
public:
Q_PROPERTY(QStringList languageNames
READ languageNames
CONSTANT)
Q_PROPERTY(QStringList languageCodes
READ languageCodes
CONSTANT)
Q_PROPERTY(int currentLanguage
READ currentLanguage
WRITE setCurrentLanguage
NOTIFY currentLanguageChanged)
Q_PROPERTY(SubsetModel *spellCheckingModel
READ spellCheckingModel
CONSTANT)
Q_INVOKABLE void reboot();
explicit LanguagePlugin(QObject *parent = nullptr);
virtual ~LanguagePlugin();
const QStringList &languageNames() const;
const QStringList &languageCodes() const;
int currentLanguage() const;
void setCurrentLanguage(int index);
Q_SIGNAL void currentLanguageChanged() const;
SubsetModel *spellCheckingModel();
Q_SLOT void spellCheckingModelChanged();
private:
void updateLanguageNamesAndCodes();
void updateCurrentLanguage();
void updateSpellCheckingModel();
int indexForLocale(const QString &name) const;
void userLoaded();
friend void userLoaded(GObject *object,
GParamSpec *pspec,
gpointer user_data);
void managerLoaded();
friend void managerLoaded(GObject *object,
GParamSpec *pspec,
gpointer user_data);
QStringList m_languageNames;
QStringList m_languageCodes;
QHash<QString, unsigned int> m_indicesByLocale;
int m_currentLanguage;
int m_nextCurrentLanguage;
ActUserManager *m_manager;
ActUser *m_user;
#ifndef ENABLE_UBUNTU_ACCOUNTSSERVICE
LomiriSystemSettings::AccountsService m_accountsService;
#endif
SubsetModel m_spellCheckingModel;
SessionService m_sessionService;
};
#endif // LANGUAGE_PLUGIN_H
|