mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24: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 windows
|
||||||
import gobject
|
import gobject
|
||||||
import winsharedutils
|
import winsharedutils
|
||||||
from winsharedutils import pid_running, isDark
|
from winsharedutils import pid_running
|
||||||
from myutils.post import POSTSOLVE
|
from myutils.post import POSTSOLVE
|
||||||
|
from myutils.utils import nowisdark
|
||||||
|
|
||||||
class commonstylebase(QWidget):
|
class commonstylebase(QWidget):
|
||||||
setstylesheetsignal = pyqtSignal()
|
setstylesheetsignal = pyqtSignal()
|
||||||
@ -905,13 +905,7 @@ class MAINUI:
|
|||||||
|
|
||||||
def setcommonstylesheet(self):
|
def setcommonstylesheet(self):
|
||||||
|
|
||||||
dl = globalconfig["darklight"]
|
dark = nowisdark()
|
||||||
if dl == 0:
|
|
||||||
dark = False
|
|
||||||
elif dl == 1:
|
|
||||||
dark = True
|
|
||||||
elif dl == 2:
|
|
||||||
dark = isDark()
|
|
||||||
darklight = ["light", "dark"][dark]
|
darklight = ["light", "dark"][dark]
|
||||||
|
|
||||||
self.currentisdark = dark
|
self.currentisdark = dark
|
||||||
|
@ -500,7 +500,7 @@ class browserdialog(saveposwindow):
|
|||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
lambda _: self.likelink(),
|
self.likelink,
|
||||||
icon="fa.heart",
|
icon="fa.heart",
|
||||||
constcolor="#FF69B4",
|
constcolor="#FF69B4",
|
||||||
sizefixed=True,
|
sizefixed=True,
|
||||||
@ -510,7 +510,7 @@ class browserdialog(saveposwindow):
|
|||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
lambda _: self.urlclicked((None, None, self.current)),
|
lambda: self.urlclicked((None, None, self.current)),
|
||||||
icon="fa.repeat",
|
icon="fa.repeat",
|
||||||
constcolor="#FF69B4",
|
constcolor="#FF69B4",
|
||||||
sizefixed=True,
|
sizefixed=True,
|
||||||
@ -1056,7 +1056,7 @@ class dialog_setting_game_internal(QWidget):
|
|||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
lambda _: listediter(
|
lambda: listediter(
|
||||||
self,
|
self,
|
||||||
_TR("禁止自动朗读的人名"),
|
_TR("禁止自动朗读的人名"),
|
||||||
_TRL(
|
_TRL(
|
||||||
@ -1234,12 +1234,13 @@ class dialog_setting_game(QDialog):
|
|||||||
l = QHBoxLayout(self)
|
l = QHBoxLayout(self)
|
||||||
self.setLayout(l)
|
self.setLayout(l)
|
||||||
l.addWidget(_)
|
l.addWidget(_)
|
||||||
l.setContentsMargins(0,0,0,0)
|
l.setContentsMargins(0, 0, 0, 0)
|
||||||
self.show()
|
self.show()
|
||||||
try:
|
try:
|
||||||
self.setGeometry(
|
self.setGeometry(
|
||||||
calculate_centered_rect(
|
calculate_centered_rect(
|
||||||
_global_dialog_savedgame_new.parent().parent().geometry(), self.size()
|
_global_dialog_savedgame_new.parent().parent().geometry(),
|
||||||
|
self.size(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
@ -2249,7 +2250,7 @@ class dialog_savedgame_v3(QWidget):
|
|||||||
tabadd_lazy(
|
tabadd_lazy(
|
||||||
self.righttop,
|
self.righttop,
|
||||||
savehook_new_data[k]["title"],
|
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:
|
except:
|
||||||
|
@ -241,7 +241,7 @@ class autoinitdialog(QDialog):
|
|||||||
else:
|
else:
|
||||||
items = line["list"]
|
items = line["list"]
|
||||||
lineW.addItems(_TRL(items))
|
lineW.addItems(_TRL(items))
|
||||||
lineW.setCurrentIndex(dd[key])
|
lineW.setCurrentIndex(dd.get(key, 0))
|
||||||
lineW.currentIndexChanged.connect(
|
lineW.currentIndexChanged.connect(
|
||||||
functools.partial(dd.__setitem__, key)
|
functools.partial(dd.__setitem__, key)
|
||||||
)
|
)
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
from qtsymbols import *
|
from qtsymbols import *
|
||||||
import functools
|
import functools, importlib
|
||||||
|
from traceback import print_exc
|
||||||
import gobject
|
import gobject
|
||||||
from myutils.config import globalconfig, _TRL, static_data
|
from myutils.config import globalconfig, _TRL, static_data
|
||||||
|
from myutils.utils import nowisdark
|
||||||
from gui.usefulwidget import (
|
from gui.usefulwidget import (
|
||||||
D_getsimplecombobox,
|
D_getsimplecombobox,
|
||||||
D_getspinbox,
|
D_getspinbox,
|
||||||
D_getcolorbutton,
|
D_getcolorbutton,
|
||||||
|
getcolorbutton,
|
||||||
D_getsimpleswitch,
|
D_getsimpleswitch,
|
||||||
selectcolor,
|
selectcolor,
|
||||||
)
|
)
|
||||||
@ -79,7 +82,7 @@ def createhorizontal_slider_tool_label(self):
|
|||||||
|
|
||||||
|
|
||||||
def createfontcombo():
|
def createfontcombo():
|
||||||
|
|
||||||
sfont_comboBox = QFontComboBox()
|
sfont_comboBox = QFontComboBox()
|
||||||
|
|
||||||
def callback(x):
|
def callback(x):
|
||||||
@ -91,6 +94,115 @@ def createfontcombo():
|
|||||||
return sfont_comboBox
|
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 uisetting(self):
|
||||||
|
|
||||||
def themelist(t):
|
def themelist(t):
|
||||||
@ -210,7 +322,7 @@ def uisetting(self):
|
|||||||
_TRL(["明亮", "黑暗", "跟随系统"]),
|
_TRL(["明亮", "黑暗", "跟随系统"]),
|
||||||
globalconfig,
|
globalconfig,
|
||||||
"darklight",
|
"darklight",
|
||||||
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
|
gobject.baseobject.setcommonstylesheet,
|
||||||
),
|
),
|
||||||
5,
|
5,
|
||||||
),
|
),
|
||||||
@ -222,10 +334,11 @@ def uisetting(self):
|
|||||||
_TRL(["默认"]) + themelist("light"),
|
_TRL(["默认"]) + themelist("light"),
|
||||||
globalconfig,
|
globalconfig,
|
||||||
"lighttheme",
|
"lighttheme",
|
||||||
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
|
functools.partial(checkthemesettingvisandapply, self, False),
|
||||||
),
|
),
|
||||||
5,
|
5,
|
||||||
),
|
),
|
||||||
|
(functools.partial(createbtnthemelight, self), 0),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
("黑暗主题", 4),
|
("黑暗主题", 4),
|
||||||
@ -234,10 +347,11 @@ def uisetting(self):
|
|||||||
themelist("dark"),
|
themelist("dark"),
|
||||||
globalconfig,
|
globalconfig,
|
||||||
"darktheme",
|
"darktheme",
|
||||||
callback=lambda _: gobject.baseobject.setcommonstylesheet(),
|
functools.partial(checkthemesettingvisandapply, self, True),
|
||||||
),
|
),
|
||||||
5,
|
5,
|
||||||
),
|
),
|
||||||
|
(functools.partial(createbtnthemedark, self), 0),
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
|
@ -372,6 +372,10 @@ def callbackwrap(d, k, call, _):
|
|||||||
call(_)
|
call(_)
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
try:
|
||||||
|
call()
|
||||||
|
except:
|
||||||
|
print_exc()
|
||||||
|
|
||||||
|
|
||||||
def comboboxcallbackwrap(internallist, d, k, call, _):
|
def comboboxcallbackwrap(internallist, d, k, call, _):
|
||||||
@ -381,6 +385,10 @@ def comboboxcallbackwrap(internallist, d, k, call, _):
|
|||||||
call(_)
|
call(_)
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
try:
|
||||||
|
call()
|
||||||
|
except:
|
||||||
|
print_exc()
|
||||||
|
|
||||||
|
|
||||||
def getsimplecombobox(lst, d, k, callback=None, fixedsize=False, internallist=None):
|
def getsimplecombobox(lst, d, k, callback=None, fixedsize=False, internallist=None):
|
||||||
|
@ -14,7 +14,6 @@ from myutils.config import (
|
|||||||
globalconfig,
|
globalconfig,
|
||||||
static_data,
|
static_data,
|
||||||
getlanguse,
|
getlanguse,
|
||||||
savehook_new_list,
|
|
||||||
savehook_new_data,
|
savehook_new_data,
|
||||||
getdefaultsavehook,
|
getdefaultsavehook,
|
||||||
)
|
)
|
||||||
@ -24,6 +23,15 @@ import re, heapq, winsharedutils
|
|||||||
from myutils.vndb import searchfordata, getvidbytitle
|
from myutils.vndb import searchfordata, getvidbytitle
|
||||||
from myutils.wrapper import tryprint
|
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():
|
def getimageformatlist():
|
||||||
_ = [_.data().decode() for _ in QImageWriter.supportedImageFormats()]
|
_ = [_.data().decode() for _ in QImageWriter.supportedImageFormats()]
|
||||||
|
@ -18,40 +18,12 @@
|
|||||||
"name": "QTWin11"
|
"name": "QTWin11"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "QtVSCodeStyle/ABYSS.py",
|
"file": "QtVSCodeStyle/dark.py",
|
||||||
"name": "QtVSCodeStyle Abyss"
|
"name": "QtVSCodeStyle Dark"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "QtVSCodeStyle/DARK_VS.py",
|
"file": "qt_material/dark.py",
|
||||||
"name": "QtVSCodeStyle Dark (Visual Studio)"
|
"name": "qt-material"
|
||||||
},
|
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"light": [
|
"light": [
|
||||||
@ -72,16 +44,12 @@
|
|||||||
"name": "QTWin11"
|
"name": "QTWin11"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "QtVSCodeStyle/LIGHT_VS.py",
|
"file": "QtVSCodeStyle/light.py",
|
||||||
"name": "QtVSCodeStyle Light (Visual Studio)"
|
"name": "QtVSCodeStyle Light"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "QtVSCodeStyle/QUIET_LIGHT.py",
|
"file": "qt_material/light.py",
|
||||||
"name": "QtVSCodeStyle Quiet Light"
|
"name": "qt-material"
|
||||||
},
|
|
||||||
{
|
|
||||||
"file": "QtVSCodeStyle/SOLARIZED_LIGHT.py",
|
|
||||||
"name": "QtVSCodeStyle Solarized Light"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user