mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 07:33:53 +08:00
.
This commit is contained in:
parent
0d87dae2b2
commit
4e401a387e
@ -1,7 +1,7 @@
|
||||
|
||||
set(VERSION_MAJOR 6)
|
||||
set(VERSION_MINOR 19)
|
||||
set(VERSION_PATCH 2)
|
||||
set(VERSION_PATCH 3)
|
||||
set(VERSION_REVISION 0)
|
||||
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
|
||||
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)
|
||||
|
@ -26,7 +26,8 @@ typedef enum _WINDOWCOMPOSITIONATTRIB
|
||||
WCA_FREEZE_REPRESENTATION = 20,
|
||||
WCA_EVER_UNCLOAKED = 21,
|
||||
WCA_VISUAL_OWNER = 22,
|
||||
WCA_LAST = 23
|
||||
WCA_LAST = 23,
|
||||
WCA_USEDARKMODECOLORS = 26
|
||||
} WINDOWCOMPOSITIONATTRIB;
|
||||
|
||||
typedef struct _WINDOWCOMPOSITIONATTRIBDATA
|
||||
@ -140,4 +141,45 @@ DECLARE_API bool clearEffect(HWND hwnd)
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
uint32_t GetOSversion() noexcept;
|
||||
|
||||
DECLARE_API bool setbackdropX(HWND hwnd, bool corner, bool dark)
|
||||
{
|
||||
#ifndef WINXP
|
||||
if (GetOSversion() <= 6)
|
||||
return false;
|
||||
ACCENT_POLICY accent;
|
||||
accent.AccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND;
|
||||
|
||||
CRegKey key;
|
||||
if (ERROR_SUCCESS != key.Open(HKEY_CURRENT_USER, LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent)"))
|
||||
return false;
|
||||
DWORD accent_int;
|
||||
if (ERROR_SUCCESS != key.QueryDWORDValue(L"AccentColorMenu", accent_int))
|
||||
return false;
|
||||
if (dark)
|
||||
accent.GradientColor = 0x40212121;
|
||||
else
|
||||
accent.GradientColor = 0x40f7f7fa;
|
||||
WINDOWCOMPOSITIONATTRIBDATA data;
|
||||
data.Attrib = WCA_ACCENT_POLICY;
|
||||
data.cbData = sizeof(accent);
|
||||
data.pvData = &accent;
|
||||
auto setWindowCompositionAttribute = (pfnSetWindowCompositionAttribute)GetProcAddress(GetModuleHandle(L"user32.dll"), "SetWindowCompositionAttribute");
|
||||
if (!setWindowCompositionAttribute)
|
||||
return false;
|
||||
setWindowCompositionAttribute(hwnd, &data);
|
||||
|
||||
if (dark)
|
||||
{
|
||||
data.Attrib = WCA_USEDARKMODECOLORS;
|
||||
setWindowCompositionAttribute(hwnd, &data);
|
||||
}
|
||||
|
||||
DWORD corner_ = corner ? 2 : 0;
|
||||
DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_, sizeof(corner_));
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
|
||||
// https://github.com/Blinue/Xaml-Islands-Cpp/blob/main/src/XamlIslandsCpp/XamlWindow.h
|
||||
|
||||
static uint32_t GetOSversion() noexcept
|
||||
uint32_t GetOSversion() noexcept
|
||||
{
|
||||
HMODULE hNtDll = GetModuleHandle(L"ntdll.dll");
|
||||
if (!hNtDll)
|
||||
|
@ -332,7 +332,9 @@ class MAINUI:
|
||||
if not text:
|
||||
return
|
||||
except Exception as e:
|
||||
self.translation_ui.displaystatus.emit(stringfyerror(e), TextType.Error_origin)
|
||||
self.translation_ui.displaystatus.emit(
|
||||
stringfyerror(e), TextType.Error_origin
|
||||
)
|
||||
return
|
||||
|
||||
if is_auto_run and (
|
||||
@ -557,8 +559,7 @@ class MAINUI:
|
||||
if iserror:
|
||||
if currentsignature == self.currentsignature:
|
||||
self.translation_ui.displaystatus.emit(
|
||||
apiname + " " + res,
|
||||
TextType.Error_translator
|
||||
apiname + " " + res, TextType.Error_translator
|
||||
)
|
||||
if len(usefultranslators) == 0:
|
||||
safe_callback("")
|
||||
@ -960,11 +961,18 @@ class MAINUI:
|
||||
print_exc()
|
||||
|
||||
def setdarkandbackdrop(self, widget, dark):
|
||||
if self.__dontshowintaborsetbackdrop(widget):
|
||||
ismenulist = isinstance(widget, (QMenu,)) or (type(widget) == QFrame)
|
||||
if ((not ismenulist)) and self.__dontshowintaborsetbackdrop(widget):
|
||||
return
|
||||
winsharedutils.SetTheme(
|
||||
int(widget.winId()), dark, globalconfig["WindowBackdrop"]
|
||||
)
|
||||
if ismenulist:
|
||||
darklight = ["light", "dark"][self.currentisdark]
|
||||
name = globalconfig[darklight + "theme2"]
|
||||
if name == "QTWin11":
|
||||
# 这个东西会导致其他主题看起来很怪,而且没办法撤销
|
||||
winsharedutils.setbackdropX(int(widget.winId()), True, dark)
|
||||
|
||||
@threader
|
||||
def clickwordcallback(self, word, append=False):
|
||||
@ -1068,10 +1076,15 @@ class MAINUI:
|
||||
style = ""
|
||||
for _ in (0,):
|
||||
try:
|
||||
idx = globalconfig[darklight + "theme"] - int(not dark)
|
||||
if idx == -1:
|
||||
name = globalconfig[darklight + "theme2"]
|
||||
_fn = None
|
||||
for n in static_data["themes"][darklight]:
|
||||
if n["name"] == name:
|
||||
_fn = n["file"]
|
||||
break
|
||||
|
||||
if not _fn:
|
||||
break
|
||||
_fn = static_data["themes"][darklight][idx]["file"]
|
||||
|
||||
if _fn.endswith(".py"):
|
||||
style = importlib.import_module(
|
||||
|
@ -139,10 +139,15 @@ def wrapedsetstylecallback(_dark, self, func):
|
||||
def checkthemeissetable(self, dark: bool):
|
||||
try:
|
||||
darklight = ["light", "dark"][dark]
|
||||
idx = globalconfig[darklight + "theme"] - int(not dark)
|
||||
if idx == -1:
|
||||
name = globalconfig[darklight + "theme2"]
|
||||
_fn = None
|
||||
for n in static_data["themes"][darklight]:
|
||||
if n["name"] == name:
|
||||
_fn = n["file"]
|
||||
break
|
||||
|
||||
if not _fn:
|
||||
return None
|
||||
_fn = static_data["themes"][darklight][idx]["file"]
|
||||
|
||||
if _fn.endswith(".py"):
|
||||
try:
|
||||
@ -603,12 +608,13 @@ def otheruisetting(self):
|
||||
D_getsimplecombobox(
|
||||
["默认"] + themelist("light"),
|
||||
globalconfig,
|
||||
"lighttheme",
|
||||
"lighttheme2",
|
||||
functools.partial(
|
||||
checkthemesettingvisandapply,
|
||||
self,
|
||||
False,
|
||||
),
|
||||
internal=["default"] + themelist("light"),
|
||||
),
|
||||
functools.partial(createbtnthemelight, self),
|
||||
),
|
||||
@ -619,12 +625,13 @@ def otheruisetting(self):
|
||||
D_getsimplecombobox(
|
||||
themelist("dark"),
|
||||
globalconfig,
|
||||
"darktheme",
|
||||
"darktheme2",
|
||||
functools.partial(
|
||||
checkthemesettingvisandapply,
|
||||
self,
|
||||
True,
|
||||
),
|
||||
internal=themelist("dark"),
|
||||
),
|
||||
functools.partial(createbtnthemedark, self),
|
||||
),
|
||||
|
@ -1014,21 +1014,22 @@ def getColor(color, parent, alpha=False):
|
||||
color_dialog = QColorDialog(color, parent)
|
||||
if alpha:
|
||||
color_dialog.setOption(QColorDialog.ColorDialogOption.ShowAlphaChannel, True)
|
||||
layout = color_dialog.layout()
|
||||
clearlayout(layout.itemAt(0).layout().takeAt(0))
|
||||
layout = layout.itemAt(0).layout().itemAt(0).layout().itemAt(2).widget().layout()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
if alpha:
|
||||
layout = color_dialog.layout()
|
||||
clearlayout(layout.itemAt(0).layout().takeAt(0))
|
||||
layout = layout.itemAt(0).layout().itemAt(0).layout().itemAt(2).widget().layout()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
layout.takeAt(1).widget().hide()
|
||||
|
||||
layout.takeAt(layout.count() - 1).widget().hide()
|
||||
layout.takeAt(layout.count() - 1).widget().hide()
|
||||
if not alpha:
|
||||
layout.takeAt(layout.count() - 1).widget().hide()
|
||||
layout.takeAt(layout.count() - 1).widget().hide()
|
||||
if not alpha:
|
||||
layout.takeAt(layout.count() - 1).widget().hide()
|
||||
layout.takeAt(layout.count() - 1).widget().hide()
|
||||
if color_dialog.exec_() != QColorDialog.DialogCode.Accepted:
|
||||
return QColor()
|
||||
return color_dialog.selectedColor()
|
||||
|
@ -278,7 +278,8 @@ def gdi_screenshot(x1, y1, x2, y2, hwnd=None):
|
||||
|
||||
maximum_window = utilsdll.maximum_window
|
||||
maximum_window.argtypes = (HWND,)
|
||||
|
||||
setbackdropX = utilsdll.setbackdropX
|
||||
setbackdropX.argtypes = HWND, c_bool, c_bool
|
||||
setAeroEffect = utilsdll.setAeroEffect
|
||||
setAeroEffect.argtypes = (HWND, c_bool)
|
||||
setAcrylicEffect = utilsdll.setAcrylicEffect
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 195ba64aafc8b63554253c8d3ace4299ec0e9ec1
|
||||
Subproject commit 0ccbf59b08fd7458820ede53833a8968e93b0d0c
|
@ -1504,8 +1504,8 @@
|
||||
}
|
||||
},
|
||||
"darklight2": 0,
|
||||
"darktheme": 0,
|
||||
"lighttheme": 1,
|
||||
"darktheme2": "PyQtDarkTheme",
|
||||
"lighttheme2": "PyQtDarkTheme",
|
||||
"usesearchword": false,
|
||||
"usecopyword": false,
|
||||
"usewordorigin": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user