This commit is contained in:
恍兮惚兮 2024-09-10 09:41:56 +08:00
parent 5e60225e16
commit 2295734cbf
6 changed files with 69 additions and 11 deletions

View File

@ -39,6 +39,7 @@ from gui.dialog_savedgame_common import (
calculatetagidx, calculatetagidx,
getreflist, getreflist,
getpixfunction, getpixfunction,
showcountgame,
addgamesingle, addgamesingle,
addgamebatch, addgamebatch,
addgamebatch_x, addgamebatch_x,
@ -94,7 +95,6 @@ class dialog_savedgame_integrated(saveposwindow):
| Qt.WindowType.WindowCloseButtonHint, | Qt.WindowType.WindowCloseButtonHint,
poslist=globalconfig["savegamedialoggeo"], poslist=globalconfig["savegamedialoggeo"],
) )
self.setWindowTitle("游戏管理")
self.setWindowIcon(qtawesome.icon("fa.gear")) self.setWindowIcon(qtawesome.icon("fa.gear"))
w, self.internallayout = getboxlayout( w, self.internallayout = getboxlayout(
[], margin0=True, makewidget=True, both=True [], margin0=True, makewidget=True, both=True
@ -155,6 +155,7 @@ class dialog_savedgame_new(QWidget):
except: except:
self.flow.widget(idx2 - 1).click() self.flow.widget(idx2 - 1).click()
showcountgame(self._parent, len(self.idxsave))
except: except:
print_exc() print_exc()
@ -169,6 +170,7 @@ class dialog_savedgame_new(QWidget):
self.idxsave.pop(idx) self.idxsave.pop(idx)
self.idxsave.insert(0, uid) self.idxsave.insert(0, uid)
self.flow.totop1(idx) self.flow.totop1(idx)
showcountgame(self._parent, len(self.idxsave))
def clicked3_batch(self): def clicked3_batch(self):
addgamebatch(self.addgame, self.reflist) addgamebatch(self.addgame, self.reflist)
@ -188,7 +190,6 @@ class dialog_savedgame_new(QWidget):
self.flow.bgclicked.connect(ItemWidget.clearfocus) self.flow.bgclicked.connect(ItemWidget.clearfocus)
self.formLayout.insertWidget(self.formLayout.count() - 1, self.flow) self.formLayout.insertWidget(self.formLayout.count() - 1, self.flow)
idx = 0 idx = 0
for k in self.reflist: for k in self.reflist:
if newtags != self.currtags: if newtags != self.currtags:
break break
@ -223,6 +224,8 @@ class dialog_savedgame_new(QWidget):
continue continue
self.newline(k, idx == 0) self.newline(k, idx == 0)
idx += 1 idx += 1
showcountgame(self._parent, idx)
self.flow.directshow() self.flow.directshow()
def showmenu(self, p): def showmenu(self, p):
@ -375,6 +378,7 @@ class dialog_savedgame_new(QWidget):
def __init__(self, parent) -> None: def __init__(self, parent) -> None:
super().__init__(parent) super().__init__(parent)
self._parent = parent
self.setstyle() self.setstyle()
gobject.global_dialog_savedgame_new = self gobject.global_dialog_savedgame_new = self
formLayout = QVBoxLayout() formLayout = QVBoxLayout()

View File

@ -32,6 +32,13 @@ from gui.usefulwidget import (
) )
def showcountgame(window, num):
if num:
window.setWindowTitle("游戏管理____-_" + str(num))
else:
window.setWindowTitle("游戏管理")
class ItemWidget(QWidget): class ItemWidget(QWidget):
focuschanged = pyqtSignal(bool, str) focuschanged = pyqtSignal(bool, str)
doubleclicked = pyqtSignal(str) doubleclicked = pyqtSignal(str)

View File

@ -15,6 +15,7 @@ from gui.dialog_savedgame_common import (
opendirforgameuid, opendirforgameuid,
startgamecheck, startgamecheck,
addgamesingle, addgamesingle,
showcountgame,
addgamebatch_x, addgamebatch_x,
) )
@ -120,6 +121,7 @@ class dialog_savedgame_legacy(QWidget):
savehook_new_list.pop(idx) savehook_new_list.pop(idx)
self.savelist.pop(idx) self.savelist.pop(idx)
self.model.removeRow(self.table.currentIndex().row()) self.model.removeRow(self.table.currentIndex().row())
showcountgame(self.parent_,len(self.savelist))
except: except:
pass pass
@ -130,6 +132,7 @@ class dialog_savedgame_legacy(QWidget):
self.model.removeRow(idx) self.model.removeRow(idx)
self.newline(0, uid) self.newline(0, uid)
self.table.setCurrentIndex(self.model.index(0, 0)) self.table.setCurrentIndex(self.model.index(0, 0))
showcountgame(self.parent_,len(self.savelist))
def clicked3(self): def clicked3(self):
addgamesingle(self, self.addgame, savehook_new_list) addgamesingle(self, self.addgame, savehook_new_list)
@ -192,7 +195,7 @@ class dialog_savedgame_legacy(QWidget):
# return # return
# dialog_savedgame._sigleton=True # dialog_savedgame._sigleton=True
super().__init__(parent) super().__init__(parent)
self.parent_ = parent
self.setAcceptDrops(True) self.setAcceptDrops(True)
formLayout = QVBoxLayout(self) # formLayout = QVBoxLayout(self) #
model = LStandardItemModel() model = LStandardItemModel()
@ -214,6 +217,9 @@ class dialog_savedgame_legacy(QWidget):
for row, k in enumerate(savehook_new_list): # 2 for row, k in enumerate(savehook_new_list): # 2
self.newline(row, k) self.newline(row, k)
self.savelist.append(k) self.savelist.append(k)
showcountgame(self.parent_,len(self.savelist))
self.table.starttraceir() self.table.starttraceir()
bottom = QHBoxLayout() bottom = QHBoxLayout()

