Browse Source

- 无挂件时禁用websocket

- 统一设置页面样式
- 删除无用注释
master
mashiros 2 years ago
parent
commit
6df0edd06c
  1. 2
      module.qml
  2. 8
      qml/Common.qml
  3. 6
      qml/Main.qml
  4. 35
      qml/StylePreferences.qml
  5. 2
      qml/WSocket.qml
  6. 6
      qml/api/StyleAPI.qml

2
module.qml

@ -7,7 +7,7 @@ NVG.Module {
initialize: function () { initialize: function () {
console.log("Initializing ADV-Plugin."); console.log("Initializing ADV-Plugin.");
Common.execute("../bin/ADVServer.exe", "-reboot"); Common.execute("../bin/ADVServer.exe", "-reboot");
Common.setWsocket(true); // Common.setWsocket(true);
return true; return true;
} }

8
qml/Common.qml

@ -11,6 +11,8 @@ Item {
readonly property var stylesURL: [] readonly property var stylesURL: []
readonly property var stylesCFG: [] readonly property var stylesCFG: []
property int widgetsNum: 0
signal audioDataUpdated(var audioData) signal audioDataUpdated(var audioData)
signal wsocketClosed() signal wsocketClosed()
@ -73,7 +75,7 @@ Item {
} }
wsPort = cfg["server"]["port"]; wsPort = cfg["server"]["port"];
}} }}
active: false active: widgetsNum>0
} }
function setWsocket(status) { function setWsocket(status) {
@ -117,8 +119,6 @@ Item {
stylesCFG.push(styleCFG); stylesCFG.push(styleCFG);
} }
// console.log(JSON.stringify(Object.keys(resource), null, 2));
// console.log(JSON.stringify(resource.files(), null, 2));
}); });
} }
@ -127,7 +127,5 @@ Item {
parse_resource(preset_list, true); parse_resource(preset_list, true);
const third_list = NVG.Resources.filter(/.*/, /top.mashiros.advp-style/); const third_list = NVG.Resources.filter(/.*/, /top.mashiros.advp-style/);
parse_resource(third_list, false); parse_resource(third_list, false);
// console.log(JSON.stringify(styles, null, 2));
// console.log(JSON.stringify(stylesURL, null, 2));
} }
} }

6
qml/Main.qml

@ -56,5 +56,11 @@ T.Widget {
Component.onCompleted: { Component.onCompleted: {
styleDialog.active = true; styleDialog.active = true;
Common.widgetsNum++;
}
Component.onDestruction: {
styleDialog.active = false;
Common.widgetsNum--;
} }
} }

35
qml/StylePreferences.qml

@ -4,6 +4,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import NERvGear 1.0 as NVG import NERvGear 1.0 as NVG
import NERvGear.Preferences 1.0 as P import NERvGear.Preferences 1.0 as P
import NERvGear.Controls 1.0
import "." import "."
@ -27,18 +28,16 @@ NVG.Window {
property var configuration property var configuration
property var old_style_cfg property var old_style_cfg
ColumnLayout { Page {
id: root id: cfg_page
anchors.fill: parent anchors.fill: parent
anchors.margins: 16
anchors.topMargin: 0
Row { header: TitleBar {
spacing: window.width - 120 text: qsTr("Settings")
standardButtons: Dialog.Save | Dialog.Reset
ToolButton { onAccepted: {
text: qsTr("Save")
onClicked: {
configuration = rootPreference.save(); configuration = rootPreference.save();
let index = configuration["index"]; let index = configuration["index"];
widget.settings[Common.stylesURL[index]] = configuration[Common.stylesURL[index]]; widget.settings[Common.stylesURL[index]] = configuration[Common.stylesURL[index]];
@ -47,11 +46,8 @@ NVG.Window {
widget.settings.current_style = Common.stylesURL[index]; widget.settings.current_style = Common.stylesURL[index];
styleDialog.active = false; styleDialog.active = false;
} }
}
ToolButton { onReset: {
text: qsTr("Reset")
onClicked: {
styleLoader.load(); styleLoader.load();
let cfg = rootPreference.save(); let cfg = rootPreference.save();
let index = cfg["index"]; let index = cfg["index"];
@ -60,13 +56,12 @@ NVG.Window {
widget.setStyleURL(Qt.resolvedUrl(Common.stylesURL[widget.settings.styles["index"]])); widget.setStyleURL(Qt.resolvedUrl(Common.stylesURL[widget.settings.styles["index"]]));
} }
} }
}
Label { ColumnLayout {
Layout.alignment: Qt.AlignCenter id: root
text: qsTr("Settings") anchors.fill: parent
font.pixelSize: 24 anchors.margins: 16
} anchors.topMargin: 0
Flickable { Flickable {
Layout.fillWidth: true Layout.fillWidth: true
@ -88,7 +83,6 @@ NVG.Window {
onPreferenceEdited: { onPreferenceEdited: {
let cfg = rootPreference.save(); let cfg = rootPreference.save();
// console.log(JSON.stringify(cfg, null, 2));
let index = cfg["index"]; let index = cfg["index"];
if (widget.settings.styles["index"] !== index) { if (widget.settings.styles["index"] !== index) {
widget.setStyleURL(""); widget.setStyleURL("");
@ -168,6 +162,7 @@ NVG.Window {
} }
} }
} }
}
onClosing: { onClosing: {
widget.setStyleURL(""); widget.setStyleURL("");

2
qml/WSocket.qml

@ -18,8 +18,6 @@ WebSocket {
onBinaryMessageReceived: { onBinaryMessageReceived: {
let arrayBuffer = new Float32Array(message); let arrayBuffer = new Float32Array(message);
// Common.audioData = arrayBuffer.slice();
Common.audioDataUpdated(arrayBuffer.slice()); Common.audioDataUpdated(arrayBuffer.slice());
// arrayBuffer = null;
} }
} }

6
qml/api/StyleAPI.qml

@ -3,9 +3,9 @@ import QtQuick 2.12
import ".." //Common.qml import ".." //Common.qml
Canvas { Canvas {
width: widget.width; width: widget.width
height: widget.height; height: widget.height
contextType: "2d"; contextType: "2d"
renderTarget: Canvas.FramebufferObject renderTarget: Canvas.FramebufferObject
renderStrategy: Canvas.Cooperative renderStrategy: Canvas.Cooperative

Loading…
Cancel
Save