mirror of
https://github.com/developersu/ClearClock.git
synced 2025-05-14 19:20:26 +03:00
Merge pull request #16 from Diyou/main
Added compatibility for plasma 6
This commit is contained in:
commit
d38b8dab62
6 changed files with 46 additions and 56 deletions
|
@ -6,13 +6,15 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QtControls
|
||||
import QtQuick.Layouts 1.12 as QtLayouts
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Dialogs
|
||||
|
||||
import org.kde.kirigami 2.3 as Kirigami
|
||||
import org.kde.kcmutils as KCM
|
||||
|
||||
|
||||
import "../lib"
|
||||
|
||||
Item {
|
||||
KCM.SimpleKCM {
|
||||
id: appearancePage
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
@ -58,31 +60,6 @@ Item {
|
|||
property int cfg_dateShadowXOffset
|
||||
property int cfg_dateShadowYOffset
|
||||
|
||||
|
||||
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: {
|
||||
|
@ -155,7 +132,7 @@ Item {
|
|||
cfg_clockFontColor = colorValue
|
||||
}
|
||||
|
||||
fontValue: cgf_clockFontFamily
|
||||
fontValue: cfg_clockFontFamily
|
||||
onFontValueChanged: {
|
||||
cfg_clockFontFamily = fontValue
|
||||
}
|
||||
|
@ -232,7 +209,7 @@ Item {
|
|||
cfg_dayFontColor = colorValue
|
||||
}
|
||||
|
||||
fontValue: cgf_dayFontFamily
|
||||
fontValue: cfg_dayFontFamily
|
||||
onFontValueChanged: {
|
||||
cfg_dayFontFamily = fontValue
|
||||
}
|
||||
|
@ -331,7 +308,7 @@ Item {
|
|||
cfg_dateFontColor = colorValue
|
||||
}
|
||||
|
||||
fontValue: cgf_dateFontFamily
|
||||
fontValue: cfg_dateFontFamily
|
||||
onFontValueChanged: {
|
||||
cfg_dateFontFamily = fontValue
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import QtQuick.Layouts 1.12 as QtLayouts
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Dialogs
|
||||
|
||||
QtControls.Button {
|
||||
id: clockFontColorButton
|
||||
|
@ -33,10 +33,12 @@ QtControls.Button {
|
|||
ColorDialog {
|
||||
id: dialog
|
||||
title: "Select Background Color"
|
||||
color: value
|
||||
showAlphaChannel: true
|
||||
selectedColor: value
|
||||
options: {
|
||||
ShowAlphaChannel: true
|
||||
}
|
||||
onAccepted: {
|
||||
value = dialog.color
|
||||
value = selectedColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.12 as QtControls
|
||||
import QtQuick.Layouts 1.12 as QtLayouts
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Dialogs
|
||||
|
||||
import org.kde.kirigami 2.3 as Kirigami
|
||||
|
||||
import "."
|
||||
|
||||
|
@ -39,10 +41,19 @@ QtLayouts.RowLayout {
|
|||
QtControls.ComboBox {
|
||||
id: fontFamilyComboBox
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
QtLayouts.Layout.minimumWidth: units.gridUnit * 10
|
||||
QtLayouts.Layout.minimumWidth: Kirigami.Units.gridUnit * 10
|
||||
model: fontModel
|
||||
textRole: "text"
|
||||
currentIndex: fontValue
|
||||
currentIndex: getIdFromModel()
|
||||
|
||||
function getIdFromModel(){
|
||||
for(var i = 0; i < model.count; i++){
|
||||
if(model.get(i).value === fontValue){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: {
|
||||
var current = model.get(currentIndex)
|
||||
|
@ -59,7 +70,7 @@ QtLayouts.RowLayout {
|
|||
checkable: true
|
||||
checked: boldValue
|
||||
|
||||
onStateChanged: {
|
||||
onToggled: {
|
||||
boldValue = checked
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +81,8 @@ QtLayouts.RowLayout {
|
|||
checkable: true
|
||||
checked: italicValue
|
||||
|
||||
onStateChanged: {
|
||||
italicvalue = checked
|
||||
onToggled: {
|
||||
italicValue = checked
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.12 as QtControls
|
||||
import QtQuick.Layouts 1.12 as QtLayouts
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Dialogs
|
||||
|
||||
import "."
|
||||
|
||||
|
|
|
@ -5,27 +5,28 @@
|
|||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtGraphicalEffects 1.12
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import org.kde.plasma.plasma5support as Plasma5Support
|
||||
|
||||
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 {
|
||||
PlasmoidItem {
|
||||
id: root
|
||||
|
||||
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
|
||||
preferredRepresentation: fullRepresentation
|
||||
Plasmoid.backgroundHints: PlasmaCore.Types.ConfigurableBackground
|
||||
|
||||
readonly property date currentDateTime: dataSource.data.Local ? dataSource.data.Local.DateTime : new Date()
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
Plasma5Support.DataSource {
|
||||
id: dataSource
|
||||
engine: "time"
|
||||
connectedSources: ["Local"]
|
||||
interval: plasmoid.configuration.clockShowSeconds ? 1000 : 60000
|
||||
intervalAlignment: plasmoid.configuration.clockShowSeconds ? PlasmaCore.Types.NoAlignment : PlasmaCore.Types.AlignToMinute
|
||||
intervalAlignment: plasmoid.configuration.clockShowSeconds ? Plasma5Support.Types.NoAlignment : Plasma5Support.Types.AlignToMinute
|
||||
}
|
||||
|
||||
FontLoader {
|
||||
|
@ -43,7 +44,7 @@ Item {
|
|||
source: "../fonts/Smooch-Regular.ttf"
|
||||
}
|
||||
|
||||
Plasmoid.fullRepresentation: ColumnLayout {
|
||||
fullRepresentation: ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: -20
|
||||
|
||||
|
@ -65,15 +66,15 @@ Item {
|
|||
}
|
||||
|
||||
Item {
|
||||
width: Math.max(textMetricsClockLabel.width, textMetricsDayLabel.width)
|
||||
height: Math.max(textMetricsClockLabel.height, textMetricsDayLabel.height)
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
implicitWidth: Math.max(textMetricsClockLabel.width, textMetricsDayLabel.width)
|
||||
implicitHeight: Math.max(textMetricsClockLabel.height, textMetricsDayLabel.height)
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Text {
|
||||
id: clockLabel
|
||||
anchors.centerIn: parent
|
||||
|
||||
property var textFormat: {
|
||||
property var getTextFormat: {
|
||||
var AMPM = plasmoid.configuration.clockUse24hFormat ? "" : " AP"
|
||||
if (plasmoid.configuration.clockShowSeconds)
|
||||
return Qt.formatTime(currentDateTime, "hh.mm.ss" + AMPM).split(".").join(plasmoid.configuration.clockSeparator)
|
||||
|
@ -81,7 +82,7 @@ Item {
|
|||
return Qt.formatTime(currentDateTime, "hh.mm" + AMPM).split(".").join(plasmoid.configuration.clockSeparator)
|
||||
}
|
||||
|
||||
text: textFormat
|
||||
text: getTextFormat
|
||||
|
||||
color: plasmoid.configuration.clockFontColor
|
||||
font.family: if (plasmoid.configuration.clockFontFamily === "ccdefault") fontOutfitBold.name
|
||||
|
@ -110,7 +111,7 @@ Item {
|
|||
color: plasmoid.configuration.dayFontColor
|
||||
font.family: if (plasmoid.configuration.dayFontFamily === "ccdefault") fontSmooch.name
|
||||
else plasmoid.configuration.dayFontFamily
|
||||
font.bold: plasmoid.configuration.daykBoldText
|
||||
font.bold: plasmoid.configuration.dayBoldText
|
||||
font.italic: plasmoid.configuration.dayItalicText
|
||||
font.pixelSize: plasmoid.configuration.dayFontSize
|
||||
|
||||
|
@ -128,7 +129,7 @@ Item {
|
|||
Text {
|
||||
id: dateLabel
|
||||
visible: plasmoid.configuration.showDateDisplay
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
text: Qt.formatDate(currentDateTime, plasmoid.configuration.dateCustomDateFormat)
|
||||
|
||||
|
|
|
@ -18,6 +18,5 @@
|
|||
"Version": "0.3",
|
||||
"Website": "https://github.com/qewer33/ClearClock"
|
||||
},
|
||||
"X-Plasma-API": "declarativeappletscript",
|
||||
"X-Plasma-MainScript": "ui/main.qml"
|
||||
"X-Plasma-API-Minimum-Version": "6.0"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue