diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index fcaabbf8..609e599e 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -39,6 +39,7 @@ from gui.dialog_savedgame_common import ( calculatetagidx, getreflist, getpixfunction, + showcountgame, addgamesingle, addgamebatch, addgamebatch_x, @@ -94,7 +95,6 @@ class dialog_savedgame_integrated(saveposwindow): | Qt.WindowType.WindowCloseButtonHint, poslist=globalconfig["savegamedialoggeo"], ) - self.setWindowTitle("游戏管理") self.setWindowIcon(qtawesome.icon("fa.gear")) w, self.internallayout = getboxlayout( [], margin0=True, makewidget=True, both=True @@ -155,6 +155,7 @@ class dialog_savedgame_new(QWidget): except: self.flow.widget(idx2 - 1).click() + showcountgame(self._parent, len(self.idxsave)) except: print_exc() @@ -169,6 +170,7 @@ class dialog_savedgame_new(QWidget): self.idxsave.pop(idx) self.idxsave.insert(0, uid) self.flow.totop1(idx) + showcountgame(self._parent, len(self.idxsave)) def clicked3_batch(self): addgamebatch(self.addgame, self.reflist) @@ -188,7 +190,6 @@ class dialog_savedgame_new(QWidget): self.flow.bgclicked.connect(ItemWidget.clearfocus) self.formLayout.insertWidget(self.formLayout.count() - 1, self.flow) idx = 0 - for k in self.reflist: if newtags != self.currtags: break @@ -223,6 +224,8 @@ class dialog_savedgame_new(QWidget): continue self.newline(k, idx == 0) idx += 1 + + showcountgame(self._parent, idx) self.flow.directshow() def showmenu(self, p): @@ -375,6 +378,7 @@ class dialog_savedgame_new(QWidget): def __init__(self, parent) -> None: super().__init__(parent) + self._parent = parent self.setstyle() gobject.global_dialog_savedgame_new = self formLayout = QVBoxLayout() diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame_common.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame_common.py index fa5f73b9..01b44d5f 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame_common.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame_common.py @@ -32,6 +32,13 @@ from gui.usefulwidget import ( ) +def showcountgame(window, num): + if num: + window.setWindowTitle("游戏管理____-_" + str(num)) + else: + window.setWindowTitle("游戏管理") + + class ItemWidget(QWidget): focuschanged = pyqtSignal(bool, str) doubleclicked = pyqtSignal(str) diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame_legacy.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame_legacy.py index 24654093..74ca34b1 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame_legacy.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame_legacy.py @@ -15,6 +15,7 @@ from gui.dialog_savedgame_common import ( opendirforgameuid, startgamecheck, addgamesingle, + showcountgame, addgamebatch_x, ) @@ -120,6 +121,7 @@ class dialog_savedgame_legacy(QWidget): savehook_new_list.pop(idx) self.savelist.pop(idx) self.model.removeRow(self.table.currentIndex().row()) + showcountgame(self.parent_,len(self.savelist)) except: pass @@ -130,6 +132,7 @@ class dialog_savedgame_legacy(QWidget): self.model.removeRow(idx) self.newline(0, uid) self.table.setCurrentIndex(self.model.index(0, 0)) + showcountgame(self.parent_,len(self.savelist)) def clicked3(self): addgamesingle(self, self.addgame, savehook_new_list) @@ -192,7 +195,7 @@ class dialog_savedgame_legacy(QWidget): # return # dialog_savedgame._sigleton=True super().__init__(parent) - + self.parent_ = parent self.setAcceptDrops(True) formLayout = QVBoxLayout(self) # model = LStandardItemModel() @@ -214,6 +217,9 @@ class dialog_savedgame_legacy(QWidget): for row, k in enumerate(savehook_new_list): # 2 self.newline(row, k) self.savelist.append(k) + + + showcountgame(self.parent_,len(self.savelist)) self.table.starttraceir() bottom = QHBoxLayout() diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame_v3.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame_v3.py index 8331b1b7..d5942ddb 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame_v3.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame_v3.py @@ -15,7 +15,7 @@ from myutils.config import ( from myutils.utils import str2rgba, get_time_stamp, loopbackrecorder from myutils.audioplayer import playonce from gui.inputdialog import autoinitdialog -from gui.specialwidget import stackedlist, shrinkableitem +from gui.specialwidget import stackedlist, shrinkableitem, shownumQPushButton from gui.usefulwidget import ( pixmapviewer, statusbutton, @@ -738,7 +738,9 @@ class dialog_savedgame_v3(QWidget): "opened": True, } savegametaged.insert(i, tag) - group0 = self.createtaglist(self.stack, title, tag["uid"], True) + group0, btn = self.createtaglist( + self.stack, title, tag["uid"], True + ) self.stack.insertw(i, group0) elif action == delgame: @@ -800,6 +802,7 @@ class dialog_savedgame_v3(QWidget): def __init__(self, parent) -> None: super().__init__(parent) + parent.setWindowTitle("游戏管理") self.setAcceptDrops(True) self.currentfocusuid = None self.reftagid = None @@ -870,7 +873,7 @@ class dialog_savedgame_v3(QWidget): title = tag["title"] tagid = tag["uid"] opened = tag.get("opened", True) - group0 = self.createtaglist(self.stack, title, tagid, opened) + group0, btn = self.createtaglist(self.stack, title, tagid, opened) self.stack.insertw(i, group0) rowreal = 0 for row, k in enumerate(lst): @@ -890,6 +893,7 @@ class dialog_savedgame_v3(QWidget): ) rowreal += 1 + btn.setnum(rowreal) def taglistrerank(self, tagid, dx): idx1 = calculatetagidx(tagid) @@ -960,7 +964,9 @@ class dialog_savedgame_v3(QWidget): "opened": True, } savegametaged.insert(i, tag) - group0 = self.createtaglist(self.stack, title, tag["uid"], True) + group0, btn = self.createtaglist( + self.stack, title, tag["uid"], True + ) self.stack.insertw(i, group0) elif action == editname: self.stack.w(i).settitle(title) @@ -975,13 +981,13 @@ class dialog_savedgame_v3(QWidget): def createtaglist(self, p, title, tagid, opened): self.reallist[tagid] = [] - _btn = QPushButton(title) + _btn = shownumQPushButton(title) _btn.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) _btn.clicked.connect(functools.partial(self._revertoepn, tagid)) _btn.customContextMenuRequested.connect( functools.partial(self.tagbuttonmenu, tagid) ) - return shrinkableitem(p, _btn, opened) + return shrinkableitem(p, _btn, opened), _btn def _revertoepn(self, tagid): item = savegametaged[calculatetagidx(tagid)] @@ -1019,11 +1025,13 @@ class dialog_savedgame_v3(QWidget): self.reallist[self.reftagid].pop(idx2) clickitem.clearfocus() group0 = self.stack.w(calculatetagidx(self.reftagid)) + group0.button().setnum(len(self.reallist[self.reftagid])) group0.popw(idx2) try: group0.w(idx2).click() except: group0.w(idx2 - 1).click() + except: print_exc() @@ -1038,6 +1046,9 @@ class dialog_savedgame_v3(QWidget): self.reallist[self.reftagid].pop(idx) self.reallist[self.reftagid].insert(0, uid) self.stack.w(calculatetagidx(self.reftagid)).torank1(idx) + self.stack.w(calculatetagidx(self.reftagid)).button().setnum( + len(self.reallist[self.reftagid]) + ) def clicked3_batch(self): addgamebatch(self.addgame, getreflist(self.reftagid)) diff --git a/LunaTranslator/LunaTranslator/gui/specialwidget.py b/LunaTranslator/LunaTranslator/gui/specialwidget.py index e2ec138a..341c804b 100644 --- a/LunaTranslator/LunaTranslator/gui/specialwidget.py +++ b/LunaTranslator/LunaTranslator/gui/specialwidget.py @@ -590,8 +590,35 @@ class delayloadvbox(QWidget): return len(self.internal_widgets) +class shownumQPushButton(QPushButton): + def __init__(self, *arg, **kw): + super().__init__(*arg, **kw) + self.num = 0 + + def setnum(self, num): + self.num = num + self.update() + + def paintEvent(self, event): + super().paintEvent(event) + if not self.num: + return + painter = QPainter(self) + painter.setPen(Qt.GlobalColor.gray) + rect = self.rect() + + textRect = self.fontMetrics().boundingRect(self.text()) + numberRect = rect.adjusted(textRect.width() + 10, 0, -10, 0) + + painter.drawText( + numberRect, + Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter, + str(self.num), + ) + + class shrinkableitem(QWidget): - def __init__(self, p, shrinker: QPushButton, opened): + def __init__(self, p, shrinker: shownumQPushButton, opened): super().__init__(p) self.lay = QVBoxLayout() # self.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Fixed) @@ -647,6 +674,9 @@ class shrinkableitem(QWidget): def len(self): return self.items.len() + def button(self): + return self.btn + class stackedlist(ScrollArea): bgclicked = pyqtSignal() diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 3a6eb057..2eaf6b3e 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 34) -set(VERSION_PATCH 6) +set(VERSION_PATCH 7) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)