This commit is contained in:
恍兮惚兮 2024-05-30 14:39:23 +08:00
parent afa8abb81e
commit 731ab0a08f
9 changed files with 45 additions and 38 deletions

View File

@ -24,6 +24,7 @@ import winsharedutils
from myutils.wrapper import Singleton_close, Singleton, threader, tryprint
from myutils.utils import (
checkifnewgame,
str2rgba,
vidchangedtask,
titlechangedtask,
imgchangedtask,
@ -57,7 +58,7 @@ class ItemWidget(QWidget):
def mousePressEvent(self, ev) -> None:
try:
self.bottommask.setStyleSheet(
f'background-color: {globalconfig["dialog_savegame_layout"]["onselectcolor"]};'
f'background-color: {str2rgba(globalconfig["dialog_savegame_layout"]["onselectcolor"],globalconfig["dialog_savegame_layout"]["transparent"])};'
)
if self != ItemWidget.globallashfocus:
@ -121,6 +122,7 @@ class ItemWidget(QWidget):
c = globalconfig["dialog_savegame_layout"][
("onfilenoexistscolor", "backcolor")[os.path.exists(exe)]
]
c = str2rgba(c, globalconfig["dialog_savegame_layout"]["transparent"])
self.maskshowfileexists.setStyleSheet(f"background-color:{c};")
@ -1221,6 +1223,10 @@ class dialog_syssetting(QDialog):
parent=self,
),
)
formLayout.addRow(
(_TR("不透明度")),
getspinbox(0, 100, globalconfig["dialog_savegame_layout"], "transparent"),
)
formLayout.addRow(
_TR("缩放"),
getsimplecombobox(

View File

@ -4,7 +4,7 @@ import threading, windows
import gobject, time
from myutils.config import globalconfig, _TR
from gui.usefulwidget import closeashidewindow, saveposwindow
from myutils.config import globalconfig
from myutils.utils import str2rgba
from myutils.wrapper import Singleton_close, threader
@ -97,13 +97,8 @@ class edittrans(QMainWindow):
super().__init__(parent, Qt.WindowType.FramelessWindowHint)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
self.setStyleSheet(
"background-color: rgba(%s, %s, %s, %s)"
% (
int(globalconfig["backcolor"][1:3], 16),
int(globalconfig["backcolor"][3:5], 16),
int(globalconfig["backcolor"][5:7], 16),
globalconfig["transparent"],
)
"background-color: %s"
% str2rgba(globalconfig["backcolor"], globalconfig["transparent"])
)
self.setupUi()

View File

@ -19,6 +19,7 @@ from gui.usefulwidget import (
getsimpleswitch,
getsimplekeyseq,
getcolorbutton,
makesubtab_lazy,
tabadd_lazy,
)
from myutils.subproc import subproc_w
@ -142,7 +143,7 @@ class AnkiWindow(QWidget):
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
self.setWindowTitle("Anki Connect")
self.currentword = ""
self.tabs = QTabWidget()
self.tabs = makesubtab_lazy(callback=self.ifshowrefresh)
self.tabs.addTab(self.createaddtab(), _TR("添加"))
tabadd_lazy(self.tabs, "设置", self.creatsetdtab)
tabadd_lazy(self.tabs, "模板", self.creattemplatetab)
@ -156,13 +157,6 @@ class AnkiWindow(QWidget):
self.tabs.currentChanged.connect(self.ifshowrefresh)
def ifshowrefresh(self, idx):
try:
w = self.tabs.currentWidget()
if "lazyfunction" in dir(w):
w.lazyfunction()
delattr(w, "lazyfunction")
except:
print_exc()
if idx == 2:
self.refreshhtml.emit()

View File

@ -211,6 +211,7 @@ class Textbrowser(QLabel):
def resizeEvent(self, event):
self.atback2.resize(event.size())
self.toplabel2.resize(event.size())
self.masklabel.resize(event.size())
def contentchangedfunction(self):
sz = self.textbrowser.document().size().toSize()
@ -250,7 +251,6 @@ class Textbrowser(QLabel):
Qt.ScrollBarPolicy.ScrollBarAlwaysOff
)
self.masklabel = QLabel(self.textbrowser)
self.masklabel.setGeometry(0, 0, 9999, 9999)
self.masklabel.setMouseTracking(True)
self.savetaglabels = []

View File

@ -12,7 +12,7 @@ import winsharedutils
from myutils.config import globalconfig, saveallconfig, _TR, static_data
from myutils.subproc import endsubprocs
from myutils.ocrutil import ocr_run, imageCut
from myutils.utils import loadpostsettingwindowmethod, getimageformat
from myutils.utils import loadpostsettingwindowmethod, getimageformat, str2rgba
from myutils.hwnd import mouseselectwindow, grabwindow, getExeIcon
from gui.dialog_savedgame import dialog_savedgame_new
from gui.dialog_memory import dialog_memory
@ -699,23 +699,22 @@ class QUnFrameWindow(resizableframeless):
)
self.translate_text.setStyleSheet(
"border-width: 0;%s;background-color: rgba(%s, %s, %s, %s)"
"border-width: 0;%s;background-color: %s"
% (
topr,
int(globalconfig["backcolor"][1:3], 16),
int(globalconfig["backcolor"][3:5], 16),
int(globalconfig["backcolor"][5:7], 16),
globalconfig["transparent"] * (not self.backtransparent) / 100,
str2rgba(
globalconfig["backcolor"],
globalconfig["transparent"] * (not self.backtransparent),
),
)
)
self._TitleLabel.setStyleSheet(
"border-width: 0;%s;background-color: rgba(%s, %s, %s, %s)"
"border-width: 0;%s;background-color: %s"
% (
bottomr,
int(globalconfig["backcolor_tool"][1:3], 16),
int(globalconfig["backcolor_tool"][3:5], 16),
int(globalconfig["backcolor_tool"][5:7], 16),
globalconfig["transparent_tool"] / 100,
str2rgba(
globalconfig["backcolor_tool"], globalconfig["transparent_tool"]
),
)
)
for _type in self.stylebuttons:
@ -951,14 +950,15 @@ class QUnFrameWindow(resizableframeless):
self.dodelayhide(delay)
def resizeEvent(self, e):
def resizeEvent(self, e: QResizeEvent):
super().resizeEvent(e)
wh = globalconfig["buttonsize"] * 1.5
height = self.height() - wh
self.translate_text.resize(self.width(), int(height))
self.adjustbuttons()
self._TitleLabel.setFixedWidth(self.width())
if e.oldSize().width() != e.size().width():
self.adjustbuttons()
self._TitleLabel.setFixedWidth(self.width())
def adjustbuttons(self):
left = []

