Compare commits

...

2 Commits

Author SHA1 Message Date
mashiros 6cf739c5eb - 统一接口 2 years ago
mashiros 75d948494c 统一设置页面样式 2 years ago
  1. BIN
      Locales/zh.qm
  2. 756
      Locales/zh.ts
  3. 20
      package.json
  4. BIN
      preview/vecto_clock.png
  5. 9
      qml/Common.qml
  6. 503
      qml/ReflectionClock.qml
  7. 206
      qml/RoundClock.qml
  8. 731
      qml/SolarsClock.qml
  9. 229
      qml/TextClock.qml
  10. 628
      qml/VectoClock.qml
  11. 44
      qml/WidgetTemplate.qml
  12. 1
      qml/qmldir
  13. 465
      reflection_clock.qml
  14. 687
      solars_clock.qml

BIN
Locales/zh.qm

Binary file not shown.

756
Locales/zh.ts

@ -0,0 +1,756 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>Common</name>
<message>
<location filename="qml/Common.qml" line="8"/>
<source>Light</source>
<translation></translation>
</message>
<message>
<location filename="qml/Common.qml" line="8"/>
<source>Normal</source>
<translation></translation>
</message>
<message>
<location filename="qml/Common.qml" line="8"/>
<source>Bold</source>
<translation></translation>
</message>
</context>
<context>
<name>ReflectionClock</name>
<message>
<location filename="qml/ReflectionClock.qml" line="16"/>
<source>Reflection Clock</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="292"/>
<location filename="qml/ReflectionClock.qml" line="318"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="302"/>
<source>Clock Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="357"/>
<source>Configuration</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="365"/>
<source>Hour Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="371"/>
<source>24 Hour Clock</source>
<translation>24</translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="379"/>
<location filename="qml/ReflectionClock.qml" line="414"/>
<location filename="qml/ReflectionClock.qml" line="458"/>
<source>Clock Background Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="385"/>
<location filename="qml/ReflectionClock.qml" line="420"/>
<location filename="qml/ReflectionClock.qml" line="465"/>
<source>Clock Font Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="393"/>
<location filename="qml/ReflectionClock.qml" line="428"/>
<location filename="qml/ReflectionClock.qml" line="474"/>
<source>Panel Background Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="399"/>
<location filename="qml/ReflectionClock.qml" line="434"/>
<location filename="qml/ReflectionClock.qml" line="481"/>
<source>Panel Font Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="408"/>
<source>Minute Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="443"/>
<source>Second Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/ReflectionClock.qml" line="450"/>
<source>Show</source>
<translation></translation>
</message>
</context>
<context>
<name>RoundClock</name>
<message>
<location filename="qml/RoundClock.qml" line="15"/>
<location filename="qml/RoundClock.qml" line="346"/>
<source>Round Clock</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="320"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="330"/>
<source>Clock Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="385"/>
<source>Configuration</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="393"/>
<source>Continuous Second Hand</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="401"/>
<source>Background Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="407"/>
<source>Background transparency</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="419"/>
<source>Hour Scale Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="425"/>
<source>Minute Scale Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="433"/>
<source>Hour Hand Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="439"/>
<source>Minute Hand Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/RoundClock.qml" line="445"/>
<source>Second Hand Color</source>
<translation></translation>
</message>
</context>
<context>
<name>SolarsClock</name>
<message>
<location filename="qml/SolarsClock.qml" line="15"/>
<location filename="qml/SolarsClock.qml" line="430"/>
<source>Solar Clock</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="404"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="414"/>
<source>Clock Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="469"/>
<source>Configuration</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="477"/>
<source>Background Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="483"/>
<source>Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="489"/>
<source>Transparency</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="502"/>
<source>Show Scale</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="508"/>
<source>Scale Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="518"/>
<source>Show Center</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="524"/>
<source>Center Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="531"/>
<source>Center Radius</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="545"/>
<source>Display Time</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="551"/>
<source>Font Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="558"/>
<source>Font Style</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="566"/>
<source>Font Weight</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="574"/>
<source>Font Size</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="588"/>
<source>Hour Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="594"/>
<location filename="qml/SolarsClock.qml" line="623"/>
<location filename="qml/SolarsClock.qml" line="652"/>
<location filename="qml/SolarsClock.qml" line="681"/>
<source>Star Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="603"/>
<location filename="qml/SolarsClock.qml" line="632"/>
<location filename="qml/SolarsClock.qml" line="661"/>
<location filename="qml/SolarsClock.qml" line="690"/>
<source>Show Orbit</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="609"/>
<location filename="qml/SolarsClock.qml" line="638"/>
<location filename="qml/SolarsClock.qml" line="667"/>
<location filename="qml/SolarsClock.qml" line="696"/>
<source>Orbit Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="617"/>
<source>Minute Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="646"/>
<source>Second Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/SolarsClock.qml" line="675"/>
<source>Millisecond Settings</source>
<translation></translation>
</message>
</context>
<context>
<name>TextClock</name>
<message>
<location filename="qml/TextClock.qml" line="15"/>
<location filename="qml/TextClock.qml" line="186"/>
<source>Text Clock</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="160"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="170"/>
<source>Clock Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="225"/>
<source>Configuration</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="233"/>
<source>Font Style</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="241"/>
<source>Font Weight</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="249"/>
<source>HighLight Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="255"/>
<source>Normal Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="261"/>
<source>Font Size</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="271"/>
<source>Letter Space</source>
<translation></translation>
</message>
<message>
<location filename="qml/TextClock.qml" line="281"/>
<source>Line Spacing</source>
<translation></translation>
</message>
</context>
<context>
<name>VectoClock</name>
<message>
<location filename="qml/VectoClock.qml" line="17"/>
<location filename="qml/VectoClock.qml" line="303"/>
<source>Vecto Clock</source>
<translation>Vecto时钟</translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="63"/>
<location filename="qml/VectoClock.qml" line="287"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="342"/>
<source>Configuration</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="350"/>
<source>Weekday Settings</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="356"/>
<location filename="qml/VectoClock.qml" line="423"/>
<location filename="qml/VectoClock.qml" line="553"/>
<source>Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="362"/>
<location filename="qml/VectoClock.qml" line="482"/>
<location filename="qml/VectoClock.qml" line="559"/>
<source>Font Size</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="372"/>
<location filename="qml/VectoClock.qml" line="492"/>
<location filename="qml/VectoClock.qml" line="569"/>
<source>Font Style</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="379"/>
<location filename="qml/VectoClock.qml" line="499"/>
<location filename="qml/VectoClock.qml" line="576"/>
<source>Font Weight</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="386"/>
<location filename="qml/VectoClock.qml" line="506"/>
<location filename="qml/VectoClock.qml" line="583"/>
<source>Letter Spacing</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="396"/>
<location filename="qml/VectoClock.qml" line="526"/>
<location filename="qml/VectoClock.qml" line="603"/>
<source>Y Offset</source>
<translation>Y偏移量</translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="406"/>
<location filename="qml/VectoClock.qml" line="536"/>
<source>Gap</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="417"/>
<source>Line Settings</source>
<translation>线</translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="429"/>
<source>Width</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="439"/>
<source>Position</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="450"/>
<source>Clock Settings</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="456"/>
<source>24 Hour Clock</source>
<translation>24</translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="462"/>
<source>Text Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="469"/>
<source>Background Visible</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="475"/>
<source>Background Color</source>
<translation></translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="516"/>
<location filename="qml/VectoClock.qml" line="593"/>
<source>X Offset</source>
<translation>X偏移量</translation>
</message>
<message>
<location filename="qml/VectoClock.qml" line="547"/>
<source>Date Settings</source>
<translation></translation>
</message>
</context>
<context>
<name>reflection_clock</name>
<message>
<source>Save</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Reset</source>
<translation type="vanished"></translation>
</message>
<message>
<source>24 Hour Clock</source>
<translation type="vanished">24</translation>
</message>
<message>
<source>Reflection Clock</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Hour Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Second Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Configuration</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Minute Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Panel Background Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Panel Font Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Clock Background Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Clock Font Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Clock Settings</source>
<translation type="vanished"></translation>
</message>
</context>
<context>
<name>round_clock</name>
<message>
<source>Save</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Reset</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Second Hand Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Hour Scale Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Minute Scale Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Round Clock</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Configuration</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Background Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Hour Hand Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Continuous Second Hand</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Minute Hand Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Clock Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Background transparency</source>
<translation type="vanished"></translation>
</message>
</context>
<context>
<name>solars_clock</name>
<message>
<source>Save</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Reset</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Center Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Background Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Transparency</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Hour Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Solar Clock</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Star Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show Center</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Font Size</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Orbit Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Font Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Millisecond Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Second Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Configuration</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Scale Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show Orbit</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show Scale</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Minute Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Display Time</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Center Radius</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Clock Settings</source>
<translation type="vanished"></translation>
</message>
</context>
<context>
<name>text_clock</name>
<message>
<source>Save</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Reset</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Letter Space</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Font Size</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Font Weight</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Text Clock</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Font Style</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Configuration</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Normal Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>HighLight Color</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Settings</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Line Spacing</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Clock Settings</source>
<translation type="vanished"></translation>
</message>
</context>
</TS>

