...
 
Commits (3)
include:
- https://invent.kde.org/sysadmin/ci-tooling/raw/master/invent/binary-flatpak.yml
variables:
BUNDLE: org.kde.mobile.plasmasettings.flatpak
flatpak:
extends: .flatpak
variables:
MANIFEST_PATH: org.kde.mobile.plasmasettings.json
APP_ID: org.kde.mobile.plasmasettings
FLATPAK_MODULE: plasma-settings
project(plasma-settings)
cmake_minimum_required(VERSION 2.8.12)
cmake_policy(SET CMP0063 NEW)
################# Disallow in-source build #################
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "plasma-settings requires an out of source build. Please create a separate build directory and run 'cmake path_to_plasma-settings [options]' there.")
endif()
include(CPack)
include(FeatureSummary)
find_package(PkgConfig)
################# set KDE specific information #################
find_package(ECM 0.0.8 REQUIRED NO_MODULE)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings)
include(ECMQMLModules)
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui)
################# now find all used packages #################
set (QT_MIN_VERSION "5.4.0")
find_package(KF5 REQUIRED COMPONENTS
WindowSystem
CoreAddons
Solid
Config
Auth
DBusAddons
I18n
Plasma
PlasmaQuick
Declarative
KIO
KDELibs4Support
)
find_package(KAccounts)
find_package(AccountsQt5 1.10 CONFIG)
find_package(SignOnQt5 8.55 CONFIG)
ecm_find_qmlmodule(org.kde.kcm 1.0)
if (KAccounts_FOUND AND AccountsQt5_FOUND AND SignOnQt5_FOUND)
include_directories(${ACCOUNTSQT_INCLUDE_DIRS} ${SIGNONQT_INCLUDE_DIRS})
endif()
add_subdirectory(src)
add_subdirectory(import)
add_subdirectory(modules)
install(DIRECTORY package/ DESTINATION ${KDE_INSTALL_DATAROOTDIR}/kpackage/genericqml/org.kde.plasma.settings)
install(FILES org.kde.mobile.plasmasettings.desktop DESTINATION ${KDE_INSTALL_APPDIR})
This diff is collapsed.
This diff is collapsed.
# Plasma Settings
Settings application for Plasma Mobile.
## API
You can find documentation for using the Active Settings infrastructure at
[docs.plasma-mobile.org/PlasmaSettings.html](https://docs.plasma-mobile.org/PlasmaSettings.html)
plasma-settings (0.0.1+git20190525-2~54.gbpf4368b) UNRELEASED; urgency=medium
** SNAPSHOT build @f4368b8edfa4e7f31fb6f3038b2cac5e90693181 **
* New upstream version 0.0.1+git20190525
-- Jenkins <jenkins@arm01.puri.sm> Fri, 16 Aug 2019 01:08:26 -0700
plasma-settings (0.0.1+git20190525-1) unstable; urgency=medium
* New snapshot
......
project(settings)
set(settings_SRCS
package.cpp
settingsplugin.cpp
settingsmodule.cpp
settingsmodulesmodel.cpp
settingscomponent.cpp
configgroup.cpp
)
add_library(settingsplugin SHARED ${settings_SRCS})
target_link_libraries(settingsplugin
Qt5::Core
Qt5::Qml
Qt5::Quick
KF5::I18n
KF5::Package
KF5::QuickAddons
KF5::ConfigCore
)
install(TARGETS settingsplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/active/settings)
install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/active/settings)
install(FILES SettingsItem.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/active/settings)
You can find documentation for using the Active Settins infrastructure at
http://techbase.kde.org/Development/Tutorials/Plasma/QML/ActiveSettings
// -*- coding: iso-8859-1 -*-
/*
* Copyright 2011-2012 Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.2
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import org.kde.active.settings 2.0 as ActiveSettings
PlasmaComponents.PageStack {
id: moduleContainer
objectName: "moduleContainer"
property alias module: settingsComponent.module
property alias icon: settingsComponent.icon
signal moduleLoaded
function pushModule(module) {
switcherPackage.name = module
var mainscript = switcherPackage.filePath("mainscript");
//print("Loading mainscript: " + mainscript);
settingsLoader.source = mainscript;
moduleContainer.push(settingsLoader);
moduleContainer.module = module
}
clip: true
Loader {
id: settingsLoader
anchors.fill: parent
}
ActiveSettings.SettingsComponent {
id: settingsComponent
onModuleChanged: {
if (module == "") {
moduleContainer.pop();
} else if (switcherPackage.name != module) {
switcherPackage.name = module
//print(" Loading package: " + switcherPackage.filePath("mainscript") + " " + module);
var mainscript = switcherPackage.filePath("mainscript");
settingsLoader.source = switcherPackage.filePath("mainscript");
//moduleContainer.replace(switcherPackage.filePath("mainscript"));
print("Loaded mainscript: " + mainscript);
moduleLoaded();
}
}
}
ActiveSettings.Package {
id: switcherPackage
}
}
/*
* Copyright 2011-2012 by Sebastian Kügler <sebas@kde.org>
* Copyright 2013 by Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "configgroup.h"
#include <QtCore/QTimer>
#include <KConfig>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QDebug>
namespace Plasma
{
class ConfigGroupPrivate {
public:
ConfigGroupPrivate(ConfigGroup *q)
: q(q),
config(nullptr),
configGroup(nullptr)
{}
~ConfigGroupPrivate()
{
delete configGroup;
}
ConfigGroup* q;
KSharedConfigPtr config;
KConfigGroup *configGroup;
QString file;
QTimer *syncTimer;
QString group;
};
ConfigGroup::ConfigGroup(QQuickItem *parent)
: QQuickItem(parent),
d(new ConfigGroupPrivate(this))
{
// Delay and compress everything within 5 seconds into one sync
d->syncTimer = new QTimer(this);
d->syncTimer->setSingleShot(true);
d->syncTimer->setInterval(1500);
connect(d->syncTimer, &QTimer::timeout, this, &ConfigGroup::sync);
}
ConfigGroup::~ConfigGroup()
{
if (d->syncTimer->isActive()) {
qDebug() << "SYNC......";
d->syncTimer->stop();
d->configGroup->sync();
}
delete d;
}
KConfigGroup* ConfigGroup::configGroup()
{
return d->configGroup;
}
QString ConfigGroup::file() const
{
return d->file;
}
void ConfigGroup::setFile(const QString& filename)
{
if (d->file == filename) {
return;
}
d->file = filename;
readConfigFile();
emit fileChanged();
}
QString ConfigGroup::group() const
{
return d->group;
}
void ConfigGroup::setGroup(const QString& groupname)
{
if (d->group == groupname) {
return;
}
d->group = groupname;
qDebug() << "Set group name: " << groupname;
readConfigFile();
emit groupChanged();
emit keyListChanged();
}
QStringList ConfigGroup::keyList() const
{
if (!d->configGroup) {
return QStringList();
}
return d->configGroup->keyList();
}
QStringList ConfigGroup::groupList() const
{
return d->configGroup->groupList();
}
bool ConfigGroup::readConfigFile()
{
// Find parent ConfigGroup
ConfigGroup* parentGroup = nullptr;
QObject* current = parent();
while (current) {
parentGroup = qobject_cast<ConfigGroup*>(current);
if (parentGroup) {
break;
}
current = current->parent();
}
delete d->configGroup;
d->configGroup = nullptr;
if (parentGroup) {
d->configGroup = new KConfigGroup(parentGroup->configGroup(), d->group);
return true;
} else {
if (d->file.isEmpty()) {
//qWarning() << "Could not find KConfig Parent: specify a file or parent to another ConfigGroup";
return false;
}
d->config = KSharedConfig::openConfig(d->file);
d->configGroup = new KConfigGroup(d->config, d->group);
qDebug() << "Opened config" << d->configGroup->entryMap();
return true;
}
}
// Bound methods and slots
bool ConfigGroup::writeEntry(const QString& key, const QVariant& value)
{
if (!d->configGroup) {
return false;
}
d->configGroup->writeEntry(key, value);
d->syncTimer->start();
return true;
}
QVariant ConfigGroup::readEntry(const QString& key)
{
if (!d->configGroup) {
return QVariant();
}
const QVariant value = d->configGroup->readEntry(key, QVariant(""));
qDebug() << " reading setting: " << key << value;
return value;
}
void ConfigGroup::deleteEntry(const QString& key)
{
d->configGroup->deleteEntry(key);
d->syncTimer->start();
}
void ConfigGroup::sync()
{
if (d->configGroup) {
qDebug() << "synching config...";
d->configGroup->sync();
}
}
} // namespace Plasma
/*
* Copyright 2011-2012 by Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CONFIGGROUP_H
#define CONFIGGROUP_H
#include <QObject>
#include <QQuickItem>
#include <QVariant>
class KConfigGroup;
namespace Plasma
{
class ConfigGroupPrivate;
class ConfigGroup : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QString file READ file WRITE setFile NOTIFY fileChanged)
Q_PROPERTY(QString group READ group WRITE setGroup NOTIFY groupChanged)
Q_PROPERTY(QStringList keyList READ keyList NOTIFY keyListChanged)
Q_PROPERTY(QStringList groupList READ groupList NOTIFY groupListChanged)
public:
ConfigGroup(QQuickItem* parent=nullptr);
~ConfigGroup() override;
KConfigGroup* configGroup();
QString file() const;
void setFile(const QString &filename);
QString group() const;
void setGroup(const QString &groupname);
QStringList keyList() const;
QStringList groupList() const;
Q_INVOKABLE QVariant readEntry(const QString &key);
Q_INVOKABLE bool writeEntry(const QString &key, const QVariant &value);
Q_INVOKABLE void deleteEntry(const QString& key);
Q_SIGNALS:
void fileChanged();
void groupChanged();
void keyListChanged();
void groupListChanged();
private:
ConfigGroupPrivate* d;
bool readConfigFile();
private Q_SLOTS:
void sync();
};
}
#endif
/***************************************************************************
* Copyright 2011 Marco Martin <mart@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "package.h"
#include <QStandardPaths>
#include <QDebug>
#include <KLocalizedString>
#include <KPackage/PackageLoader>
Package::Package(QObject *parent)
: QObject(parent)
{
}
Package::~Package()
{
}
QString Package::name() const
{
return m_name;
}
void Package::setName(const QString &name)
{
if (m_name == name) {
return;
}
m_name = name;
m_package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
m_package.setPath(name);
QString domain = QStringLiteral("plasma_package_") + name;
KLocalizedString::setApplicationDomain(domain.toLocal8Bit().data());
emit nameChanged(name);
emit visibleNameChanged();
}
QString Package::visibleName() const
{
if (!m_package.isValid()) {
return QString();
}
return m_package.metadata().name();
}
QString Package::filePath(const QString &fileType, const QString &fileName) const
{
if (!m_package.isValid()) {
return QString();
}
if (fileName.isEmpty()) {
return m_package.filePath(fileType.toLatin1());
} else {
return m_package.filePath(fileType.toLatin1(), fileName);
}
}
QString Package::filePath(const QString &fileType) const
{
if (!m_package.isValid()) {
return QString();
}
return m_package.filePath(fileType.toLatin1());
}
/***************************************************************************
* Copyright 2011 Marco Martin <mart@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef PACKAGE_H
#define PACKAGE_H
#include <QQuickItem>
#include <QUrl>
#include <KPackage/Package>
class QTimer;
class Package : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString visibleName READ visibleName NOTIFY visibleNameChanged)
public:
Package(QObject *parent = nullptr);
~Package() override;
QString name() const;
void setName(const QString &name);
Q_INVOKABLE QString filePath(const QString &fileType, const QString &filename) const;
Q_INVOKABLE QString filePath(const QString &fileType) const;
QString visibleName() const;
Q_SIGNALS:
void nameChanged(const QString &);
void visibleNameChanged();
private:
QString m_name;
KPackage::Package m_package;
};
#endif
module org.kde.active.settings
plugin settingsplugin
SettingsItem 2.0 SettingsItem.qml
/*
Copyright 2011 Marco Martin <notmart@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "settingscomponent.h"
#include "settingsmodule.h"
#include <QQmlEngine>
#include <QQmlComponent>
#include <QDebug>
#include <KPluginMetaData>
#include <KPluginLoader>
#include <KPluginFactory>
#include <kquickaddons/configmodule.h>
#include <KPackage/Package>
#include <KPackage/PackageLoader>
class SettingsComponentPrivate {
public:
QString module;
QString icon;
SettingsModule *settingsModule;
KQuickAddons::ConfigModule *kcm;
bool valid : 1;
KPackage::Package package;
};
SettingsComponent::SettingsComponent(QQuickItem *parent)
: QQuickItem(parent)
{
d = new SettingsComponentPrivate;
d->package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
d->settingsModule = nullptr;
d->kcm = nullptr;
d->valid = false;
}
SettingsComponent::~SettingsComponent()
{
}
void SettingsComponent::loadModule(const QString &name)
{
d->settingsModule->deleteLater();
d->settingsModule = nullptr;
d->kcm->deleteLater();
d->kcm = nullptr;
d->package.setPath(name);
//KGlobal::locale()->insertCatalog("plasma_package_" + name);
#warning "Re-enable translation catalog, port insertCatalog"
QString pluginName = name;
QString query;
if (pluginName.isEmpty()) {
qDebug() << "Not loading plugin ..." << pluginName;
return;
}
const QString plugin = KPluginLoader::findPlugin(QLatin1String("kcms/") + name);
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML");
package.setDefaultPackageRoot("kpackage/kcms");
package.setPath(name);
KPluginMetaData info(package.metadata());
//try pure QML mode
if (plugin.isEmpty()) {
d->kcm = new KQuickAddons::ConfigModule(info, this, QVariantList());
} else {
//qml-kcm mode
KPluginLoader loader(plugin);
KPluginFactory* factory = loader.factory();
if (!factory) {
qWarning() << "Error loading KCM plugin:" << loader.errorString();
d->valid = false;
emit validChanged();
return;
} else {
d->kcm = factory->create<KQuickAddons::ConfigModule >();
if (!d->kcm) {
qWarning() << "Error creating object from plugin" << loader.fileName();
d->valid = false;
emit validChanged();
return;
}
}
}
d->settingsModule = new SettingsModule(this);
connect(d->settingsModule, &SettingsModule::nameChanged, this, &SettingsComponent::nameChanged);
connect(d->settingsModule, &SettingsModule::descriptionChanged,
this, &SettingsComponent::descriptionChanged);
if (!d->kcm->mainUi()) {
d->valid = false;
emit validChanged();
return;
}
d->kcm->mainUi()->setParentItem(this);
{
//set anchors
QQmlExpression expr(QtQml::qmlContext(d->kcm->mainUi()), d->kcm->mainUi(), "parent");
QQmlProperty prop(d->kcm->mainUi(), "anchors.fill");
prop.write(expr.evaluate());
}
d->kcm->load();
//instant apply
connect(d->kcm, &KQuickAddons::ConfigModule::needsSaveChanged, [=]() {
if (d->kcm->needsSave()) {
d->kcm->save();
}
});
d->settingsModule->setName(info.name());
setIcon(info.iconName());
d->settingsModule->setDescription(info.description());
d->settingsModule->setModule(info.pluginId());
d->valid = true;
emit mainUiChanged();
emit kcmChanged();
emit validChanged();
}
QQuickItem *SettingsComponent::mainUi() const
{
if (d->kcm) {
return d->kcm->mainUi();
}
return nullptr;
}
KQuickAddons::ConfigModule *SettingsComponent::kcm() const
{
return d->kcm;
}
bool SettingsComponent::isValid() const
{
return d->valid;
}
QString SettingsComponent::description() const
{
if (d->settingsModule) {
return d->settingsModule->description();
}
return QString();
}
void SettingsComponent::setDescription(const QString &description)
{
if (d->settingsModule && d->settingsModule->description() != description) {
d->settingsModule->setDescription(description);
emit descriptionChanged();
}
}
QString SettingsComponent::icon() const
{
return d->icon;
}
void SettingsComponent::setIcon(const QString& name)
{
if (name != d->icon) {
d->icon = name;
emit iconChanged();
}
}
QString SettingsComponent::module() const
{
return d->module;
}
void SettingsComponent::setModule(const QString &module)
{
if (d->module != module) {
d->module = module;
loadModule(module);
emit moduleChanged();
}
}
QString SettingsComponent::name() const
{
if (d->settingsModule) {
return d->settingsModule->name();
}
return QString();
}
void SettingsComponent::setName(const QString &name)
{
if (d->settingsModule && d->settingsModule->name() != name) {
d->settingsModule->setName(name);
emit nameChanged();
}
}
/*
Copyright 2011 Sebastian Kügler <sebas@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef SETTINGSCOMPONENT_H
#define SETTINGSCOMPONENT_H
#include <QQuickItem>
class SettingsComponentPrivate;
namespace KQuickAddons {
class ConfigModule;
}
class SettingsComponent : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
Q_PROPERTY(QString module READ module WRITE setModule NOTIFY moduleChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
Q_PROPERTY(QQuickItem *mainUi READ mainUi NOTIFY mainUiChanged)
Q_PROPERTY(KQuickAddons::ConfigModule *kcm READ kcm NOTIFY kcmChanged)
public:
SettingsComponent(QQuickItem *parent = nullptr);
~SettingsComponent() override;
QString description() const;
QString module() const;
QString name() const;
QString icon() const;
bool isValid() const;
QQuickItem *mainUi() const;
KQuickAddons::ConfigModule *kcm() const;
Q_SIGNALS:
void descriptionChanged();
void moduleChanged();
void nameChanged();
void iconChanged();
void validChanged();
void mainUiChanged();
void kcmChanged();
public Q_SLOTS:
void setModule(const QString &module);
void setDescription(const QString &description);
void setName(const QString &name);
void setIcon(const QString &name);
void loadModule(const QString &name);
private:
SettingsComponentPrivate* d;
};
#endif
/*
* Copyright 2011 Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "settingsmodule.h"
class SettingsModulePrivate {
public:
QString name;
QString description;
QString module;
QString iconName;
QString category;
};
SettingsModule::SettingsModule(QObject *parent, const QVariantList &v)
: QObject(parent),
d(new SettingsModulePrivate)
{
Q_UNUSED(v);
}
SettingsModule::~SettingsModule()
{
delete d;
}
QString SettingsModule::name() const
{
return d->name;
}
QString SettingsModule::description() const
{
return d->description;
}
QString SettingsModule::module() const
{
return d->module;
}
QString SettingsModule::iconName() const
{
return d->iconName;
}
QString SettingsModule::category() const
{
return d->category;
}
void SettingsModule::setName(const QString &name)
{
if (d->name != name) {
d->name = name;
emit nameChanged();
}
}
void SettingsModule::setDescription(const QString &description)
{
if (d->description != description) {
d->description = description;
emit descriptionChanged();
}
}
void SettingsModule::setIconName(const QString &iconName)
{
if (d->iconName != iconName) {
d->iconName = iconName;
emit iconNameChanged();
}
}
void SettingsModule::setModule(const QString &module)
{
if (d->module != module) {
d->module = module;
emit moduleChanged();
}
}
void SettingsModule::setCategory(const QString &category)
{
if (d->category != category) {
d->category = category;
emit categoryChanged();
}
}
/*
* Copyright 2011 Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SETTINGSMODULE_H
#define SETTINGSMODULE_H
#include <QObject>
#include <QVariant>
class SettingsModulePrivate;
/**
* @class SettingsModule A class to manage settings from declarative UIs.
* This class serves two functions:
* - Provide a plugin implementation
* - Provide a settings module
* This is done from one class in order to simplify the code. You can export
* any QObject-based class through qmlRegisterType(), however.
*/
class SettingsModule : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
Q_PROPERTY(QString module READ module WRITE setModule NOTIFY moduleChanged)
Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
Q_PROPERTY(QString category READ category WRITE setCategory NOTIFY categoryChanged)
public:
explicit SettingsModule(QObject *parent = nullptr, const QVariantList &v = QVariantList());
~SettingsModule() override;
QString name() const;
QString description() const;
QString iconName() const;
QString module() const;
QString category() const;
public Q_SLOTS:
void setName(const QString &name);
void setDescription(const QString &description);
void setModule(const QString &module);
void setIconName(const QString &iconName);
void setCategory(const QString &category);
Q_SIGNALS:
void nameChanged();
void descriptionChanged();
void moduleChanged();
void iconNameChanged();
void categoryChanged();
private:
SettingsModulePrivate *d;
};
#endif
/***************************************************************************
* *
* Copyright 2011 Sebastian Kügler <sebas@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY 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, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "settingsmodulesmodel.h"
#include <QQmlContext>
#include <QQmlEngine>
#include <QTimer>
#include <KPackage/PackageLoader>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KPluginMetaData>
#include <KPluginLoader>
#include <QDebug>
class SettingsModulesModelPrivate {
public:
SettingsModulesModelPrivate(SettingsModulesModel *parent)
: populateTimer(new QTimer(parent))
{}
QList<SettingsModule*> settingsModules;
QTimer *populateTimer;
QString appName;
QString formFactor;
};
SettingsModulesModel::SettingsModulesModel(QQmlComponent *parent)
: QQmlComponent(parent),
d(new SettingsModulesModelPrivate(this))
{
qDebug() << "Creating SettingsModel";
d->populateTimer->setInterval(0);
d->populateTimer->setSingleShot(true);
connect(d->populateTimer, &QTimer::timeout, this, &SettingsModulesModel::populate);
d->populateTimer->start();
connect(this, &SettingsModulesModel::formFactorChanged, this, &SettingsModulesModel::populate);
}
SettingsModulesModel::~SettingsModulesModel()
{
delete d;
}
QQmlListProperty<SettingsModule> SettingsModulesModel::settingsModules()
{
return QQmlListProperty<SettingsModule>(this, d->settingsModules);
}
QString SettingsModulesModel::application() const
{
return d->appName;
}
void SettingsModulesModel::setApplication(const QString &appName)
{
qDebug() << "setting application to" << appName;
if (d->appName != appName) {
d->appName = appName;
for (auto m: d->settingsModules) {
m->deleteLater();
}
d->settingsModules.clear();
emit applicationChanged();
emit settingsModulesChanged();
d->populateTimer->start();
}
}
bool compareModules(const SettingsModule *l, const SettingsModule *r)
{
if (l == r) {
return false;
}
if (!l) {
return false;
} else if (!r) {
return true;
}
// base it on the category weighting; if neither has a category weight the compare
// strings
KConfigGroup orderConfig(KSharedConfig::openConfig(), "SettingsCategoryWeights");
const int lG = orderConfig.readEntry(l->category(), -1);
const int rG = orderConfig.readEntry(r->category(), -1);
//qDebug() << l->name() << l->category() << lG << " vs " << r->name() << r->category() << rG;
if (lG < 0) {
if (rG > 0) {
return false;
}
int rv = l->category().compare(r->category(), Qt::CaseInsensitive);
if (rv == 0) {
rv = l->name().compare(r->name(), Qt::CaseInsensitive);
}
return rv < 0;
} else if (rG < 0) {
return true;
}
if (lG == rG) {
return l->name().compare(r->name(), Qt::CaseInsensitive) < 0;
}
return lG > rG;
}
void SettingsModulesModel::populate()
{
for (auto m: d->settingsModules) {
m->deleteLater();
}
d->settingsModules.clear();
QSet<QString> seen; // track dupes
auto plugins = KPluginLoader::findPlugins("kcms");
for (auto plugin : KPackage::PackageLoader::self()->listPackages(QString(), "kpackage/kcms/")) {
plugins << plugin;
}
for (auto plugin : plugins) {
if (seen.contains(plugin.pluginId())) {
continue;
}
// Filter out modules that are not explicitely suitable for the "handset" formfactor
if (!formFactor().isEmpty() && !plugin.formFactors().contains(formFactor()) && formFactor() != QStringLiteral("all")) {
continue;
}
SettingsModule* item = new SettingsModule(this);
item->setName(plugin.name());
item->setDescription(plugin.description());
item->setIconName(plugin.iconName());
item->setModule(plugin.pluginId());
item->setCategory(plugin.category());
d->settingsModules.append(item);
seen.insert(plugin.pluginId());
}
qStableSort(d->settingsModules.begin(), d->settingsModules.end(), compareModules);
//emit dataChanged();
emit settingsModulesChanged();
}
QString SettingsModulesModel::formFactor() const
{
return d->formFactor;
}
void SettingsModulesModel::setFormFactor(const QString& f)
{
if (d->formFactor != f) {
d->formFactor = f;
emit formFactorChanged();
}
}
/***************************************************************************
* *
* Copyright 2011 Sebastian Kügler <sebas@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY 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, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef COMPLETIONMODEL_H
#define COMPLETIONMODEL_H
#include <QQmlComponent>
#include <QObject>
#include <QImage>
#include "settingsmodule.h"
class History;
class SettingsModulesModelPrivate;
class SettingsModulesModel : public QQmlComponent
{
Q_OBJECT
Q_PROPERTY(QQmlListProperty<SettingsModule> settingsModules READ settingsModules NOTIFY settingsModulesChanged)
Q_PROPERTY(QString application READ application WRITE setApplication NOTIFY applicationChanged)
Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
public:
SettingsModulesModel(QQmlComponent* parent = nullptr);
~SettingsModulesModel() override;
QQmlListProperty<SettingsModule> settingsModules();
QString application() const;
void setApplication(const QString &appname);
QString formFactor() const;
void setFormFactor(const QString &f);
public Q_SLOTS:
void populate();
Q_SIGNALS:
void dataChanged();
void settingsModulesChanged();
void applicationChanged();
void formFactorChanged();
private:
SettingsModulesModelPrivate * const d;
};
#endif // COMPLETIONMODEL_H
/*
* Copyright 2011-2014 Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "settingsplugin.h"
#include <QDebug>
#include <QQmlContext>
//#include <QScriptEngine>
#include <kquickaddons/configmodule.h>
//#include "settingsmoduleloader.h"
#include "settingsmodulesmodel.h"
#include "settingscomponent.h"
#include "configgroup.h"
#include "package.h"
void SettingsPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.active.settings"));
const int major = 2;
const int minor = 0;
qmlRegisterType<SettingsModulesModel>(uri, major, minor, "SettingsModulesModel");
qmlRegisterType<SettingsModule>(uri, major, minor, "SettingsModule");
qmlRegisterType<SettingsComponent>(uri, major, minor, "SettingsComponent");
qmlRegisterType<Package>(uri, major, minor, "Package");
qmlRegisterType<Plasma::ConfigGroup>(uri, major, minor, "ConfigGroup");
qmlRegisterType<KQuickAddons::ConfigModule>();
}
/*
* Copyright 2011-2014 by Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SETTINGSPLUGIN_H
#define SETTINGSPLUGIN_H
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
class SettingsPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
//void initializeEngine(QQmlEngine *engine, const char *uri);
void registerTypes(const char *uri) override;
};
#endif
# Install the packages, also make it known to the system
add_subdirectory(theme)
if (${KF5KDELibs4Support_FOUND})
add_subdirectory(time)
endif()
# Power
add_subdirectory(powermanagement)
# Accounts
if (KAccounts_FOUND AND AccountsQt5_FOUND AND SignOnQt5_FOUND)
add_subdirectory(accounts)
endif()
install(FILES kaccounts.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
kpackage_install_package(package kcm_mobile_kaccounts kcms)
[Desktop Entry]
Name=Accounts
Name[ca]=Comptes
Name[ca@valencia]=Comptes
Name[cs]=Účty
Name[da]=Konti
Name[de]=Zugänge
Name[el]=Λογαριασμοί
Name[en_GB]=Accounts
Name[es]=Cuentas
Name[fi]=Tilit
Name[fr]=Comptes
Name[gl]=Contas
Name[it]=Account
Name[ko]=계정
Name[nl]=Accounts
Name[nn]=Kontoar
Name[pl]=Konta
Name[pt]=Contas
Name[pt_BR]=Contas
Name[sk]=Účty
Name[sl]=Računi
Name[sv]=Konton
Name[uk]=Облікові записи
Name[x-test]=xxAccountsxx
Name[zh_CN]=帐户
Name[zh_TW]=帳號
Comment=Add Your Online Accounts
Comment[ca]=Afegiu els vostres comptes en línia
Comment[ca@valencia]=Afegiu els vostres comptes en línia
Comment[cs]=Přidejte svoje účty online
Comment[da]=Tilføj dine onlinekonti
Comment[de]=Fügen Sie Ihre Online-Zugänge hinzu
Comment[el]=Προσθέστε τους διαδικτυακούς σας λογαριασμούς
Comment[en_GB]=Add Your Online Accounts
Comment[es]=Añadir cuentas en línea
Comment[fi]=Lisää verkkotilisi
Comment[fr]=Ajouter vos comptes en ligne
Comment[gl]=Engadir as contas de internet
Comment[it]=Aggiungi i tuoi account online
Comment[ko]=내 온라인 계정 추가
Comment[nl]=Uw online accounts toevoegen
Comment[nn]=Legg til nettkontoar
Comment[pl]=Dodaj swoje konta internetowe
Comment[pt]=Adicionar as Suas Contas 'Online'
Comment[pt_BR]=Adicione suas contas online
Comment[sl]=Dodajte vaše spletne račune
Comment[sv]=Lägg till dina nätkonton
Comment[uk]=Додавання ваших облікових записів
Comment[x-test]=xxAdd Your Online Accountsxx
Comment[zh_CN]=添加您的在线帐号
Comment[zh_TW]=新增您的網路帳號
Icon=applications-internet
Exec=plasma-settings -m kcm_mobile_kaccounts
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-ParentApp=kcontrol
X-KDE-FormFactors=handset,tablet,mediacenter
X-KDE-System-Settings-Parent-Category=display
X-KDE-Weight=70
X-KDE-Keywords=accounts, online
X-KDE-Keywords[ca]=comptes,en línia
X-KDE-Keywords[ca@valencia]=comptes,en línia
X-KDE-Keywords[cs]=účty, online
X-KDE-Keywords[da]=konti, online
X-KDE-Keywords[de]=accounts, online, zugang
X-KDE-Keywords[el]=λογαριασμοί, διαδικτυακοί
X-KDE-Keywords[en_GB]=accounts, online
X-KDE-Keywords[es]=cuentas, en línea
X-KDE-Keywords[fi]=tilit, verkko
X-KDE-Keywords[fr]=comptes, en ligne
X-KDE-Keywords[gl]=contas, internet
X-KDE-Keywords[it]=account, online
X-KDE-Keywords[ko]=accounts, online, 계정, 온라인
X-KDE-Keywords[nl]=accounts, online
X-KDE-Keywords[nn]=kontoar, nett, Internett, tilkopla
X-KDE-Keywords[pl]=konta,internet,online
X-KDE-Keywords[pt]=contas, online
X-KDE-Keywords[pt_BR]=contas, online
X-KDE-Keywords[sl]=računi,splet
X-KDE-Keywords[sv]=konton, uppkoppling
X-KDE-Keywords[uk]=облікові записи,мережа,accounts,online
X-KDE-Keywords[x-test]=xxaccountsxx,xx onlinexx
X-KDE-Keywords[zh_CN]=accounts, online, 账户, 在线
X-KDE-Keywords[zh_TW]=accounts, online, 帳號, 線上, 網路
Categories=Qt;KDE;X-KDE-settings-system;
/*
* Copyright 2015 Martin Klapetek <mklapetek@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.7
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.0 as Controls
import org.kde.kirigami 2.4 as Kirigami
import org.kde.active.settings 2.0 as ActiveSettings
import org.kde.kaccounts 1.0
import org.kde.kcm 1.2
import Ubuntu.OnlineAccounts 0.1 as OA
SimpleKCM {
id: kaccountsRoot
objectName: "kaccountsModule"
// Existing accounts
ListView {
clip: true
model: OA.AccountServiceModel {
id: accountsModel
service: "global"
includeDisabled: true
}
delegate: Kirigami.SwipeListItem {
Controls.Label