View File

@ -117,10 +117,10 @@ class closeashidewindow(saveposwindow):
def showfunction(self):
if self.isMinimized():
self.showNormal()
elif self.isHidden():
self.show()
else:
elif self.isVisible():
self.hide()
else:
self.show()
def closeEvent(self, event: QCloseEvent):
self.hide()
@ -812,7 +812,7 @@ def makegrid(grid, save=False, savelist=None, savelay=None):
return gridlayoutwidget
def makesubtab_lazy(titles=None, functions=None, klass=None):
def makesubtab_lazy(titles=None, functions=None, klass=None, callback=None):
if klass:
tab = klass()
else:
@ -826,6 +826,8 @@ def makesubtab_lazy(titles=None, functions=None, klass=None):
delattr(w, "lazyfunction")
except:
print_exc()
if callback:
callback(i)
tab.currentChanged.connect(functools.partial(__, tab))
if titles and functions:

View File

@ -623,3 +623,12 @@ def parsekeystringtomodvkcode(keystring, modes=False):
if modes:
mode = _modes
return mode, vkcode
def str2rgba(string, alpha100):
return "rgba(%s, %s, %s, %s)" % (
int(string[1:3], 16),
int(string[3:5], 16),
int(string[5:7], 16),
alpha100 / 100,
)

View File

@ -240,7 +240,8 @@
"textH": 50,
"backcolor": "#c38282",
"onselectcolor": "#007fff",
"onfilenoexistscolor": "#acacac"
"onfilenoexistscolor": "#acacac",
"transparent": 25
},
"profiles_index": 0,
"ocrautobindwindow": true,

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 2)
set(VERSION_PATCH 3)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)