- 修复Text控件边缘色差
- TopUI.qml - 新增[曲线]选项 - 新增[切换UI]挂件动作 - BottomUI.qml - 新增[曲线]选项
This commit is contained in:
parent
fee59b2811
commit
252effc514
@ -18,7 +18,9 @@ T.Widget {
|
||||
property real tmin: 0
|
||||
editing: styleDialog.active
|
||||
|
||||
readonly property var configs: widget.settings.styles ? widget.settings.styles : {"Circle Color":"#fffcf9","Line Color":"#fffcf9","Line Width":38,"Shadow Color":"#e0e0e0","Shadow Size":0.5,"Battle UI":false,"Clock Visible":true,"Full Clock":true,"Font Color":"#f5f5f5","Font Size":44,"Font Name":0,"Font Weight":0,"Text Vertical Offset":16}
|
||||
readonly property var defaultValues: {"Curve":true,"Circle Color":"#fffcf9","Line Color":"#fffcf9","Line Width":38,"Shadow Color":"#e0e0e0","Shadow Size":0.5,"Battle UI":false,"Clock Visible":true,"Full Clock":true,"Font Color":"#f5f5f5","Font Size":44,"Font Name":0,"Font Weight":0,"Text Vertical Offset":16}
|
||||
|
||||
readonly property var configs: widget.settings.styles
|
||||
|
||||
property string line_color: configs["Line Color"]
|
||||
property string shadowColor: configs["Shadow Color"]
|
||||
@ -28,21 +30,24 @@ T.Widget {
|
||||
readonly property real w: widget.width
|
||||
readonly property real r: (w**2+4*h**2)/2/h
|
||||
|
||||
property real triangle_size: 24
|
||||
onConfigsChanged: {
|
||||
line.requestPaint();
|
||||
triangle.requestPaint();
|
||||
}
|
||||
|
||||
Canvas {
|
||||
id: triangle
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: height/2
|
||||
width: triangle_size
|
||||
height: triangle_size*Math.sin(Math.PI/6)
|
||||
width: 0.4*h
|
||||
height: 0.4*h*Math.sin(Math.PI/6)
|
||||
contextType: "2d"
|
||||
onPaint: {
|
||||
context.reset();
|
||||
context.clearRect(0,0,width,height);
|
||||
context.shadowBlur = shadowBlur;
|
||||
context.shadowColor = shadowColor;
|
||||
context.lineWidth = Math.max(0.08*configs["Line Width"] - shadowBlur, 0.1);
|
||||
context.lineWidth = Math.max(0.08*configs["Line Width"], 0.1);
|
||||
context.strokeStyle = line_color;
|
||||
context.beginPath();
|
||||
context.moveTo(0,0);
|
||||
@ -65,11 +70,17 @@ T.Widget {
|
||||
context.clearRect(0,0,width,height);
|
||||
context.shadowBlur = shadowBlur;
|
||||
context.shadowColor = shadowColor;
|
||||
context.lineWidth = Math.max(0.08*configs["Line Width"] - shadowBlur, 0.1);
|
||||
context.lineWidth = Math.max(0.08*configs["Line Width"], 0.1);
|
||||
context.strokeStyle = line_color;
|
||||
let deg = Math.asin(w/2/r)*0.95;
|
||||
context.beginPath();
|
||||
context.arc(w/2, r+h/2, r-shadowBlur/2, deg+Math.PI*3/2, -deg+Math.PI*3/2, true);
|
||||
if (configs["Curve"]) {
|
||||
let deg = Math.asin(w/2/r)*0.95;
|
||||
context.beginPath();
|
||||
context.arc(w/2, r+h/2, r, deg+Math.PI*3/2, -deg+Math.PI*3/2, true);
|
||||
} else {
|
||||
context.beginPath();
|
||||
context.moveTo(0, height/2);
|
||||
context.lineTo(width, height/2);
|
||||
}
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
@ -147,14 +158,18 @@ T.Widget {
|
||||
|
||||
onPreferenceEdited: {
|
||||
widget.settings.styles = rootPreference.save();
|
||||
line.requestPaint();
|
||||
triangle.requestPaint();
|
||||
}
|
||||
|
||||
P.SwitchPreference {
|
||||
name: "Curve"
|
||||
label: qsTr("Curve")
|
||||
defaultValue: defaultValues["Curve"]
|
||||
}
|
||||
|
||||
P.ColorPreference {
|
||||
name: "Line Color"
|
||||
label: qsTr("Line Color")
|
||||
defaultValue: "#fffcf9"
|
||||
defaultValue: defaultValues["Line Color"]
|
||||
}
|
||||
|
||||
P.SliderPreference {
|
||||
@ -163,14 +178,14 @@ T.Widget {
|
||||
from: 1
|
||||
to: 100
|
||||
stepSize: 1
|
||||
defaultValue: 38
|
||||
defaultValue: defaultValues["Line Width"]
|
||||
displayValue: value + "%"
|
||||
}
|
||||
|
||||
P.ColorPreference {
|
||||
name: "Shadow Color"
|
||||
label: qsTr("Shadow Color")
|
||||
defaultValue: "#e0e0e0"
|
||||
defaultValue: defaultValues["Shadow Color"]
|
||||
}
|
||||
|
||||
P.SliderPreference {
|
||||
@ -179,7 +194,7 @@ T.Widget {
|
||||
from: 0
|
||||
to: 3
|
||||
stepSize: 0.1
|
||||
defaultValue: 0.5
|
||||
defaultValue: defaultValues["Shadow Size"]
|
||||
displayValue: Math.round(value*10)/10 + "px"
|
||||
}
|
||||
|
||||
@ -200,9 +215,11 @@ T.Widget {
|
||||
onClosing: {
|
||||
widget.settings.styles = configuration;
|
||||
styleDialog.active = false;
|
||||
line.requestPaint();
|
||||
triangle.requestPaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
widget.settings.styles = widget.settings.styles ?? defaultValues;
|
||||
}
|
||||
}
|
||||
|
||||
186
qml/TopUI.qml
186
qml/TopUI.qml
@ -19,10 +19,27 @@ T.Widget {
|
||||
editing: styleDialog.active
|
||||
|
||||
readonly property var fonts: Qt.fontFamilies()
|
||||
readonly property var fontweight: ["normal", "bold"]
|
||||
readonly property var sfontweight: [qsTr("Normal"), qsTr("Bold")]
|
||||
readonly property var fontweight: [Font.Light, Font.Normal, Font.Bold]
|
||||
readonly property var sfontweight: [qsTr("Light"), qsTr("Normal"), qsTr("Bold")]
|
||||
|
||||
readonly property var configs: widget.settings.styles ? widget.settings.styles : {"Circle Color":"#fffcf9","Line Color":"#fffcf9","Line Width":38,"Shadow Color":"#e0e0e0","Shadow Size":0.5,"Battle UI":false,"Clock Visible":true,"Full Clock":true,"Font Color":"#f5f5f5","Font Size":60,"Font Name":fonts.length-1,"Font Weight":0,"Text Vertical Offset":-30}
|
||||
readonly property var defaultValues: {
|
||||
"Curve": "true",
|
||||
"Line Color": "#fffcf9",
|
||||
"Line Width": 38,
|
||||
"Shadow Color": "#e0e0e0",
|
||||
"Shadow Size": 0.5,
|
||||
"Battle UI": false,
|
||||
"Circle Color": "#fffcf9",
|
||||
"Clock Visible": true,
|
||||
"Full Clock": true,
|
||||
"Font Color": "#f5f5f5",
|
||||
"Font Size": 44,
|
||||
"Font Name": 0,
|
||||
"Font Weight": 0,
|
||||
"Text Vertical Offset": 16
|
||||
}
|
||||
|
||||
readonly property var configs: widget.settings.styles
|
||||
|
||||
property string circle_color: configs["Circle Color"]
|
||||
property string line_color: configs["Line Color"]
|
||||
@ -34,6 +51,42 @@ T.Widget {
|
||||
readonly property real w: widget.width
|
||||
readonly property real r: (w**2+h**2)/4/h
|
||||
|
||||
onConfigsChanged: {
|
||||
line.requestPaint();
|
||||
c0.requestPaint();
|
||||
c1.requestPaint();
|
||||
c2.requestPaint();
|
||||
c3.requestPaint();
|
||||
c4.requestPaint();
|
||||
c5.requestPaint();
|
||||
}
|
||||
|
||||
action: T.Action {
|
||||
id: thiz
|
||||
|
||||
title: qsTr("Top Line Action")
|
||||
description: title
|
||||
|
||||
execute: function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!styleDialog.active) {
|
||||
let cfg = widget.settings.styles;
|
||||
cfg["Battle UI"] = !cfg["Battle UI"];
|
||||
widget.settings.styles = cfg;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
preference: P.SelectPreference {
|
||||
label: qsTr("Command")
|
||||
model: [ qsTr("Toggle UI") ]
|
||||
defaultValue: 0
|
||||
load: function () {}
|
||||
save: function () {}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 250
|
||||
|
||||
@ -44,32 +97,26 @@ T.Widget {
|
||||
if (tmin !== now.getMinutes()) {
|
||||
tmin = now.getMinutes();
|
||||
thour = now.getHours();
|
||||
if (!configs["Full Clock"])
|
||||
t12hour = thour > 12 ? thour - 12 : thour;
|
||||
text_clock.requestPaint();
|
||||
t12hour = thour > 12 ? thour - 12 : thour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Canvas{
|
||||
Text {
|
||||
id: text_clock
|
||||
width: widget.width
|
||||
height: widget.height
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: widget.height/200*configs["Text Vertical Offset"]
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
contextType: "2d"
|
||||
visible: widget.NVG.View.exposed && !configs["Battle UI"] && configs["Clock Visible"]
|
||||
|
||||
onPaint: {
|
||||
context.clearRect(0,0,width,height);
|
||||
context.fillStyle = configs["Font Color"];
|
||||
context.font = "normal normal " + ["normal", "bold"][configs["Font Weight"]] + " " + widget.height/200*configs["Font Size"] + "px " + fonts[configs["Font Name"]];
|
||||
context.textAlign = 'center';
|
||||
context.beginPath();
|
||||
context.fillText(configs["Full Clock"] ? ("0"+thour).slice(-2) + ":" + ("0"+tmin).slice(-2) : ("0"+t12hour).slice(-2) + ":" + ("0"+tmin).slice(-2), width/2, height/2);
|
||||
context.fill();
|
||||
}
|
||||
style: Text.Outline
|
||||
styleColor: "transparent"
|
||||
|
||||
color: configs["Font Color"]
|
||||
text: configs["Full Clock"] ? ("0"+thour).slice(-2) + ":" + ("0"+tmin).slice(-2) : ("0"+t12hour).slice(-2) + ":" + ("0"+tmin).slice(-2)
|
||||
font.pointSize: widget.height/200*configs["Font Size"]
|
||||
font.family: fonts[configs["Font Name"]]
|
||||
font.weight: fontweight[configs["Font Weight"]]
|
||||
visible: widget.NVG.View.exposed && !configs["Battle UI"] && configs["Clock Visible"]
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -284,15 +331,31 @@ T.Widget {
|
||||
context.strokeStyle = line_color;
|
||||
let deg = Math.asin(w/2/r)*0.95;
|
||||
context.beginPath();
|
||||
if (circle.visible) {
|
||||
context.arc(w/2, -r+h/2, r, deg+Math.PI/2, Math.PI/2+circle.scale*size/1.22/r, true);
|
||||
context.stroke();
|
||||
context.beginPath();
|
||||
context.arc(w/2, -r+h/2, r, -deg+Math.PI/2, Math.PI/2-circle.scale*size/1.22/r, false);
|
||||
context.stroke();
|
||||
if (configs["Curve"]) {
|
||||
if (circle.visible) {
|
||||
context.arc(w/2, -r+h/2, r, deg+Math.PI/2, Math.PI/2+circle.scale*size/1.22/r, true);
|
||||
context.stroke();
|
||||
context.beginPath();
|
||||
context.arc(w/2, -r+h/2, r, -deg+Math.PI/2, Math.PI/2-circle.scale*size/1.22/r, false);
|
||||
context.stroke();
|
||||
} else {
|
||||
context.arc(w/2, -r+h/2, r, deg+Math.PI/2, -deg+Math.PI/2, true);
|
||||
context.stroke();
|
||||
}
|
||||
} else {
|
||||
context.arc(w/2, -r+h/2, r, deg+Math.PI/2, -deg+Math.PI/2, true);
|
||||
context.stroke();
|
||||
if (circle.visible) {
|
||||
context.moveTo(0, height/2);
|
||||
context.lineTo(width/2-circle.scale*size/1.22, height/2);
|
||||
context.stroke();
|
||||
context.beginPath();
|
||||
context.moveTo(width/2+circle.scale*size/1.22, height/2);
|
||||
context.lineTo(width, height/2);
|
||||
context.stroke();
|
||||
} else {
|
||||
context.moveTo(0, height/2);
|
||||
context.lineTo(width, height/2);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,14 +402,6 @@ T.Widget {
|
||||
rootPreference.load();
|
||||
let cfg = rootPreference.save();
|
||||
widget.settings.styles = cfg;
|
||||
line.requestPaint();
|
||||
c0.requestPaint();
|
||||
c1.requestPaint();
|
||||
c2.requestPaint();
|
||||
c3.requestPaint();
|
||||
c4.requestPaint();
|
||||
c5.requestPaint();
|
||||
text_clock.requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,26 +431,18 @@ T.Widget {
|
||||
|
||||
onPreferenceEdited: {
|
||||
widget.settings.styles = rootPreference.save();
|
||||
line.requestPaint();
|
||||
c0.requestPaint();
|
||||
c1.requestPaint();
|
||||
c2.requestPaint();
|
||||
c3.requestPaint();
|
||||
c4.requestPaint();
|
||||
c5.requestPaint();
|
||||
text_clock.requestPaint();
|
||||
}
|
||||
|
||||
P.ColorPreference {
|
||||
name: "Circle Color"
|
||||
label: qsTr("Circle Color")
|
||||
defaultValue: "#fffcf9"
|
||||
P.SwitchPreference {
|
||||
name: "Curve"
|
||||
label: qsTr("Curve")
|
||||
defaultValue: defaultValues["Curve"]
|
||||
}
|
||||
|
||||
P.ColorPreference {
|
||||
name: "Line Color"
|
||||
label: qsTr("Line Color")
|
||||
defaultValue: "#fffcf9"
|
||||
defaultValue: defaultValues["Line Color"]
|
||||
}
|
||||
|
||||
P.SliderPreference {
|
||||
@ -404,14 +451,14 @@ T.Widget {
|
||||
from: 1
|
||||
to: 100
|
||||
stepSize: 1
|
||||
defaultValue: 38
|
||||
defaultValue: defaultValues["Line Width"]
|
||||
displayValue: value + "%"
|
||||
}
|
||||
|
||||
P.ColorPreference {
|
||||
name: "Shadow Color"
|
||||
label: qsTr("Shadow Color")
|
||||
defaultValue: "#e0e0e0"
|
||||
defaultValue: defaultValues["Shadow Color"]
|
||||
}
|
||||
|
||||
P.SliderPreference {
|
||||
@ -420,7 +467,7 @@ T.Widget {
|
||||
from: 0
|
||||
to: 3
|
||||
stepSize: 0.1
|
||||
defaultValue: 0.5
|
||||
defaultValue: defaultValues["Shadow Size"]
|
||||
displayValue: Math.round(value*10)/10 + "px"
|
||||
}
|
||||
|
||||
@ -430,7 +477,14 @@ T.Widget {
|
||||
id: _cfg_battle_ui
|
||||
name: "Battle UI"
|
||||
label: qsTr("Battle UI")
|
||||
defaultValue: false
|
||||
defaultValue: defaultValues["Battle UI"]
|
||||
}
|
||||
|
||||
P.ColorPreference {
|
||||
name: "Circle Color"
|
||||
label: qsTr("Circle Color")
|
||||
visible: _cfg_battle_ui.value
|
||||
defaultValue: defaultValues["Circle Color"]
|
||||
}
|
||||
|
||||
P.Separator {}
|
||||
@ -441,7 +495,7 @@ T.Widget {
|
||||
label: qsTr("Clock Visible")
|
||||
visible: !_cfg_battle_ui.value
|
||||
enabled: visible
|
||||
defaultValue: true
|
||||
defaultValue: defaultValues["Clock Visible"]
|
||||
}
|
||||
|
||||
P.SwitchPreference {
|
||||
@ -449,7 +503,7 @@ T.Widget {
|
||||
label: qsTr("24 Hour Clock")
|
||||
visible: !_cfg_battle_ui.value
|
||||
enabled: visible && _cfg_clock_visible.value
|
||||
defaultValue: true
|
||||
defaultValue: defaultValues["Full Clock"]
|
||||
}
|
||||
|
||||
P.ColorPreference {
|
||||
@ -457,7 +511,7 @@ T.Widget {
|
||||
label: qsTr("Font Color")
|
||||
visible: !_cfg_battle_ui.value
|
||||
enabled: visible && _cfg_clock_visible.value
|
||||
defaultValue: "#f5f5f5"
|
||||
defaultValue: defaultValues["Font Color"]
|
||||
}
|
||||
|
||||
P.SliderPreference {
|
||||
@ -468,7 +522,7 @@ T.Widget {
|
||||
from: 1
|
||||
to: 100
|
||||
stepSize: 1
|
||||
defaultValue: 60
|
||||
defaultValue: defaultValues["Font Size"]
|
||||
displayValue: value + "%"
|
||||
}
|
||||
|
||||
@ -478,7 +532,7 @@ T.Widget {
|
||||
visible: !_cfg_battle_ui.value
|
||||
enabled: visible && _cfg_clock_visible.value
|
||||
icon.name: "solid:\uf1fc"
|
||||
defaultValue: fonts.length-1
|
||||
defaultValue: defaultValues["Font Name"]
|
||||
model: fonts
|
||||
}
|
||||
|
||||
@ -488,7 +542,7 @@ T.Widget {
|
||||
visible: !_cfg_battle_ui.value
|
||||
enabled: visible && _cfg_clock_visible.value
|
||||
icon.name: "solid:\uf1fc"
|
||||
defaultValue: 0
|
||||
defaultValue: defaultValues["Font Weight"]
|
||||
model: sfontweight
|
||||
}
|
||||
|
||||
@ -500,7 +554,7 @@ T.Widget {
|
||||
from: -100
|
||||
to: 100
|
||||
stepSize: 1
|
||||
defaultValue: -30
|
||||
defaultValue: defaultValues["Text Vertical Offset"]
|
||||
displayValue: value + "%"
|
||||
}
|
||||
|
||||
@ -521,15 +575,11 @@ T.Widget {
|
||||
onClosing: {
|
||||
widget.settings.styles = configuration;
|
||||
styleDialog.active = false;
|
||||
line.requestPaint();
|
||||
c0.requestPaint();
|
||||
c1.requestPaint();
|
||||
c2.requestPaint();
|
||||
c3.requestPaint();
|
||||
c4.requestPaint();
|
||||
c5.requestPaint();
|
||||
text_clock.requestPaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
widget.settings.styles = widget.settings.styles ?? defaultValues;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user