diff --git a/applets/CMakeLists.txt b/applets/CMakeLists.txt index 10b62eaa0..b404fa256 100644 --- a/applets/CMakeLists.txt +++ b/applets/CMakeLists.txt @@ -1,21 +1,21 @@ plasma_install_package(activitybar org.kde.plasma.activitybar) add_subdirectory(icon) plasma_install_package(analog-clock org.kde.plasma.analogclock) plasma_install_package(mediacontroller org.kde.plasma.mediacontroller) plasma_install_package(panelspacer org.kde.plasma.panelspacer) plasma_install_package(lock_logout org.kde.plasma.lock_logout) add_subdirectory(systemmonitor) add_subdirectory(batterymonitor) +add_subdirectory(calendar) add_subdirectory(devicenotifier) add_subdirectory(digital-clock) -plasma_install_package(calendar org.kde.plasma.calendar) plasma_install_package(clipboard org.kde.plasma.clipboard) if(NOT WIN32) # #notifications # #should compile also on windows? (even if doesn't really make sense) add_subdirectory(notifications) add_subdirectory(systemtray) endif() diff --git a/applets/calendar/CMakeLists.txt b/applets/calendar/CMakeLists.txt new file mode 100644 index 000000000..166d663b8 --- /dev/null +++ b/applets/calendar/CMakeLists.txt @@ -0,0 +1,14 @@ +set(calendarapplet_SRCS + calendarapplet.cpp +) + +add_library(plasma_applet_calendar MODULE ${calendarapplet_SRCS}) + +kcoreaddons_desktop_to_json(plasma_applet_calendar package/metadata.desktop) + +target_link_libraries(plasma_applet_calendar + KF5::Plasma) + +install(TARGETS plasma_applet_calendar DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/applets) + +plasma_install_package(package org.kde.plasma.calendar) diff --git a/applets/calendar/contents/ui/configGeneral.qml b/applets/calendar/calendarapplet.cpp similarity index 63% copy from applets/calendar/contents/ui/configGeneral.qml copy to applets/calendar/calendarapplet.cpp index b43394cd3..ec605b0a0 100644 --- a/applets/calendar/contents/ui/configGeneral.qml +++ b/applets/calendar/calendarapplet.cpp @@ -1,39 +1,43 @@ /* - * Copyright 2015 Martin Klapetek + * Copyright 2016 Kai Uwe Broulik * * 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 + * 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 +#include "calendarapplet.h" + +#include -Item { - id: generalPage - - width: childrenRect.width - height: childrenRect.height +CalendarApplet::CalendarApplet(QObject *parent, const QVariantList &data) + : Plasma::Applet(parent, data) +{ - property alias cfg_showWeekNumbers: showWeekNumbers.checked +} - QtLayouts.ColumnLayout { - QtControls.CheckBox { - id: showWeekNumbers - text: i18n("Show week numbers in Calendar") - } - } +CalendarApplet::~CalendarApplet() +{ } + +int CalendarApplet::weekNumber(const QDateTime &dateTime) const +{ + return dateTime.date().weekNumber(); +} + +K_EXPORT_PLASMA_APPLET_WITH_JSON(calendar, CalendarApplet, "metadata.json") + +#include "calendarapplet.moc" diff --git a/applets/calendar/contents/config/config.qml b/applets/calendar/calendarapplet.h similarity index 66% copy from applets/calendar/contents/config/config.qml copy to applets/calendar/calendarapplet.h index 24f3b4572..41b1b0d9b 100644 --- a/applets/calendar/contents/config/config.qml +++ b/applets/calendar/calendarapplet.h @@ -1,36 +1,38 @@ /* - * Copyright 2013 Bhushan Shah + * Copyright 2016 Kai Uwe Broulik * * 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 + * along with this program. If not, see . + * */ -import QtQuick 2.0 +#pragma once + +#include + +class QDateTime; + +class CalendarApplet : public Plasma::Applet +{ + Q_OBJECT + +public: + explicit CalendarApplet(QObject *parent, const QVariantList &data); + ~CalendarApplet() override; -import org.kde.plasma.configuration 2.0 + Q_INVOKABLE int weekNumber(const QDateTime &dateTime) const; -ConfigModel { - ConfigCategory { - name: i18n("General") - icon: "preferences-system-time" - source: "configGeneral.qml" - } -// ConfigCategory { -// name: i18n("Agenda") -// icon: "view-calendar-agenda" -// source: "configAgenda.qml" -// } -} +}; diff --git a/applets/calendar/contents/config/config.qml b/applets/calendar/package/contents/config/config.qml similarity index 100% rename from applets/calendar/contents/config/config.qml rename to applets/calendar/package/contents/config/config.qml diff --git a/applets/calendar/contents/config/main.xml b/applets/calendar/package/contents/config/main.xml similarity index 87% rename from applets/calendar/contents/config/main.xml rename to applets/calendar/package/contents/config/main.xml index 4c8ee0123..728ac4e6c 100644 --- a/applets/calendar/contents/config/main.xml +++ b/applets/calendar/package/contents/config/main.xml @@ -1,19 +1,22 @@ 9 17 false + + d + diff --git a/applets/calendar/contents/images/mini-calendar.svgz b/applets/calendar/package/contents/images/mini-calendar.svgz similarity index 100% rename from applets/calendar/contents/images/mini-calendar.svgz rename to applets/calendar/package/contents/images/mini-calendar.svgz diff --git a/applets/calendar/contents/ui/configAgenda.qml b/applets/calendar/package/contents/ui/configAgenda.qml similarity index 100% rename from applets/calendar/contents/ui/configAgenda.qml rename to applets/calendar/package/contents/ui/configAgenda.qml diff --git a/applets/calendar/contents/ui/configGeneral.qml b/applets/calendar/package/contents/ui/configGeneral.qml similarity index 52% rename from applets/calendar/contents/ui/configGeneral.qml rename to applets/calendar/package/contents/ui/configGeneral.qml index b43394cd3..78efb419f 100644 --- a/applets/calendar/contents/ui/configGeneral.qml +++ b/applets/calendar/package/contents/ui/configGeneral.qml @@ -1,39 +1,70 @@ /* * 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 Item { id: generalPage width: childrenRect.width height: childrenRect.height property alias cfg_showWeekNumbers: showWeekNumbers.checked + property string cfg_compactDisplay QtLayouts.ColumnLayout { QtControls.CheckBox { id: showWeekNumbers text: i18n("Show week numbers in Calendar") } + + QtLayouts.RowLayout { + QtControls.Label { + text: i18nc("What information is shown in the calendar icon", "Icon:") + } + + QtControls.ComboBox { + id: compactDisplayCombo + QtLayouts.Layout.minimumWidth: units.gridUnit * 7 // horrible default sizing in ComboBox + model: [{ + text: i18nc("Show the number of the day (eg. 31) in the icon", "Day in month"), + value: "d" + }, { + text: i18nc("Show the week number (eg. 50) in the icon", "Week number"), + value: "w" + }] + onActivated: { + cfg_compactDisplay = compactDisplayCombo.model[index].value + } + + Component.onCompleted: { + for (var i = 0, length = model.length; i < length; ++i) { + if (model[i].value === cfg_compactDisplay) { + currentIndex = i + return + } + } + } + } + } } } diff --git a/applets/calendar/contents/ui/main.qml b/applets/calendar/package/contents/ui/main.qml similarity index 63% rename from applets/calendar/contents/ui/main.qml rename to applets/calendar/package/contents/ui/main.qml index d4c874d8b..a9f0d0b52 100644 --- a/applets/calendar/contents/ui/main.qml +++ b/applets/calendar/package/contents/ui/main.qml @@ -1,72 +1,106 @@ /* * Copyright 2013 Heena Mahour * Copyright 2013 Sebastian Kügler + * Copyright 2016 Kai Uwe Broulik * * 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, see . */ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.calendar 2.0 Item { Plasmoid.switchWidth: units.gridUnit * 12 Plasmoid.switchHeight: units.gridUnit * 12 Plasmoid.toolTipMainText: Qt.formatDate(dataSource.data.Local.DateTime, "dddd") Plasmoid.toolTipSubText: { // this logic is taken from digital-clock: // remove "dddd" from the locale format string // /all/ locales in LongFormat have "dddd" either // at the beginning or at the end. so we just // remove it + the delimiter and space var format = Qt.locale().dateFormat(Locale.LongFormat); format = format.replace(/(^dddd.?\s)|(,?\sdddd$)/, ""); return Qt.formatDate(dataSource.data.Local.DateTime, format) } Layout.minimumWidth: units.iconSizes.large Layout.minimumHeight: units.iconSizes.large + PlasmaCore.DataSource { + id: dataSource + engine: "time" + connectedSources: ["Local"] + interval: 60000 + intervalAlignment: PlasmaCore.Types.AlignToMinute + } + + Plasmoid.compactRepresentation: MouseArea { + onClicked: plasmoid.expanded = !plasmoid.expanded + + PlasmaCore.IconItem { + anchors.fill: parent + source: Qt.resolvedUrl("../images/mini-calendar.svgz") + + PlasmaComponents.Label { + anchors { + fill: parent + margins: Math.round(parent.width * 0.1) + } + height: undefined + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 1000 + minimumPointSize: theme.smallestFont.pointSize + text: { + var d = new Date(dataSource.data.Local.DateTime) + var format = plasmoid.configuration.compactDisplay + + if (format === "w") { + return plasmoid.nativeInterface.weekNumber(d) + } + + return Qt.formatDate(d, format) + } + fontSizeMode: Text.Fit + } + } + } + Plasmoid.fullRepresentation: Item { // sizing taken from digital clock readonly property int _minimumWidth: calendar.showWeekNumbers ? Math.round(_minimumHeight * 1.75) : Math.round(_minimumHeight * 1.5) readonly property int _minimumHeight: units.gridUnit * 14 Layout.minimumWidth: _minimumWidth Layout.minimumHeight: _minimumHeight Layout.preferredWidth: _minimumWidth Layout.preferredHeight: Math.round(_minimumHeight * 1.5) - PlasmaCore.DataSource { - id: dataSource - engine: "time" - connectedSources: ["Local"] - interval: 60000 - intervalAlignment: PlasmaCore.Types.AlignToMinute - } - MonthView { id: calendar today: dataSource.data["Local"]["DateTime"] showWeekNumbers: plasmoid.configuration.showWeekNumbers anchors.fill: parent } } } diff --git a/applets/calendar/metadata.desktop b/applets/calendar/package/metadata.desktop similarity index 100% rename from applets/calendar/metadata.desktop rename to applets/calendar/package/metadata.desktop