View File

@ -15,7 +15,7 @@ from myutils.config import (
from myutils.utils import str2rgba, get_time_stamp, loopbackrecorder from myutils.utils import str2rgba, get_time_stamp, loopbackrecorder
from myutils.audioplayer import playonce from myutils.audioplayer import playonce
from gui.inputdialog import autoinitdialog from gui.inputdialog import autoinitdialog
from gui.specialwidget import stackedlist, shrinkableitem from gui.specialwidget import stackedlist, shrinkableitem, shownumQPushButton
from gui.usefulwidget import ( from gui.usefulwidget import (
pixmapviewer, pixmapviewer,
statusbutton, statusbutton,
@ -738,7 +738,9 @@ class dialog_savedgame_v3(QWidget):
"opened": True, "opened": True,
} }
savegametaged.insert(i, tag) 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) self.stack.insertw(i, group0)
elif action == delgame: elif action == delgame:
@ -800,6 +802,7 @@ class dialog_savedgame_v3(QWidget):
def __init__(self, parent) -> None: def __init__(self, parent) -> None:
super().__init__(parent) super().__init__(parent)
parent.setWindowTitle("游戏管理")
self.setAcceptDrops(True) self.setAcceptDrops(True)
self.currentfocusuid = None self.currentfocusuid = None
self.reftagid = None self.reftagid = None
@ -870,7 +873,7 @@ class dialog_savedgame_v3(QWidget):
title = tag["title"] title = tag["title"]
tagid = tag["uid"] tagid = tag["uid"]
opened = tag.get("opened", True) 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) self.stack.insertw(i, group0)
rowreal = 0 rowreal = 0
for row, k in enumerate(lst): for row, k in enumerate(lst):
@ -890,6 +893,7 @@ class dialog_savedgame_v3(QWidget):
) )
rowreal += 1 rowreal += 1
btn.setnum(rowreal)
def taglistrerank(self, tagid, dx): def taglistrerank(self, tagid, dx):
idx1 = calculatetagidx(tagid) idx1 = calculatetagidx(tagid)
@ -960,7 +964,9 @@ class dialog_savedgame_v3(QWidget):
"opened": True, "opened": True,
} }
savegametaged.insert(i, tag) 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) self.stack.insertw(i, group0)
elif action == editname: elif action == editname:
self.stack.w(i).settitle(title) self.stack.w(i).settitle(title)
@ -975,13 +981,13 @@ class dialog_savedgame_v3(QWidget):
def createtaglist(self, p, title, tagid, opened): def createtaglist(self, p, title, tagid, opened):
self.reallist[tagid] = [] self.reallist[tagid] = []
_btn = QPushButton(title) _btn = shownumQPushButton(title)
_btn.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) _btn.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
_btn.clicked.connect(functools.partial(self._revertoepn, tagid)) _btn.clicked.connect(functools.partial(self._revertoepn, tagid))
_btn.customContextMenuRequested.connect( _btn.customContextMenuRequested.connect(
functools.partial(self.tagbuttonmenu, tagid) functools.partial(self.tagbuttonmenu, tagid)
) )
return shrinkableitem(p, _btn, opened) return shrinkableitem(p, _btn, opened), _btn
def _revertoepn(self, tagid): def _revertoepn(self, tagid):
item = savegametaged[calculatetagidx(tagid)] item = savegametaged[calculatetagidx(tagid)]
@ -1019,11 +1025,13 @@ class dialog_savedgame_v3(QWidget):
self.reallist[self.reftagid].pop(idx2) self.reallist[self.reftagid].pop(idx2)
clickitem.clearfocus() clickitem.clearfocus()
group0 = self.stack.w(calculatetagidx(self.reftagid)) group0 = self.stack.w(calculatetagidx(self.reftagid))
group0.button().setnum(len(self.reallist[self.reftagid]))
group0.popw(idx2) group0.popw(idx2)
try: try:
group0.w(idx2).click() group0.w(idx2).click()
except: except:
group0.w(idx2 - 1).click() group0.w(idx2 - 1).click()
except: except:
print_exc() print_exc()
@ -1038,6 +1046,9 @@ class dialog_savedgame_v3(QWidget):
self.reallist[self.reftagid].pop(idx) self.reallist[self.reftagid].pop(idx)
self.reallist[self.reftagid].insert(0, uid) self.reallist[self.reftagid].insert(0, uid)
self.stack.w(calculatetagidx(self.reftagid)).torank1(idx) 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): def clicked3_batch(self):
addgamebatch(self.addgame, getreflist(self.reftagid)) addgamebatch(self.addgame, getreflist(self.reftagid))

View File

@ -590,8 +590,35 @@ class delayloadvbox(QWidget):
return len(self.internal_widgets) 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): class shrinkableitem(QWidget):
def __init__(self, p, shrinker: QPushButton, opened): def __init__(self, p, shrinker: shownumQPushButton, opened):
super().__init__(p) super().__init__(p)
self.lay = QVBoxLayout() self.lay = QVBoxLayout()
# self.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Fixed) # self.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Fixed)
@ -647,6 +674,9 @@ class shrinkableitem(QWidget):
def len(self): def len(self):
return self.items.len() return self.items.len()
def button(self):
return self.btn
class stackedlist(ScrollArea): class stackedlist(ScrollArea):
bgclicked = pyqtSignal() bgclicked = pyqtSignal()

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 5) set(VERSION_MAJOR 5)
set(VERSION_MINOR 34) set(VERSION_MINOR 34)
set(VERSION_PATCH 6) set(VERSION_PATCH 7)
add_library(pch pch.cpp) add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h) target_precompile_headers(pch PUBLIC pch.h)