20
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"
}
]
}

BIN
preview/vecto_clock.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

9
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")]
}

503
qml/ReflectionClock.qml

@ -0,0 +1,503 @@
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
WidgetTemplate {
id: widget
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["Hour Settings"]["Full Clock"]
property string am_pm: ""
Rectangle {
id: main
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
width: 345*multi
height: 222*multi
Rectangle {
id: hour
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 15*multi
width: 100*multi
height: 111*multi
Rectangle {
id: hour_top
color: widget.settings.styles["Hour Settings"]["Clock BG Color"]
width: 100*multi
height: 80*multi
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
Text {
id: hour_text
text: ""
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
font.family: "Microsoft YaHei"
}
}
Rectangle {
id: hour_bottom
color: widget.settings.styles["Hour Settings"]["Panel BG Color"]
width: 100*multi
height: 30*multi
anchors.top: hour_top.bottom
anchors.topMargin: multi
anchors.left: parent.left
anchors.leftMargin: 0
Text {
text: "HOURS"+am_pm
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
font.family: "Microsoft YaHei"
font.letterSpacing: 2*multi
}
}
}
Rectangle {
id: min
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: hour.right
anchors.leftMargin: 15*multi
width: 100*multi
height: 111*multi
Rectangle {
id: min_top
color: widget.settings.styles["Min Settings"]["Clock BG Color"]
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
width: 100*multi
height: 80*multi
Text {
id: min_text
text: ""
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
font.family: "Microsoft YaHei"
}
}
Rectangle {
id: min_bottom
color: widget.settings.styles["Min Settings"]["Panel BG Color"]
width: 100*multi
height: 30*multi
anchors.top: min_top.bottom
anchors.topMargin: multi
anchors.left: parent.left
anchors.leftMargin: 0
Text {
text: "MINUTES"
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
font.family: "Microsoft YaHei"
font.letterSpacing: 2*multi
}
}
}
Rectangle {
id: sec
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: min.right
anchors.leftMargin: 15*multi
visible: widget.settings.styles["Sec Settings"]["Visible"]
width: 100*multi
height: 111*multi
Rectangle {
id: sec_top
color: widget.settings.styles["Sec Settings"]["Clock BG Color"]
width: 100*multi
height: 80*multi
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
Text {
id: sec_text
text: ""
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
font.family: "Microsoft YaHei"
}
}
Rectangle {
id: sec_bottom
color: widget.settings.styles["Sec Settings"]["Panel BG Color"]
width: 100*multi
height: 30*multi
anchors.top: sec_top.bottom
anchors.topMargin: multi
anchors.left: parent.left
anchors.leftMargin: 0
Text {
text: "SECONDS"
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
font.family: "Microsoft YaHei"
font.letterSpacing: 2*multi
}
}
}
}
OpacityMask {
width: main.width
height: main.height
anchors.top: main.bottom
anchors.topMargin: multi
source: main
maskSource: Rectangle {
width: main.width
height: main.height
gradient: Gradient{
GradientStop{position: 0.0;color:"transparent"}
GradientStop{position: 1.0;color:"#FFF"}
}
}
transform: Scale {yScale: -1}
}
Timer {
interval: 250
repeat: true
running: widget.NVG.View.exposed
onTriggered: {
var now = new Date(),
sec = now.getSeconds(),
min = now.getMinutes(),
hr = now.getHours();
if(!full_clock) {
am_pm = "|" + (hr > 11 ? "PM" : "AM");
if (hr === 0 || hr === 24)
hr = 12;
else if(hr > 12)
hr -= 12;
} else {
am_pm = "";
}
hour_text.text = hr < 10 ? "0"+hr : hr;
min_text.text = min < 10 ? "0"+min : min;
sec_text.text = sec < 10 ? "0"+sec : sec;
}
}
menu: Menu {
Action {
text: qsTr("Settings") + "..."
onTriggered: styleDialog.active = true
}
}
Loader {
id: styleDialog
active: false
sourceComponent: NVG.Window {
id: window
title: qsTr("Clock Settings")
visible: true
minimumWidth: 380
minimumHeight: 480
width: minimumWidth
height: minimumHeight
transientParent: widget.NVG.View.window
property var configuration
Page {
id: cfg_page
anchors.fill: parent
header: TitleBar {
text: qsTr("Settings")
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: 0
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: "Hour Settings"
label: qsTr("Hour Settings")
live: true
icon.name: "regular:\uf1de"
P.SwitchPreference {
name: "Full Clock"
label: qsTr("24 Hour Clock")
defaultValue: defaultValues["Hour Settings"]["Full Clock"]
}
P.Separator {}
P.ColorPreference {
name: "Clock BG Color"
label: qsTr("Clock Background Color")
defaultValue: defaultValues["Hour Settings"]["Clock BG Color"]
}
P.ColorPreference {
name: "Clock Font Color"
label: qsTr("Clock Font Color")
defaultValue: defaultValues["Hour Settings"]["Clock Font Color"]
}
P.Separator {}
P.ColorPreference {
name: "Panel BG Color"
label: qsTr("Panel Background Color")
defaultValue: defaultValues["Hour Settings"]["Panel BG Color"]
}
P.ColorPreference {
name: "Panel Font Color"
label: qsTr("Panel Font Color")
defaultValue: defaultValues["Hour Settings"]["Panel Font Color"]
}
}
P.Separator {}
P.DialogPreference {
name: "Min Settings"
label: qsTr("Minute Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Clock BG Color"
label: qsTr("Clock Background Color")
defaultValue: defaultValues["Min Settings"]["Clock BG Color"]
}
P.ColorPreference {
name: "Clock Font Color"
label: qsTr("Clock Font Color")
defaultValue: defaultValues["Min Settings"]["Clock Font Color"]
}
P.Separator {}
P.ColorPreference {
name: "Panel BG Color"
label: qsTr("Panel Background Color")
defaultValue: defaultValues["Min Settings"]["Panel BG Color"]
}
P.ColorPreference {
name: "Panel Font Color"
label: qsTr("Panel Font Color")
defaultValue: defaultValues["Min Settings"]["Panel Font Color"]
}
}
P.Separator {}
P.DialogPreference {
name: "Sec Settings"
label: qsTr("Second Settings")
live: true
icon.name: "regular:\uf1de"
P.SwitchPreference {
id: cfg_sec_en
name: "Visible"
label: qsTr("Show")
defaultValue: defaultValues["Sec Settings"]["Visible"]
}
P.Separator {}
P.ColorPreference {
name: "Clock BG Color"
label: qsTr("Clock Background Color")
enabled: cfg_sec_en.value
defaultValue: defaultValues["Sec Settings"]["Clock BG Color"]
}
P.ColorPreference {
name: "Clock Font Color"
label: qsTr("Clock Font Color")
enabled: cfg_sec_en.value
defaultValue: defaultValues["Sec Settings"]["Clock Font Color"]
}
P.Separator {}
P.ColorPreference {
name: "Panel BG Color"
label: qsTr("Panel Background Color")
enabled: cfg_sec_en.value
defaultValue: defaultValues["Sec Settings"]["Panel BG Color"]
}
P.ColorPreference {
name: "Panel Font Color"
label: qsTr("Panel Font Color")
enabled: cfg_sec_en.value
defaultValue: defaultValues["Sec Settings"]["Panel Font Color"]
}
}
Component.onCompleted: {
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
}
}
}
}
}
onClosing: {
widget.settings.styles = configuration;
styleDialog.active = false;
}
}
}
}

