Skip to content

Commit

Permalink
update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Jun 5, 2023
1 parent 1e9fa7e commit 292a36e
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 149 deletions.
7 changes: 3 additions & 4 deletions db/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ namespace NekoGui {
if (latency < 0) {
return Qt::red;
} else if (latency > 0) {
if (latency < 100) {
auto greenMs = dataStore->test_latency_url.startsWith("https://") ? 200 : 100;
if (latency < greenMs) {
return Qt::darkGreen;
} else if (latency < 200) {
return Qt::darkYellow;
} else {
return Qt::red;
return Qt::darkYellow;
}
} else {
return {};
Expand Down
2 changes: 1 addition & 1 deletion fmt/CustomBean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace NekoGui_fmt {
return core;
};

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

QString DisplayAddress() override {
if (core == "internal") {
Expand Down
2 changes: 1 addition & 1 deletion fmt/HysteriaBean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace NekoGui_fmt {
return ::DisplayAddress(serverAddress, serverPort);
}

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

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

Expand Down
12 changes: 12 additions & 0 deletions go/cmd/updater/launcher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !linux

package main

import (
"log"
"runtime"
)

func Launcher() {
log.Fatalln("launcher is not for your platform", runtime.GOOS)
}
5 changes: 0 additions & 5 deletions go/cmd/updater/launcher_darwin.go

This file was deleted.

10 changes: 0 additions & 10 deletions go/cmd/updater/launcher_windows.go

This file was deleted.

7 changes: 7 additions & 0 deletions go/cmd/updater/msgbox.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !windows

package main

func MessageBoxPlain(title, caption string) int {
return 0
}
26 changes: 26 additions & 0 deletions go/cmd/updater/msgbox_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"syscall"
"unsafe"
)

// MessageBoxPlain of Win32 API.
func MessageBoxPlain(title, caption string) int {
const (
NULL = 0
MB_OK = 0
)
return MessageBox(NULL, caption, title, MB_OK)
}

// MessageBox of Win32 API.
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
ret, _, _ := syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),
uintptr(flags))

return int(ret)
}
1 change: 1 addition & 0 deletions go/cmd/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Updater() {
// update move
err := Mv("./nekoray_update/nekoray", "./")
if err != nil {
MessageBoxPlain("NekoGui Updater", "Update failed. Please close the running instance and run the updater again.\n\n"+err.Error())
log.Fatalln(err.Error())
}

Expand Down
10 changes: 7 additions & 3 deletions main/NekoGui_Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <random>

#include <QApplication>
#include <QUrlQuery>
#include <QTcpServer>
#include <QTimer>
Expand Down Expand Up @@ -194,9 +195,12 @@ QString DisplayTime(long long time, int formatType) {
}

QWidget *GetMessageBoxParent() {
if (mainwindow == nullptr) return nullptr;
if (mainwindow->isVisible()) return mainwindow;
return nullptr;
auto activeWindow = QApplication::activeWindow();
if (activeWindow == nullptr && mainwindow != nullptr) {
if (mainwindow->isVisible()) return mainwindow;
return nullptr;
}
return activeWindow;
}

int MessageBoxWarning(const QString &title, const QString &text) {
Expand Down
12 changes: 8 additions & 4 deletions translations/fa_IR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,10 @@ This needs to be run NekoBox with administrator privileges.</source>
<source>Select Profile</source>
<translation>انتخاب کردن پروفایل</translation>
</message>
<message>
<source>Name cannot be empty.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditCustom</name>
Expand Down Expand Up @@ -816,6 +820,10 @@ This needs to be run NekoBox with administrator privileges.</source>
<source>Please fill the complete config.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Name cannot be empty.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditHysteria</name>
Expand Down Expand Up @@ -1360,10 +1368,6 @@ This needs to be run NekoBox with administrator privileges.</source>
<source>Remove %1 item(s) ?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset traffic of %1 item(s) ?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copied %1 item(s)</source>
<translation type="unfinished"></translation>
Expand Down
12 changes: 8 additions & 4 deletions translations/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ This needs to be run NekoBox with administrator privileges.</source>
<source>Traffic order is from top to bottom</source>
<translation>流量顺序是从上到下(最后一个配置为流量的出口)</translation>
</message>
<message>
<source>Name cannot be empty.</source>
<translation>名称 不能为空</translation>
</message>
</context>
<context>
<name>EditCustom</name>
Expand Down Expand Up @@ -814,6 +818,10 @@ This needs to be run NekoBox with administrator privileges.</source>
<source>Please fill the complete config.</source>
<translation>请填写完整配置。</translation>
</message>
<message>
<source>Name cannot be empty.</source>
<translation>名称 不能为空</translation>
</message>
</context>
<context>
<name>EditHysteria</name>
Expand Down Expand Up @@ -1169,10 +1177,6 @@ This needs to be run NekoBox with administrator privileges.</source>
<source>Remove %1 item(s) ?</source>
<translation>删除 %1 个项目?</translation>
</message>
<message>
<source>Reset traffic of %1 item(s) ?</source>
<translation>重置 %1 个项目的流量?</translation>
</message>
<message>
<source>Config copied</source>
<translation>配置已复制</translation>
Expand Down
Loading

0 comments on commit 292a36e

Please sign in to comment.