diff --git a/CMakeLists.txt b/CMakeLists.txt index ca803175c..fd889a3b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,169 +1,170 @@ project(plasma-desktop) set(PROJECT_VERSION "5.11.90") set(PROJECT_VERSION_MAJOR 5) cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(QT_MIN_VERSION "5.7.0") find_package(ECM 0.0.11 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMInstallIcons) include(ECMMarkAsTest) include(ECMMarkNonGuiExecutable) include(ECMOptionalAddSubdirectory) include(ECMQtDeclareLoggingCategory) include(FeatureSummary) include(CheckIncludeFiles) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Quick QuickWidgets DBus Widgets X11Extras Svg Concurrent ) set(KF5_MIN_VERSION "5.34.0") find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Auth Plasma PlasmaQuick DocTools I18n KCMUtils NewStuff KDELibs4Support Notifications NotifyConfig Attica Wallet Runner GlobalAccel Declarative People DBusAddons Activities ActivitiesStats Config ) find_package(LibKWorkspace CONFIG REQUIRED) find_package(LibTaskManager CONFIG REQUIRED) +find_package(LibColorCorrect CONFIG REQUIRED) find_package(KWinDBusInterface CONFIG REQUIRED) find_package(ScreenSaverDBusInterface CONFIG REQUIRED) find_package(KRunnerAppDBusInterface CONFIG REQUIRED) find_package(KSMServerDBusInterface CONFIG REQUIRED) find_package(KF5ItemModels CONFIG REQUIRED) find_package(KF5Emoticons CONFIG REQUIRED) find_package(AppStreamQt 0.10.4) set_package_properties(AppStreamQt PROPERTIES DESCRIPTION "Appstream integration" TYPE RECOMMENDED PURPOSE "Needed to allow appstream integration from application menus" ) find_package(KF5Baloo 5.15) set_package_properties(KF5Baloo PROPERTIES DESCRIPTION "File Searching" TYPE RECOMMENDED PURPOSE "Needed to build the File Search KCM" ) find_package(Fontconfig) set_package_properties(Fontconfig PROPERTIES DESCRIPTION "Font access configuration library" URL "http://www.freedesktop.org/wiki/Software/fontconfig" TYPE OPTIONAL PURPOSE "Needed to build font configuration and installation tools" ) find_package(X11) set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries" URL "http://www.x.org" TYPE REQUIRED PURPOSE "Required for building the X11 based workspace" ) find_package(UDev) set_package_properties(UDev PROPERTIES DESCRIPTION "UDev library" URL "http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html" TYPE OPTIONAL PURPOSE "Required for device discovery in keyboard daemon" ) find_package(XCB REQUIRED COMPONENTS XCB SHM IMAGE OPTIONAL_COMPONENTS XKB XINPUT ) set_package_properties(XCB PROPERTIES TYPE REQUIRED) add_feature_info("XCB-XKB" XCB_XKB_FOUND "Required for building kcm/keyboard") add_feature_info("libxft" X11_Xft_FOUND "X FreeType interface library required for font installation") find_package(Evdev) set_package_properties(Evdev PROPERTIES TYPE OPTIONAL) add_feature_info("Evdev" EVDEV_FOUND "Evdev driver headers needed for input KCM") find_package(Synaptics) set_package_properties(Synaptics PROPERTIES TYPE OPTIONAL) add_feature_info("Synaptics" SYNAPTICS_FOUND "Synaptics libraries needed for touchpad KCM") find_package(XorgLibinput) set_package_properties(XorgLibinput PROPERTIES TYPE OPTIONAL) add_feature_info("XorgLibinput" XORGLIBINPUT_FOUND "Libinput driver headers needed for input KCM") include(ConfigureChecks.cmake) find_package(Breeze ${PROJECT_VERSION} CONFIG) set_package_properties(Breeze PROPERTIES TYPE OPTIONAL PURPOSE "For setting the default window decoration plugin") if(${Breeze_FOUND}) if(${BREEZE_WITH_KDECORATION}) set(HAVE_BREEZE_DECO true) else() set(HAVE_BREEZE_DECO FALSE) endif() else() set(HAVE_BREEZE_DECO FALSE) endif() if(${AppStreamQt_FOUND}) set(HAVE_APPSTREAMQT true) endif() include_directories("${CMAKE_CURRENT_BINARY_DIR}") configure_file(config-workspace.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-workspace.h) configure_file(config-unix.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-unix.h ) configure_file(config-appstream.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-appstream.h ) configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h) configure_file(config-runtime.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-runtime.h) plasma_install_package(desktoppackage org.kde.plasma.desktop shells shell) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) add_subdirectory(layout-templates) add_subdirectory(doc) add_subdirectory(runners) add_subdirectory(containments) add_subdirectory(toolboxes) add_subdirectory(applets) add_subdirectory(dataengines) add_subdirectory(kcms) add_subdirectory(knetattach) add_subdirectory(attica-kde) add_subdirectory(imports/activitymanager/) add_subdirectory(solid-device-automounter) if(X11_Xkb_FOUND AND XCB_XKB_FOUND) add_subdirectory(kaccess) endif() install(FILES org.kde.plasmashell.metainfo.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/kcms/CMakeLists.txt b/kcms/CMakeLists.txt index b8c0b19db..f59b2d7fe 100644 --- a/kcms/CMakeLists.txt +++ b/kcms/CMakeLists.txt @@ -1,69 +1,70 @@ remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS) find_package(Freetype) set_package_properties(Freetype PROPERTIES DESCRIPTION "A font rendering engine" URL "http://www.freetype.org" TYPE OPTIONAL PURPOSE "Needed to build kfontinst, a simple font installer." ) set(libkxftconfig_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/fonts/kxftconfig.cpp ) if(X11_Xkb_FOUND AND XCB_XKB_FOUND) add_subdirectory( keyboard ) endif() if (EVDEV_FOUND AND XORGLIBINPUT_FOUND AND X11_Xinput_FOUND) add_subdirectory( input ) endif() add_subdirectory( access ) add_subdirectory( dateandtime ) add_subdirectory( autostart ) add_subdirectory( ksplash ) add_subdirectory( launch ) add_subdirectory( colors ) add_subdirectory( krdb ) add_subdirectory( style ) add_subdirectory( desktoptheme ) add_subdirectory( standard_actions ) add_subdirectory( keys ) add_subdirectory( ksmserver ) add_subdirectory( lookandfeel ) +add_subdirectory( nightcolor ) add_subdirectory( hardware ) add_subdirectory( desktoppaths ) add_subdirectory(activities) add_subdirectory(componentchooser) add_subdirectory(emoticons) add_subdirectory(icons) add_subdirectory(kded) add_subdirectory(knotify) add_subdirectory(formats) add_subdirectory(translations) add_subdirectory(spellchecking) add_subdirectory(phonon) add_subdirectory(runners) add_subdirectory(workspaceoptions) if (KF5Baloo_FOUND) add_subdirectory(baloo) endif() add_subdirectory(solid_actions) add_subdirectory(cursortheme) if (SYNAPTICS_FOUND AND X11_Xinput_FOUND) add_subdirectory(touchpad) endif() if( FREETYPE_FOUND ) if(FONTCONFIG_FOUND ) add_subdirectory( fonts ) endif() endif() if(FONTCONFIG_FOUND AND FREETYPE_FOUND) add_subdirectory( kfontinst ) endif() diff --git a/kcms/nightcolor/CMakeLists.txt b/kcms/nightcolor/CMakeLists.txt new file mode 100644 index 000000000..8789c3c31 --- /dev/null +++ b/kcms/nightcolor/CMakeLists.txt @@ -0,0 +1,24 @@ +# KI18N Translation Domain for this library +add_definitions(-DTRANSLATION_DOMAIN=\"kcm_nightcolor\") + +set(kcm_nightcolor_SRCS + kcm.cpp +) + +add_library(kcm_nightcolor MODULE ${kcm_nightcolor_SRCS}) + +target_link_libraries(kcm_nightcolor + KF5::QuickAddons + KF5::I18n + + PW::LibColorCorrect +) + +kcoreaddons_desktop_to_json(kcm_nightcolor "kcm_nightcolor.desktop" SERVICE_TYPES kcmodule.desktop) + +#this desktop file is installed only for retrocompatibility with sycoca +install(FILES kcm_nightcolor.desktop DESTINATION ${SERVICES_INSTALL_DIR}) + +install(TARGETS kcm_nightcolor DESTINATION ${PLUGIN_INSTALL_DIR}/kcms) + +kpackage_install_package(package kcm_nightcolor kcms) diff --git a/kcms/nightcolor/Messages.sh b/kcms/nightcolor/Messages.sh new file mode 100644 index 000000000..0a8bafc78 --- /dev/null +++ b/kcms/nightcolor/Messages.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT `find . -name "*.cpp" -o -name "*.qml"` -o $podir/kcm_nightcolor.pot diff --git a/kcms/nightcolor/kcm.cpp b/kcms/nightcolor/kcm.cpp new file mode 100644 index 000000000..5445b0bf4 --- /dev/null +++ b/kcms/nightcolor/kcm.cpp @@ -0,0 +1,55 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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 . +*********************************************************************/ +#include "kcm.h" + +#include +#include +#include +#include + +K_PLUGIN_FACTORY_WITH_JSON(KCMNightColorFactory, "kcm_nightcolor.json", registerPlugin();) + +namespace ColorCorrect { + +KCMNightColor::KCMNightColor(QObject *parent, const QVariantList& args) + : KQuickAddons::ConfigModule(parent, args) +{ + KAboutData* about = new KAboutData(QStringLiteral("kcm_nightcolor"), i18n("Night Color"), + QStringLiteral("0.1"), QString(), KAboutLicense::LGPL); + about->addAuthor(i18n("Roman Gilg"), QString(), QStringLiteral("subdiff@gmail.com")); + setAboutData(about); + setButtons(Apply | Default); +} + +void KCMNightColor::load() +{ + emit loadRelay(); +} + +void KCMNightColor::defaults() +{ + emit defaultsRelay(); +} + +void KCMNightColor::save() +{ + emit saveRelay(); +} + +} + +#include "kcm.moc" diff --git a/kcms/nightcolor/kcm.h b/kcms/nightcolor/kcm.h new file mode 100644 index 000000000..53a8c198a --- /dev/null +++ b/kcms/nightcolor/kcm.h @@ -0,0 +1,44 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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 . +*********************************************************************/ +#ifndef _KCM_NIGHTCOLOR_H +#define _KCM_NIGHTCOLOR_H + +#include + +namespace ColorCorrect { + +class KCMNightColor : public KQuickAddons::ConfigModule +{ + Q_OBJECT +public: + KCMNightColor(QObject* parent, const QVariantList& args); + ~KCMNightColor() {} + +public Q_SLOTS: + void load(); + void save(); + void defaults(); + +Q_SIGNALS: + void loadRelay(); + void saveRelay(); + void defaultsRelay(); +}; + +} + +#endif // _KCM_NIGHTCOLOR_H diff --git a/kcms/nightcolor/kcm_nightcolor.desktop b/kcms/nightcolor/kcm_nightcolor.desktop new file mode 100644 index 000000000..d78343f19 --- /dev/null +++ b/kcms/nightcolor/kcm_nightcolor.desktop @@ -0,0 +1,23 @@ +[Desktop Entry] +Icon=preferences-desktop-display-nightcolor +Exec=kcmshell5 kcm_nightcolor + +Type=Service +X-KDE-ServiceTypes=KCModule + +X-DocPath=https://userbase.kde.org/TODOX + +X-KDE-Library=kcm_nightcolor +X-KDE-ParentApp=kcontrol + +X-KDE-System-Settings-Parent-Category=display +X-KDE-Weight=120 + +Name=Night Color +Name[de]=Nachtfarbe +Comment=Adjust color temperatur at night to reduce eye strain +Comment[de]=Passe Farbtemperatur nachts an um Augen zu entlasten + +X-KDE-Keywords=kwin,window,manager,night,colors,redshift,eyes +X-KDE-Keywords[de]=KWin,Fenster,Verwaltung,Nacht,Farben,Redshift,Augen +Categories=Qt;KDE;X-KDE-settings-nightcolor diff --git a/kcms/nightcolor/package/contents/ui/LocationsAutoView.qml b/kcms/nightcolor/package/contents/ui/LocationsAutoView.qml new file mode 100644 index 000000000..383cead70 --- /dev/null +++ b/kcms/nightcolor/package/contents/ui/LocationsAutoView.qml @@ -0,0 +1,47 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 as Controls + +GridLayout { + columns: 2 + rowSpacing: units.smallSpacing + columnSpacing: units.smallSpacing + enabled: activator.checked + + Controls.Label { + text: i18n("Latitude") + Layout.alignment: Qt.AlignRight + enabled: false + } + NumberField { + id: latitudeField + backend: locator.latitude + enabled: false + } + Controls.Label { + text: i18n("Longitude") + Layout.alignment: Qt.AlignRight + enabled: false + } + NumberField { + id: longitudeField + backend: locator.longitude + enabled: false + } +} diff --git a/kcms/nightcolor/package/contents/ui/LocationsFixedView.qml b/kcms/nightcolor/package/contents/ui/LocationsFixedView.qml new file mode 100644 index 000000000..2ed1d984d --- /dev/null +++ b/kcms/nightcolor/package/contents/ui/LocationsFixedView.qml @@ -0,0 +1,75 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 as Controls + +GridLayout { + columns: 2 + rowSpacing: units.smallSpacing + columnSpacing: units.smallSpacing + enabled: activator.checked + + Connections { + target: root + onReset: reset() + } + + function reset() { + latitudeFixedField.backend = cA.latitudeFixed; + longitudeFixedField.backend = cA.longitudeFixed; + } + + Controls.Label { + text: i18n("Latitude") + Layout.alignment: Qt.AlignRight + } + NumberField { + id: latitudeFixedField + backend: cA.latitudeFixedStaged + validator: DoubleValidator {bottom: -90; top: 90; decimals: 10} + onBackendChanged: { + cA.latitudeFixedStaged = backend; + manualLocationsViewRow.change(); + calcNeedsSave(); + } + } + + Controls.Label { + text: i18n("Longitude") + Layout.alignment: Qt.AlignRight + } + NumberField { + id: longitudeFixedField + backend: cA.longitudeFixedStaged + validator: DoubleValidator {bottom: -180; top: 180; decimals: 10} + onBackendChanged: { + cA.longitudeFixedStaged = backend; + manualLocationsViewRow.change(); + calcNeedsSave(); + } + } + Controls.Button { + Layout.columnSpan: 2 + Layout.alignment: Qt.AlignHCenter + text: i18n("Detect location") + onClicked: { + latitudeFixedField.backend = locator.latitude; + longitudeFixedField.backend = locator.longitude; + } + } +} diff --git a/kcms/nightcolor/package/contents/ui/NumberField.qml b/kcms/nightcolor/package/contents/ui/NumberField.qml new file mode 100644 index 000000000..a678c7cb5 --- /dev/null +++ b/kcms/nightcolor/package/contents/ui/NumberField.qml @@ -0,0 +1,48 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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.1 +import QtQuick.Controls 1.4 as Controls + +Controls.TextField { + property double backend + + maximumLength: 10 + horizontalAlignment: TextInput.AlignHCenter + + inputMethodHints: Qt.ImhFormattedNumbersOnly + + text: backend + + onBackendChanged: { + text = backend; + } + + onTextChanged: { + var textFloat = parseFloat(text); + if (textFloat == undefined || isNaN(textFloat)) { + return; + } + backend = textFloat; + } + + onFocusChanged: { + var textFloat = parseFloat(text); + if (!focus && (textFloat == undefined || isNaN(textFloat))) { + text = backend; + } + } +} diff --git a/kcms/nightcolor/package/contents/ui/TimeField.qml b/kcms/nightcolor/package/contents/ui/TimeField.qml new file mode 100644 index 000000000..f160f0631 --- /dev/null +++ b/kcms/nightcolor/package/contents/ui/TimeField.qml @@ -0,0 +1,71 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 as Controls + +Controls.TextField { + id: field + + property date backend + horizontalAlignment: TextInput.AlignHCenter + + onBackendChanged: readIn() + + function getNormedDate() { + var nD = new Date(); + nD.setHours(backend.getHours()); + nD.setMinutes(backend.getMinutes()); + return nD; + } + + function readIn() { + if (!backend) { + return; + } + + var hours = backend.getHours(); + var minutes = backend.getMinutes(); + if (hours < 10) { + hours = "0" + hours; + } + if (minutes < 10) { + minutes = "0" + minutes; + } + + text = hours + ":" + minutes; + } + + function submit() { + if (text.length != 5) { + return; + } + var hours = text.slice(0, 2); + var minutes = text.slice(3, 5); + + var date = new Date(); + date.setHours(hours); + date.setMinutes(minutes); + + backend = date; + } + + inputMethodHints: Qt.ImhPreferNumbers + validator: RegExpValidator { regExp: /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/ } + + onEditingFinished: submit() +} diff --git a/kcms/nightcolor/package/contents/ui/TimingsView.qml b/kcms/nightcolor/package/contents/ui/TimingsView.qml new file mode 100644 index 000000000..2d14f3c57 --- /dev/null +++ b/kcms/nightcolor/package/contents/ui/TimingsView.qml @@ -0,0 +1,78 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 as Controls + +GridLayout { + columns: 2 + rowSpacing: units.smallSpacing + columnSpacing: units.smallSpacing + enabled: activator.checked + + property double latitude + property double longitude + + property var morningTimings: sunCalc.getMorningTimings(latitude, longitude) + property var eveningTimings: sunCalc.getEveningTimings(latitude, longitude) + + function reset() { + morningTimings = sunCalc.getMorningTimings(latitude, longitude); + eveningTimings = sunCalc.getEveningTimings(latitude, longitude); + } + + Controls.Label { + text: i18n("Sunrise begins") + Layout.alignment: Qt.AlignRight + enabled: false + } + TimeField { + id: mornBeginField + backend: morningTimings.begin + enabled: false + } + Controls.Label { + text: i18n("and ends") + Layout.alignment: Qt.AlignRight + enabled: false + } + TimeField { + id: mornEndField + backend: morningTimings.end + enabled: false + } + Controls.Label { + text: i18n("Sunset begins") + Layout.alignment: Qt.AlignRight + enabled: false + } + TimeField { + id: evenBeginField + backend: eveningTimings.begin + enabled: false + } + Controls.Label { + text: i18n("and ends") + Layout.alignment: Qt.AlignRight + enabled: false + } + TimeField { + id: evenEndField + backend: eveningTimings.end + enabled: false + } +} diff --git a/kcms/nightcolor/package/contents/ui/main.qml b/kcms/nightcolor/package/contents/ui/main.qml new file mode 100644 index 000000000..0772d2457 --- /dev/null +++ b/kcms/nightcolor/package/contents/ui/main.qml @@ -0,0 +1,360 @@ +/******************************************************************** +Copyright 2017 Roman Gilg + +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.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.4 as Controls + +import org.kde.kquickcontrolsaddons 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.extras 2.0 as PlasmaExtras + +import org.kde.colorcorrect 0.1 as CC + +Item { + id: root + + implicitHeight: units.gridUnit * 20 + + property int error: cA.error + + property bool defaultRequested: false + + CC.CompositorAdaptor { + id: cA + } + + CC.Geolocator { + id: locator + } + + CC.SunCalc { + id: sunCalc + } + + function calcNeedsSave() { + kcm.needsSave = cA.checkStaged(); + // If the user changes something manually again after + // Default was triggered, only allow a normal + // configuration change again: + defaultRequested = false; + } + + Connections { + target: kcm + onLoadRelay: cA.reloadData() + onSaveRelay: defaultRequested ? cA.sendConfigurationAll() : cA.sendConfiguration(); + onDefaultsRelay: { + if (!cA.nightColorAvailable) { + return; + } + activator.checked = cA.activeDefault; + tempSlider.value = cA.nightTemperatureDefault; + modeSwitcher.currentIndex = cA.modeDefault; + + // set everything else to default as well + cA.latitudeFixedStaged = cA.latitudeFixedDefault; + cA.longitudeFixedStaged = cA.longitudeFixedDefault; + + cA.morningBeginFixedStaged = cA.morningBeginFixedDefault; + cA.eveningBeginFixedStaged = cA.eveningBeginFixedDefault; + cA.transitionTimeStaged = cA.transitionTimeDefault; + + kcm.needsSave = cA.checkStagedAll(); + defaultRequested = true; + } + } + + Connections { + target: cA + onDataUpdated: calcNeedsSave() + onStagedDataReset: { + activator.checked = cA.active; + tempSlider.value = cA.nightTemperature; + modeSwitcher.currentIndex = cA.mode; + reset(); + calcNeedsSave(); + } + } + signal reset() + + Item { + id: main + width: childrenRect.width + height: childrenRect.height + + enabled: cA.nightColorAvailable + + Controls.CheckBox { + id: activator + text: i18n("Activate Night Color") + checked: cA.active + + onCheckedChanged: { + cA.activeStaged = checked; + calcNeedsSave(); + } + } + + ColumnLayout { + id: mainControls + anchors.top: activator.bottom + anchors.topMargin: units.largeSpacing + + enabled: activator.checked + + Controls.Label { + text: i18n("Night Color Temperature: ") + tempSlider.value + i18n(" K") + } + + Controls.Slider { + id: tempSlider + implicitWidth: units.gridUnit * 15 + + minimumValue: cA.minimalTemperature + maximumValue: cA.neutralTemperature + value: cA.nightTemperature + stepSize: 100 + + onValueChanged: { + cA.nightTemperatureStaged = value; + calcNeedsSave(); + } + } + + RowLayout { + spacing: units.largeSpacing + Controls.Label { + text: i18n("Operation mode:") + } + Controls.ComboBox { + id: modeSwitcher + width: theme.mSize(theme.defaultFont).width * 9 + model: [i18n("Automatic"), + i18n("Location"), + i18n("Times")] + currentIndex: cA.mode + onCurrentIndexChanged: { + cA.modeStaged = currentIndex; + advancedControlLoader.updatePage(currentIndex); + calcNeedsSave(); + } + } + } + } + + Loader { + id: advancedControlLoader + + anchors.top: mainControls.bottom + anchors.topMargin: units.largeSpacing + + function updatePage(index) { + sourceComponent = undefined; + var page; + if (index == CC.CompositorAdaptor.ModeLocation) { + page = manualLocationsView; + } else if (index == CC.CompositorAdaptor.ModeTimings) { + page = manualTimingsView; + } else { + page = automaticView; + } + + sourceComponent = page; + } + } + + Component { + id: automaticView + Row { + spacing: units.largeSpacing + + Loader { + sourceComponent: TimingsView { + latitude: locator.latitude + longitude: locator.longitude + } + } + Loader { + sourceComponent: LocationsAutoView {} + } + + } + } + + Component { + id: manualLocationsView + + Row { + id: manualLocationsViewRow + spacing: units.largeSpacing + + signal change() + + Loader { + sourceComponent: TimingsView { + latitude: cA.latitudeFixedStaged + longitude: cA.longitudeFixedStaged + + Connections { + target: manualLocationsViewRow + onChange: { + reset(); + } + } + } + } + Loader { + sourceComponent: LocationsFixedView {} + } + } + } + + Component { + id: manualTimingsView + Column { + spacing: units.smallSpacing + + GridLayout { + id: manualTimingsViewGrid + + columns: 3 + rowSpacing: units.smallSpacing + columnSpacing: units.smallSpacing + enabled: activator.checked && cA.timingsEnabled + + Connections { + target: root + onReset: { + mornBeginManField.backend = cA.morningBeginFixed; + evenBeginManField.backend = cA.eveningBeginFixed; + transTimeField.backend = cA.transitionTime; + } + } + + Controls.Label { + text: i18n("Sunrise begins") + Layout.alignment: Qt.AlignRight + } + TimeField { + id: mornBeginManField + backend: cA.morningBeginFixedStaged + onBackendChanged: {cA.morningBeginFixedStaged = backend; + calcNeedsSave(); + } + } + Controls.Label { + enabled: false + text: i18n("(HH:MM)") + } + Controls.Label { + text: i18n("Sunset begins") + Layout.alignment: Qt.AlignRight + } + TimeField { + id: evenBeginManField + backend: cA.eveningBeginFixedStaged + onBackendChanged: {cA.eveningBeginFixedStaged = backend; + calcNeedsSave(); + } + } + Controls.Label { + enabled: false + text: i18n("(HH:MM)") + } + Controls.Label { + text: i18n("Transition duration") + Layout.alignment: Qt.AlignRight + } + NumberField { + id: transTimeField + backend: cA.transitionTimeStaged + onBackendChanged: {cA.transitionTimeStaged = backend; + calcNeedsSave(); + } + + inputMethodHints: Qt.ImhDigitsOnly + validator: IntValidator {bottom: 1; top: 600;} // less than 12 hours (in minutes: 720) + } + Controls.Label { + enabled: false + text: i18n("(In minutes - min. 1, max. 600)") + } + } + Controls.Label { + id: manualTimingsError1 + anchors.horizontalCenter: manualTimingsViewGrid.horizontalCenter + visible: evenBeginManField.getNormedDate() - mornBeginManField.getNormedDate() <= 0 + + font.italic: true + text: i18n("Error: Morning not before evening.") + } + Controls.Label { + id: manualTimingsError2 + anchors.horizontalCenter: manualTimingsViewGrid.horizontalCenter + visible: { + if (manualTimingsError1.visible) { + return false; + } + var trTime = transTimeField.backend * 60 * 1000; + var mor = mornBeginManField.getNormedDate(); + var eve = evenBeginManField.getNormedDate(); + + return eve - mor <= trTime || eve - mor >= 86400000 - trTime; + } + font.italic: true + text: i18n("Error: Transition time overlaps.") + } + } + } + } + + // error message as overlay + Item { + width: 0.8 * main.width + height: 0.8 * main.height + anchors.centerIn: main + + visible: error != CC.CompositorAdaptor.ErrorCodeSuccess + + Rectangle { + anchors.centerIn: parent + width: errorMessage.contentWidth * 1.1 + height: errorMessage.contentHeight * 1.1 + color: theme.backgroundColor + opacity: 0.8 + + border { + width: units.devicePixelRatio + color: theme.textColor + } + } + + PlasmaExtras.Heading { + id: errorMessage + anchors.fill: parent + + level: 4 + text: cA.errorText + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + wrapMode: Text.Wrap + textFormat: Text.PlainText + } + } +} diff --git a/kcms/nightcolor/package/metadata.desktop b/kcms/nightcolor/package/metadata.desktop new file mode 100644 index 000000000..c60f7c835 --- /dev/null +++ b/kcms/nightcolor/package/metadata.desktop @@ -0,0 +1,22 @@ +[Desktop Entry] +Name=Night Color +Name[de]=Nachtfarbe +Comment=Adjust color temperatur at night to reduce eye strain +Comment[de]=Passe Farbtemperatur nachts an um Augen zu entlasten + +Icon=preferences-desktop +Encoding=UTF-8 +Keywords= +Type=Service +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Roman Gilg +X-KDE-PluginInfo-Email=subdiff@gmail.com +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=kcm_nightcolor +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-KDE-ServiceTypes=Plasma/Generic +X-Plasma-API=declarativeappletscript + +X-Plasma-MainScript=ui/main.qml +X-Plasma-RemoteLocation=