206
round_clock.qml → qml/RoundClock.qml

@ -4,23 +4,36 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
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
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();
@ -139,7 +152,7 @@ T.Widget {
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: thour*30+tmin*0.5+tsec*0.6/60
rotation: thour*30+tmin*0.5+tsec*0.01
onWidthChanged: {
requestPaint();
@ -318,8 +331,6 @@ T.Widget {
visible: true
minimumWidth: 380
minimumHeight: 540
maximumWidth: minimumWidth
maximumHeight: minimumHeight
width: minimumWidth
height: minimumHeight
@ -327,127 +338,118 @@ T.Widget {
property var configuration
ColumnLayout {
id: root
Page {
id: cfg_page
anchors.fill: parent
anchors.margins: 16
anchors.topMargin: 0
Row {
spacing: 234
ToolButton {
text: qsTr("Save")
onClicked: {
configuration = rootPreference.save();
widget.settings.styles = configuration;
styleDialog.active = false;
}
header: TitleBar {
text: qsTr("Round Clock")
standardButtons: Dialog.Save | Dialog.Reset
onAccepted: {
configuration = rootPreference.save();
widget.settings.styles = configuration;
styleDialog.active = false;
}
ToolButton {
text: qsTr("Reset")
onClicked: {
rootPreference.load();
let cfg = rootPreference.save();
widget.settings.styles = cfg;
}
onReset: {
rootPreference.load();
let cfg = rootPreference.save();
widget.settings.styles = cfg;
}
}
Label {
Layout.alignment: Qt.AlignCenter
text: qsTr("Settings")
font.pixelSize: 24
}
ColumnLayout {
id: root
anchors.fill: parent
anchors.margins: 16
anchors.topMargin: 0
Flickable {
Layout.fillWidth: true
Layout.fillHeight: true
Flickable {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
contentWidth: preferenceLayout.implicitWidth
contentHeight: preferenceLayout.implicitHeight
clip: true
contentWidth: preferenceLayout.implicitWidth
contentHeight: preferenceLayout.implicitHeight
ColumnLayout {
id: preferenceLayout
width: root.width
ColumnLayout {
id: preferenceLayout
width: root.width
P.PreferenceGroup {
id: rootPreference
Layout.fillWidth: true
P.PreferenceGroup {
id: rootPreference
Layout.fillWidth: true
label: qsTr("Configuration")
label: qsTr("Configuration")
onPreferenceEdited: {
widget.settings.styles = rootPreference.save();
}
onPreferenceEdited: {
widget.settings.styles = rootPreference.save();
}
P.SwitchPreference {
name: "Sec Continue"
label: qsTr("Continuous Second Hand")
defaultValue: true
}
P.SwitchPreference {
name: "Sec Continue"
label: qsTr("Continuous Second Hand")
defaultValue: defaultValues["Sec Continue"]
}
P.Separator {}
P.Separator {}
P.ColorPreference {
name: "BG Color"
label: qsTr("Background Color")
defaultValue: "#2196f3"
}
P.ColorPreference {
name: "BG Color"
label: qsTr("Background Color")
defaultValue: defaultValues["BG Color"]
}
P.SliderPreference {
name: "BG Alpha"
label: qsTr("Background transparency")
from: 0
to: 100
stepSize: 1
defaultValue: 50
displayValue: value + "%"
}
P.SliderPreference {
name: "BG Alpha"
label: qsTr("Background transparency")
from: 0
to: 100
stepSize: 1
defaultValue: defaultValues["BG Alpha"]
displayValue: value + "%"
}
P.Separator {}
P.Separator {}
P.ColorPreference {
name: "HGRID Color"
label: qsTr("Hour Scale Color")
defaultValue: "#fff"
}
P.ColorPreference {
name: "HGRID Color"
label: qsTr("Hour Scale Color")
defaultValue: defaultValues["HGRID Color"]
}
P.ColorPreference {
name: "MGRID Color"
label: qsTr("Minute Scale Color")
defaultValue: "#fff"
}
P.ColorPreference {
name: "MGRID Color"
label: qsTr("Minute Scale Color")
defaultValue: defaultValues["MGRID Color"]
}
P.Separator {}
P.Separator {}
P.ColorPreference {
name: "Hhand Color"
label: qsTr("Hour Hand Color")
defaultValue: "#fff"
}
P.ColorPreference {
name: "Hhand Color"
label: qsTr("Hour Hand Color")
defaultValue: defaultValues["Hhand Color"]
}
P.ColorPreference {
name: "Mhand Color"
label: qsTr("Minute Hand Color")
defaultValue: "#fff"
}
P.ColorPreference {
name: "Mhand Color"
label: qsTr("Minute Hand Color")
defaultValue: defaultValues["Mhand Color"]
}
P.ColorPreference {
name: "Shand Color"
label: qsTr("Second Hand Color")
defaultValue: "#F3A829"
}
P.ColorPreference {
name: "Shand Color"
label: qsTr("Second Hand Color")
defaultValue: defaultValues["Shand Color"]
}
Component.onCompleted: {
if(!widget.settings.styles) {
configuration = rootPreference.save();
widget.settings.styles = configuration;
Component.onCompleted: {
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
}
}

731
qml/SolarsClock.qml

@ -0,0 +1,731 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
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
WidgetTemplate {
id: widget
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
readonly property real rsec: maxr*0.5
property real thour: 0
property real tmin: 0
property real tsec: 0
property real tmsec: 0
property var configs: widget.settings.styles
onConfigsChanged: {
background.requestPaint();
hour.requestPaint();
min.requestPaint();
sec.requestPaint();
millisec_orbit.requestPaint();
millisec_star.requestPaint();
center.requestPaint();
}
function colorToRGBA(color, alpha) {
var color1, color2, color3;
color = ""+color;
if (typeof color !== "string") return;
if (color.charAt(0) === "#") {
color = color.substring(1);
}
var not16num = color.split("").filter(function (item, index) {
return isNaN(parseInt(item, 16))
});
if(not16num.length) return;
switch (color.length) {
case 3:
color1 = color.substr(0,1);
color2 = color.substr(1,1);
color3 = color.substr(2,1);
color1 = color1 + color1;
color2 = color2 + color2;
color3 = color3 + color3;
break;
case 6:
color1 = color.substr(0,2);
color2 = color.substr(2,2);
color3 = color.substr(4,2);
break;
default:
return false;
}
color1 = parseInt(color1, 16);
color2 = parseInt(color2, 16);
color3 = parseInt(color3, 16);
return "rgba("+color1+","+color2+","+color3+","+alpha+")";
}
Timer {
interval: 50
running: widget.NVG.View.exposed
repeat: true
onTriggered: {
var now = new Date();
tmsec = now.getMilliseconds();
tsec = now.getSeconds();
tmin = now.getMinutes();
thour = now.getHours();
main_time.text = (thour<10 ? "0"+thour : thour) + ":" + (tmin<10 ? "0"+tmin : tmin) + ":" + (tsec<10 ? "0"+tsec : tsec);
thour = thour > 12 ? thour - 12 : thour;
tsec += tmsec/1000;
}
}
Canvas {
id: background
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2); //
context.rotate(-Math.PI/2); //90x12
context.fillStyle = colorToRGBA(configs["BG Settings"]["BG Color"], configs["BG Settings"]["BG Alpha"]/100);
context.beginPath();
context.arc(0, 0, maxr, 0, Math.PI * 2, true);
context.fill();
if (configs["Hour Settings"]["Show Orbit"]) {
context.strokeStyle = configs["Hour Settings"]["Horbit Color"];
context.lineWidth = maxr*0.01;
context.beginPath();
context.arc(0, 0, rhour, 0, Math.PI * 2, true);
context.stroke();
}
if (configs["Min Settings"]["Show Orbit"]) {
context.strokeStyle = configs["Min Settings"]["Morbit Color"];
context.lineWidth = maxr*0.01;
context.beginPath();
context.arc(0, 0, rmin, 0, Math.PI * 2, true);
context.stroke();
}
if (configs["Sec Settings"]["Show Orbit"]) {
context.strokeStyle = configs["Sec Settings"]["Sorbit Color"];
context.lineWidth = maxr*0.01;
context.beginPath();
context.arc(0, 0, rsec, 0, Math.PI * 2, true);
context.stroke();
}
if (configs["BG Settings"]["Show HGrid"]) {
context.strokeStyle = configs["BG Settings"]["HGRID Color"];
context.lineWidth = maxr*0.016;
context.lineCap = "round";
for (var i = 0; i < 12; i++) {
context.beginPath();
if (!(i%3)) {
context.moveTo(rmin+maxr*0.07, 0);
} else {
context.moveTo(rmin+maxr*0.035, 0);
}
context.lineTo(rmin, 0);
context.stroke();
context.rotate(Math.PI / 6);
}
}
}
}
Canvas {
id: hour
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: thour*30+tmin*0.5+tsec*0.6/60
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.03;
context.lineCap = "round";
context.fillStyle = configs["Hour Settings"]["Hstar Color"];
context.beginPath();
context.arc(0, -rhour, maxr*0.075, 0, Math.PI * 2, true);
context.fill();
}
}
Canvas {
id: min
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: tmin*6+tsec*0.1
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.04;
context.lineCap = "round";
context.fillStyle = configs["Min Settings"]["Mstar Color"];
context.beginPath();
context.arc(0, -rmin, maxr*0.06, 0, Math.PI * 2, true);
context.fill();
}
}
Canvas {
id: sec
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: widget.tsec*6
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.04;
context.lineCap = "round";
context.fillStyle = configs["Sec Settings"]["Sstar Color"];
context.beginPath();
context.arc(0, -rsec, maxr*0.045, 0, Math.PI * 2, true);
context.fill();
}
}
Canvas {
id: millisec_orbit
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: widget.tsec*6
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
if (configs["MSec Settings"]["Show Orbit"]) {
context.translate(width/2, height/2);
context.strokeStyle = configs["MSec Settings"]["MSorbit Color"];
context.lineWidth = maxr*0.005;
context.beginPath();
context.arc(0, -rsec, maxr*0.1, 0, Math.PI * 2, true);
context.stroke();
}
}
Canvas {
id: millisec_star
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
transform: Rotation {
//
origin.x: width/2
origin.y: height/2-rsec
axis{
x: 0
y: 0
z: 1
}
angle: tmsec*0.360
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.05;
context.lineCap = "round";
context.fillStyle = configs["MSec Settings"]["MSstar Color"];
context.beginPath();
context.arc(0, -rsec-maxr*0.1, maxr*0.025, 0, Math.PI * 2, true);
context.fill();
}
}
}
Canvas {
id: center
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
visible: configs["BG Settings"]["Show Center"]
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = colorToRGBA(configs["BG Settings"]["Center Color"], 0.5);
context.shadowBlur = maxr*0.1;
context.shadowOffsetX = maxr*0.05/2.5;
context.shadowOffsetY = maxr*0.05/2.5;
context.beginPath();
context.arc(0, 0, maxr*0.003*configs["BG Settings"]["Center Radius"], 0, Math.PI * 2, true);
context.fillStyle = configs["BG Settings"]["Center Color"];
context.fill();
}
}
menu: Menu {
Action {
text: qsTr("Settings") + "..."
onTriggered: styleDialog.active = true
}
}
Loader {
id: styleDialog
active: false
sourceComponent: NVG.Window {
id: window
title: qsTr("Clock Settings")
visible: true
minimumWidth: 400
minimumHeight: 660
width: minimumWidth
height: minimumHeight
transientParent: widget.NVG.View.window
property var configuration
Page {
id: cfg_page
anchors.fill: parent
header: TitleBar {
text: qsTr("Solar 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: 0
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: "BG Settings"
label: qsTr("Background Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "BG Color"
label: qsTr("Color")
defaultValue: defaultValues["BG Settings"]["BG Color"]
}
P.SliderPreference {
name: "BG Alpha"
label: qsTr("Transparency")
from: 0
to: 100
stepSize: 1
defaultValue: defaultValues["BG Settings"]["BG Alpha"]
displayValue: value + "%"
}
P.Separator {}
P.SwitchPreference {
id: show_hgrid
name: "Show HGrid"
label: qsTr("Show Scale")
defaultValue: defaultValues["BG Settings"]["Show HGrid"]
}
P.ColorPreference {
name: "HGRID Color"
label: qsTr("Scale Color")
enabled: show_hgrid.value
defaultValue: defaultValues["BG Settings"]["HGRID Color"]
}
P.Separator {}
P.SwitchPreference {
id: showCenter
name: "Show Center"
label: qsTr("Show Center")
defaultValue: defaultValues["BG Settings"]["Show Center"]
}
P.ColorPreference {
name: "Center Color"
label: qsTr("Center Color")
enabled: showCenter.value
defaultValue: defaultValues["BG Settings"]["Center Color"]
}
P.SliderPreference {
name: "Center Radius"
label: qsTr("Center Radius")
enabled: showCenter.value
from: 30
to: 100
stepSize: 1
defaultValue: defaultValues["BG Settings"]["Center Radius"]
displayValue: value + "%"
}
P.Separator {}
P.SwitchPreference {
id: showClock
name: "Show Clock"
label: qsTr("Display Time")
defaultValue: defaultValues["BG Settings"]["Show Clock"]
}
P.ColorPreference {
name: "Clock Color"
label: qsTr("Font Color")
enabled: showClock.value
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 {
name: "Font Size"
label: qsTr("Font Size")
enabled: showClock.value
from: 50
to: 100
stepSize: 1
defaultValue: defaultValues["BG Settings"]["Font Size"]
displayValue: value + "%"
}
}
P.Separator {}
P.DialogPreference {
name: "Hour Settings"
label: qsTr("Hour Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Hstar Color"
label: qsTr("Star Color")
defaultValue: defaultValues["Hour Settings"]["Hstar Color"]
}
P.Separator {}
P.SwitchPreference {
id: hour_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: defaultValues["Hour Settings"]["Show Orbit"]
}
P.ColorPreference {
name: "Horbit Color"
label: qsTr("Orbit Color")
enabled: hour_settings_show_orbit.value
defaultValue: defaultValues["Hour Settings"]["Horbit Color"]
}
}
P.DialogPreference {
name: "Min Settings"
label: qsTr("Minute Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Mstar Color"
label: qsTr("Star Color")
defaultValue: defaultValues["Min Settings"]["Mstar Color"]
}
P.Separator {}
P.SwitchPreference {
id: min_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: defaultValues["Min Settings"]["Show Orbit"]
}
P.ColorPreference {
name: "Morbit Color"
label: qsTr("Orbit Color")
enabled: min_settings_show_orbit.value
defaultValue: defaultValues["Min Settings"]["Morbit Color"]
}
}
P.DialogPreference {
name: "Sec Settings"
label: qsTr("Second Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Sstar Color"
label: qsTr("Star Color")
defaultValue: defaultValues["Sec Settings"]["Sstar Color"]
}
P.Separator {}
P.SwitchPreference {
id: sec_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: defaultValues["Sec Settings"]["Show Orbit"]
}
P.ColorPreference {
name: "Sorbit Color"
label: qsTr("Orbit Color")
enabled: sec_settings_show_orbit.value
defaultValue: defaultValues["Sec Settings"]["Sorbit Color"]
}
}
P.DialogPreference {
name: "MSec Settings"
label: qsTr("Millisecond Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "MSstar Color"
label: qsTr("Star Color")
defaultValue: defaultValues["MSec Settings"]["MSstar Color"]
}
P.Separator {}
P.SwitchPreference {
id: msec_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: defaultValues["MSec Settings"]["Show Orbit"]
}
P.ColorPreference {
name: "MSorbit Color"
label: qsTr("Orbit Color")
enabled: msec_settings_show_orbit.value
defaultValue: defaultValues["MSec Settings"]["MSorbit Color"]
}
}
Component.onCompleted: {
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
}
}
}
}
}
onClosing: {
widget.settings.styles = configuration;
styleDialog.active = false;
}
}
}
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: Common.fontweight[configs["BG Settings"]["Font Weight"]]
font.family: Common.fonts[configs["BG Settings"]["Font Name"]]//"Microsoft YaHei"
}
}

229
text_clock.qml → qml/TextClock.qml

@ -2,19 +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
@ -42,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;
@ -76,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"]
}
@ -161,8 +171,6 @@ T.Widget {
visible: true
minimumWidth: 380
minimumHeight: 580
maximumWidth: minimumWidth
maximumHeight: minimumHeight
width: minimumWidth
height: minimumHeight
@ -170,127 +178,118 @@ T.Widget {
property var configuration
ColumnLayout {
id: root
Page {
id: cfg_page
anchors.fill: parent
anchors.margins: 16
anchors.topMargin: 0
Row {
spacing: 234
ToolButton {
text: qsTr("Save")
onClicked: {
configuration = rootPreference.save();
widget.settings.styles = configuration;
styleDialog.active = false;
}
header: TitleBar {
text: qsTr("Text Clock")
standardButtons: Dialog.Save | Dialog.Reset
onAccepted: {
configuration = rootPreference.save();
widget.settings.styles = configuration;
styleDialog.active = false;
}
ToolButton {
text: qsTr("Reset")
onClicked: {
rootPreference.load();
let cfg = rootPreference.save();
widget.settings.styles = cfg;
}
onReset: {
rootPreference.load();
let cfg = rootPreference.save();
widget.settings.styles = cfg;
}
}
Label {
Layout.alignment: Qt.AlignCenter
text: qsTr("Settings")
font.pixelSize: 24
}
ColumnLayout {
id: root
anchors.fill: parent
anchors.margins: 16
anchors.topMargin: 0
Flickable {
Layout.fillWidth: true
Layout.fillHeight: true
Flickable {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
contentWidth: preferenceLayout.implicitWidth
contentHeight: preferenceLayout.implicitHeight
clip: true
contentWidth: preferenceLayout.implicitWidth
contentHeight: preferenceLayout.implicitHeight
ColumnLayout {
id: preferenceLayout
width: root.width
ColumnLayout {
id: preferenceLayout
width: root.width
P.PreferenceGroup {
id: rootPreference
Layout.fillWidth: true
P.PreferenceGroup {
id: rootPreference
Layout.fillWidth: true
label: qsTr("Configuration")
label: qsTr("Configuration")
onPreferenceEdited: {
widget.settings.styles = rootPreference.save();
}
onPreferenceEdited: {
widget.settings.styles = rootPreference.save();
}
P.SelectPreference {
name: "Font Name"
label: qsTr("Font Style")
icon.name: "solid:\uf1fc"
defaultValue: 408
model: fonts
}
P.SelectPreference {
name: "Font Name"
label: qsTr("Font Style")
icon.name: "solid:\uf1fc"
defaultValue: defaultValues["Font Name"]
model: Common.fonts
}
P.SelectPreference {
name: "Font Weight"
label: qsTr("Font Weight")
icon.name: "solid:\uf1fc"
defaultValue: 0
model: sfontweight
}
P.SelectPreference {
name: "Font Weight"
label: qsTr("Font Weight")
icon.name: "solid:\uf1fc"
defaultValue: defaultValues["Font Weight"]
model: Common.sfontweight
}
P.ColorPreference {
name: "HighLight Color"
label: qsTr("HighLight Color")
defaultValue: "#FFF"
}
P.ColorPreference {
name: "HighLight Color"
label: qsTr("HighLight Color")
defaultValue: defaultValues["HighLight Color"]
}
P.ColorPreference {
name: "Normal Color"
label: qsTr("Normal Color")
defaultValue: "#333333"
}
P.ColorPreference {
name: "Normal Color"
label: qsTr("Normal Color")
defaultValue: defaultValues["Normal Color"]
}
P.SliderPreference {
name: "Font Size"
label: qsTr("Font Size")
from: 1
to: 40
stepSize: 1
defaultValue: 20
displayValue: value
}
P.SliderPreference {
name: "Font Size"
label: qsTr("Font Size")
from: 1
to: 40
stepSize: 1
defaultValue: defaultValues["Font Size"]
displayValue: value
}
P.SliderPreference {
name: "Letter Space"
label: qsTr("Letter Space")
from: 1
to: 40
stepSize: 1
defaultValue: 20
displayValue: value
}
P.SliderPreference {
name: "Letter Space"
label: qsTr("Letter Space")
from: 1
to: 40
stepSize: 1
defaultValue: defaultValues["Letter Space"]
displayValue: value
}
P.SliderPreference {
name: "Line Height"
label: qsTr("Line Spacing")
from: 0.8
to: 2
stepSize: 0.1
defaultValue: 1.5
displayValue: value.toFixed(1)
}
P.SliderPreference {
name: "Line Height"
label: qsTr("Line Spacing")
from: 0.8
to: 2
stepSize: 0.1
defaultValue: defaultValues["Line Height"]
displayValue: value.toFixed(1)
}
Component.onCompleted: {
if(!widget.settings.styles) {
configuration = rootPreference.save();
widget.settings.styles = configuration;
Component.onCompleted: {
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
}
}
@ -303,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};
}
}
}

628
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;
}
}
}
}

44
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();
}
}

1
qml/qmldir

@ -0,0 +1 @@
singleton Common 1.0 Common.qml

465
reflection_clock.qml

@ -1,465 +0,0 @@
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.Templates 1.0 as T
import NERvGear.Preferences 1.0 as P
T.Widget {
id: widget
solid: true
title: qsTr("Reflection Clock")
resizable: true
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
property string am_pm: ""
Rectangle {
id: main
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
width: 345*multi
height: 222*multi
Rectangle {
id: hour
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 15*multi
width: 100*multi
height: 111*multi
Rectangle {
id: hour_top
color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Clock BG Color"] : "#2196f3"
width: 100*multi
height: 80*multi
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
Text {
id: hour_text
text: ""
color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Clock Font Color"] : "#ffffff"
anchors.centerIn: parent
font.pointSize: 35*multi
font.weight: Font.Light
font.family: "Microsoft YaHei"
}
}
Rectangle {
id: hour_bottom
color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Panel BG Color"] : "#2196f3"
width: 100*multi
height: 30*multi
anchors.top: hour_top.bottom
anchors.topMargin: multi
anchors.left: parent.left
anchors.leftMargin: 0
Text {
text: "HOURS"+am_pm
color: widget.settings.styles ? widget.settings.styles["Hour Settings"]["Panel Font Color"] : "#ffffff"
anchors.centerIn: parent
font.pointSize: 9*multi
font.weight: Font.Normal
font.family: "Microsoft YaHei"
font.letterSpacing: 2*multi
}
}
}
Rectangle {
id: min
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: hour.right
anchors.leftMargin: 15*multi
width: 100*multi
height: 111*multi
Rectangle {
id: min_top
color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Clock BG Color"] : "#2196f3"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
width: 100*multi
height: 80*multi
Text {
id: min_text
text: ""
color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Clock Font Color"] : "#ffffff"
anchors.centerIn: parent
font.pointSize: 35*multi
font.weight: Font.Light
font.family: "Microsoft YaHei"
}
}
Rectangle {
id: min_bottom
color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Panel BG Color"] : "#2196f3"
width: 100*multi
height: 30*multi
anchors.top: min_top.bottom
anchors.topMargin: multi
anchors.left: parent.left
anchors.leftMargin: 0
Text {
text: "MINUTES"
color: widget.settings.styles ? widget.settings.styles["Min Settings"]["Panel Font Color"] : "#ffffff"
anchors.centerIn: parent
font.pointSize: 9*multi
font.weight: Font.Normal
font.family: "Microsoft YaHei"
font.letterSpacing: 2*multi
}
}
}
Rectangle {
id: sec
color: "transparent"
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: min.right
anchors.leftMargin: 15*multi
visible: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Visible"] : true
width: 100*multi
height: 111*multi
Rectangle {
id: sec_top
color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Clock BG Color"] : "#ff006a"
width: 100*multi
height: 80*multi
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
Text {
id: sec_text
text: ""
color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Clock Font Color"] : "#ffffff"
anchors.centerIn: parent
font.pointSize: 35*multi
font.weight: Font.Light
font.family: "Microsoft YaHei"
}
}
Rectangle {
id: sec_bottom
color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Panel BG Color"] : "#ff006a"
width: 100*multi
height: 30*multi
anchors.top: sec_top.bottom
anchors.topMargin: multi
anchors.left: parent.left
anchors.leftMargin: 0
Text {
text: "SECONDS"
color: widget.settings.styles ? widget.settings.styles["Sec Settings"]["Panel Font Color"] : "#ffffff"
anchors.centerIn: parent
font.pointSize: 9*multi
font.weight: Font.Normal
font.family: "Microsoft YaHei"
font.letterSpacing: 2*multi
}
}
}
}
OpacityMask {
width: main.width
height: main.height
anchors.top: main.bottom
anchors.topMargin: multi
source: main
maskSource: Rectangle {
width: main.width
height: main.height
gradient: Gradient{
GradientStop{position: 0.0;color:"transparent"}
GradientStop{position: 1.0;color:"#FFF"}
}
}
transform: Scale {yScale: -1}
}
Timer {
interval: 250
repeat: true
running: widget.NVG.View.exposed
onTriggered: {
var now = new Date(),
sec = now.getSeconds(),
min = now.getMinutes(),
hr = now.getHours();
if(!full_clock) {
am_pm = "|" + (hr > 11 ? "PM" : "AM");
if (hr === 0 || hr === 24)
hr = 12;
else if(hr > 12)
hr -= 12;
} else {
am_pm = "";
}
hour_text.text = hr < 10 ? "0"+hr : hr;
min_text.text = min < 10 ? "0"+min : min;
sec_text.text = sec < 10 ? "0"+sec : sec;
}
}
menu: Menu {
Action {
text: qsTr("Settings") + "..."
onTriggered: styleDialog.active = true
}
}
Loader {
id: styleDialog
active: false
sourceComponent: NVG.Window {
id: window
title: qsTr("Clock Settings")
visible: true
minimumWidth: 380
minimumHeight: 480
maximumWidth: minimumWidth
maximumHeight: minimumHeight
width: minimumWidth
height: minimumHeight
transientParent: widget.NVG.View.window
property var configuration
ColumnLayout {
id: root
anchors.fill: parent
anchors.margins: 16
anchors.topMargin: 0
Row {
spacing: 234
ToolButton {
text: qsTr("Save")
onClicked: {
configuration = rootPreference.save();
widget.settings.styles = configuration;
styleDialog.active = false;
}
}
ToolButton {
text: qsTr("Reset")
onClicked: {
rootPreference.load();
let cfg = rootPreference.save();
widget.settings.styles = cfg;
}
}
}
Label {
Layout.alignment: Qt.AlignCenter
text: qsTr("Settings")
font.pixelSize: 24
}
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: "Hour Settings"
label: qsTr("Hour Settings")
live: true
icon.name: "regular:\uf1de"
P.SwitchPreference {
name: "Full Clock"
label: qsTr("24 Hour Clock")
defaultValue: true
}
P.Separator {}
P.ColorPreference {
name: "Clock BG Color"
label: qsTr("Clock Background Color")
defaultValue: "#2196f3"
}
P.ColorPreference {
name: "Clock Font Color"
label: qsTr("Clock Font Color")
defaultValue: "#ffffff"
}
P.Separator {}
P.ColorPreference {
name: "Panel BG Color"
label: qsTr("Panel Background Color")
defaultValue: "#2196f3"
}
P.ColorPreference {
name: "Panel Font Color"
label: qsTr("Panel Font Color")
defaultValue: "#ffffff"
}
}
P.Separator {}
P.DialogPreference {
name: "Min Settings"
label: qsTr("Minute Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Clock BG Color"
label: qsTr("Clock Background Color")
defaultValue: "#2196f3"
}
P.ColorPreference {
name: "Clock Font Color"
label: qsTr("Clock Font Color")
defaultValue: "#ffffff"
}
P.Separator {}
P.ColorPreference {
name: "Panel BG Color"
label: qsTr("Panel Background Color")
defaultValue: "#2196f3"
}
P.ColorPreference {
name: "Panel Font Color"
label: qsTr("Panel Font Color")
defaultValue: "#ffffff"
}
}
P.Separator {}
P.DialogPreference {
name: "Sec Settings"
label: qsTr("Second Settings")
live: true
icon.name: "regular:\uf1de"
P.SwitchPreference {
id: cfg_sec_en
name: "Visible"
label: qsTr("Show")
defaultValue: true
}
P.Separator {}
P.ColorPreference {
name: "Clock BG Color"
label: qsTr("Clock Background Color")
enabled: cfg_sec_en.value
defaultValue: "#ff006a"
}
P.ColorPreference {
name: "Clock Font Color"
label: qsTr("Clock Font Color")
enabled: cfg_sec_en.value
defaultValue: "#ffffff"
}
P.Separator {}
P.ColorPreference {
name: "Panel BG Color"
label: qsTr("Panel Background Color")
enabled: cfg_sec_en.value
defaultValue: "#ff006a"
}
P.ColorPreference {
name: "Panel Font Color"
label: qsTr("Panel Font Color")
enabled: cfg_sec_en.value
defaultValue: "#ffffff"
}
}
Component.onCompleted: {
if(!widget.settings.styles) {
configuration = rootPreference.save();
widget.settings.styles = configuration;
}
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
}
}
}
}
onClosing: {
widget.settings.styles = configuration;
styleDialog.active = false;
}
}
}
}

687
solars_clock.qml

@ -1,687 +0,0 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import NERvGear 1.0 as NVG
import NERvGear.Templates 1.0 as T
import NERvGear.Preferences 1.0 as P
T.Widget {
id: widget
solid: true
title: qsTr("Solar Clock")
resizable: true
editing: styleDialog.active
property real maxr: Math.min(width/2, height/2) -10
readonly property real rhour: maxr*0.9
readonly property real rmin: maxr*0.72
readonly property real rsec: maxr*0.5
property real thour: 0
property real tmin: 0
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"}}
onConfigsChanged: {
background.requestPaint();
hour.requestPaint();
min.requestPaint();
sec.requestPaint();
millisec_orbit.requestPaint();
millisec_star.requestPaint();
center.requestPaint();
}
function colorToRGBA(color, alpha) {
var color1, color2, color3;
color = ""+color;
if (typeof color !== "string") return;
if (color.charAt(0) === "#") {
color = color.substring(1);
}
var not16num = color.split("").filter(function (item, index) {
return isNaN(parseInt(item, 16))
});
if(not16num.length) return;
switch (color.length) {
case 3:
color1 = color.substr(0,1);
color2 = color.substr(1,1);
color3 = color.substr(2,1);
color1 = color1 + color1;
color2 = color2 + color2;
color3 = color3 + color3;
break;
case 6:
color1 = color.substr(0,2);
color2 = color.substr(2,2);
color3 = color.substr(4,2);
break;
default:
return false;
}
color1 = parseInt(color1, 16);
color2 = parseInt(color2, 16);
color3 = parseInt(color3, 16);
return "rgba("+color1+","+color2+","+color3+","+alpha+")";
}
Timer {
interval: 50
running: widget.NVG.View.exposed
repeat: true
onTriggered: {
var now = new Date();
tmsec = now.getMilliseconds();
tsec = now.getSeconds();
tmin = now.getMinutes();
thour = now.getHours();
main_time.text = (thour<10 ? "0"+thour : thour) + ":" + (tmin<10 ? "0"+tmin : tmin) + ":" + (tsec<10 ? "0"+tsec : tsec);
thour = thour > 12 ? thour - 12 : thour;
tsec += tmsec/1000;
}
}
Canvas {
id: background
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2); //
context.rotate(-Math.PI/2); //90x12
context.fillStyle = colorToRGBA(configs["BG Settings"]["BG Color"], configs["BG Settings"]["BG Alpha"]/100);
context.beginPath();
context.arc(0, 0, maxr, 0, Math.PI * 2, true);
context.fill();
if (configs["Hour Settings"]["Show Orbit"]) {
context.strokeStyle = configs["Hour Settings"]["Horbit Color"];
context.lineWidth = maxr*0.01;
context.beginPath();
context.arc(0, 0, rhour, 0, Math.PI * 2, true);
context.stroke();
}
if (configs["Min Settings"]["Show Orbit"]) {
context.strokeStyle = configs["Min Settings"]["Morbit Color"];
context.lineWidth = maxr*0.01;
context.beginPath();
context.arc(0, 0, rmin, 0, Math.PI * 2, true);
context.stroke();
}
if (configs["Sec Settings"]["Show Orbit"]) {
context.strokeStyle = configs["Sec Settings"]["Sorbit Color"];
context.lineWidth = maxr*0.01;
context.beginPath();
context.arc(0, 0, rsec, 0, Math.PI * 2, true);
context.stroke();
}
if (configs["BG Settings"]["Show HGrid"]) {
context.strokeStyle = configs["BG Settings"]["HGRID Color"];
context.lineWidth = maxr*0.016;
context.lineCap = "round";
for (var i = 0; i < 12; i++) {
context.beginPath();
if (!(i%3)) {
context.moveTo(rmin+maxr*0.07, 0);
} else {
context.moveTo(rmin+maxr*0.035, 0);
}
context.lineTo(rmin, 0);
context.stroke();
context.rotate(Math.PI / 6);
}
}
}
}
Canvas {
id: hour
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: thour*30+tmin*0.5+tsec*0.6/60
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.03;
context.lineCap = "round";
context.fillStyle = configs["Hour Settings"]["Hstar Color"];
context.beginPath();
context.arc(0, -rhour, maxr*0.075, 0, Math.PI * 2, true);
context.fill();
}
}
Canvas {
id: min
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: tmin*6+tsec*0.1
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.04;
context.lineCap = "round";
context.fillStyle = configs["Min Settings"]["Mstar Color"];
context.beginPath();
context.arc(0, -rmin, maxr*0.06, 0, Math.PI * 2, true);
context.fill();
}
}
Canvas {
id: sec
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: widget.tsec*6
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.04;
context.lineCap = "round";
context.fillStyle = configs["Sec Settings"]["Sstar Color"];
context.beginPath();
context.arc(0, -rsec, maxr*0.045, 0, Math.PI * 2, true);
context.fill();
}
}
Canvas {
id: millisec_orbit
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
rotation: widget.tsec*6
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
if (configs["MSec Settings"]["Show Orbit"]) {
context.translate(width/2, height/2);
context.strokeStyle = configs["MSec Settings"]["MSorbit Color"];
context.lineWidth = maxr*0.005;
context.beginPath();
context.arc(0, -rsec, maxr*0.1, 0, Math.PI * 2, true);
context.stroke();
}
}
Canvas {
id: millisec_star
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
transform: Rotation {
//
origin.x: width/2
origin.y: height/2-rsec
axis{
x: 0
y: 0
z: 1
}
angle: tmsec*0.360
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = 'rgba(0,0,0,.5)';
context.shadowBlur = maxr*0.05;
context.lineCap = "round";
context.fillStyle = configs["MSec Settings"]["MSstar Color"];
context.beginPath();
context.arc(0, -rsec-maxr*0.1, maxr*0.025, 0, Math.PI * 2, true);
context.fill();
}
}
}
Canvas {
id: center
width: widget.width;
height: widget.height;
contextType: "2d";
renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative
visible: configs["BG Settings"]["Show Center"]
onWidthChanged: {
requestPaint();
}
onHeightChanged: {
requestPaint();
}
onPaint: {
context.resetTransform();
context.clearRect(0,0,widget.width,widget.height);
context.translate(width/2, height/2);
context.shadowColor = colorToRGBA(configs["BG Settings"]["Center Color"], 0.5);
context.shadowBlur = maxr*0.1;
context.shadowOffsetX = maxr*0.05/2.5;
context.shadowOffsetY = maxr*0.05/2.5;
context.beginPath();
context.arc(0, 0, maxr*0.003*configs["BG Settings"]["Center Radius"], 0, Math.PI * 2, true);
context.fillStyle = configs["BG Settings"]["Center Color"];
context.fill();
}
}
menu: Menu {
Action {
text: qsTr("Settings") + "..."
onTriggered: styleDialog.active = true
}
}
Loader {
id: styleDialog
active: false
sourceComponent: NVG.Window {
id: window
title: qsTr("Clock Settings")
visible: true
minimumWidth: 400
minimumHeight: 660
maximumWidth: minimumWidth
maximumHeight: minimumHeight
width: minimumWidth
height: minimumHeight
transientParent: widget.NVG.View.window
property var configuration
ColumnLayout {
id: root
anchors.fill: parent
anchors.margins: 16
anchors.topMargin: 0
Row {
spacing: 270
ToolButton {
text: qsTr("Save")
onClicked: {
configuration = rootPreference.save();
widget.settings.styles = configuration;
styleDialog.active = false;
}
}
ToolButton {
text: qsTr("Reset")
onClicked: {
rootPreference.load();
let cfg = rootPreference.save();
widget.settings.styles = cfg;
}
}
}
Label {
Layout.alignment: Qt.AlignCenter
text: qsTr("Settings")
font.pixelSize: 24
}
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: "BG Settings"
label: qsTr("Background Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "BG Color"
label: qsTr("Color")
defaultValue: "#212121"
}
P.SliderPreference {
name: "BG Alpha"
label: qsTr("Transparency")
from: 0
to: 100
stepSize: 1
defaultValue: 100
displayValue: value + "%"
}
P.Separator {}
P.SwitchPreference {
id: show_hgrid
name: "Show HGrid"
label: qsTr("Show Scale")
defaultValue: true
}
P.ColorPreference {
name: "HGRID Color"
label: qsTr("Scale Color")
enabled: show_hgrid.value
defaultValue: "#616161"
}
P.Separator {}
P.SwitchPreference {
id: showCenter
name: "Show Center"
label: qsTr("Show Center")
defaultValue: true
}
P.ColorPreference {
name: "Center Color"
label: qsTr("Center Color")
enabled: showCenter.value
defaultValue: "#ffeb3b"
}
P.SliderPreference {
name: "Center Radius"
label: qsTr("Center Radius")
enabled: showCenter.value
from: 30
to: 100
stepSize: 1
defaultValue: 85
displayValue: value + "%"
}
P.Separator {}
P.SwitchPreference {
id: showClock
name: "Show Clock"
label: qsTr("Display Time")
defaultValue: true
}
P.ColorPreference {
name: "Clock Color"
label: qsTr("Font Color")
enabled: showClock.value
defaultValue: "#616161"
}
P.SliderPreference {
name: "Font Size"
label: qsTr("Font Size")
enabled: showClock.value
from: 50
to: 100
stepSize: 1
defaultValue: 100
displayValue: value + "%"
}
}
P.Separator {}
P.DialogPreference {
name: "Hour Settings"
label: qsTr("Hour Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Hstar Color"
label: qsTr("Star Color")
defaultValue: "#ffa000"
}
P.Separator {}
P.SwitchPreference {
id: hour_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: true
}
P.ColorPreference {
name: "Horbit Color"
label: qsTr("Orbit Color")
enabled: hour_settings_show_orbit.value
defaultValue: "#616161"
}
}
P.DialogPreference {
name: "Min Settings"
label: qsTr("Minute Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Mstar Color"
label: qsTr("Star Color")
defaultValue: "#ff5722"
}
P.Separator {}
P.SwitchPreference {
id: min_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: true
}
P.ColorPreference {
name: "Morbit Color"
label: qsTr("Orbit Color")
enabled: min_settings_show_orbit.value
defaultValue: "#616161"
}
}
P.DialogPreference {
name: "Sec Settings"
label: qsTr("Second Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "Sstar Color"
label: qsTr("Star Color")
defaultValue: "#2196f3"
}
P.Separator {}
P.SwitchPreference {
id: sec_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: true
}
P.ColorPreference {
name: "Sorbit Color"
label: qsTr("Orbit Color")
enabled: sec_settings_show_orbit.value
defaultValue: "#616161"
}
}
P.DialogPreference {
name: "MSec Settings"
label: qsTr("Millisecond Settings")
live: true
icon.name: "regular:\uf1de"
P.ColorPreference {
name: "MSstar Color"
label: qsTr("Star Color")
defaultValue: "#9e9e9e"
}
P.Separator {}
P.SwitchPreference {
id: msec_settings_show_orbit
name: "Show Orbit"
label: qsTr("Show Orbit")
defaultValue: true
}
P.ColorPreference {
name: "MSorbit Color"
label: qsTr("Orbit Color")
enabled: msec_settings_show_orbit.value
defaultValue: "#9e9e9e"
}
}
Component.onCompleted: {
if(!widget.settings.styles) {
configuration = rootPreference.save();
widget.settings.styles = configuration;
}
rootPreference.load(widget.settings.styles);
configuration = widget.settings.styles;
}
}
}
}
}
onClosing: {
widget.settings.styles = configuration;
styleDialog.active = false;
}
}
}
Text {
id: main_time
text: ""
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"
}
}
Loading…
Cancel
Save