Commit b5551c17 authored by Piotr Kąkol's avatar Piotr Kąkol Committed by Nate Graham

Cleaned code for binary clock applet and added comments

Reviewers: ngraham

Reviewed By: ngraham

Subscribers: plasma-devel, ngraham, gladhorn

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D14267
parent 8713b500
......@@ -3,6 +3,7 @@
*
* Based on analog-clock config.qml:
* Copyright 2013 Marco Martin <mart@kde.org>
* Copyright 2018 Piotr Kąkol <piotrkakol@protonmail.com>
*
* 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
......@@ -29,4 +30,4 @@ ConfigModel {
icon: "preferences-desktop-color"
source: "configGeneral.qml"
}
}
}
\ No newline at end of file
......@@ -37,5 +37,4 @@
<default>blue</default>
</entry>
</group>
</kcfg>
</kcfg>
\ No newline at end of file
......@@ -2,9 +2,10 @@
* Rewrite of the KDE4-Plasma Binary Clock for KF5/Plasma/QML
*
* Copyright 2014 Joseph Wenninger <jowenn@kde.org>
* Copyright 2018 Piotr Kąkol <piotrkakol@protonmail.com>
*
* Original code (KDE4):
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
* Copyright 2007 by Davide Bettio <davide.bettio@kdemail.net>
*
* Based on FuzzyClock.qml:
......@@ -42,11 +43,10 @@ Item {
Layout.maximumWidth: Infinity
Layout.preferredWidth: Layout.minimumWidth
Layout.minimumHeight: 16+(units.smallSpacing * 5)
// Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity
Layout.minimumHeight: 16+(units.smallSpacing*5)
//Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity
//Layout.preferredHeight: Layout.minimumHeight
readonly property int formFactor: plasmoid.formFactor
readonly property bool constrained: formFactor == PlasmaCore.Types.Vertical || formFactor == PlasmaCore.Types.Horizontal
......@@ -60,82 +60,81 @@ Item {
readonly property bool showOffLeds: plasmoid.configuration.showOffLeds
readonly property bool showGrid: plasmoid.configuration.showGrid
readonly property int base: plasmoid.configuration.showBcdFormat? 10:16
readonly property int base: plasmoid.configuration.showBcdFormat ? 10 : 16
readonly property int dots: showSeconds? 6:4
readonly property int dots: showSeconds ? 6 : 4
readonly property color onColor: plasmoid.configuration.useCustomColorForActive?plasmoid.configuration.customColorForActive: theme.textColor
readonly property color offColor: plasmoid.configuration.useCustomColorForInactive?plasmoid.configuration.customColorForInactive:Qt.rgba(onColor.r,onColor.g,onColor.b,0.4)
readonly property color gridColor: plasmoid.configuration.useCustomColorForGrid?plasmoid.configuration.customColorForGrid:Qt.rgba(onColor.r,onColor.g,onColor.b,0.6)
readonly property color onColor: plasmoid.configuration.useCustomColorForActive ? plasmoid.configuration.customColorForActive : theme.textColor
readonly property color offColor: plasmoid.configuration.useCustomColorForInactive ? plasmoid.configuration.customColorForInactive : Qt.rgba(onColor.r, onColor.g, onColor.b, 0.4)
readonly property color gridColor: plasmoid.configuration.useCustomColorForGrid ? plasmoid.configuration.customColorForGrid : Qt.rgba(onColor.r, onColor.g, onColor.b, 0.6)
readonly property real dotSize: Math.min((height-5*units.smallSpacing)/4,(width-(dots+1)*units.smallSpacing)/dots)
readonly property real displayTop: (height - 4*dotSize-3*units.smallSpacing) /2
readonly property real displayLeft: (width - dots*dotSize-(dots-1)*units.smallSpacing) /2
readonly property real dotSize: Math.min((height-5*units.smallSpacing)/4, (width-(dots+1)*units.smallSpacing)/dots)
readonly property real displayTop: (height - 4*dotSize-3*units.smallSpacing)/2
readonly property real displayLeft: (width - dots*dotSize-(dots-1)*units.smallSpacing)/2
/* displaying calendar after clicking binary clock applet */
MouseArea {
id: mouseArea
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: plasmoid.expanded = !plasmoid.expanded
onClicked: plasmoid.expanded = !plasmoid.expanded
}
/*hours*/
/* hours */
DotColumn {
x:displayLeft
y:displayTop
val:hours/base
x: displayLeft
y: displayTop
val: hours/base
}
DotColumn {
x:displayLeft+(dotSize+units.smallSpacing)
y:displayTop
val:hours%base
x: displayLeft+(dotSize+units.smallSpacing)
y: displayTop
val: hours%base
}
/*minutes*/
/* minutes */
DotColumn {
x:displayLeft+(dotSize+units.smallSpacing)*2
y:displayTop
val:minutes/base
x: displayLeft+(dotSize+units.smallSpacing)*2
y: displayTop
val: minutes/base
}
DotColumn {
x:displayLeft+(dotSize+units.smallSpacing)*3
y:displayTop
val:minutes%base
x: displayLeft+(dotSize+units.smallSpacing)*3
y: displayTop
val: minutes%base
}
/* seconds */
DotColumn {
x:displayLeft+(dotSize+units.smallSpacing)*4
y:displayTop
val:seconds/base
visible:showSeconds
x: displayLeft+(dotSize+units.smallSpacing)*4
y: displayTop
val: seconds/base
visible: showSeconds
}
DotColumn {
x:displayLeft+(dotSize+units.smallSpacing)*5
y:displayTop
val:seconds%base
visible:showSeconds
x: displayLeft+(dotSize+units.smallSpacing)*5
y: displayTop
val: seconds%base
visible: showSeconds
}
/* upper grid border */
Rectangle {
x:displayLeft-units.smallSpacing
y:displayTop-units.smallSpacing
width:dots*(dotSize+units.smallSpacing)+units.smallSpacing
height:units.smallSpacing
visible:showGrid
color:gridColor
x: displayLeft-units.smallSpacing
y: displayTop-units.smallSpacing
width: dots*(dotSize+units.smallSpacing)+units.smallSpacing
height: units.smallSpacing
visible: showGrid
color: gridColor
}
/* left grid border */
Rectangle {
x:displayLeft-units.smallSpacing
y:displayTop
width:units.smallSpacing
height:4*(dotSize+units.smallSpacing)
visible:showGrid
color:gridColor
x: displayLeft-units.smallSpacing
y: displayTop
width: units.smallSpacing
height: 4*(dotSize+units.smallSpacing)
visible: showGrid
color: gridColor
}
}
}
\ No newline at end of file
......@@ -2,9 +2,10 @@
* Rewrite of the KDE4-Plasma Binary Clock for KF5/Plasma/QML
*
* Copyright 2014 Joseph Wenninger <jowenn@kde.org>
* Copyright 2018 Piotr Kąkol <piotrkakol@protonmail.com>
*
* Original code (KDE4):
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
* Copyright 2007 by Davide Bettio <davide.bettio@kdemail.net>
*
* This program is free software; you can redistribute it and/or
......@@ -27,28 +28,33 @@ Item {
property int val
property int bit
/* both active and inactive squares */
Rectangle {
width: main.dotSize
height: width
color: (val & bit) ? main.onColor:main.offColor
x:0
y:0
visible:main.showOffLeds || color!=main.offColor
width: main.dotSize
height: width
color: (val & bit) ? main.onColor : main.offColor
x: 0
y: 0
visible: main.showOffLeds || color != main.offColor
}
/* bottom border for each square */
Rectangle {
visible:main.showGrid
x:0
y:main.dotSize
width:main.dotSize
height:units.smallSpacing
color:main.gridColor;
visible: main.showGrid
x: 0
y: main.dotSize
width: main.dotSize
height: units.smallSpacing
color: main.gridColor
}
/* right border for each square */
Rectangle {
visible:main.showGrid
x:main.dotSize
y:0
width:units.smallSpacing
height:main.dotSize+units.smallSpacing
color:main.gridColor
visible: main.showGrid
x: main.dotSize
y: 0
width: units.smallSpacing
height: main.dotSize+units.smallSpacing
color: main.gridColor
}
}
}
\ No newline at end of file
......@@ -4,8 +4,9 @@
* Copyright 2014 Joseph Wenninger <jowenn@kde.org>
*
* Original code (KDE4):
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
* Copyright 2007 by Davide Bettio <davide.bettio@kdemail.net>
* Copyright 2018 Piotr Kąkol <piotrkakol@protonmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -23,31 +24,30 @@
import QtQuick 2.0
Item {
property int val
Dot {
x:0
y:0
val:parent.val
bit:8
x: 0
y: 0
val: parent.val
bit: 8
}
Dot {
x:0
y:(dotSize+units.smallSpacing)
val:parent.val
bit:4
x: 0
y: (dotSize+units.smallSpacing)
val: parent.val
bit: 4
}
Dot {
x:0
y:2*(dotSize+units.smallSpacing)
val:parent.val
bit:2
x: 0
y: 2*(dotSize+units.smallSpacing)
val: parent.val
bit: 2
}
Dot {
x:0
y:3*(dotSize+units.smallSpacing)
val:parent.val
bit:1
x: 0
y: 3*(dotSize+units.smallSpacing)
val: parent.val
bit: 1
}
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
*
* Based on analog-clock configGeneral.qml:
* Copyright 2013 David Edmundson <davidedmundson@kde.org>
* Copyright 2018 Piotr Kąkol <piotrkakol@protonmail.com>
*
* 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
......@@ -24,7 +25,6 @@ import QtQuick.Controls 1.0 as QtControls
import QtQuick.Layouts 1.1
import org.kde.kquickcontrols 2.0 as KQuickControls
ColumnLayout {
id: generalConfigPage
......@@ -74,7 +74,7 @@ ColumnLayout {
title: i18nc("@title:group", "Colors")
GridLayout {
columns: 2;
columns: 2
QtControls.CheckBox {
id: useCustomColorForActiveCheckBox
text: i18nc("@option:check", "Use custom color for active LEDs")
......@@ -107,4 +107,4 @@ ColumnLayout {
Item { // tighten layout
Layout.fillHeight: true
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
* Copyright 2013 Heena Mahour <heena393@gmail.com>
* Copyright 2013 Sebastian Kügler <sebas@kde.org>
* Copyright 2014 Kai Uwe Broulik <kde@privat.broulik.de>
* Copyright 2018 Piotr Kąkol <piotrkakol@protonmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -19,6 +20,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import QtQuick.Layouts 1.1
......@@ -31,7 +33,7 @@ import org.kde.plasma.calendar 2.0 as PlasmaCalendar
Item {
id: root
property bool showSeconds:plasmoid.configuration.showSeconds
property bool showSeconds: plasmoid.configuration.showSeconds
property int hours
property int minutes
property int seconds
......@@ -40,14 +42,14 @@ Item {
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
Plasmoid.toolTipMainText: Qt.formatDate(dataSource.data["Local"]["DateTime"],"dddd")
Plasmoid.toolTipMainText: Qt.formatDate(dataSource.data["Local"]["DateTime"], "dddd")
Plasmoid.toolTipSubText: Qt.formatDate(dataSource.data["Local"]["DateTime"], Qt.locale().dateFormat(Locale.LongFormat).replace(/(^dddd.?\s)|(,?\sdddd$)/, ""))
PlasmaCore.DataSource {
id: dataSource
engine: "time"
connectedSources: ["Local"]
interval: showSeconds?1000:30000
interval: showSeconds ? 1000 : 30000
onDataChanged: {
var date = new Date(data["Local"]["DateTime"]);
hours = date.getHours();
......@@ -67,4 +69,4 @@ Item {
today: dataSource.data["Local"]["DateTime"]
}
}
}
\ No newline at end of file
......@@ -113,8 +113,8 @@ Icon=clock
Type=Service
X-KDE-ServiceTypes=Plasma/Applet
X-KDE-PluginInfo-Author=Joseph Wenninger,Davide Bettio
X-KDE-PluginInfo-Email=jowenn@kde.org, davide.bettio@kdemail.net
X-KDE-PluginInfo-Author=Joseph Wenninger,Davide Bettio,Piotr Kąkol
X-KDE-PluginInfo-Email=jowenn@kde.org, davide.bettio@kdemail.net, piotrkakol@protonmail.com
X-KDE-PluginInfo-Name=org.kde.plasma.binaryclock
X-KDE-PluginInfo-Version=2.0
X-KDE-PluginInfo-Website=plasma.kde.org
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment