Skip to content

Commit 292a36e

Browse files
committed
update ui
1 parent 1e9fa7e commit 292a36e

18 files changed

+224
-149
lines changed

db/Database.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,11 @@ namespace NekoGui {
136136
if (latency < 0) {
137137
return Qt::red;
138138
} else if (latency > 0) {
139-
if (latency < 100) {
139+
auto greenMs = dataStore->test_latency_url.startsWith("https://") ? 200 : 100;
140+
if (latency < greenMs) {
140141
return Qt::darkGreen;
141-
} else if (latency < 200) {
142-
return Qt::darkYellow;
143142
} else {
144-
return Qt::red;
143+
return Qt::darkYellow;
145144
}
146145
} else {
147146
return {};

fmt/CustomBean.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace NekoGui_fmt {
3131
return core;
3232
};
3333

34-
QString DisplayCoreType() override { return NeedExternal(false) ? core : software_core_name; };
34+
QString DisplayCoreType() override { return NeedExternal(true) == 0 ? software_core_name : core; };
3535

3636
QString DisplayAddress() override {
3737
if (core == "internal") {

fmt/HysteriaBean.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace NekoGui_fmt {
6363
return ::DisplayAddress(serverAddress, serverPort);
6464
}
6565

66-
QString DisplayCoreType() override { return NeedExternal(false) == 0 ? software_core_name : "Hysteria"; };
66+
QString DisplayCoreType() override { return NeedExternal(true) == 0 ? software_core_name : "Hysteria"; };
6767

6868
QString DisplayType() override { return "Hysteria"; };
6969

go/cmd/updater/launcher.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build !linux
2+
3+
package main
4+
5+
import (
6+
"log"
7+
"runtime"
8+
)
9+
10+
func Launcher() {
11+
log.Fatalln("launcher is not for your platform", runtime.GOOS)
12+
}

go/cmd/updater/launcher_darwin.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

go/cmd/updater/launcher_windows.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

go/cmd/updater/msgbox.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build !windows
2+
3+
package main
4+
5+
func MessageBoxPlain(title, caption string) int {
6+
return 0
7+
}

go/cmd/updater/msgbox_windows.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package main
2+
3+
import (
4+
"syscall"
5+
"unsafe"
6+
)
7+
8+
// MessageBoxPlain of Win32 API.
9+
func MessageBoxPlain(title, caption string) int {
10+
const (
11+
NULL = 0
12+
MB_OK = 0
13+
)
14+
return MessageBox(NULL, caption, title, MB_OK)
15+
}
16+
17+
// MessageBox of Win32 API.
18+
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
19+
ret, _, _ := syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
20+
uintptr(hwnd),
21+
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
22+
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),
23+
uintptr(flags))
24+
25+
return int(ret)
26+
}

go/cmd/updater/updater.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func Updater() {
6464
// update move
6565
err := Mv("./nekoray_update/nekoray", "./")
6666
if err != nil {
67+
MessageBoxPlain("NekoGui Updater", "Update failed. Please close the running instance and run the updater again.\n\n"+err.Error())
6768
log.Fatalln(err.Error())
6869
}
6970

main/NekoGui_Utils.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <random>
77

8+
#include <QApplication>
89
#include <QUrlQuery>
910
#include <QTcpServer>
1011
#include <QTimer>
@@ -194,9 +195,12 @@ QString DisplayTime(long long time, int formatType) {
194195
}
195196

196197
QWidget *GetMessageBoxParent() {
197-
if (mainwindow == nullptr) return nullptr;
198-
if (mainwindow->isVisible()) return mainwindow;
199-
return nullptr;
198+
auto activeWindow = QApplication::activeWindow();
199+
if (activeWindow == nullptr && mainwindow != nullptr) {
200+
if (mainwindow->isVisible()) return mainwindow;
201+
return nullptr;
202+
}
203+
return activeWindow;
200204
}
201205

202206
int MessageBoxWarning(const QString &title, const QString &text) {

0 commit comments

Comments
 (0)