Commit 1f61ab2c authored by Benjamin Port's avatar Benjamin Port Committed by Benjamin Port
Browse files

KCM translations : Setup module data

parent ca2765cc
......@@ -7,6 +7,15 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kcm_translations\")
########### next target ###############
set(kcm_translations_PART_SRCS translations.cpp translationsmodel.cpp translationssettings.cpp)
kcmutils_generate_module_data(
kcm_translations_PART_SRCS
MODULE_DATA_HEADER translationsdata.h
MODULE_DATA_CLASS_NAME TranslationsData
SETTINGS_HEADERS translationssettings.h
SETTINGS_CLASSES TranslationsSettings
)
kconfig_add_kcfg_files(kcm_translations_PART_SRCS translationssettingsbase.kcfgc GENERATE_MOC)
add_library(kcm_translations MODULE ${kcm_translations_PART_SRCS})
......
......@@ -20,6 +20,7 @@
*/
#include "translations.h"
#include "translationsdata.h"
#include "translationsmodel.h"
#include "translationssettings.h"
......@@ -28,11 +29,11 @@
#include <KPluginFactory>
#include <KSharedConfig>
K_PLUGIN_CLASS_WITH_JSON(Translations, "kcm_translations.json")
K_PLUGIN_FACTORY_WITH_JSON(TranslationsFactory, "kcm_translations.json", registerPlugin<Translations>();registerPlugin<TranslationsData>();)
Translations::Translations(QObject *parent, const QVariantList &args)
: KQuickAddons::ManagedConfigModule(parent, args)
, m_settings(new TranslationsSettings(this))
, m_data(new TranslationsData(this))
, m_translationsModel(new TranslationsModel(this))
, m_selectedTranslationsModel(new SelectedTranslationsModel(this))
, m_availableTranslationsModel(new AvailableTranslationsModel(this))
......@@ -78,8 +79,8 @@ bool Translations::everSaved() const
void Translations::load()
{
KQuickAddons::ManagedConfigModule::load();
m_availableTranslationsModel->setSelectedLanguages(m_settings->configuredLanguages());
m_selectedTranslationsModel->setSelectedLanguages(m_settings->configuredLanguages());
m_availableTranslationsModel->setSelectedLanguages(settings()->configuredLanguages());
m_selectedTranslationsModel->setSelectedLanguages(settings()->configuredLanguages());
}
void Translations::save()
......@@ -92,8 +93,8 @@ void Translations::save()
void Translations::defaults()
{
KQuickAddons::ManagedConfigModule::defaults();
m_availableTranslationsModel->setSelectedLanguages(m_settings->configuredLanguages());
m_selectedTranslationsModel->setSelectedLanguages(m_settings->configuredLanguages());
m_availableTranslationsModel->setSelectedLanguages(settings()->configuredLanguages());
m_selectedTranslationsModel->setSelectedLanguages(settings()->configuredLanguages());
}
void Translations::selectedLanguagesChanged()
......@@ -105,10 +106,15 @@ void Translations::selectedLanguagesChanged()
configuredLanguages.removeOne(lang);
}
m_settings->setConfiguredLanguages(configuredLanguages);
settings()->setConfiguredLanguages(configuredLanguages);
m_selectedTranslationsModel->setSelectedLanguages(configuredLanguages);
}
TranslationsSettings *Translations::settings() const
{
return m_data->settings();
}
bool Translations::isSaveNeeded() const
{
return !m_selectedTranslationsModel->missingLanguages().isEmpty();
......
......@@ -28,6 +28,7 @@ class AvailableTranslationsModel;
class SelectedTranslationsModel;
class TranslationsModel;
class TranslationsSettings;
class TranslationsData;
class Translations : public KQuickAddons::ManagedConfigModule
{
......@@ -47,6 +48,7 @@ class Translations : public KQuickAddons::ManagedConfigModule
QAbstractItemModel* availableTranslationsModel() const;
bool everSaved() const;
TranslationsSettings *settings() const;
public Q_SLOTS:
void load() override;
......@@ -62,7 +64,7 @@ class Translations : public KQuickAddons::ManagedConfigModule
private:
bool isSaveNeeded() const override;
TranslationsSettings *m_settings;
TranslationsData *m_data;
TranslationsModel *m_translationsModel;
SelectedTranslationsModel *m_selectedTranslationsModel;
AvailableTranslationsModel *m_availableTranslationsModel;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment