diff --git a/applets/binary-clock/package/contents/config/config.qml b/applets/binary-clock/package/contents/config/config.qml --- a/applets/binary-clock/package/contents/config/config.qml +++ b/applets/binary-clock/package/contents/config/config.qml @@ -1,5 +1,6 @@ /* * Copyright 2014 Joseph Wenninger + * Copyright 2018 Piotr Kąkol * * Based on analog-clock config.qml: * Copyright 2013 Marco Martin @@ -29,4 +30,4 @@ icon: "preferences-desktop-color" source: "configGeneral.qml" } -} +} \ No newline at end of file diff --git a/applets/binary-clock/package/contents/config/main.xml b/applets/binary-clock/package/contents/config/main.xml --- a/applets/binary-clock/package/contents/config/main.xml +++ b/applets/binary-clock/package/contents/config/main.xml @@ -17,6 +17,12 @@ false + + + false + + + 1 false @@ -37,5 +43,4 @@ blue - - + \ No newline at end of file diff --git a/applets/binary-clock/package/contents/ui/BinaryClock.qml b/applets/binary-clock/package/contents/ui/BinaryClock.qml --- a/applets/binary-clock/package/contents/ui/BinaryClock.qml +++ b/applets/binary-clock/package/contents/ui/BinaryClock.qml @@ -2,9 +2,10 @@ * Rewrite of the KDE4-Plasma Binary Clock for KF5/Plasma/QML * * Copyright 2014 Joseph Wenninger + * Copyright 2018 Piotr Kąkol * * Original code (KDE4): - * Copyright 2007 by Riccardo Iaconelli * + * Copyright 2007 by Riccardo Iaconelli * Copyright 2007 by Davide Bettio * * Based on FuzzyClock.qml: @@ -36,106 +37,106 @@ Item { id: main - readonly property real w1: (main.height-5*units.smallSpacing)*dots/4 + readonly property int squares: showSeconds ? 6 : 4 - Layout.minimumWidth: w1 < 20 ? 20 : w1 + readonly property bool showOffLeds: plasmoid.configuration.showOffLeds + readonly property bool showGrid: plasmoid.configuration.showGrid + + // length of spaces between squares and also grid thickness + readonly property int breakLength: plasmoid.configuration.useCustomGridThickness ? plasmoid.configuration.gridThickness : units.smallSpacing + // square size taking into account grid visibility and position of the taskbar + readonly property int squareSize: plasmoid.formFactor == PlasmaCore.Types.Horizontal + ? (height-(showGrid ? 5 : 3)*breakLength)/4 // for horizontal taskbar + : (width-(showGrid ? 7 : 5)*breakLength)/squares // for vertical taskbar + // width of the binary clock applet including left and right margins + readonly property real appletWidth: squares*squareSize+breakLength*(squares+(showGrid ? 3 : 1)) + + Layout.minimumWidth: appletWidth < 20 ? 20 : appletWidth Layout.maximumWidth: Infinity Layout.preferredWidth: Layout.minimumWidth - Layout.minimumHeight: 16+(units.smallSpacing * 5) - // Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity + Layout.minimumHeight: 16+(breakLength*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 - readonly property bool showSeconds: root.showSeconds readonly property int hours: root.hours readonly property int minutes: root.minutes readonly property int seconds: root.seconds + + readonly property int base: plasmoid.configuration.showBcdFormat ? 10 : 16 - 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 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 int displayTop: (height - 4*squareSize-3*breakLength)/2 + readonly property int displayLeft: (width - squares*squareSize-(squares-1)*breakLength)/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*/ - DotColumn { - x:displayLeft - y:displayTop - val:hours/base + /* hours */ + SquareColumn { + x: displayLeft + y: displayTop + val: hours/base } - DotColumn { - x:displayLeft+(dotSize+units.smallSpacing) - y:displayTop - val:hours%base + SquareColumn { + x: displayLeft+(squareSize+breakLength) + y: displayTop + val: hours%base } - - /*minutes*/ - DotColumn { - x:displayLeft+(dotSize+units.smallSpacing)*2 - y:displayTop - val:minutes/base + /* minutes */ + SquareColumn { + x: displayLeft+(squareSize+breakLength)*2 + y: displayTop + val: minutes/base } - DotColumn { - x:displayLeft+(dotSize+units.smallSpacing)*3 - y:displayTop - val:minutes%base + SquareColumn { + x: displayLeft+(squareSize+breakLength)*3 + y: displayTop + val: minutes%base } /* seconds */ - DotColumn { - x:displayLeft+(dotSize+units.smallSpacing)*4 - y:displayTop - val:seconds/base - visible:showSeconds + SquareColumn { + x: displayLeft+(squareSize+breakLength)*4 + y: displayTop + val: seconds/base + visible: showSeconds } - - DotColumn { - x:displayLeft+(dotSize+units.smallSpacing)*5 - y:displayTop - val:seconds%base - visible:showSeconds + SquareColumn { + x: displayLeft+(squareSize+breakLength)*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-breakLength + y: displayTop-breakLength + width: squares*(squareSize+breakLength)+breakLength + height: breakLength + 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-breakLength + y: displayTop + width: breakLength + height: 4*(squareSize+breakLength) + visible: showGrid + color: gridColor } - -} +} \ No newline at end of file diff --git a/applets/binary-clock/package/contents/ui/Dot.qml b/applets/binary-clock/package/contents/ui/Square.qml rename from applets/binary-clock/package/contents/ui/Dot.qml rename to applets/binary-clock/package/contents/ui/Square.qml --- a/applets/binary-clock/package/contents/ui/Dot.qml +++ b/applets/binary-clock/package/contents/ui/Square.qml @@ -2,9 +2,10 @@ * Rewrite of the KDE4-Plasma Binary Clock for KF5/Plasma/QML * * Copyright 2014 Joseph Wenninger + * Copyright 2018 Piotr Kąkol * * Original code (KDE4): - * Copyright 2007 by Riccardo Iaconelli * + * Copyright 2007 by Riccardo Iaconelli * Copyright 2007 by Davide Bettio * * This program is free software; you can redistribute it and/or @@ -27,28 +28,33 @@ 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.squareSize + 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.squareSize + width: main.squareSize + height: main.breakLength + 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.squareSize + y: 0 + width: main.breakLength + height: main.squareSize+main.breakLength + color: main.gridColor } -} +} \ No newline at end of file diff --git a/applets/binary-clock/package/contents/ui/DotColumn.qml b/applets/binary-clock/package/contents/ui/SquareColumn.qml rename from applets/binary-clock/package/contents/ui/DotColumn.qml rename to applets/binary-clock/package/contents/ui/SquareColumn.qml --- a/applets/binary-clock/package/contents/ui/DotColumn.qml +++ b/applets/binary-clock/package/contents/ui/SquareColumn.qml @@ -2,9 +2,10 @@ * Rewrite of the KDE4-Plasma Binary Clock for KF5/Plasma/QML * * Copyright 2014 Joseph Wenninger + * Copyright 2018 Piotr Kąkol * * Original code (KDE4): - * Copyright 2007 by Riccardo Iaconelli * + * Copyright 2007 by Riccardo Iaconelli * Copyright 2007 by Davide Bettio * * This program is free software; you can redistribute it and/or @@ -23,31 +24,30 @@ import QtQuick 2.0 - Item { property int val - Dot { - x:0 - y:0 - val:parent.val - bit:8 + Square { + x: 0 + y: 0 + val: parent.val + bit: 8 } - Dot { - x:0 - y:(dotSize+units.smallSpacing) - val:parent.val - bit:4 + Square { + x: 0 + y: (squareSize+main.breakLength) + val: parent.val + bit: 4 } - Dot { - x:0 - y:2*(dotSize+units.smallSpacing) - val:parent.val - bit:2 + Square { + x: 0 + y: 2*(squareSize+main.breakLength) + val: parent.val + bit: 2 } - Dot { - x:0 - y:3*(dotSize+units.smallSpacing) - val:parent.val - bit:1 + Square { + x: 0 + y: 3*(squareSize+main.breakLength) + val: parent.val + bit: 1 } -} +} \ No newline at end of file diff --git a/applets/binary-clock/package/contents/ui/configGeneral.qml b/applets/binary-clock/package/contents/ui/configGeneral.qml --- a/applets/binary-clock/package/contents/ui/configGeneral.qml +++ b/applets/binary-clock/package/contents/ui/configGeneral.qml @@ -1,5 +1,6 @@ /* * Copyright 2014 Joseph Wenninger + * Copyright 2018 Piotr Kąkol * * Based on analog-clock configGeneral.qml: * Copyright 2013 David Edmundson @@ -32,6 +33,8 @@ property alias cfg_showOffLeds: showOffLedsCheckBox.checked property alias cfg_showSeconds: showSecondsCheckBox.checked property alias cfg_showBcdFormat: showBcdFormatCheckBox.checked + property alias cfg_useCustomGridThickness: useCustomGridThicknessCheckBox.checked + property alias cfg_gridThickness: gridThicknessSpinBox.value property alias cfg_useCustomColorForActive: useCustomColorForActiveCheckBox.checked property alias cfg_customColorForActive: customColorForActive.color property alias cfg_useCustomColorForInactive: useCustomColorForInactiveCheckBox.checked @@ -64,6 +67,16 @@ id: showBcdFormatCheckBox text: i18nc("@option:check", "Display in BCD format (decimal)") } + GridLayout { + columns: 2 + QtControls.CheckBox { + id: useCustomGridThicknessCheckBox + text: i18nc("@option:check", "Use custom grid thickness") + } + QtControls.SpinBox { + id: gridThicknessSpinBox + } + } } } @@ -74,7 +87,7 @@ 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 +120,4 @@ Item { // tighten layout Layout.fillHeight: true } -} +} \ No newline at end of file diff --git a/applets/binary-clock/package/contents/ui/main.qml b/applets/binary-clock/package/contents/ui/main.qml --- a/applets/binary-clock/package/contents/ui/main.qml +++ b/applets/binary-clock/package/contents/ui/main.qml @@ -1,5 +1,6 @@ /* * Copyright 2014 Joseph Wenninger + * Copyright 2018 Piotr Kąkol * * Based on fuzzy-clock main.qml: * Copyright 2013 Heena Mahour @@ -19,6 +20,7 @@ * 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 @@ -31,23 +33,23 @@ Item { id: root - property bool showSeconds:plasmoid.configuration.showSeconds + property bool showSeconds: plasmoid.configuration.showSeconds property int hours property int minutes property int seconds width: units.gridUnit * 10 height: units.gridUnit * 4 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 : 60000 onDataChanged: { var date = new Date(data["Local"]["DateTime"]); hours = date.getHours(); @@ -67,4 +69,4 @@ today: dataSource.data["Local"]["DateTime"] } -} +} \ No newline at end of file diff --git a/applets/binary-clock/package/metadata.desktop b/applets/binary-clock/package/metadata.desktop --- a/applets/binary-clock/package/metadata.desktop +++ b/applets/binary-clock/package/metadata.desktop @@ -113,8 +113,8 @@ 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