Initial commit

This commit is contained in:
qewer33 2021-12-12 13:16:29 +03:00
commit e8ef960f47
12 changed files with 694 additions and 0 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.directory
ClearClock.creator.user
ClearClock.cxxflags
ClearClock.cflags
ClearClock.creator

2
ClearClock.config Normal file
View file

@ -0,0 +1,2 @@
// Add predefined macros for your project here. For example:
// #define THE_ANSWER 42

1
README.md Normal file
View file

@ -0,0 +1 @@

7
install.sh Executable file
View file

@ -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}/"

View file

@ -0,0 +1,21 @@
/*
SPDX-FileCopyrightText: 2013 Bhushan Shah <bhush94@gmail.com>
SPDX-FileCopyrightText: 2015 Martin Klapetek <mklapetek@kde.org>
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"
}
}

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="Appearance">
<!-- Clock Display Settings -->
<entry name="clockUse24hFormat" type="UInt">
<label>Force the clock to use 12/24 hour time, instead of following the user locale.</label>
<default>1</default>
</entry>
<entry name="clockFontColor" type="Color">
<label>Color of text</label>
<default>#ffffff</default>
</entry>
<entry name="clockFontFamily" type="string">
<label>Sets the clock font family.</label>
<default></default>
</entry>
<entry name="clockBoldText" type="Bool">
<label>Sets the clock font to bold.</label>
<default>true</default>
</entry>
<entry name="clockItalicText" type="Bool">
<label>Sets the clock font to italic.</label>
<default>false</default>
</entry>
<entry name="clockFontSize" type="int">
<label>Sets the size of the day font in pixels.</label>
<default>220</default>
</entry>
<!-- Day Display Settings -->
<entry name="showDayDisplay" type="Bool">
<label>Whether the day should be shown in the clock.</label>
<default>true</default>
</entry>
<entry name="dayFontColor" type="Color">
<label>Color of text</label>
<default>#5e4573</default>
</entry>
<entry name="dayFontFamily" type="string">
<label>Sets the day font family.</label>
<default></default>
</entry>
<entry name="dayBoldText" type="Bool">
<label>Sets the day font to bold.</label>
<default>false</default>
</entry>
<entry name="dayItalicText" type="Bool">
<label>Sets the day font to italic.</label>
<default>false</default>
</entry>
<entry name="dayFontSize" type="int">
<label>Sets the size of the day font in pixels.</label>
<default>100</default>
</entry>
<!-- Date Display Settings -->
<entry name="showDateDisplay" type="Bool">
<label>Whether the date should be shown below the clock.</label>
<default>true</default>
</entry>
<entry name="customDateFormat" type="string">
<label>Custom date format string.</label>
<default>d MMMM yyyy</default>
</entry>
<entry name="dateFontColor" type="Color">
<label>Color of text</label>
<default>#ffffff</default>
</entry>
<entry name="dateFontFamily" type="string">
<label>Sets the date font family.</label>
<default></default>
</entry>
<entry name="dateBoldText" type="Bool">
<label>Sets the date font to bold.</label>
<default>false</default>
</entry>
<entry name="dateItalicText" type="Bool">
<label>Sets the date font to italic.</label>
<default>false</default>
</entry>
<entry name="dateFontSize" type="int">
<label>Sets the size of the date font in pixels.</label>
<default>24</default>
</entry>
<entry name="dateLetterSpacing" type="int">
<label>Sets the letter spacing of the date font.</label>
<default>2</default>
</entry>
</group>
</kcfg>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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}
}
##^##*/

View file

@ -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
}
}
}

23
package/metadata.json Normal file
View file

@ -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"
}