diff --git a/applets/digital-clock/package/contents/ui/configCalendar.qml b/applets/digital-clock/package/contents/ui/configCalendar.qml index 7ff92e556..c706f2049 100644 --- a/applets/digital-clock/package/contents/ui/configCalendar.qml +++ b/applets/digital-clock/package/contents/ui/configCalendar.qml @@ -1,72 +1,73 @@ /* * Copyright 2015 Martin Klapetek * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see */ import QtQuick 2.0 import QtQuick.Controls 1.0 as QtControls import QtQuick.Layouts 1.0 as QtLayouts import org.kde.plasma.calendar 2.0 as PlasmaCalendar Item { id: calendarPage width: childrenRect.width height: childrenRect.height signal configurationChanged property alias cfg_showWeekNumbers: showWeekNumbers.checked function saveConfig() { plasmoid.configuration.enabledCalendarPlugins = PlasmaCalendar.EventPluginsManager.enabledPlugins; } QtLayouts.ColumnLayout { QtControls.CheckBox { id: showWeekNumbers text: i18n("Show week numbers in Calendar") } QtControls.GroupBox { QtLayouts.Layout.fillWidth: true title: i18n("Available Calendar Plugins") flat: true Repeater { id: calendarPluginsRepeater model: PlasmaCalendar.EventPluginsManager.model delegate: QtLayouts.RowLayout { QtControls.CheckBox { text: model.display checked: model.checked onClicked: { //needed for model's setData to be called model.checked = checked; + calendarPage.configurationChanged(); } } } } } } Component.onCompleted: { PlasmaCalendar.EventPluginsManager.populateEnabledPluginsList(plasmoid.configuration.enabledCalendarPlugins); } } diff --git a/plasmacalendarintegration/HolidaysConfig.qml b/plasmacalendarintegration/HolidaysConfig.qml index 108ce2885..b16dbda2d 100644 --- a/plasmacalendarintegration/HolidaysConfig.qml +++ b/plasmacalendarintegration/HolidaysConfig.qml @@ -1,110 +1,112 @@ /* * Copyright 2013 Kai Uwe Broulik * Copyright 2015 Martin Klapetek * * 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) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * 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, see */ import QtQuick 2.0 import QtQuick.Controls 1.2 as QtControls import QtQuick.Layouts 1.0 import QtQuick.Dialogs 1.1 -import org.kde.plasma.private.digitalclock 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kholidays 1.0 as KHolidays import org.kde.holidayeventshelperplugin 1.0 Item { id: holidaysConfig width: parent.width height: parent.height + signal configurationChanged + function saveConfig() { - KHolidays.HolidayRegionsModel.saveConfig(); + configHelper.saveConfig(); } // This is just for getting the column width QtControls.CheckBox { id: checkbox visible: false } QmlConfigHelper { id: configHelper } ColumnLayout { anchors.fill: parent QtControls.TextField { id: filter Layout.fillWidth: true placeholderText: i18n("Search Holiday Regions") } QtControls.TableView { id: holidaysView signal toggleCurrent Layout.fillWidth: true Layout.fillHeight: true Keys.onSpacePressed: toggleCurrent() model: KHolidays.HolidayRegionsModel { id: holidaysModel } QtControls.TableViewColumn { width: checkbox.width delegate: QtControls.CheckBox { id: checkBox anchors.centerIn: parent - checked: styleData.value + checked: model ? configHelper.selectedRegions.indexOf(model.region) != -1 : false activeFocusOnTab: false // only let the TableView as a whole get focus onClicked: { //needed for model's setData to be called if (checked) { configHelper.addRegion(model.region); } else { configHelper.removeRegion(model.region); } + holidaysConfig.configurationChanged(); } } resizable: false movable: false } QtControls.TableViewColumn { role: "region" title: i18n("Region") } QtControls.TableViewColumn { role: "name" title: i18n("Name") } QtControls.TableViewColumn { role: "description" title: i18n("Description") } } } } diff --git a/plasmacalendarintegration/qmlhelper/holidayeventshelperplugin.cpp b/plasmacalendarintegration/qmlhelper/holidayeventshelperplugin.cpp index adf07631c..9287cd0d5 100644 --- a/plasmacalendarintegration/qmlhelper/holidayeventshelperplugin.cpp +++ b/plasmacalendarintegration/qmlhelper/holidayeventshelperplugin.cpp @@ -1,81 +1,80 @@ /* Copyright (c) 2015 Martin Klapetek 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 "holidayeventshelperplugin.h" #include #include #include #include class QmlConfigHelper : public QObject { Q_OBJECT + Q_PROPERTY(QStringList selectedRegions READ selectedRegions NOTIFY selectedRegionsChanged) public: QmlConfigHelper(QObject *parent = 0) : QObject(parent) { KSharedConfig::Ptr config = KSharedConfig::openConfig("plasma_calendar_holiday_regions"); m_configGroup = config->group("General"); - connect(this, &QmlConfigHelper::selectedRegionsChanged, [=] { - m_configGroup.writeEntry("selectedRegions", m_regions); - }); + m_regions = m_configGroup.readEntry("selectedRegions", QStringList()); } - ~QmlConfigHelper() + QStringList selectedRegions() const { - m_configGroup.sync(); + return m_regions; } Q_INVOKABLE void saveConfig() { + m_configGroup.writeEntry("selectedRegions", m_regions); m_configGroup.sync(); } Q_INVOKABLE void addRegion(const QString ®ion) { if (!m_regions.contains(region)) { m_regions.append(region); + Q_EMIT selectedRegionsChanged(); } - - Q_EMIT selectedRegionsChanged(); } Q_INVOKABLE void removeRegion(const QString ®ion) { - m_regions.removeOne(region); - - Q_EMIT selectedRegionsChanged(); + if (m_regions.removeOne(region)) { + Q_EMIT selectedRegionsChanged(); + } } Q_SIGNALS: void selectedRegionsChanged(); private: QStringList m_regions; KConfigGroup m_configGroup; }; void HolidayEventsHelperPlugin::registerTypes(const char* uri) { qmlRegisterType(uri, 1, 0, "QmlConfigHelper"); } #include "holidayeventshelperplugin.moc"