Skip to content

Commit 1a4b035

Browse files
committed
兼容windows
1 parent 167df9f commit 1a4b035

20 files changed

+113
-72
lines changed

pc/functions/base.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ var baseSyncRoutes = map[string]syncHandler{
3939
os.Exit(2)
4040
return
4141
},
42+
// 退出
43+
"exit": func(p map[string]interface{}) (result interface{}) {
44+
dep.DoClose()
45+
os.Exit(0)
46+
return
47+
},
4248
// config
4349
"config": func(p map[string]interface{}) (result interface{}) {
4450
maxParallelCorutineNumber := int(p["maxParallelCorutineNumber"].(float64))

pc/gui/gui.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
package gui
44

55
import (
6-
"bytes"
76
_ "github.com/peterq/pan-light/pc/functions"
87
_ "github.com/peterq/pan-light/pc/gui/bridge"
98
_ "github.com/peterq/pan-light/pc/gui/comp"
10-
"io/ioutil"
11-
"time"
12-
13-
//_ "github.com/peterq/pan-light/pc/gui/qml"
9+
_ "github.com/peterq/pan-light/pc/gui/qml"
1410
"github.com/peterq/pan-light/qt/bindings/core"
1511
"github.com/peterq/pan-light/qt/bindings/gui"
1612
"github.com/peterq/pan-light/qt/bindings/qml"
@@ -25,19 +21,22 @@ func StartGui() {
2521

2622
// 下面2句话居然能解决windows 异常退出的bug
2723
core.QCoreApplication_SetOrganizationName("PeterQ") //needed to fix an QML Settings issue on windows
28-
quick.QQuickWindow_SetSceneGraphBackend(quick.QSGRendererInterface__Software)
24+
if os.Getenv("pan_light_render_exception_fix") == "true" {
25+
quick.QQuickWindow_SetSceneGraphBackend(quick.QSGRendererInterface__Software)
26+
}
27+
28+
//rccFile := "E:\\pan-light\\qml.rcc"
29+
//bin, _ := ioutil.ReadFile(rccFile)
30+
//go func() {
31+
// for range time.Tick(2 * time.Second) {
32+
// n, _ := ioutil.ReadFile(rccFile)
33+
// if !bytes.Equal(bin, n) {
34+
// os.Exit(2)
35+
// }
36+
// }
37+
//}()
38+
//core.QResource_RegisterResource(rccFile, "/")
2939

30-
rccFile := "E:\\pan-light\\qml.rcc"
31-
bin, _ := ioutil.ReadFile(rccFile)
32-
go func() {
33-
for range time.Tick(2 * time.Second) {
34-
n, _ := ioutil.ReadFile(rccFile)
35-
if !bytes.Equal(bin, n) {
36-
os.Exit(2)
37-
}
38-
}
39-
}()
40-
core.QResource_RegisterResource(rccFile, "/")
4140
app := gui.NewQGuiApplication(len(os.Args), os.Args)
4241

4342
engine := qml.NewQQmlApplicationEngine(nil)

pc/gui/qml/comps/Alert.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Window {
2323
}
2424
height: msg.implicitHeight + 24 + 100
2525

26-
flags: Qt.Dialog | Qt.WindowModal | Qt.WindowCloseButtonHint
26+
flags: Qt.MSWindowsFixedSizeDialogHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
27+
| Qt.WindowModal | Qt.Dialog
2728
modality: Qt.WindowModal
2829

2930
Dialog {

pc/gui/qml/comps/PromiseDialog.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Item {
3434
parent: G.root
3535
Window {
3636
id: window
37-
flags: Qt.Dialog | Qt.WindowModal | Qt.WindowCloseButtonHint
37+
flags: Qt.MSWindowsFixedSizeDialogHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
38+
| Qt.WindowModal | Qt.Dialog
3839
modality: Qt.ApplicationModal
3940
title: root.title
4041
minimumHeight: 100

pc/gui/qml/comps/confirm-window.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Window {
2222
}
2323
height: msg.implicitHeight + 24 + 150
2424

25-
flags: Qt.Dialog | Qt.WindowModal | Qt.WindowCloseButtonHint
25+
flags: Qt.MSWindowsFixedSizeDialogHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
26+
| Qt.WindowModal | Qt.Dialog
2627
modality: Qt.WindowModal
2728

2829
Dialog {

pc/gui/qml/comps/desktop-widget.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Window {
160160
}
161161
Controls.MenuItem {
162162
text: '退出程序'
163-
onTriggered: Qt.quit()
163+
onTriggered: Util.exit()
164164
}
165165
}
166166

@@ -189,7 +189,7 @@ Window {
189189
}
190190
MenuItem {
191191
text: '退出程序'
192-
onTriggered: Qt.quit()
192+
onTriggered: Util.exit()
193193
}
194194
}
195195
// 系统托盘

pc/gui/qml/comps/prompt-window.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Window {
2727
}
2828
height: msg.implicitHeight + 24 + 150
2929

30-
flags: Qt.Dialog | Qt.WindowModal | Qt.WindowCloseButtonHint
30+
// flags: Qt.Dialog | Qt.WindowModal | Qt.WindowCloseButtonHint
31+
flags: Qt.MSWindowsFixedSizeDialogHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
32+
| Qt.WindowModal | Qt.Dialog
3133
modality: Qt.WindowModal
3234

3335
function checkInput() {

pc/gui/qml/comps/select-save-path.qml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ FileDialog {
1818
console.log(v)
1919
}
2020
onAccepted: {
21-
resolve(file)
21+
console.log(file.toString())
22+
var savePath = file.toString().replace('file://'
23+
+ (Qt.platform.os == "windows" ? '/' : '')
24+
, '')
25+
if (Qt.platform.os == "windows") {
26+
savePath = savePath.split('/').join('\\')
27+
}
28+
resolve(savePath)
2229
}
2330
onRejected: {
2431
reject('用户取消选择保存路径')

pc/gui/qml/js/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,7 @@ function unixTime(t) {
470470
return date + ' ' + time
471471
}
472472

473+
function exit() {
474+
callGoSync('exit')
475+
}
476+

pc/gui/qml/login/FixedWindow.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Window {
77
maximumHeight: height
88
minimumWidth: width
99
maximumWidth: width
10-
flags: Qt.Dialog | Qt.WindowModal |Qt.WindowCloseButtonHint
10+
flags: Qt.MSWindowsFixedSizeDialogHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
11+
| Qt.WindowModal | Qt.Dialog
1112
visible: false
1213
modality: Qt.WindowModal
1314
}

0 commit comments

Comments
 (0)