commit e8ef960f472c3c8555af631a0e7ee171672efe0b Author: qewer33 Date: Sun Dec 12 13:16:29 2021 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9decb29 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.directory +ClearClock.creator.user +ClearClock.cxxflags +ClearClock.cflags +ClearClock.creator diff --git a/ClearClock.config b/ClearClock.config new file mode 100644 index 0000000..e0284f4 --- /dev/null +++ b/ClearClock.config @@ -0,0 +1,2 @@ +// Add predefined macros for your project here. For example: +// #define THE_ANSWER 42 diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ + diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..ada2777 --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ + #!/usr/bin/env bash + +PROJECT_ID="org.kde.plasma.clearclock" +INSTALL_LOCATION="/home/qewer33/.local/share/plasma/plasmoids/" + +mkdir "${INSTALL_LOCATION}${PROJECT_ID}" +cp -R "package/." "${INSTALL_LOCATION}${PROJECT_ID}/" diff --git a/package/contents/config/config.qml b/package/contents/config/config.qml new file mode 100644 index 0000000..73b624d --- /dev/null +++ b/package/contents/config/config.qml @@ -0,0 +1,21 @@ +/* + SPDX-FileCopyrightText: 2013 Bhushan Shah + SPDX-FileCopyrightText: 2015 Martin Klapetek + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL +*/ + +import QtQuick 2.0 +import QtQml 2.2 + +import org.kde.plasma.configuration 2.0 + +ConfigModel { + id: configModel + + ConfigCategory { + name: i18n("Appearance") + icon: "preferences-desktop-color" + source: "configAppearance.qml" + } +} diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml new file mode 100644 index 0000000..3a885a0 --- /dev/null +++ b/package/contents/config/main.xml @@ -0,0 +1,93 @@ + + + + + + + + + 1 + + + + #ffffff + + + + + + + + true + + + + false + + + + 220 + + + + + true + + + + #5e4573 + + + + + + + + false + + + + false + + + + 100 + + + + + true + + + + d MMMM yyyy + + + + #ffffff + + + + + + + + false + + + + false + + + + 24 + + + + 2 + + + diff --git a/package/contents/fonts/Outfit-Bold.ttf b/package/contents/fonts/Outfit-Bold.ttf new file mode 100644 index 0000000..625fa99 Binary files /dev/null and b/package/contents/fonts/Outfit-Bold.ttf differ diff --git a/package/contents/fonts/Outfit-Regular.ttf b/package/contents/fonts/Outfit-Regular.ttf new file mode 100644 index 0000000..7a60fc6 Binary files /dev/null and b/package/contents/fonts/Outfit-Regular.ttf differ diff --git a/package/contents/fonts/Smooch-Regular.ttf b/package/contents/fonts/Smooch-Regular.ttf new file mode 100644 index 0000000..6530f04 Binary files /dev/null and b/package/contents/fonts/Smooch-Regular.ttf differ diff --git a/package/contents/ui/configAppearance.qml b/package/contents/ui/configAppearance.qml new file mode 100644 index 0000000..3f12c13 --- /dev/null +++ b/package/contents/ui/configAppearance.qml @@ -0,0 +1,419 @@ +/* + * + */ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 as QtControls +import QtQuick.Layouts 1.15 as QtLayouts +import QtQuick.Dialogs 1.2 + +import org.kde.kirigami 2.3 as Kirigami + +Item { + id: appearancePage + width: childrenRect.width + height: childrenRect.height + + signal configurationChanged + + property alias cfg_clockUse24hFormat: use24hFormat.checkState + property string cfg_clockFontColor: clockFontColorRect.color + property string cfg_clockFontFamily + property alias cfg_clockBoldText: clockBoldCheckBox.checked + property alias cfg_clockItalicText: clockItalicCheckBox.checked + property alias cfg_clockFontSize: clockFontSizeSpinBox.value + + property alias cfg_showDayDisplay: showDayDisplayCheckBox.checked + property string cfg_dayFontColor: dayFontColorRect.color + property string cfg_dayFontFamily + property alias cfg_dayBoldText: dayBoldCheckBox.checked + property alias cfg_dayItalicText: dayItalicCheckBox.checked + property alias cfg_dayFontSize: dayFontSizeSpinBox.value + + property alias cfg_showDateDisplay: showDateDisplayCheckBox.checked + property alias cfg_dateCustomDateFormat: customDateFormat.text + property string cfg_dateFontColor: dateFontColorRect.color + property string cfg_dateFontFamily + property alias cfg_dateBoldText: dateBoldCheckBox.checked + property alias cfg_dateItalicText: dateItalicCheckBox.checked + property alias cfg_dateFontSize: dateFontSizeSpinBox.value + + function fixFontFamilyChange(id, comboBox) { + // HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined + if (id) { + for (var i = 0, j = fontsModel.count; i < j; ++i) { + if (fontsModel.get(i).value === id) { + comboBox.currentIndex = i + break + } + } + } + } + + onCfg_clockFontFamilyChanged: { + fixFontFamilyChange(cfg_clockFontFamily, clockFontFamilyComboBox) + } + + onCfg_dayFontFamilyChanged: { + fixFontFamilyChange(cfg_dayFontFamily, dayFontFamilyComboBox) + } + + onCfg_dateFontFamilyChanged: { + fixFontFamilyChange(cfg_dateFontFamily, dateFontFamilyComboBox) + } + + ListModel { + id: fontsModel + Component.onCompleted: { + var arr = [] // use temp array to avoid constant binding stuff + arr.push({ + "text": i18nc("Use default font", "Default"), + "value": "" + }) + + var fonts = Qt.fontFamilies() + var foundIndex = 0 + for (var i = 0, j = fonts.length; i < j; ++i) { + arr.push({ + "text": fonts[i], + "value": fonts[i] + }) + } + append(arr) + } + } + + QtLayouts.ColumnLayout { + id: layout + anchors.fill: parent + + QtLayouts.ColumnLayout { + QtLayouts.Layout.fillWidth: true + spacing: 10 + + QtControls.Label { + text: i18n("Clock Display Settings") + font.bold: true + font.pixelSize: 17 + } + + QtControls.CheckBox { + id: use24hFormat + text: i18n("Use 24-hour clock") + } + + QtLayouts.RowLayout { + + QtControls.Label { + text: i18n("Font style:") + } + + QtControls.Button { + id: clockFontColorButton + text: i18n(" ") + Rectangle { + id: clockFontColorRect + anchors.fill: parent + border.color: "darkgray" + border.width: 1 + radius: 4 + color: cfg_clockFontColor + opacity: if (enabled) 1 + else 0.4 + } + MouseArea { + anchors.fill: parent + onClicked: clockFontColorDialog.open() + } + } + + ColorDialog { + id: clockFontColorDialog + title: "Select Background Color" + currentColor: cfg_clockFontColor + onAccepted: { + cfg_clockFontColor = clockFontColorDialog.color + } + } + + QtControls.ComboBox { + id: clockFontFamilyComboBox + QtLayouts.Layout.fillWidth: true + // ComboBox's sizing is just utterly broken + QtLayouts.Layout.minimumWidth: units.gridUnit * 10 + model: fontsModel + // doesn't autodeduce from model because we manually populate it + textRole: "text" + + onCurrentIndexChanged: { + var current = model.get(currentIndex) + if (current) { + cfg_clockFontFamily = current.value + appearancePage.configurationChanged() + } + } + } + + QtControls.Button { + id: clockBoldCheckBox + // ToolTip.text: i18n("Bold text") + icon.name: "format-text-bold" + checkable: true + // Accessible.name: ToolTip.text + } + + QtControls.Button { + id: clockItalicCheckBox + // ToolTip.text: i18n("Italic text") + icon.name: "format-text-italic" + checkable: true + // Accessible.name: ToolTip.text + } + + QtControls.SpinBox { + id: clockFontSizeSpinBox + + from: 10 + to: 350 + } + + QtControls.Label { + text: "px" + } + } + } + + QtLayouts.ColumnLayout { + QtLayouts.Layout.fillWidth: true + spacing: 10 + + QtControls.Label { + text: i18n("Day Display Settings") + font.bold: true + font.pixelSize: 17 + } + + QtControls.CheckBox { + id: showDayDisplayCheckBox + text: i18n("Show day display") + } + + QtLayouts.RowLayout { + QtLayouts.Layout.fillWidth: true + enabled: showDayDisplayCheckBox.checked + + QtControls.Label { + text: i18n("Font style:") + opacity: if (enabled) 1 + else 0.4 + } + + QtControls.Button { + id: dayFontColorButton + text: i18n(" ") + Rectangle { + id: dayFontColorRect + anchors.fill: parent + border.color: "darkgray" + border.width: 1 + radius: 4 + color: cfg_dayFontColor + opacity: if (enabled) 1 + else 0.4 + } + MouseArea { + anchors.fill: parent + onClicked: dayFontColorDialog.open() + } + } + + ColorDialog { + id: dayFontColorDialog + title: "Select Background Color" + currentColor: cfg_dayFontColor + onAccepted: { + cfg_dayFontColor = dayFontColorDialog.color + } + } + + QtControls.ComboBox { + id: dayFontFamilyComboBox + QtLayouts.Layout.fillWidth: true + // ComboBox's sizing is just utterly broken + QtLayouts.Layout.minimumWidth: units.gridUnit * 10 + model: fontsModel + // doesn't autodeduce from model because we manually populate it + textRole: "text" + + onCurrentIndexChanged: { + var current = model.get(currentIndex) + if (current) { + cfg_dayFontFamily = current.value + appearancePage.configurationChanged() + } + } + } + + QtControls.Button { + id: dayBoldCheckBox + // ToolTip.text: i18n("Bold text") + icon.name: "format-text-bold" + checkable: true + // Accessible.name: ToolTip.text + } + + QtControls.Button { + id: dayItalicCheckBox + // ToolTip.text: i18n("Italic text") + icon.name: "format-text-italic" + checkable: true + // Accessible.name: ToolTip.text + } + + QtControls.SpinBox { + id: dayFontSizeSpinBox + + from: 10 + to: 350 + } + + QtControls.Label { + text: "px" + opacity: if (enabled) 1 + else 0.4 + } + } + } + + QtLayouts.ColumnLayout { + QtLayouts.Layout.fillWidth: true + spacing: 10 + + QtControls.Label { + text: i18n("Date Display Settings") + font.bold: true + font.pixelSize: 17 + } + + QtControls.CheckBox { + id: showDateDisplayCheckBox + text: i18n("Show date display") + } + + QtLayouts.RowLayout { + enabled: showDateDisplayCheckBox.checked + + QtControls.Label { + text: i18n("Date format:") + } + + QtLayouts.RowLayout { + QtControls.TextField { + id: customDateFormat + QtLayouts.Layout.fillWidth: true + } + + QtControls.Button { + // ToolTip.text: i18n("Time format documentation") + icon.name: "exifinfo" + // Accessible.name: ToolTip.text + onClicked: Qt.openUrlExternally(link) + } + } + } + + QtLayouts.RowLayout { + QtLayouts.Layout.fillWidth: true + enabled: showDateDisplayCheckBox.checked + + QtControls.Label { + text: i18n("Font style:") + opacity: if (enabled) 1 + else 0.4 + } + + QtControls.Button { + id: dateFontColorButton + text: i18n(" ") + Rectangle { + id: dateFontColorRect + anchors.fill: parent + border.color: "darkgray" + border.width: 1 + radius: 4 + color: cfg_dateFontColor + opacity: if (enabled) 1 + else 0.4 + } + MouseArea { + anchors.fill: parent + onClicked: dateFontColorDialog.open() + } + } + + ColorDialog { + id: dateFontColorDialog + title: "Select Background Color" + currentColor: cfg_dateFontColor + onAccepted: { + cfg_dateFontColor = dateFontColorDialog.color + } + } + + QtControls.ComboBox { + id: dateFontFamilyComboBox + QtLayouts.Layout.fillWidth: true + // ComboBox's sizing is just utterly broken + QtLayouts.Layout.minimumWidth: units.gridUnit * 10 + model: fontsModel + // doesn't autodeduce from model because we manually populate it + textRole: "text" + + onCurrentIndexChanged: { + var current = model.get(currentIndex) + if (current) { + cfg_dateFontFamily = current.value + appearancePage.configurationChanged() + } + } + } + + QtControls.Button { + id: dateBoldCheckBox + // ToolTip.text: i18n("Bold text") + icon.name: "format-text-bold" + checkable: true + // Accessible.name: ToolTip.text + } + + QtControls.Button { + id: dateItalicCheckBox + // ToolTip.text: i18n("Italic text") + icon.name: "format-text-italic" + checkable: true + // Accessible.name: ToolTip.text + } + + QtControls.SpinBox { + id: dateFontSizeSpinBox + + from: 10 + to: 350 + } + + QtControls.Label { + text: "px" + opacity: if (enabled) 1 + else 0.4 + } + } + } + } +} + +/*##^## +Designer { + D{i:0;autoSize:true;height:480;width:640}D{i:1}D{i:3}D{i:2} +} +##^##*/ + diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml new file mode 100644 index 0000000..ae9f639 --- /dev/null +++ b/package/contents/ui/main.qml @@ -0,0 +1,123 @@ +/* + SPDX-FileCopyrightText: 2021 qewer33 + SPDX-License-Identifier: LGPL-2.1-or-later +*/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.12 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.components 3.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras + +Item { + id: root + + Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation + Plasmoid.backgroundHints: PlasmaCore.Types.ConfigurableBackground + + readonly property date currentDateTime: dataSource.data.Local ? dataSource.data.Local.DateTime : new Date() + + PlasmaCore.DataSource { + id: dataSource + engine: "time" + connectedSources: ["Local"] + interval: 60000 + intervalAlignment: PlasmaCore.Types.AlignToMinute + } + + FontLoader { + id: fontOutfitBold + source: "../fonts/Outfit-Bold.ttf" + } + + FontLoader { + id: fontOutfitRegular + source: "../fonts/Outfit-Regular.ttf" + } + + FontLoader { + id: fontSmooch + source: "../fonts/Smooch-Regular.ttf" + } + + function max(a, b) { + if (a > b) + return a + else + return b + } + + Plasmoid.fullRepresentation: ColumnLayout { + anchors.fill: parent + spacing: -20 + + TextMetrics { + id: textMetricsTimeLabel + font.family: timeLabel.font.family + font.pixelSize: timeLabel.font.pixelSize + font.bold: timeLabel.font.bold + text: " 99:99 " + } + + TextMetrics { + id: textMetricsDayLabel + font.family: dayLabel.font.family + font.pixelSize: dayLabel.font.pixelSize + text: " Wednesday " + } + + Item { + width: max(textMetricsTimeLabel.width, textMetricsDayLabel.width) + height: max(textMetricsTimeLabel.height, textMetricsDayLabel.height) + Layout.alignment: Qt.AlignCenter + + PlasmaComponents.Label { + id: timeLabel + anchors.centerIn: parent + + text: Qt.formatTime(currentDateTime).replace(":", ".") + + color: plasmoid.configuration.clockFontColor + font.family: if (plasmoid.configuration.clockFontFamily === "") fontOutfitBold.name + else plasmoid.configuration.clockFontFamily + font.bold: plasmoid.configuration.clockBoldText + font.italic: plasmoid.configuration.clockItalicText + font.pixelSize: plasmoid.configuration.clockFontSize + } + + PlasmaComponents.Label { + id: dayLabel + visible: plasmoid.configuration.showDayDisplay + anchors.centerIn: parent + + text: Qt.formatDate(currentDateTime, "dddd") + + color: plasmoid.configuration.dayFontColor + font.family: if (plasmoid.configuration.dayFontFamily === "") fontSmooch.name + else plasmoid.configuration.dayFontFamily + font.bold: plasmoid.configuration.daykBoldText + font.italic: plasmoid.configuration.dayItalicText + font.pixelSize: plasmoid.configuration.dayFontSize + } + } + + PlasmaComponents.Label { + id: dateLabel + visible: plasmoid.configuration.showDateDisplay + Layout.alignment: Qt.AlignCenter + + text: Qt.formatDate(currentDateTime, plasmoid.configuration.customDateFormat) + + color: plasmoid.configuration.dateFontColor + font.family: if (plasmoid.configuration.dateFontFamily === "") fontOutfitRegular.name + else plasmoid.configuration.dateFontFamily + font.bold: plasmoid.configuration.dateBoldText + font.italic: plasmoid.configuration.dateItalicText + font.pixelSize: plasmoid.configuration.dateFontSize + font.capitalization: Font.AllUppercase + font.letterSpacing: plasmoid.configuration.dateLetterSpacing + } + } +} diff --git a/package/metadata.json b/package/metadata.json new file mode 100644 index 0000000..e7a5f4f --- /dev/null +++ b/package/metadata.json @@ -0,0 +1,23 @@ +{ + "KPlugin": { + "Authors": [ + { + "Name": "qewer33" + } + ], + "Name": "ClearClock", + "Id": "org.kde.plasma.clearclock", + "Description": "A clean and customizable date/time display for your desktop", + "Category": "Utilities", + "Icon": "org.kde.plasma.analogclock", + "EnabledByDefault": true, + "License": "LGPL-2.1+", + "ServiceTypes": [ + "Plasma/Applet" + ], + "Version": "1.0", + "Website": "https://plasma.kde.org/" + }, + "X-Plasma-API": "declarativeappletscript", + "X-Plasma-MainScript": "ui/main.qml" +}