mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
set
This commit is contained in:
parent
1319f12400
commit
56bf499079
@ -40,9 +40,9 @@ from gui.attachprocessdialog import AttachProcessDialog
|
||||
import windows
|
||||
import gobject
|
||||
import winsharedutils
|
||||
from winsharedutils import pid_running, isDark
|
||||
from winsharedutils import pid_running
|
||||
from myutils.post import POSTSOLVE
|
||||
|
||||
from myutils.utils import nowisdark
|
||||
|
||||
class commonstylebase(QWidget):
|
||||
setstylesheetsignal = pyqtSignal()
|
||||
@ -905,13 +905,7 @@ class MAINUI:
|
||||
|
||||
def setcommonstylesheet(self):
|
||||
|
||||
dl = globalconfig["darklight"]
|
||||
if dl == 0:
|
||||
dark = False
|
||||
elif dl == 1:
|
||||
dark = True
|
||||
elif dl == 2:
|
||||
dark = isDark()
|
||||
dark = nowisdark()
|
||||
darklight = ["light", "dark"][dark]
|
||||
|
||||
self.currentisdark = dark
|
||||
|
@ -500,7 +500,7 @@ class browserdialog(saveposwindow):
|
||||
getcolorbutton(
|
||||
"",
|
||||
"",
|
||||
lambda _: self.likelink(),
|
||||
self.likelink,
|
||||
icon="fa.heart",
|
||||
constcolor="#FF69B4",
|
||||
sizefixed=True,
|
||||
@ -510,7 +510,7 @@ class browserdialog(saveposwindow):
|
||||
getcolorbutton(
|
||||
"",
|
||||
"",
|
||||
lambda _: self.urlclicked((None, None, self.current)),
|
||||
lambda: self.urlclicked((None, None, self.current)),
|
||||
icon="fa.repeat",
|
||||
constcolor="#FF69B4",
|
||||
sizefixed=True,
|
||||
@ -1056,7 +1056,7 @@ class dialog_setting_game_internal(QWidget):
|
||||
getcolorbutton(
|
||||
"",
|
||||
"",
|
||||
lambda _: listediter(
|
||||
lambda: listediter(
|
||||
self,
|
||||
_TR("禁止自动朗读的人名"),
|
||||
_TRL(
|
||||
@ -1234,12 +1234,13 @@ class dialog_setting_game(QDialog):
|
||||
l = QHBoxLayout(self)
|
||||
self.setLayout(l)
|
||||
l.addWidget(_)
|
||||
l.setContentsMargins(0,0,0,0)
|
||||
l.setContentsMargins(0, 0, 0, 0)
|
||||
self.show()
|
||||
try:
|
||||
self.setGeometry(
|
||||
calculate_centered_rect(
|
||||
_global_dialog_savedgame_new.parent().parent().geometry(), self.size()
|
||||
_global_dialog_savedgame_new.parent().parent().geometry(),
|
||||
self.size(),
|
||||
)
|
||||
)
|
||||
except:
|
||||
@ -2249,7 +2250,7 @@ class dialog_savedgame_v3(QWidget):
|
||||
tabadd_lazy(
|
||||
self.righttop,
|
||||
savehook_new_data[k]["title"],
|
||||
lambda v: v.addWidget(dialog_setting_game_internal(self, k))
|
||||
lambda v: v.addWidget(dialog_setting_game_internal(self, k)),
|
||||
)
|
||||
|
||||
except:
|
||||
|
@ -241,7 +241,7 @@ class autoinitdialog(QDialog):
|
||||
else:
|
||||
items = line["list"]
|
||||
lineW.addItems(_TRL(items))
|
||||
lineW.setCurrentIndex(dd[key])
|
||||
lineW.setCurrentIndex(dd.get(key, 0))
|
||||
lineW.currentIndexChanged.connect(
|
||||
functools.partial(dd.__setitem__, key)
|
||||
)
|
||||
|
@ -1,11 +1,14 @@
|
||||
from qtsymbols import *
|
||||
import functools
|
||||
import functools, importlib
|
||||
from traceback import print_exc
|
||||
import gobject
|
||||
from myutils.config import globalconfig, _TRL, static_data
|
||||
from myutils.utils import nowisdark
|
||||
from gui.usefulwidget import (
|
||||
D_getsimplecombobox,
|
||||
D_getspinbox,
|
||||
D_getcolorbutton,
|
||||
getcolorbutton,
|
||||
D_getsimpleswitch,
|
||||
selectcolor,
|
||||
)
|
||||
@ -79,7 +82,7 @@ def createhorizontal_slider_tool_label(self):
|
||||
|
||||
|
||||
def createfontcombo():
|
||||
|
||||
|
||||
sfont_comboBox = QFontComboBox()
|
||||
|
||||
def callback(x):
|
||||
@ -91,6 +94,115 @@ def createfontcombo():
|
||||
return sfont_comboBox
|
||||
|
||||
|
||||
def maybesetstyle(_dark):
|
||||
if _dark == nowisdark():
|
||||
gobject.baseobject.setcommonstylesheet()
|
||||
|
||||
|
||||
def wrapedsetstylecallback(_dark, self, func):
|
||||
try:
|
||||
func(self, functools.partial(maybesetstyle, _dark))
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
|
||||
def checkthemeissetable(self, dark: bool):
|
||||
try:
|
||||
darklight = ["light", "dark"][dark]
|
||||
idx = globalconfig[darklight + "theme"] - int(not dark)
|
||||
if idx == -1:
|
||||
return None
|
||||
_fn = static_data["themes"][darklight][idx]["file"]
|
||||
|
||||
if _fn.endswith(".py"):
|
||||
try:
|
||||
return functools.partial(
|
||||
wrapedsetstylecallback,
|
||||
dark,
|
||||
self,
|
||||
importlib.import_module(
|
||||
"files.themes." + _fn[:-3].replace("/", ".")
|
||||
).get_setting_window,
|
||||
)
|
||||
except:
|
||||
return None
|
||||
elif _fn.endswith(".qss"):
|
||||
return None
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def checkthemesettingvisandapply_1(self, _dark):
|
||||
try:
|
||||
if _dark:
|
||||
|
||||
darksetting = checkthemeissetable(self, True)
|
||||
self.darksetting = darksetting
|
||||
if not self.darksetting:
|
||||
self.btnthemedark.hide()
|
||||
else:
|
||||
self.btnthemedark.show()
|
||||
self.btnthemedark.clicked.connect(self.darksetting)
|
||||
else:
|
||||
|
||||
lightsetting = checkthemeissetable(self, False)
|
||||
self.lightsetting = lightsetting
|
||||
|
||||
if not self.lightsetting:
|
||||
self.btnthemelight.hide()
|
||||
else:
|
||||
self.btnthemelight.show()
|
||||
self.btnthemelight.clicked.connect(self.lightsetting)
|
||||
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
|
||||
def createbtnthemelight(self):
|
||||
lightsetting = checkthemeissetable(self, False)
|
||||
self.lightsetting = lightsetting
|
||||
self.btnthemelight = getcolorbutton(
|
||||
globalconfig,
|
||||
"",
|
||||
callback=lambda: 1,
|
||||
icon="fa.gear",
|
||||
constcolor="#FF69B4",
|
||||
)
|
||||
try:
|
||||
if not self.lightsetting:
|
||||
self.btnthemelight.hide()
|
||||
else:
|
||||
self.btnthemelight.clicked.connect(self.lightsetting)
|
||||
except:
|
||||
pass
|
||||
return self.btnthemelight
|
||||
|
||||
|
||||
def createbtnthemedark(self):
|
||||
darksetting = checkthemeissetable(self, True)
|
||||
self.darksetting = darksetting
|
||||
self.btnthemedark = getcolorbutton(
|
||||
globalconfig,
|
||||
"",
|
||||
callback=lambda: 1,
|
||||
icon="fa.gear",
|
||||
constcolor="#FF69B4",
|
||||
)
|
||||
try:
|
||||
if not self.darksetting:
|
||||
self.btnthemedark.hide()
|
||||
else:
|
||||
self.btnthemedark.clicked.connect(self.darksetting)
|
||||
except:
|
||||
pass
|
||||
return self.btnthemedark
|
||||
|
||||
|
||||
def checkthemesettingvisandapply(self, _dark):
|
||||
checkthemesettingvisandapply_1(self, _dark)
|
||||
maybesetstyle(_dark)
|
||||
|
||||
|
||||
def uisetting(self):
|
||||
|
||||
def themelist(t):
|
||||
@ -210,7 +322,7 @@ def uisetting(self):
|
||||
_TRL(["明亮", "黑暗", "跟随系统"]),
|
||||
globalconfig,
|
||||
"darklight",
|
||||
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
|
||||
gobject.baseobject.setcommonstylesheet,
|
||||
),
|
||||
5,
|
||||
),
|
||||
@ -222,10 +334,11 @@ def uisetting(self):
|
||||
_TRL(["默认"]) + themelist("light"),
|
||||
globalconfig,
|
||||
"lighttheme",
|
||||
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
|
||||
functools.partial(checkthemesettingvisandapply, self, False),
|
||||
),
|
||||
5,
|
||||
),
|
||||
(functools.partial(createbtnthemelight, self), 0),
|
||||
],
|
||||
[
|
||||
("黑暗主题", 4),
|
||||
@ -234,10 +347,11 @@ def uisetting(self):
|
||||
themelist("dark"),
|
||||
globalconfig,
|
||||
"darktheme",
|
||||
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
|
||||
functools.partial(checkthemesettingvisandapply, self, True),
|
||||
),
|
||||
5,
|
||||
),
|
||||
(functools.partial(createbtnthemedark, self), 0),
|
||||
],
|
||||
[],
|
||||
[
|
||||
|
@ -372,6 +372,10 @@ def callbackwrap(d, k, call, _):
|
||||
call(_)
|
||||
except:
|
||||
print_exc()
|
||||
try:
|
||||
call()
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
|
||||
def comboboxcallbackwrap(internallist, d, k, call, _):
|
||||
@ -381,6 +385,10 @@ def comboboxcallbackwrap(internallist, d, k, call, _):
|
||||
call(_)
|
||||
except:
|
||||
print_exc()
|
||||
try:
|
||||
call()
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
|
||||
def getsimplecombobox(lst, d, k, callback=None, fixedsize=False, internallist=None):
|
||||
|
@ -14,7 +14,6 @@ from myutils.config import (
|
||||
globalconfig,
|
||||
static_data,
|
||||
getlanguse,
|
||||
savehook_new_list,
|
||||
savehook_new_data,
|
||||
getdefaultsavehook,
|
||||
)
|
||||
@ -24,6 +23,15 @@ import re, heapq, winsharedutils
|
||||
from myutils.vndb import searchfordata, getvidbytitle
|
||||
from myutils.wrapper import tryprint
|
||||
|
||||
def nowisdark():
|
||||
dl = globalconfig["darklight"]
|
||||
if dl == 0:
|
||||
dark = False
|
||||
elif dl == 1:
|
||||
dark = True
|
||||
elif dl == 2:
|
||||
dark = winsharedutils.isDark()
|
||||
return dark
|
||||
|
||||
def getimageformatlist():
|
||||
_ = [_.data().decode() for _ in QImageWriter.supportedImageFormats()]
|
||||
|
@ -18,40 +18,12 @@
|
||||
"name": "QTWin11"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/ABYSS.py",
|
||||
"name": "QtVSCodeStyle Abyss"
|
||||
"file": "QtVSCodeStyle/dark.py",
|
||||
"name": "QtVSCodeStyle Dark"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/DARK_VS.py",
|
||||
"name": "QtVSCodeStyle Dark (Visual Studio)"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/KIMBIE_DARK.py",
|
||||
"name": "QtVSCodeStyle Kimbie Dark"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/MONOKAI.py",
|
||||
"name": "QtVSCodeStyle Monokai"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/MONOKAI_DIMMED.py",
|
||||
"name": "QtVSCodeStyle Monokai Dimmed"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/RED.py",
|
||||
"name": "QtVSCodeStyle Red"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/SOLARIZED_DARK.py",
|
||||
"name": "QtVSCodeStyle Solarized Dark"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/TOMORROW_NIGHT_BLUE.py",
|
||||
"name": "QtVSCodeStyle Tomorrow Night Blue"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/DARK_HIGH_CONTRAST.py",
|
||||
"name": "QtVSCodeStyle Dark High Contrast"
|
||||
"file": "qt_material/dark.py",
|
||||
"name": "qt-material"
|
||||
}
|
||||
],
|
||||
"light": [
|
||||
@ -72,16 +44,12 @@
|
||||
"name": "QTWin11"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/LIGHT_VS.py",
|
||||
"name": "QtVSCodeStyle Light (Visual Studio)"
|
||||
"file": "QtVSCodeStyle/light.py",
|
||||
"name": "QtVSCodeStyle Light"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/QUIET_LIGHT.py",
|
||||
"name": "QtVSCodeStyle Quiet Light"
|
||||
},
|
||||
{
|
||||
"file": "QtVSCodeStyle/SOLARIZED_LIGHT.py",
|
||||
"name": "QtVSCodeStyle Solarized Light"
|
||||
"file": "qt_material/light.py",
|
||||
"name": "qt-material"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user