diff --git a/Locales/zh.qm b/Locales/zh.qm index 1d112c1..f72df4a 100644 Binary files a/Locales/zh.qm and b/Locales/zh.qm differ diff --git a/Locales/zh.ts b/Locales/zh.ts new file mode 100644 index 0000000..3456424 --- /dev/null +++ b/Locales/zh.ts @@ -0,0 +1,756 @@ + + + + + Common + + + Light + 细体 + + + + Normal + 普通 + + + + Bold + 加粗 + + + + ReflectionClock + + + Reflection Clock + 倒影时钟 + + + + + Settings + 设置 + + + + Clock Settings + 时钟设置 + + + + Configuration + 配置项 + + + + Hour Settings + 时设置 + + + + 24 Hour Clock + 24时制 + + + + + + Clock Background Color + 时钟背景颜色 + + + + + + Clock Font Color + 时钟字体颜色 + + + + + + Panel Background Color + 面板背景颜色 + + + + + + Panel Font Color + 面板字体颜色 + + + + Minute Settings + 分设置 + + + + Second Settings + 秒设置 + + + + Show + 显示 + + + + RoundClock + + + + Round Clock + 圆盘时钟 + + + + Settings + 设置 + + + + Clock Settings + 时钟设置 + + + + Configuration + 配置项 + + + + Continuous Second Hand + 秒针连续 + + + + Background Color + 背景颜色 + + + + Background transparency + 背景透明度 + + + + Hour Scale Color + 时刻度颜色 + + + + Minute Scale Color + 分刻度颜色 + + + + Hour Hand Color + 时针颜色 + + + + Minute Hand Color + 分针颜色 + + + + Second Hand Color + 秒针颜色 + + + + SolarsClock + + + + Solar Clock + 太阳系时钟 + + + + Settings + 设置 + + + + Clock Settings + 时钟设置 + + + + Configuration + 配置项 + + + + Background Settings + 背景设置 + + + + Color + 颜色 + + + + Transparency + 透明度 + + + + Show Scale + 显示刻度 + + + + Scale Color + 刻度颜色 + + + + Show Center + 中心显示 + + + + Center Color + 中心颜色 + + + + Center Radius + 中心半径 + + + + Display Time + 显示时间 + + + + Font Color + 字体颜色 + + + + Font Style + 字体样式 + + + + Font Weight + 字体粗细 + + + + Font Size + 字体大小 + + + + Hour Settings + 时设置 + + + + + + + Star Color + 星球颜色 + + + + + + + Show Orbit + 显示轨道 + + + + + + + Orbit Color + 轨道颜色 + + + + Minute Settings + 分设置 + + + + Second Settings + 秒设置 + + + + Millisecond Settings + 毫秒设置 + + + + TextClock + + + + Text Clock + 文字时钟挂件 + + + + Settings + 设置 + + + + Clock Settings + 时钟设置 + + + + Configuration + 配置项 + + + + Font Style + 字体样式 + + + + Font Weight + 字体粗细 + + + + HighLight Color + 高亮颜色 + + + + Normal Color + 普通颜色 + + + + Font Size + 字体大小 + + + + Letter Space + 文字间隔 + + + + Line Spacing + 行距 + + + + VectoClock + + + + Vecto Clock + Vecto时钟 + + + + + Settings + 设置 + + + + Configuration + 配置项 + + + + Weekday Settings + 星期设置 + + + + + + Color + 颜色 + + + + + + Font Size + 字体大小 + + + + + + Font Style + 字体样式 + + + + + + Font Weight + 字体粗细 + + + + + + Letter Spacing + 文字间隔 + + + + + + Y Offset + Y偏移量 + + + + + Gap + 间距 + + + + Line Settings + 线设置 + + + + Width + 宽度 + + + + Position + 位置 + + + + Clock Settings + 时钟设置 + 时钟设置 + + + + 24 Hour Clock + 24时制 + + + + Text Color + 文字颜色 + + + + Background Visible + 背景可见 + + + + Background Color + 背景颜色 + + + + + X Offset + X偏移量 + + + + Date Settings + 日期设置 + + + + reflection_clock + + Save + 保存 + + + Show + 显示 + + + Reset + 重置 + + + 24 Hour Clock + 24时制 + + + Reflection Clock + 倒影时钟 + + + Hour Settings + 时设置 + + + Second Settings + 秒设置 + + + Configuration + 配置项 + + + Minute Settings + 分设置 + + + Panel Background Color + 面板背景颜色 + + + Settings + 设置 + + + Panel Font Color + 面板字体颜色 + + + Clock Background Color + 时钟背景颜色 + + + Clock Font Color + 时钟字体颜色 + + + Clock Settings + 时钟设置 + + + + round_clock + + Save + 保存 + + + Reset + 重置 + + + Second Hand Color + 秒针颜色 + + + Hour Scale Color + 时刻度颜色 + + + Minute Scale Color + 分刻度颜色 + + + Round Clock + 圆盘时钟 + + + Configuration + 配置项 + + + Background Color + 背景颜色 + + + Hour Hand Color + 时针颜色 + + + Continuous Second Hand + 秒针连续 + + + Minute Hand Color + 分针颜色 + + + Settings + 设置 + + + Clock Settings + 时钟设置 + + + Background transparency + 背景透明度 + + + + solars_clock + + Save + 保存 + + + Color + 颜色 + + + Reset + 重置 + + + Center Color + 中心颜色 + + + Background Settings + 背景设置 + + + Transparency + 透明度 + + + Hour Settings + 时设置 + + + Solar Clock + 太阳系时钟 + + + Star Color + 星球颜色 + + + Show Center + 中心显示 + + + Font Size + 字体大小 + + + Orbit Color + 轨道颜色 + + + Font Color + 字体颜色 + + + Millisecond Settings + 毫秒设置 + + + Second Settings + 秒设置 + + + Configuration + 配置项 + + + Scale Color + 刻度颜色 + + + Show Orbit + 显示轨道 + + + Show Scale + 显示刻度 + + + Minute Settings + 分设置 + + + Display Time + 显示时间 + + + Center Radius + 中心半径 + + + Settings + 设置 + + + Clock Settings + 时钟设置 + + + + text_clock + + Save + 保存 + + + Reset + 重置 + + + Letter Space + 文字间隔 + + + Font Size + 字体大小 + + + Font Weight + 字体粗细 + + + Text Clock + 文字时钟挂件 + + + Font Style + 字体样式 + + + Configuration + 配置项 + + + Normal Color + 普通颜色 + + + HighLight Color + 高亮颜色 + + + Settings + 设置 + + + Line Spacing + 行距 + + + Clock Settings + 时钟设置 + + + diff --git a/package.json b/package.json index e8ed14e..9aca7d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "top.mashiros.widget.nclocks", - "version": "1.0.0", + "version": "1.0.1", "title": { "en": "Clock Collections Plugin", @@ -40,7 +40,7 @@ "zh": "太阳系时钟挂件" }, "preview": "preview/solars_clock.png", - "entry": "solars_clock.qml" + "entry": "qml/SolarsClock.qml" }, { "location": "/nclocks/reflection", @@ -50,7 +50,7 @@ "zh": "倒影时钟挂件" }, "preview": "preview/reflection_clock.png", - "entry": "reflection_clock.qml" + "entry": "qml/ReflectionClock.qml" }, { "location": "/nclocks/round", @@ -60,7 +60,7 @@ "zh": "圆盘时钟挂件" }, "preview": "preview/round_clock.png", - "entry": "round_clock.qml" + "entry": "qml/RoundClock.qml" }, { "location": "/nclocks/text", @@ -70,7 +70,17 @@ "zh": "文字时钟挂件" }, "preview": "preview/text_clock.png", - "entry": "text_clock.qml" + "entry": "qml/TextClock.qml" + }, + { + "location": "/nclocks/vecto", + "catalog": "widget", + "title": { + "en": "Vecto Clock Widget", + "zh": "Vecto时钟挂件" + }, + "preview": "preview/vecto_clock.png", + "entry": "qml/VectoClock.qml" } ] } \ No newline at end of file diff --git a/preview/vecto_clock.png b/preview/vecto_clock.png new file mode 100644 index 0000000..e8a5e5e Binary files /dev/null and b/preview/vecto_clock.png differ diff --git a/qml/Common.qml b/qml/Common.qml new file mode 100644 index 0000000..4335adb --- /dev/null +++ b/qml/Common.qml @@ -0,0 +1,9 @@ +pragma Singleton + +import QtQuick 2.12 + +QtObject { + readonly property var fonts: Qt.fontFamilies() + readonly property var fontweight: [Font.Light, Font.Normal, Font.Bold] + readonly property var sfontweight: [qsTr("Light"), qsTr("Normal"), qsTr("Bold")] +} \ No newline at end of file diff --git a/reflection_clock.qml b/qml/ReflectionClock.qml similarity index 78% rename from reflection_clock.qml rename to qml/ReflectionClock.qml index eac7042..0e45d70 100644 --- a/reflection_clock.qml +++ b/qml/ReflectionClock.qml @@ -11,16 +11,40 @@ import NERvGear.Preferences 1.0 as P -T.Widget { +WidgetTemplate { id: widget - solid: true title: qsTr("Reflection Clock") + editing: styleDialog.active resizable: true + version: "1.0.0" + defaultValues: { + "Hour Settings": { + "Full Clock": true, + "Clock BG Color": "#2196f3", + "Clock Font Color": "#ffffff", + "Panel BG Color": "#2196f3", + "Panel Font Color": "#ffffff" + }, + "Min Settings": { + "Clock BG Color": "#2196f3", + "Clock Font Color": "#ffffff", + "Panel BG Color": "#2196f3", + "Panel Font Color": "#ffffff" + }, + "Sec Settings": { + "Visible": true, + "Clock BG Color": "#ff006a", + "Clock Font Color": "#ffffff", + "Panel BG Color": "#ff006a", + "Panel Font Color": "#ffffff" + } + } + readonly property real minWH: Math.min(width/1.64, height) readonly property real multi: minWH/220 - readonly property bool full_clock: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Full Clock"] : true + readonly property bool full_clock: widget.settings.styles["Hour Settings"]["Full Clock"] property string am_pm: "" Rectangle { @@ -45,7 +69,7 @@ T.Widget { Rectangle { id: hour_top - color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Clock BG Color"] : "#2196f3" + color: widget.settings.styles["Hour Settings"]["Clock BG Color"] width: 100*multi height: 80*multi anchors.top: parent.top @@ -56,7 +80,11 @@ T.Widget { Text { id: hour_text text: "" - color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Clock Font Color"] : "#ffffff" + + style: Text.Outline + styleColor: "transparent" + + color: widget.settings.styles["Hour Settings"]["Clock Font Color"] anchors.centerIn: parent font.pointSize: 35*multi font.weight: Font.Light @@ -66,7 +94,7 @@ T.Widget { Rectangle { id: hour_bottom - color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Panel BG Color"] : "#2196f3" + color: widget.settings.styles["Hour Settings"]["Panel BG Color"] width: 100*multi height: 30*multi anchors.top: hour_top.bottom @@ -76,7 +104,11 @@ T.Widget { Text { text: "HOURS"+am_pm - color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Panel Font Color"] : "#ffffff" + + style: Text.Outline + styleColor: "transparent" + + color: widget.settings.styles["Hour Settings"]["Panel Font Color"] anchors.centerIn: parent font.pointSize: 9*multi font.weight: Font.Normal @@ -99,7 +131,7 @@ T.Widget { Rectangle { id: min_top - color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Clock BG Color"] : "#2196f3" + color: widget.settings.styles["Min Settings"]["Clock BG Color"] anchors.top: parent.top anchors.topMargin: 0 anchors.left: parent.left @@ -110,7 +142,11 @@ T.Widget { Text { id: min_text text: "" - color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Clock Font Color"] : "#ffffff" + + style: Text.Outline + styleColor: "transparent" + + color: widget.settings.styles["Min Settings"]["Clock Font Color"] anchors.centerIn: parent font.pointSize: 35*multi font.weight: Font.Light @@ -120,7 +156,7 @@ T.Widget { Rectangle { id: min_bottom - color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Panel BG Color"] : "#2196f3" + color: widget.settings.styles["Min Settings"]["Panel BG Color"] width: 100*multi height: 30*multi anchors.top: min_top.bottom @@ -130,7 +166,11 @@ T.Widget { Text { text: "MINUTES" - color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Panel Font Color"] : "#ffffff" + + style: Text.Outline + styleColor: "transparent" + + color: widget.settings.styles["Min Settings"]["Panel Font Color"] anchors.centerIn: parent font.pointSize: 9*multi font.weight: Font.Normal @@ -148,13 +188,13 @@ T.Widget { anchors.topMargin: 0 anchors.left: min.right anchors.leftMargin: 15*multi - visible: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Visible"] : true + visible: widget.settings.styles["Sec Settings"]["Visible"] width: 100*multi height: 111*multi Rectangle { id: sec_top - color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Clock BG Color"] : "#ff006a" + color: widget.settings.styles["Sec Settings"]["Clock BG Color"] width: 100*multi height: 80*multi anchors.top: parent.top @@ -165,7 +205,11 @@ T.Widget { Text { id: sec_text text: "" - color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Clock Font Color"] : "#ffffff" + + style: Text.Outline + styleColor: "transparent" + + color: widget.settings.styles["Sec Settings"]["Clock Font Color"] anchors.centerIn: parent font.pointSize: 35*multi font.weight: Font.Light @@ -175,7 +219,7 @@ T.Widget { Rectangle { id: sec_bottom - color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Panel BG Color"] : "#ff006a" + color: widget.settings.styles["Sec Settings"]["Panel BG Color"] width: 100*multi height: 30*multi anchors.top: sec_top.bottom @@ -185,7 +229,11 @@ T.Widget { Text { text: "SECONDS" - color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Panel Font Color"] : "#ffffff" + + style: Text.Outline + styleColor: "transparent" + + color: widget.settings.styles["Sec Settings"]["Panel Font Color"] anchors.centerIn: parent font.pointSize: 9*multi font.weight: Font.Normal @@ -321,7 +369,7 @@ T.Widget { P.SwitchPreference { name: "Full Clock" label: qsTr("24 Hour Clock") - defaultValue: true + defaultValue: defaultValues["Hour Settings"]["Full Clock"] } P.Separator {} @@ -329,13 +377,13 @@ T.Widget { P.ColorPreference { name: "Clock BG Color" label: qsTr("Clock Background Color") - defaultValue: "#2196f3" + defaultValue: defaultValues["Hour Settings"]["Clock BG Color"] } P.ColorPreference { name: "Clock Font Color" label: qsTr("Clock Font Color") - defaultValue: "#ffffff" + defaultValue: defaultValues["Hour Settings"]["Clock Font Color"] } P.Separator {} @@ -343,13 +391,13 @@ T.Widget { P.ColorPreference { name: "Panel BG Color" label: qsTr("Panel Background Color") - defaultValue: "#2196f3" + defaultValue: defaultValues["Hour Settings"]["Panel BG Color"] } P.ColorPreference { name: "Panel Font Color" label: qsTr("Panel Font Color") - defaultValue: "#ffffff" + defaultValue: defaultValues["Hour Settings"]["Panel Font Color"] } } @@ -364,13 +412,13 @@ T.Widget { P.ColorPreference { name: "Clock BG Color" label: qsTr("Clock Background Color") - defaultValue: "#2196f3" + defaultValue: defaultValues["Min Settings"]["Clock BG Color"] } P.ColorPreference { name: "Clock Font Color" label: qsTr("Clock Font Color") - defaultValue: "#ffffff" + defaultValue: defaultValues["Min Settings"]["Clock Font Color"] } P.Separator {} @@ -378,13 +426,13 @@ T.Widget { P.ColorPreference { name: "Panel BG Color" label: qsTr("Panel Background Color") - defaultValue: "#2196f3" + defaultValue: defaultValues["Min Settings"]["Panel BG Color"] } P.ColorPreference { name: "Panel Font Color" label: qsTr("Panel Font Color") - defaultValue: "#ffffff" + defaultValue: defaultValues["Min Settings"]["Panel Font Color"] } } @@ -400,7 +448,7 @@ T.Widget { id: cfg_sec_en name: "Visible" label: qsTr("Show") - defaultValue: true + defaultValue: defaultValues["Sec Settings"]["Visible"] } P.Separator {} @@ -409,14 +457,14 @@ T.Widget { name: "Clock BG Color" label: qsTr("Clock Background Color") enabled: cfg_sec_en.value - defaultValue: "#ff006a" + defaultValue: defaultValues["Sec Settings"]["Clock BG Color"] } P.ColorPreference { name: "Clock Font Color" label: qsTr("Clock Font Color") enabled: cfg_sec_en.value - defaultValue: "#ffffff" + defaultValue: defaultValues["Sec Settings"]["Clock Font Color"] } P.Separator {} @@ -425,22 +473,18 @@ T.Widget { name: "Panel BG Color" label: qsTr("Panel Background Color") enabled: cfg_sec_en.value - defaultValue: "#ff006a" + defaultValue: defaultValues["Sec Settings"]["Panel BG Color"] } P.ColorPreference { name: "Panel Font Color" label: qsTr("Panel Font Color") enabled: cfg_sec_en.value - defaultValue: "#ffffff" + defaultValue: defaultValues["Sec Settings"]["Panel Font Color"] } } Component.onCompleted: { - if(!widget.settings.styles) { - configuration = rootPreference.save(); - widget.settings.styles = configuration; - } rootPreference.load(widget.settings.styles); configuration = widget.settings.styles; } diff --git a/round_clock.qml b/qml/RoundClock.qml similarity index 92% rename from round_clock.qml rename to qml/RoundClock.qml index 2ced197..f0f71f4 100644 --- a/round_clock.qml +++ b/qml/RoundClock.qml @@ -10,18 +10,30 @@ import NERvGear.Preferences 1.0 as P -T.Widget { +WidgetTemplate { id: widget - solid: true title: qsTr("Round Clock") + editing: styleDialog.active resizable: true + version: "1.0.0" + defaultValues: { + "Sec Continue": true, + "BG Color": "#2196f3", + "BG Alpha": 50, + "HGRID Color": "#ffffff", + "MGRID Color": "#ffffff", + "Hhand Color": "#ffffff", + "Mhand Color": "#ffffff", + "Shand Color": "#f3a829" + } + property real maxr: Math.min(width/2, height/2) -10 property real thour: 0 property real tmin: 0 property real tsec: 0 - property var configs: widget.settings.styles ? widget.settings.styles : {"Sec Continue":true,"BG Color":"#2196f3","BG Alpha":50,"HGRID Color":"#ffffff","MGRID Color":"#ffffff","Hhand Color":"#ffffff","Mhand Color":"#ffffff","Shand Color":"#f3a829"} + property var configs: widget.settings.styles onConfigsChanged: { background.requestPaint(); @@ -331,7 +343,7 @@ T.Widget { anchors.fill: parent header: TitleBar { - text: qsTr("Settings") + text: qsTr("Round Clock") standardButtons: Dialog.Save | Dialog.Reset @@ -379,7 +391,7 @@ T.Widget { P.SwitchPreference { name: "Sec Continue" label: qsTr("Continuous Second Hand") - defaultValue: true + defaultValue: defaultValues["Sec Continue"] } P.Separator {} @@ -387,7 +399,7 @@ T.Widget { P.ColorPreference { name: "BG Color" label: qsTr("Background Color") - defaultValue: "#2196f3" + defaultValue: defaultValues["BG Color"] } P.SliderPreference { @@ -396,7 +408,7 @@ T.Widget { from: 0 to: 100 stepSize: 1 - defaultValue: 50 + defaultValue: defaultValues["BG Alpha"] displayValue: value + "%" } @@ -405,13 +417,13 @@ T.Widget { P.ColorPreference { name: "HGRID Color" label: qsTr("Hour Scale Color") - defaultValue: "#fff" + defaultValue: defaultValues["HGRID Color"] } P.ColorPreference { name: "MGRID Color" label: qsTr("Minute Scale Color") - defaultValue: "#fff" + defaultValue: defaultValues["MGRID Color"] } P.Separator {} @@ -419,26 +431,22 @@ T.Widget { P.ColorPreference { name: "Hhand Color" label: qsTr("Hour Hand Color") - defaultValue: "#fff" + defaultValue: defaultValues["Hhand Color"] } P.ColorPreference { name: "Mhand Color" label: qsTr("Minute Hand Color") - defaultValue: "#fff" + defaultValue: defaultValues["Mhand Color"] } P.ColorPreference { name: "Shand Color" label: qsTr("Second Hand Color") - defaultValue: "#F3A829" + defaultValue: defaultValues["Shand Color"] } Component.onCompleted: { - if(!widget.settings.styles) { - configuration = rootPreference.save(); - widget.settings.styles = configuration; - } rootPreference.load(widget.settings.styles); configuration = widget.settings.styles; } diff --git a/solars_clock.qml b/qml/SolarsClock.qml similarity index 84% rename from solars_clock.qml rename to qml/SolarsClock.qml index c3490a6..7478a2c 100644 --- a/solars_clock.qml +++ b/qml/SolarsClock.qml @@ -10,14 +10,50 @@ import NERvGear.Preferences 1.0 as P -T.Widget { +WidgetTemplate { id: widget - solid: true title: qsTr("Solar Clock") resizable: true - editing: styleDialog.active + version: "1.0.0" + defaultValues: { + "BG Settings": { + "BG Color": "#212121", + "BG Alpha": 100, + "Show HGrid": true, + "HGRID Color": "#616161", + "Show Center": true, + "Center Color": "#ffeb3b", + "Center Radius": 85, + "Show Clock": true, + "Clock Color": "#616161", + "Font Name": Common.fonts.length-1, + "Font Weight": 1, + "Font Size": 100 + }, + "Hour Settings": { + "Hstar Color": "#ffa000", + "Show Orbit": true, + "Horbit Color": "#616161" + }, + "Min Settings": { + "Mstar Color": "#ff5722", + "Show Orbit": true, + "Morbit Color": "#616161" + }, + "Sec Settings": { + "Sstar Color": "#2196f3", + "Show Orbit": true, + "Sorbit Color": "#616161" + }, + "MSec Settings": { + "MSstar Color": "#9e9e9e", + "Show Orbit": true, + "MSorbit Color": "#9e9e9e" + } + } + property real maxr: Math.min(width/2, height/2) -10 readonly property real rhour: maxr*0.9 readonly property real rmin: maxr*0.72 @@ -27,7 +63,7 @@ T.Widget { property real tsec: 0 property real tmsec: 0 - property var configs: widget.settings.styles ? widget.settings.styles : {"BG Settings":{"BG Color":"#212121","BG Alpha":100,"Show HGrid":true,"HGRID Color":"#616161","Show Center":true,"Center Color":"#ffeb3b","Center Radius":85,"Show Clock":true,"Clock Color":"#616161","Font Size":100},"Hour Settings":{"Hstar Color":"#ffa000","Show Orbit":true,"Horbit Color":"#616161"},"Min Settings":{"Mstar Color":"#ff5722","Show Orbit":true,"Morbit Color":"#616161"},"Sec Settings":{"Sstar Color":"#2196f3","Show Orbit":true,"Sorbit Color":"#616161"},"MSec Settings":{"MSstar Color":"#9e9e9e","Show Orbit":true,"MSorbit Color":"#9e9e9e"}} + property var configs: widget.settings.styles onConfigsChanged: { background.requestPaint(); @@ -391,7 +427,7 @@ T.Widget { anchors.fill: parent header: TitleBar { - text: qsTr("Settings") + text: qsTr("Solar Clock") standardButtons: Dialog.Save | Dialog.Reset @@ -445,7 +481,7 @@ T.Widget { P.ColorPreference { name: "BG Color" label: qsTr("Color") - defaultValue: "#212121" + defaultValue: defaultValues["BG Settings"]["BG Color"] } P.SliderPreference { @@ -454,7 +490,7 @@ T.Widget { from: 0 to: 100 stepSize: 1 - defaultValue: 100 + defaultValue: defaultValues["BG Settings"]["BG Alpha"] displayValue: value + "%" } @@ -464,14 +500,14 @@ T.Widget { id: show_hgrid name: "Show HGrid" label: qsTr("Show Scale") - defaultValue: true + defaultValue: defaultValues["BG Settings"]["Show HGrid"] } P.ColorPreference { name: "HGRID Color" label: qsTr("Scale Color") enabled: show_hgrid.value - defaultValue: "#616161" + defaultValue: defaultValues["BG Settings"]["HGRID Color"] } P.Separator {} @@ -480,14 +516,14 @@ T.Widget { id: showCenter name: "Show Center" label: qsTr("Show Center") - defaultValue: true + defaultValue: defaultValues["BG Settings"]["Show Center"] } P.ColorPreference { name: "Center Color" label: qsTr("Center Color") enabled: showCenter.value - defaultValue: "#ffeb3b" + defaultValue: defaultValues["BG Settings"]["Center Color"] } P.SliderPreference { @@ -497,7 +533,7 @@ T.Widget { from: 30 to: 100 stepSize: 1 - defaultValue: 85 + defaultValue: defaultValues["BG Settings"]["Center Radius"] displayValue: value + "%" } @@ -507,14 +543,28 @@ T.Widget { id: showClock name: "Show Clock" label: qsTr("Display Time") - defaultValue: true + defaultValue: defaultValues["BG Settings"]["Show Clock"] } P.ColorPreference { name: "Clock Color" label: qsTr("Font Color") enabled: showClock.value - defaultValue: "#616161" + defaultValue: defaultValues["BG Settings"]["Clock Color"] + } + + P.SelectPreference { + name: "Font Name" + label: qsTr("Font Style") + defaultValue: defaultValues["BG Settings"]["Font Name"] + model: Common.fonts + } + + P.SelectPreference { + name: "Font Weight" + label: qsTr("Font Weight") + defaultValue: defaultValues["BG Settings"]["Font Weight"] + model: Common.sfontweight } P.SliderPreference { @@ -524,7 +574,7 @@ T.Widget { from: 50 to: 100 stepSize: 1 - defaultValue: 100 + defaultValue: defaultValues["BG Settings"]["Font Size"] displayValue: value + "%" } } @@ -540,7 +590,7 @@ T.Widget { P.ColorPreference { name: "Hstar Color" label: qsTr("Star Color") - defaultValue: "#ffa000" + defaultValue: defaultValues["Hour Settings"]["Hstar Color"] } P.Separator {} @@ -549,14 +599,14 @@ T.Widget { id: hour_settings_show_orbit name: "Show Orbit" label: qsTr("Show Orbit") - defaultValue: true + defaultValue: defaultValues["Hour Settings"]["Show Orbit"] } P.ColorPreference { name: "Horbit Color" label: qsTr("Orbit Color") enabled: hour_settings_show_orbit.value - defaultValue: "#616161" + defaultValue: defaultValues["Hour Settings"]["Horbit Color"] } } @@ -569,7 +619,7 @@ T.Widget { P.ColorPreference { name: "Mstar Color" label: qsTr("Star Color") - defaultValue: "#ff5722" + defaultValue: defaultValues["Min Settings"]["Mstar Color"] } P.Separator {} @@ -578,14 +628,14 @@ T.Widget { id: min_settings_show_orbit name: "Show Orbit" label: qsTr("Show Orbit") - defaultValue: true + defaultValue: defaultValues["Min Settings"]["Show Orbit"] } P.ColorPreference { name: "Morbit Color" label: qsTr("Orbit Color") enabled: min_settings_show_orbit.value - defaultValue: "#616161" + defaultValue: defaultValues["Min Settings"]["Morbit Color"] } } @@ -598,7 +648,7 @@ T.Widget { P.ColorPreference { name: "Sstar Color" label: qsTr("Star Color") - defaultValue: "#2196f3" + defaultValue: defaultValues["Sec Settings"]["Sstar Color"] } P.Separator {} @@ -607,14 +657,14 @@ T.Widget { id: sec_settings_show_orbit name: "Show Orbit" label: qsTr("Show Orbit") - defaultValue: true + defaultValue: defaultValues["Sec Settings"]["Show Orbit"] } P.ColorPreference { name: "Sorbit Color" label: qsTr("Orbit Color") enabled: sec_settings_show_orbit.value - defaultValue: "#616161" + defaultValue: defaultValues["Sec Settings"]["Sorbit Color"] } } @@ -627,7 +677,7 @@ T.Widget { P.ColorPreference { name: "MSstar Color" label: qsTr("Star Color") - defaultValue: "#9e9e9e" + defaultValue: defaultValues["MSec Settings"]["MSstar Color"] } P.Separator {} @@ -636,22 +686,18 @@ T.Widget { id: msec_settings_show_orbit name: "Show Orbit" label: qsTr("Show Orbit") - defaultValue: true + defaultValue: defaultValues["MSec Settings"]["Show Orbit"] } P.ColorPreference { name: "MSorbit Color" label: qsTr("Orbit Color") enabled: msec_settings_show_orbit.value - defaultValue: "#9e9e9e" + defaultValue: defaultValues["MSec Settings"]["MSorbit Color"] } } Component.onCompleted: { - if(!widget.settings.styles) { - configuration = rootPreference.save(); - widget.settings.styles = configuration; - } rootPreference.load(widget.settings.styles); configuration = widget.settings.styles; } @@ -671,11 +717,15 @@ T.Widget { Text { id: main_time text: "" + + style: Text.Outline + styleColor: "transparent" + visible: configs["BG Settings"]["Show Clock"] color: configs["BG Settings"]["Clock Color"] anchors.centerIn: parent font.pointSize: 0.0009*configs["BG Settings"]["Center Radius"]*maxr*configs["BG Settings"]["Font Size"]/100 - font.weight: Font.Normal - font.family: "Microsoft YaHei" + font.weight: Common.fontweight[configs["BG Settings"]["Font Weight"]] + font.family: Common.fonts[configs["BG Settings"]["Font Name"]]//"Microsoft YaHei" } } diff --git a/text_clock.qml b/qml/TextClock.qml similarity index 87% rename from text_clock.qml rename to qml/TextClock.qml index 6fc46fa..785386e 100644 --- a/text_clock.qml +++ b/qml/TextClock.qml @@ -2,20 +2,30 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 -import QtGraphicalEffects 1.0 import NERvGear 1.0 as NVG import NERvGear.Controls 1.0 import NERvGear.Templates 1.0 as T import NERvGear.Preferences 1.0 as P +import "." - -T.Widget { +WidgetTemplate { id: widget - solid: true title: qsTr("Text Clock") resizable: true + editing: styleDialog.active + + version: "1.0.0" + defaultValues: { + "Font Name": Common.fonts.length-1, + "Font Weight": 0, + "Normal Color": "#333333", + "HighLight Color": "#FFF", + "Font Size": 20, + "Letter Space": 20, + "Line Height": 1.5 + } property real day: 1 property real hours: 0 @@ -43,10 +53,6 @@ T.Widget { "9": 10, "1": 11, "13": 11, "6": 12, "3": 13, "4": 14, "5": 15, "2": 16, "8": 17, "11": 18, "23": 18, "7": 19, "12": 20, "10": 21, "OCLOCK": 22, "0": 23, "24": 23} - readonly property var fonts: Qt.fontFamilies() - readonly property var fontweight: [Font.Light, Font.Normal, Font.DemiBold, Font.Bold, Font.Black] - readonly property var sfontweight: ["Light", "Normal", "DemiBold", "Bold", "Black"] - function stringFormat(rtext, format) { if (!rtext) return null; @@ -77,10 +83,13 @@ T.Widget { color: widget.settings.styles["Normal Color"] text: "" + style: Text.Outline + styleColor: "transparent" + anchors.centerIn: parent font.pointSize: widget.settings.styles["Font Size"] - font.weight: fontweight[widget.settings.styles["Font Weight"]] - font.family: fonts[widget.settings.styles["Font Name"]] + font.weight: Common.fontweight[widget.settings.styles["Font Weight"]] + font.family: Common.fonts[widget.settings.styles["Font Name"]] lineHeight: widget.settings.styles["Line Height"] font.letterSpacing: widget.settings.styles["Letter Space"] } @@ -174,7 +183,7 @@ T.Widget { anchors.fill: parent header: TitleBar { - text: qsTr("Settings") + text: qsTr("Text Clock") standardButtons: Dialog.Save | Dialog.Reset @@ -223,28 +232,28 @@ T.Widget { name: "Font Name" label: qsTr("Font Style") icon.name: "solid:\uf1fc" - defaultValue: 408 - model: fonts + defaultValue: defaultValues["Font Name"] + model: Common.fonts } P.SelectPreference { name: "Font Weight" label: qsTr("Font Weight") icon.name: "solid:\uf1fc" - defaultValue: 0 - model: sfontweight + defaultValue: defaultValues["Font Weight"] + model: Common.sfontweight } P.ColorPreference { name: "HighLight Color" label: qsTr("HighLight Color") - defaultValue: "#FFF" + defaultValue: defaultValues["HighLight Color"] } P.ColorPreference { name: "Normal Color" label: qsTr("Normal Color") - defaultValue: "#333333" + defaultValue: defaultValues["Normal Color"] } P.SliderPreference { @@ -253,7 +262,7 @@ T.Widget { from: 1 to: 40 stepSize: 1 - defaultValue: 20 + defaultValue: defaultValues["Font Size"] displayValue: value } @@ -263,7 +272,7 @@ T.Widget { from: 1 to: 40 stepSize: 1 - defaultValue: 20 + defaultValue: defaultValues["Letter Space"] displayValue: value } @@ -273,15 +282,11 @@ T.Widget { from: 0.8 to: 2 stepSize: 0.1 - defaultValue: 1.5 + defaultValue: defaultValues["Line Height"] displayValue: value.toFixed(1) } Component.onCompleted: { - if(!widget.settings.styles) { - configuration = rootPreference.save(); - widget.settings.styles = configuration; - } rootPreference.load(widget.settings.styles); configuration = widget.settings.styles; } @@ -297,10 +302,4 @@ T.Widget { } } } - - Component.onCompleted: { - if (!widget.settings.styles) { - widget.settings.styles = {"Font Name": fonts.length-1, "Font Weight": 0, "Normal Color": "#333333", "HighLight Color": "#FFF", "Font Size": 20, "Letter Space": 20, "Line Height": 1.5}; - } - } } diff --git a/qml/VectoClock.qml b/qml/VectoClock.qml new file mode 100644 index 0000000..7113d73 --- /dev/null +++ b/qml/VectoClock.qml @@ -0,0 +1,628 @@ +import QtQuick 2.12 + +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtGraphicalEffects 1.0 +import QtQuick.Shapes 1.1 + +import NERvGear 1.0 as NVG +import NERvGear.Controls 1.0 +import NERvGear.Templates 1.0 as T +import NERvGear.Preferences 1.0 as P + +import "." + +WidgetTemplate { + id: widget + title: qsTr("Vecto Clock") + editing: styleDialog.active + resizable: true + + version: "1.0.0" + defaultValues: { + "Weekday Settings": { + "Color": "#ffffff", + "Font Size": 43, + "Font Name": Common.fonts.length - 1, + "Font Weight": 2, + "Letter Spacing": 4, + "Y Offset": 50, + "Gap": 12 + }, + "Line Settings": { + "Color": "#ffffff", + "Width": 30, + "Position": -8 + }, + "Clock Settings": { + "Full Clock": false, + "Text Color": "#554e49", + "Background Visible": true, + "Background Color": "#ffffff", + "Font Size": 33, + "Font Name": Common.fonts.length - 1, + "Font Weight": 1, + "Letter Spacing": 0, + "X Offset": 0, + "Y Offset": 24, + "Gap": 9 + }, + "Date Settings": { + "Color": "#ffffff", + "Font Size": 10, + "Font Name": Common.fonts.length - 1, + "Font Weight": 1, + "Letter Spacing": 25, + "X Offset": 29, + "Y Offset": 12 + } + } + + menu: Menu { + Action { + text: qsTr("Settings") + "..." + onTriggered: styleDialog.active = true + } + } + + readonly property var configs: widget.settings.styles + + onConfigsChanged: { + weekday_mask_source.requestPaint(); + divline.requestPaint(); + clockbg.requestPaint(); + configsFlag = true; + } + + property bool configsFlag: false + + property real thour: 0 + property real t12hour: 0 + property real tmin: -1 + + readonly property var weekdays: ["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"] + property int weekday: -1 + readonly property var months: ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"] + property string dateString: "" + + readonly property real whRatio: width/height + readonly property real fixWHRatio: 2.1 + + property real clock_width: main.height*fixWHRatio * (0.5-0.005*configs["Line Settings"]["Position"]) + property real left_gap_ratio: configs["Weekday Settings"]["Gap"]/100 + property real right_gap_ratio: configs["Clock Settings"]["Gap"]/100 + property real clock_text_size: weekday_mask.height*configs["Clock Settings"]["Font Size"]/100 + property real right_topMargin: (timeinfo.height-clock_text_size)*configs["Clock Settings"]["Y Offset"]/100 + + Item { + id: main + anchors.centerIn: parent + width: widget.width + height: whRatio > fixWHRatio ? widget.height : widget.width/fixWHRatio + + Item { + id: weekday_mask + width: main.width - clock_width + height: main.height + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + layer.enabled: true + layer.effect: OpacityMask{ + maskSource: weekday_mask_source + } + + Canvas { + id: weekday_mask_source + visible: false + anchors.fill: parent + renderStrategy: Canvas.Cooperative + contextType: "2d" + onPaint: { + context.reset(); + context.clearRect(0,0,width,height); + context.beginPath(); + context.lineTo(weekday_mask.width-weekday_mask.height*left_gap_ratio, 0); + context.lineTo(weekday_mask.width-0.45*weekday_mask.height-weekday_mask.height*left_gap_ratio, weekday_mask.height); + context.lineTo(0, weekday_mask.height); + context.lineTo(0, 0); + context.closePath(); + context.fill(); + } + onHeightChanged: { + requestPaint(); + } + onWidthChanged: { + requestPaint(); + } + } + + Text { + id: weekday_text + text: weekday>-1 ? weekdays[weekday] : "" + color: configs["Weekday Settings"]["Color"] + anchors.left: parent.left + anchors.top: parent.top + anchors.topMargin: (weekday_mask.height-height*0.75)*configs["Weekday Settings"]["Y Offset"]/100 + + style: Text.Outline + styleColor: "transparent" + + font.pixelSize: weekday_mask.height*configs["Weekday Settings"]["Font Size"]/100 + font.letterSpacing: weekday_mask.width/text.length*configs["Weekday Settings"]["Letter Spacing"]/100 + font.family: Common.fonts[configs["Weekday Settings"]["Font Name"]] + font.weight: Common.fontweight[configs["Weekday Settings"]["Font Weight"]] + } + } + + Item { + id: timeinfo + width: clock_width+0.45*timeinfo.height + height: main.height + anchors.right: parent.right + anchors.top: parent.top + + Canvas { + id: divline + anchors.fill: parent + renderTarget: Canvas.FramebufferObject + renderStrategy: Canvas.Cooperative + contextType: "2d" + onPaint: { + context.reset(); + context.clearRect(0,0,width,height); + context.lineWidth = 6*configs["Line Settings"]["Width"]/100; + context.strokeStyle = configs["Line Settings"]["Color"]; + context.beginPath(); + context.moveTo(0, timeinfo.height); + context.lineTo(0.45*timeinfo.height, 0); + context.closePath(); + context.stroke(); + } + onHeightChanged: { + requestPaint(); + } + } + + Canvas { + id: clockbg + width: timeinfo.width + height: clock_text_size + visible: configs["Clock Settings"]["Background Visible"] + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: right_topMargin + renderStrategy: Canvas.Cooperative + contextType: "2d" + onPaint: { + context.reset(); + context.clearRect(0,0,width,height); + context.fillStyle = configs["Clock Settings"]["Background Color"]; + context.beginPath(); + context.moveTo(timeinfo.width, 0); + context.lineTo(0.45*(timeinfo.height-right_topMargin)+timeinfo.height*right_gap_ratio, 0); + context.lineTo(timeinfo.height*right_gap_ratio, timeinfo.height-right_topMargin); + context.lineTo(timeinfo.width, timeinfo.height); + context.closePath(); + context.fill(); + } + onHeightChanged: { + requestPaint(); + } + } + + Text { + id: clock_text + anchors.horizontalCenter: clockbg.horizontalCenter + anchors.horizontalCenterOffset: -right_topMargin*0.225 + timeinfo.width*(0.225*configs["Clock Settings"]["X Offset"]+12.5)/100 + timeinfo.height*right_gap_ratio/2 + anchors.verticalCenterOffset: height/100 + anchors.verticalCenter: clockbg.verticalCenter + text: "" + color: configs["Clock Settings"]["Text Color"] + + style: Text.Outline + styleColor: "transparent" + + font.pixelSize: clock_text_size/1.7 + font.letterSpacing: clock_width/text.length*configs["Clock Settings"]["Letter Spacing"]/100 + font.family: Common.fonts[configs["Clock Settings"]["Font Name"]] + font.weight: Common.fontweight[configs["Clock Settings"]["Font Weight"]] + } + + Text { + id: date_text + anchors.top: clockbg.bottom + anchors.topMargin: (configs["Date Settings"]["Y Offset"]>0 ? (main.height-right_topMargin-clock_text_size-height) : right_topMargin+clock_text_size)*configs["Date Settings"]["Y Offset"]/100 + anchors.left: clockbg.left + anchors.leftMargin: (configs["Date Settings"]["X Offset"]>0 ? clock_width : main.width-timeinfo.width)*configs["Date Settings"]["X Offset"]/100 + + text: dateString + color: configs["Date Settings"]["Color"] + + style: Text.Outline + styleColor: "transparent" + + font.pixelSize: timeinfo.height*configs["Date Settings"]["Font Size"]/100 + font.letterSpacing: clock_width/text.length*configs["Date Settings"]["Letter Spacing"]/100 + font.family: Common.fonts[configs["Date Settings"]["Font Name"]] + font.weight: Common.fontweight[configs["Date Settings"]["Font Weight"]] + } + } + } + + Timer { + interval: 250 + + running: true + repeat: true + onTriggered: { + var now = new Date(); + if (tmin !== now.getMinutes() || configsFlag) { + configsFlag = false; + tmin = now.getMinutes(); + thour = now.getHours(); + if (configs["Clock Settings"]["Full Clock"]) { + clock_text.text = [("0"+thour).slice(-2), ("0"+tmin).slice(-2)].join(":"); + } else { + t12hour = thour > 12 ? thour - 12 : thour; + clock_text.text = [t12hour,("0"+tmin).slice(-2)].join(":") + (thour > 11 ? "PM" : "AM"); + } + + if (weekday !== now.getDay()) { + weekday = now.getDay(); + dateString = [months[now.getMonth()], now.getDate(), now.getFullYear()].join(" "); + } + } + } + } + + + + + + Loader { + id: styleDialog + active: false + sourceComponent: NVG.Window { + id: window + title: qsTr("Settings") + visible: true + minimumWidth: 500 + minimumHeight: 600 + width: minimumWidth + height: minimumHeight + + transientParent: widget.NVG.View.window + + property var configuration + + Page { + id: cfg_page + anchors.fill: parent + + header: TitleBar { + text: qsTr("Vecto Clock") + + standardButtons: Dialog.Save | Dialog.Reset + + onAccepted: { + configuration = rootPreference.save(); + widget.settings.styles = configuration; + styleDialog.active = false; + } + + onReset: { + rootPreference.load(); + let cfg = rootPreference.save(); + widget.settings.styles = cfg; + } + } + + ColumnLayout { + id: root + anchors.fill: parent + anchors.margins: 16 + anchors.topMargin: 16 + + Flickable { + Layout.fillWidth: true + Layout.fillHeight: true + + clip: true + contentWidth: preferenceLayout.implicitWidth + contentHeight: preferenceLayout.implicitHeight + + ColumnLayout { + id: preferenceLayout + width: root.width + + P.PreferenceGroup { + id: rootPreference + Layout.fillWidth: true + + label: qsTr("Configuration") + + onPreferenceEdited: { + widget.settings.styles = rootPreference.save(); + } + + P.DialogPreference { + name: "Weekday Settings" + label: qsTr("Weekday Settings") + live: true + icon.name: "regular:\uf1de" + + P.ColorPreference { + name: "Color" + label: qsTr("Color") + defaultValue: defaultValues["Weekday Settings"]["Color"] + } + + P.SliderPreference { + name: "Font Size" + label: qsTr("Font Size") + from: 1 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Weekday Settings"]["Font Size"] + displayValue: value + "%" + } + + P.SelectPreference { + name: "Font Name" + label: qsTr("Font Style") + defaultValue: defaultValues["Weekday Settings"]["Font Name"] + model: Common.fonts + } + + P.SelectPreference { + name: "Font Weight" + label: qsTr("Font Weight") + defaultValue: defaultValues["Weekday Settings"]["Font Weight"] + model: Common.sfontweight + } + + P.SliderPreference { + name: "Letter Spacing" + label: qsTr("Letter Spacing") + from: 0 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Weekday Settings"]["Letter Spacing"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "Y Offset" + label: qsTr("Y Offset") + from: 0 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Weekday Settings"]["Y Offset"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "Gap" + label: qsTr("Gap") + from: 0 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Weekday Settings"]["Gap"] + displayValue: value + "%" + } + } + + P.DialogPreference { + name: "Line Settings" + label: qsTr("Line Settings") + live: true + icon.name: "regular:\uf1de" + + P.ColorPreference { + name: "Color" + label: qsTr("Color") + defaultValue: defaultValues["Line Settings"]["Color"] + } + + P.SliderPreference { + name: "Width" + label: qsTr("Width") + from: 1 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Line Settings"]["Width"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "Position" + label: qsTr("Position") + from: -100 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Line Settings"]["Position"] + displayValue: value + "%" + } + } + + P.DialogPreference { + name: "Clock Settings" + label: qsTr("Clock Settings") + live: true + icon.name: "regular:\uf1de" + + P.SwitchPreference { + name: "Full Clock" + label: qsTr("24 Hour Clock") + defaultValue: defaultValues["Clock Settings"]["Full Clock"] + } + + P.ColorPreference { + name: "Text Color" + label: qsTr("Text Color") + defaultValue: defaultValues["Clock Settings"]["Text Color"] + } + + P.SwitchPreference { + id: _cfg_clock_background_visible + name:"Background Visible" + label: qsTr("Background Visible") + defaultValue: defaultValues["Clock Settings"]["Background Visible"] + } + + P.ColorPreference { + name: "Background Color" + label: qsTr("Background Color") + enabled: _cfg_clock_background_visible.value + defaultValue: defaultValues["Clock Settings"]["Background Color"] + } + + P.SliderPreference { + name: "Font Size" + label: qsTr("Font Size") + from: 1 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Clock Settings"]["Font Size"] + displayValue: value + "%" + } + + P.SelectPreference { + name: "Font Name" + label: qsTr("Font Style") + defaultValue: defaultValues["Clock Settings"]["Font Name"] + model: Common.fonts + } + + P.SelectPreference { + name: "Font Weight" + label: qsTr("Font Weight") + defaultValue: defaultValues["Clock Settings"]["Font Weight"] + model: Common.sfontweight + } + + P.SliderPreference { + name: "Letter Spacing" + label: qsTr("Letter Spacing") + from: 0 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Clock Settings"]["Letter Spacing"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "X Offset" + label: qsTr("X Offset") + from: -100 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Clock Settings"]["X Offset"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "Y Offset" + label: qsTr("Y Offset") + from: 0 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Clock Settings"]["Y Offset"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "Gap" + label: qsTr("Gap") + from: 0 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Clock Settings"]["Gap"] + displayValue: value + "%" + } + } + + P.DialogPreference { + name: "Date Settings" + label: qsTr("Date Settings") + live: true + icon.name: "regular:\uf1de" + + P.ColorPreference { + name: "Color" + label: qsTr("Color") + defaultValue: defaultValues["Date Settings"]["Color"] + } + + P.SliderPreference { + name: "Font Size" + label: qsTr("Font Size") + from: 1 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Date Settings"]["Font Size"] + displayValue: value + "%" + } + + P.SelectPreference { + name: "Font Name" + label: qsTr("Font Style") + defaultValue: defaultValues["Date Settings"]["Font Name"] + model: Common.fonts + } + + P.SelectPreference { + name: "Font Weight" + label: qsTr("Font Weight") + defaultValue: defaultValues["Date Settings"]["Font Weight"] + model: Common.sfontweight + } + + P.SliderPreference { + name: "Letter Spacing" + label: qsTr("Letter Spacing") + from: 0 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Date Settings"]["Letter Spacing"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "X Offset" + label: qsTr("X Offset") + from: -100 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Date Settings"]["X Offset"] + displayValue: value + "%" + } + + P.SliderPreference { + name: "Y Offset" + label: qsTr("Y Offset") + from: -100 + to: 100 + stepSize: 1 + defaultValue: defaultValues["Date Settings"]["Y Offset"] + displayValue: value + "%" + } + } + + Component.onCompleted: { + rootPreference.load(widget.settings.styles); + configuration = widget.settings.styles; + } + } + } + } + } + } + + onClosing: { + widget.settings.styles = configuration; + styleDialog.active = false; + } + } + } +} diff --git a/qml/WidgetTemplate.qml b/qml/WidgetTemplate.qml new file mode 100644 index 0000000..8fb82a0 --- /dev/null +++ b/qml/WidgetTemplate.qml @@ -0,0 +1,44 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +import NERvGear 1.0 as NVG +import NERvGear.Templates 1.0 as T + + +T.Widget { + solid: true + visible: true + + property string version: "" + property var defaultValues: {} + signal completed() + signal updated() + + function updateObject(targetObj, sourceObj) { + for (let prop in sourceObj) { + if (sourceObj.hasOwnProperty(prop) && sourceObj[prop] !== undefined) { + if (typeof sourceObj[prop] === 'object') { + Object.assign(targetObj[prop], sourceObj[prop]); + } else { + targetObj[prop] = sourceObj[prop]; + } + } + } + return targetObj; + } + + onUpdated: { + widget.settings.styles = updateObject(JSON.parse(JSON.stringify(defaultValues)), widget.settings.styles); + } + + Component.onCompleted: { + if (!widget.settings.styles) { + widget.settings.styles = defaultValues; + widget.settings.version = version; + } else if (widget.settings.version !== version) { + updated(); + widget.settings.version = version; + } + completed(); + } +} diff --git a/qml/qmldir b/qml/qmldir new file mode 100644 index 0000000..f7640a6 --- /dev/null +++ b/qml/qmldir @@ -0,0 +1 @@ +singleton Common 1.0 Common.qml \ No newline at end of file