mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-26 23:24:13 +08:00
.
This commit is contained in:
parent
a9cfd873aa
commit
e6839de4e3
@ -23,6 +23,7 @@ from gui.usefulwidget import (
|
||||
getboxlayout,
|
||||
MySwitch,
|
||||
Prompt_dialog,
|
||||
IconButton,
|
||||
getsimplecombobox,
|
||||
)
|
||||
from gui.dialog_savedgame_common import (
|
||||
@ -48,6 +49,7 @@ from gui.dialog_savedgame_common import (
|
||||
class dialog_savedgame_integrated(saveposwindow):
|
||||
|
||||
def selectlayout(self, type):
|
||||
self.syssettingbtn.setVisible(type != 2)
|
||||
try:
|
||||
globalconfig["gamemanager_integrated_internal_layout"] = type
|
||||
klass = [
|
||||
@ -83,6 +85,7 @@ class dialog_savedgame_integrated(saveposwindow):
|
||||
[self.layout1btn, self.layout2btn, self.layout3btn][
|
||||
(type + 2) % 3
|
||||
].setEnabled(True)
|
||||
self.__internal = _
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
@ -99,7 +102,7 @@ class dialog_savedgame_integrated(saveposwindow):
|
||||
w, self.internallayout = getboxlayout(
|
||||
[], margin0=True, makewidget=True, both=True
|
||||
)
|
||||
|
||||
self.__internal = None
|
||||
self.internallayout.addWidget(QWidget())
|
||||
self.setCentralWidget(w)
|
||||
self.layout1btn = MySwitch(self, icon="fa.th")
|
||||
@ -108,22 +111,41 @@ class dialog_savedgame_integrated(saveposwindow):
|
||||
self.layout1btn.clicked.connect(functools.partial(self.selectlayout, 0))
|
||||
self.layout2btn.clicked.connect(functools.partial(self.selectlayout, 1))
|
||||
self.layout3btn.clicked.connect(functools.partial(self.selectlayout, 2))
|
||||
self.layout1btn.setFixedSize(QSize(20, 20))
|
||||
self.layout2btn.setFixedSize(QSize(20, 20))
|
||||
self.layout3btn.setFixedSize(QSize(20, 20))
|
||||
self.layout1btn.setFixedSize(QSize(20, 25))
|
||||
self.layout2btn.setFixedSize(QSize(20, 25))
|
||||
self.layout3btn.setFixedSize(QSize(20, 25))
|
||||
self.syssettingbtn = IconButton(icon="fa.gear", parent=self)
|
||||
self.syssettingbtn.setFixedSize(QSize(25, 25))
|
||||
self.syssettingbtn.clicked.connect(self.syssetting)
|
||||
self.show()
|
||||
self.selectlayout(globalconfig["gamemanager_integrated_internal_layout"])
|
||||
|
||||
def syssetting(self):
|
||||
dialog_syssetting(
|
||||
self.__internal,
|
||||
type_={0: 1, 1: 2}[globalconfig["gamemanager_integrated_internal_layout"]],
|
||||
)
|
||||
|
||||
def resizeEvent(self, e: QResizeEvent):
|
||||
self.layout1btn.move(e.size().width() - self.layout1btn.width(), 0)
|
||||
self.layout1btn.move(e.size().width() - self.layout1btn.width() - 5, 0)
|
||||
self.layout2btn.move(
|
||||
e.size().width() - self.layout2btn.width() - self.layout1btn.width(), 0
|
||||
e.size().width() - self.layout2btn.width() - self.layout1btn.width() - 5, 0
|
||||
)
|
||||
self.layout3btn.move(
|
||||
e.size().width()
|
||||
- self.layout3btn.width()
|
||||
- self.layout2btn.width()
|
||||
- self.layout1btn.width(),
|
||||
- self.layout1btn.width()
|
||||
- 5,
|
||||
0,
|
||||
)
|
||||
self.syssettingbtn.move(
|
||||
e.size().width()
|
||||
- self.syssettingbtn.width()
|
||||
- self.layout3btn.width()
|
||||
- self.layout2btn.width()
|
||||
- self.layout1btn.width()
|
||||
- 5,
|
||||
0,
|
||||
)
|
||||
|
||||
@ -188,7 +210,13 @@ class dialog_savedgame_new(QWidget):
|
||||
self.flow.deleteLater()
|
||||
self.flow = lazyscrollflow()
|
||||
self.flow.bgclicked.connect(ItemWidget.clearfocus)
|
||||
self.formLayout.insertWidget(self.formLayout.count() - 1, self.flow)
|
||||
self.flow.setsize(
|
||||
QSize(
|
||||
globalconfig["dialog_savegame_layout"]["itemw"],
|
||||
globalconfig["dialog_savegame_layout"]["itemh"],
|
||||
)
|
||||
)
|
||||
self.formLayout.insertWidget(self.formLayout.count(), self.flow)
|
||||
idx = 0
|
||||
for k in self.reflist:
|
||||
if newtags != self.currtags:
|
||||
@ -242,13 +270,11 @@ class dialog_savedgame_new(QWidget):
|
||||
gamesetting = LAction(("游戏设置"))
|
||||
addgame = LAction(("添加游戏"))
|
||||
batchadd = LAction(("批量添加"))
|
||||
othersetting = LAction(("其他设置"))
|
||||
|
||||
if self.currentfocusuid:
|
||||
exists = os.path.exists(get_launchpath(self.currentfocusuid))
|
||||
if exists:
|
||||
menu.addAction(startgame)
|
||||
if exists:
|
||||
menu.addAction(opendir)
|
||||
menu.addAction(gamesetting)
|
||||
menu.addAction(delgame)
|
||||
@ -264,7 +290,6 @@ class dialog_savedgame_new(QWidget):
|
||||
menu.addAction(addgame)
|
||||
menu.addAction(batchadd)
|
||||
menu.addSeparator()
|
||||
menu.addAction(othersetting)
|
||||
action = menu.exec(self.mapToGlobal(p))
|
||||
if action == startgame:
|
||||
startgamecheck(self, getreflist(self.reftagid), self.currentfocusuid)
|
||||
@ -280,8 +305,6 @@ class dialog_savedgame_new(QWidget):
|
||||
self.clicked3()
|
||||
elif action == batchadd:
|
||||
self.clicked3_batch()
|
||||
elif action == othersetting:
|
||||
dialog_syssetting(self)
|
||||
|
||||
elif action == editname or action == addlist:
|
||||
_dia = Prompt_dialog(
|
||||
@ -351,6 +374,19 @@ class dialog_savedgame_new(QWidget):
|
||||
),
|
||||
)
|
||||
|
||||
def callchange(self):
|
||||
self.flow.setsize(
|
||||
QSize(
|
||||
globalconfig["dialog_savegame_layout"]["itemw"],
|
||||
globalconfig["dialog_savegame_layout"]["itemh"],
|
||||
)
|
||||
)
|
||||
self.flow.resizeandshow()
|
||||
for _ in self.flow.widgets:
|
||||
if not isinstance(_, ItemWidget):
|
||||
continue
|
||||
_.others()
|
||||
|
||||
def setstyle(self):
|
||||
key = "savegame_textfont1"
|
||||
fontstring = globalconfig.get(key, "")
|
||||
@ -416,7 +452,7 @@ class dialog_savedgame_new(QWidget):
|
||||
self.currtags = tuple()
|
||||
self.tagswidget.tagschanged.connect(self.tagschanged)
|
||||
_ = QLabel()
|
||||
_.setFixedWidth(60)
|
||||
_.setFixedWidth(80)
|
||||
layout.addWidget(self.tagswidget)
|
||||
layout.addWidget(_)
|
||||
formLayout.addLayout(layout)
|
||||
@ -425,29 +461,8 @@ class dialog_savedgame_new(QWidget):
|
||||
self.customContextMenuRequested.connect(self.showmenu)
|
||||
formLayout.addWidget(self.flow)
|
||||
self.formLayout = formLayout
|
||||
buttonlayout = QHBoxLayout()
|
||||
self.buttonlayout = buttonlayout
|
||||
self.savebutton = []
|
||||
self.simplebutton(
|
||||
"开始游戏",
|
||||
True,
|
||||
lambda: startgamecheck(
|
||||
self, getreflist(self.reftagid), self.currentfocusuid
|
||||
),
|
||||
True,
|
||||
)
|
||||
self.simplebutton("游戏设置", True, self.showsettingdialog, False)
|
||||
self.simplebutton("删除游戏", True, self.clicked2, False)
|
||||
self.simplebutton("打开目录", True, self.clicked4, True)
|
||||
|
||||
self.simplebutton("添加到列表", True, self.addtolist, False)
|
||||
# if globalconfig["startgamenototop"]:
|
||||
self.simplebutton("左移", True, functools.partial(self.moverank, -1), False)
|
||||
self.simplebutton("右移", True, functools.partial(self.moverank, 1), False)
|
||||
self.simplebutton("添加游戏", False, self.clicked3, 1)
|
||||
self.simplebutton("批量添加", False, self.clicked3_batch, 1)
|
||||
self.simplebutton("其他设置", False, lambda: dialog_syssetting(self), False)
|
||||
formLayout.addLayout(buttonlayout)
|
||||
self.idxsave = []
|
||||
self.setLayout(formLayout)
|
||||
self.activategamenum = 1
|
||||
@ -484,6 +499,17 @@ class dialog_savedgame_new(QWidget):
|
||||
idx = getreflist(uid).index(gameuid)
|
||||
getreflist(uid).insert(0, getreflist(uid).pop(idx))
|
||||
|
||||
def keyPressEvent(self, e: QKeyEvent):
|
||||
if e.key() == Qt.Key.Key_Return:
|
||||
startgamecheck(self, getreflist(self.reftagid), self.currentfocusuid)
|
||||
elif e.key() == Qt.Key.Key_Delete:
|
||||
self.clicked2()
|
||||
elif e.key() == Qt.Key.Key_Left:
|
||||
self.moverank(-1)
|
||||
elif e.key() == Qt.Key.Key_Right:
|
||||
self.moverank(1)
|
||||
super().keyPressEvent(e)
|
||||
|
||||
def moverank(self, dx):
|
||||
game = self.currentfocusuid
|
||||
|
||||
@ -503,16 +529,6 @@ class dialog_savedgame_new(QWidget):
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
def simplebutton(self, text, save, callback, exists):
|
||||
button5 = LPushButton(text)
|
||||
button5.setMinimumWidth(10)
|
||||
if save:
|
||||
self.savebutton.append((button5, exists))
|
||||
button5.clicked.connect(callback)
|
||||
button5.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
self.buttonlayout.addWidget(button5)
|
||||
return button5
|
||||
|
||||
def itemfocuschanged(self, b, k):
|
||||
|
||||
if b:
|
||||
@ -542,16 +558,9 @@ class dialog_savedgame_new(QWidget):
|
||||
|
||||
def newline(self, k, first=False):
|
||||
|
||||
itemw = globalconfig["dialog_savegame_layout"]["itemw"]
|
||||
itemh = globalconfig["dialog_savegame_layout"]["itemh"]
|
||||
|
||||
if first:
|
||||
self.idxsave.insert(0, k)
|
||||
self.flow.insertwidget(
|
||||
0, (functools.partial(self.getagameitem, k, True), QSize(itemw, itemh))
|
||||
)
|
||||
self.flow.insertwidget(0, functools.partial(self.getagameitem, k, True))
|
||||
else:
|
||||
self.idxsave.append(k)
|
||||
self.flow.addwidget(
|
||||
(functools.partial(self.getagameitem, k, False), QSize(itemw, itemh))
|
||||
)
|
||||
self.flow.addwidget(functools.partial(self.getagameitem, k, False))
|
||||
|
@ -76,26 +76,26 @@ class ItemWidget(QWidget):
|
||||
def resizeEvent(self, a0: QResizeEvent) -> None:
|
||||
self.bottommask.resize(a0.size())
|
||||
self.maskshowfileexists.resize(a0.size())
|
||||
self.resizex()
|
||||
|
||||
def resizex(self):
|
||||
margin = globalconfig["dialog_savegame_layout"]["margin"]
|
||||
textH = (
|
||||
globalconfig["dialog_savegame_layout"]["textH"]
|
||||
if globalconfig["showgametitle"]
|
||||
else 0
|
||||
)
|
||||
self._w.setFixedHeight(self.height() - textH)
|
||||
self.wrap.setContentsMargins(margin, margin, margin, margin)
|
||||
|
||||
def others(self):
|
||||
self._lb.setText(self.file if globalconfig["showgametitle"] else "")
|
||||
self.resizex()
|
||||
self._img.switch()
|
||||
|
||||
def __init__(self, gameuid, pixmap, file) -> None:
|
||||
super().__init__()
|
||||
self.itemw = globalconfig["dialog_savegame_layout"]["itemw"]
|
||||
self.itemh = globalconfig["dialog_savegame_layout"]["itemh"]
|
||||
# self.imgw = globalconfig["dialog_savegame_layout"]["imgw"]
|
||||
# self.imgh = globalconfig["dialog_savegame_layout"]["imgh"]
|
||||
# margin = (
|
||||
# self.itemw - self.imgw
|
||||
# ) // 2 # globalconfig['dialog_savegame_layout']['margin']
|
||||
margin = globalconfig["dialog_savegame_layout"]["margin"]
|
||||
if globalconfig["showgametitle"]:
|
||||
textH = globalconfig["dialog_savegame_layout"]["textH"]
|
||||
else:
|
||||
textH = 0
|
||||
self.imgw = self.itemw - 2 * margin
|
||||
self.imgh = self.itemh - textH - 2 * margin
|
||||
#
|
||||
self.setFixedSize(QSize(self.itemw, self.itemh))
|
||||
# self.setFocusPolicy(Qt.StrongFocus)
|
||||
self.file = file
|
||||
self.maskshowfileexists = QLabel(self)
|
||||
exists = os.path.exists(get_launchpath(gameuid))
|
||||
self.maskshowfileexists.setObjectName("savegame_exists" + str(exists))
|
||||
@ -104,19 +104,18 @@ class ItemWidget(QWidget):
|
||||
self.bottommask.setObjectName("savegame_onselectcolor1")
|
||||
layout = QVBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
self._img = IMGWidget(self.imgw, self.imgh, pixmap)
|
||||
self._img = IMGWidget(pixmap)
|
||||
_w = QWidget()
|
||||
_w.setStyleSheet("background-color: rgba(255,255,255, 0);")
|
||||
wrap = QVBoxLayout()
|
||||
_w.setLayout(wrap)
|
||||
_w.setFixedHeight(self.imgh + 2 * margin)
|
||||
wrap.setContentsMargins(margin, margin, margin, margin)
|
||||
self._w = _w
|
||||
wrap.addWidget(self._img)
|
||||
self.wrap = wrap
|
||||
layout.addWidget(_w)
|
||||
layout.setSpacing(0)
|
||||
self._lb = QLabel()
|
||||
if globalconfig["showgametitle"]:
|
||||
self._lb.setText(file)
|
||||
self._lb.setText(file if globalconfig["showgametitle"] else "")
|
||||
self._lb.setWordWrap(True)
|
||||
self._lb.setObjectName("savegame_textfont1")
|
||||
self._lb.setAlignment(Qt.AlignmentFlag.AlignHCenter)
|
||||
@ -156,10 +155,12 @@ class IMGWidget(QLabel):
|
||||
elif globalconfig["imagewrapmode"] == 3:
|
||||
return size
|
||||
|
||||
def setimg(self, pixmap):
|
||||
if type(pixmap) != QPixmap:
|
||||
pixmap = pixmap()
|
||||
|
||||
def setimg(self, pixmap: QPixmap):
|
||||
if not (self.height() and self.width()):
|
||||
return
|
||||
if self.__last == (self.size(), globalconfig["imagewrapmode"]):
|
||||
return
|
||||
self.__last = (self.size(), globalconfig["imagewrapmode"])
|
||||
rate = self.devicePixelRatioF()
|
||||
newpixmap = QPixmap(self.size() * rate)
|
||||
newpixmap.setDevicePixelRatio(rate)
|
||||
@ -169,7 +170,6 @@ class IMGWidget(QLabel):
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
painter.drawPixmap(self.getrect(pixmap.size()), pixmap)
|
||||
painter.end()
|
||||
|
||||
self.setPixmap(newpixmap)
|
||||
|
||||
def getrect(self, size):
|
||||
@ -180,11 +180,20 @@ class IMGWidget(QLabel):
|
||||
rect.setSize(size)
|
||||
return rect
|
||||
|
||||
def __init__(self, w, h, pixmap) -> None:
|
||||
def resizeEvent(self, a0):
|
||||
self.setimg(self._pixmap)
|
||||
return super().resizeEvent(a0)
|
||||
|
||||
def __init__(self, pixmap) -> None:
|
||||
super().__init__()
|
||||
self.setFixedSize(QSize(w, h))
|
||||
self.setScaledContents(True)
|
||||
self.setimg(pixmap)
|
||||
if type(pixmap) != QPixmap:
|
||||
pixmap = pixmap()
|
||||
self._pixmap = pixmap
|
||||
self.__last = None
|
||||
|
||||
def switch(self):
|
||||
self.setimg(self._pixmap)
|
||||
|
||||
|
||||
class ClickableLabel(QLabel):
|
||||
@ -592,6 +601,9 @@ class dialog_syssetting(LDialog):
|
||||
|
||||
self.parent().setstyle()
|
||||
|
||||
def closeEvent(self, e):
|
||||
self.parent().callchange()
|
||||
|
||||
def __init__(self, parent, type_=1) -> None:
|
||||
super().__init__(parent, Qt.WindowType.WindowCloseButtonHint)
|
||||
self.setWindowTitle("其他设置")
|
||||
@ -607,26 +619,11 @@ class dialog_syssetting(LDialog):
|
||||
getsimpleswitch(globalconfig, "startgamenototop"),
|
||||
)
|
||||
|
||||
if type_ == 1:
|
||||
formLayout.addRow(
|
||||
"显示标题",
|
||||
getsimpleswitch(globalconfig, "showgametitle"),
|
||||
)
|
||||
formLayout.addRow(
|
||||
"缩放",
|
||||
getsimplecombobox(
|
||||
["填充", "适应", "拉伸", "居中"],
|
||||
globalconfig,
|
||||
"imagewrapmode",
|
||||
),
|
||||
)
|
||||
formLayout.addRow(SplitLine())
|
||||
if type_ == 1:
|
||||
for key, name in [
|
||||
("itemw", "宽度"),
|
||||
("itemh", "高度"),
|
||||
# ("imgw", "图片宽度"),
|
||||
# ("imgh", "图片高度"),
|
||||
("margin", "边距"),
|
||||
("textH", "文字区高度"),
|
||||
]:
|
||||
@ -643,10 +640,21 @@ class dialog_syssetting(LDialog):
|
||||
isfontselector=True,
|
||||
),
|
||||
)
|
||||
formLayout.addRow(
|
||||
"显示标题",
|
||||
getsimpleswitch(globalconfig, "showgametitle"),
|
||||
)
|
||||
formLayout.addRow(
|
||||
"缩放",
|
||||
getsimplecombobox(
|
||||
["填充", "适应", "拉伸", "居中"],
|
||||
globalconfig,
|
||||
"imagewrapmode",
|
||||
),
|
||||
)
|
||||
|
||||
elif type_ == 2:
|
||||
for key, name in [
|
||||
("listitemwidth", "宽度"),
|
||||
("listitemheight", "高度"),
|
||||
]:
|
||||
formLayout.addRow(
|
||||
|
@ -1,7 +1,7 @@
|
||||
from qtsymbols import *
|
||||
import os, functools, uuid, threading, shutil, time
|
||||
from traceback import print_exc
|
||||
import gobject
|
||||
import gobject, base64
|
||||
from myutils.config import (
|
||||
savehook_new_list,
|
||||
savehook_new_data,
|
||||
@ -34,7 +34,6 @@ from gui.dialog_savedgame_common import (
|
||||
opendirforgameuid,
|
||||
getcachedimage,
|
||||
getpixfunction,
|
||||
dialog_syssetting,
|
||||
addgamesingle,
|
||||
addgamebatch,
|
||||
addgamebatch_x,
|
||||
@ -84,6 +83,11 @@ class clickitem(QWidget):
|
||||
self.bottommask.resize(a0.size())
|
||||
self.maskshowfileexists.resize(a0.size())
|
||||
self.bottomline.resize(a0.size())
|
||||
size = globalconfig["dialog_savegame_layout"]["listitemheight"]
|
||||
margin = min(3, int(size / 15))
|
||||
self.lay1.setContentsMargins(margin, margin, margin, margin)
|
||||
self._.setFixedSize(QSize(size - 2 * margin, size - 2 * margin))
|
||||
self._2.setFixedHeight(size)
|
||||
|
||||
def __init__(self, uid):
|
||||
super().__init__()
|
||||
@ -91,10 +95,8 @@ class clickitem(QWidget):
|
||||
self.uid = uid
|
||||
self.lay = QHBoxLayout()
|
||||
self.lay.setSpacing(0)
|
||||
size = globalconfig["dialog_savegame_layout"]["listitemheight"]
|
||||
margin = min(3, int(size / 15))
|
||||
lay1 = QHBoxLayout()
|
||||
lay1.setContentsMargins(margin, margin, margin, margin)
|
||||
self.lay1 = lay1
|
||||
self.lay.setContentsMargins(0, 0, 0, 0)
|
||||
self.maskshowfileexists = QLabel(self)
|
||||
exists = os.path.exists(get_launchpath(uid))
|
||||
@ -105,9 +107,8 @@ class clickitem(QWidget):
|
||||
_ = QLabel(self)
|
||||
_.setStyleSheet("""background-color: rgba(255,255,255, 0);""")
|
||||
self.bottomline = _
|
||||
|
||||
_ = QLabel()
|
||||
_.setFixedSize(QSize(size - 2 * margin, size - 2 * margin))
|
||||
self._ = _
|
||||
_.setScaledContents(True)
|
||||
_.setStyleSheet("background-color: rgba(255,255,255, 0);")
|
||||
icon = getpixfunction(uid, small=True, iconfirst=True)
|
||||
@ -117,7 +118,7 @@ class clickitem(QWidget):
|
||||
self.lay.addLayout(lay1)
|
||||
_ = QLabel(savehook_new_data[uid]["title"])
|
||||
_.setWordWrap(True)
|
||||
_.setFixedHeight(size)
|
||||
self._2 = _
|
||||
_.setObjectName("savegame_textfont2")
|
||||
self.lay.addWidget(_)
|
||||
self.setLayout(self.lay)
|
||||
@ -190,6 +191,7 @@ class ImageDelegate(QStyledItemDelegate):
|
||||
|
||||
|
||||
class MyQListWidget(QListWidget):
|
||||
iscleared = pyqtSignal(bool)
|
||||
|
||||
def sethor(self, hor):
|
||||
if hor:
|
||||
@ -211,7 +213,11 @@ class MyQListWidget(QListWidget):
|
||||
self.loadTimer = QTimer(interval=25, timeout=self.loadImage)
|
||||
self.loadTimer.start()
|
||||
|
||||
def islg1(self):
|
||||
self.iscleared.emit(self.model().rowCount() > 1)
|
||||
|
||||
def loadImage(self):
|
||||
self.islg1()
|
||||
try:
|
||||
start = self.indexAt(self.viewport().rect().topLeft()).row()
|
||||
end = self.indexAt(self.viewport().rect().bottomRight()).row()
|
||||
@ -313,7 +319,8 @@ class hoverbtn(LLabel):
|
||||
clicked = pyqtSignal()
|
||||
|
||||
def mousePressEvent(self, a0: QMouseEvent) -> None:
|
||||
self.clicked.emit()
|
||||
if a0.button() == Qt.MouseButton.LeftButton:
|
||||
self.clicked.emit()
|
||||
return super().mousePressEvent(a0)
|
||||
|
||||
def __init__(self, *argc):
|
||||
@ -345,6 +352,10 @@ class viewpixmap_x(QWidget):
|
||||
def sizeHint(self):
|
||||
return QSize(400, 400)
|
||||
|
||||
def setnextable(self, b):
|
||||
self.leftclick.setVisible(b)
|
||||
self.rightclick.setVisible(b)
|
||||
|
||||
def __init__(self, parent=None) -> None:
|
||||
super().__init__(parent)
|
||||
self.pixmapviewer = pixmapviewer(self)
|
||||
@ -552,6 +563,7 @@ class pixwrapper(QWidget):
|
||||
self.vlayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.pixview = viewpixmap_x(self)
|
||||
self.pixview.startgame.connect(self.startgame)
|
||||
self.previewimages.list.iscleared.connect(self.pixview.setnextable)
|
||||
self.spliter = QSplitter(self)
|
||||
self.vlayout.addWidget(self.spliter)
|
||||
self.setrank(rank)
|
||||
@ -643,6 +655,7 @@ class pixwrapper(QWidget):
|
||||
self.k = k
|
||||
pixmaps = savehook_new_data[k]["imagepath_all"].copy()
|
||||
self.previewimages.setpixmaps(pixmaps, savehook_new_data[k]["currentvisimage"])
|
||||
self.pixview.bottombtn.setVisible(os.path.exists(get_launchpath(k)))
|
||||
|
||||
|
||||
class dialog_savedgame_v3(QWidget):
|
||||
@ -655,7 +668,7 @@ class dialog_savedgame_v3(QWidget):
|
||||
self.righttop.removeTab(1)
|
||||
tabadd_lazy(
|
||||
self.righttop,
|
||||
savehook_new_data[k]["title"],
|
||||
"设置",
|
||||
lambda v: v.addWidget(dialog_setting_game_internal(self, k)),
|
||||
)
|
||||
self.righttop.setCurrentIndex(currvis)
|
||||
@ -670,13 +683,6 @@ class dialog_savedgame_v3(QWidget):
|
||||
else:
|
||||
self.currentfocusuid = None
|
||||
|
||||
for _btn, exists in self.savebutton:
|
||||
_able1 = b and (
|
||||
(not exists)
|
||||
or (self.currentfocusuid)
|
||||
and (os.path.exists(get_launchpath(self.currentfocusuid)))
|
||||
)
|
||||
_btn.setEnabled(_able1)
|
||||
if self.currentfocusuid:
|
||||
self.viewitem(k)
|
||||
|
||||
@ -700,7 +706,6 @@ class dialog_savedgame_v3(QWidget):
|
||||
self.reftagid,
|
||||
getreflist(self.reftagid),
|
||||
),
|
||||
1 + globalconfig["dialog_savegame_layout"]["listitemheight"],
|
||||
)
|
||||
self.stack.directshow()
|
||||
|
||||
@ -794,6 +799,12 @@ class dialog_savedgame_v3(QWidget):
|
||||
def directshow(self):
|
||||
self.stack.directshow()
|
||||
|
||||
def callchange(self):
|
||||
self.stack.setheight(
|
||||
globalconfig["dialog_savegame_layout"]["listitemheight"] + 1
|
||||
)
|
||||
self.stack.directshow_1()
|
||||
|
||||
def setstyle(self):
|
||||
key = "savegame_textfont2"
|
||||
fontstring = globalconfig.get(key, "")
|
||||
@ -832,17 +843,20 @@ class dialog_savedgame_v3(QWidget):
|
||||
self.reftagid = None
|
||||
self.reallist = {}
|
||||
self.stack = stackedlist()
|
||||
self.stack.setheight(
|
||||
globalconfig["dialog_savegame_layout"]["listitemheight"] + 1
|
||||
)
|
||||
self.stack.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||
self.stack.customContextMenuRequested.connect(self.stack_showmenu)
|
||||
self.stack.setFixedWidth(
|
||||
globalconfig["dialog_savegame_layout"]["listitemwidth"]
|
||||
)
|
||||
|
||||
self.stack.bgclicked.connect(clickitem.clearfocus)
|
||||
self.setstyle()
|
||||
lay = QHBoxLayout()
|
||||
self.setLayout(lay)
|
||||
lay.addWidget(self.stack)
|
||||
lay.setSpacing(0)
|
||||
spl = QSplitter()
|
||||
_l = QHBoxLayout()
|
||||
_l.addWidget(spl)
|
||||
self.setLayout(_l)
|
||||
|
||||
spl.addWidget(self.stack)
|
||||
self.righttop = makesubtab_lazy()
|
||||
self.pixview = pixwrapper()
|
||||
self.pixview.startgame.connect(
|
||||
@ -855,31 +869,15 @@ class dialog_savedgame_v3(QWidget):
|
||||
rightlay.setContentsMargins(0, 0, 0, 0)
|
||||
_w.setLayout(rightlay)
|
||||
self.righttop.addTab(_w, "画廊")
|
||||
lay.addWidget(self.righttop)
|
||||
rightlay.addWidget(self.pixview)
|
||||
self.buttonlayout = QHBoxLayout()
|
||||
self.savebutton = []
|
||||
rightlay.addLayout(self.buttonlayout)
|
||||
spl.addWidget(self.righttop)
|
||||
|
||||
def __(_):
|
||||
globalconfig["dialog_savegame_layout"]["listitemwidth_2"] = spl.sizes()
|
||||
|
||||
spl.setSizes(globalconfig["dialog_savegame_layout"]["listitemwidth_2"])
|
||||
spl.splitterMoved.connect(__)
|
||||
rightlay.addWidget(self.pixview)
|
||||
|
||||
self.simplebutton(
|
||||
"开始游戏",
|
||||
True,
|
||||
lambda: startgamecheck(
|
||||
self, getreflist(self.reftagid), self.currentfocusuid
|
||||
),
|
||||
True,
|
||||
)
|
||||
self.simplebutton("删除游戏", True, self.shanchuyouxi, False)
|
||||
self.simplebutton("打开目录", True, self.clicked4, True)
|
||||
self.simplebutton("添加到列表", True, self.addtolist, False)
|
||||
# if globalconfig["startgamenototop"]:
|
||||
self.simplebutton("上移", True, functools.partial(self.moverank, -1), False)
|
||||
self.simplebutton("下移", True, functools.partial(self.moverank, 1), False)
|
||||
self.simplebutton("添加游戏", False, self.clicked3, 1)
|
||||
self.simplebutton("批量添加", False, self.clicked3_batch, 1)
|
||||
self.simplebutton(
|
||||
"其他设置", False, lambda: dialog_syssetting(self, type_=2), False
|
||||
)
|
||||
isfirst = True
|
||||
for i, tag in enumerate(savegametaged):
|
||||
# None
|
||||
@ -913,7 +911,6 @@ class dialog_savedgame_v3(QWidget):
|
||||
group0.insertw(
|
||||
rowreal,
|
||||
functools.partial(self.delayitemcreater, k, vis, tagid, lst),
|
||||
1 + globalconfig["dialog_savegame_layout"]["listitemheight"],
|
||||
)
|
||||
|
||||
rowreal += 1
|
||||
@ -1083,16 +1080,6 @@ class dialog_savedgame_v3(QWidget):
|
||||
def clicked(self):
|
||||
startgamecheck(self, getreflist(self.reftagid), self.currentfocusuid)
|
||||
|
||||
def simplebutton(self, text, save, callback, exists):
|
||||
button5 = LPushButton(text)
|
||||
button5.setMinimumWidth(10)
|
||||
if save:
|
||||
self.savebutton.append((button5, exists))
|
||||
button5.clicked.connect(callback)
|
||||
button5.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
self.buttonlayout.addWidget(button5)
|
||||
return button5
|
||||
|
||||
def dragEnterEvent(self, event: QDragEnterEvent):
|
||||
if event.mimeData().hasUrls():
|
||||
event.accept()
|
||||
|
@ -120,14 +120,21 @@ class Setting(closeashidewindow):
|
||||
)
|
||||
self.setCentralWidget(self.tab_widget)
|
||||
do()
|
||||
width = 0
|
||||
fn = QFont()
|
||||
fn.setPointSizeF(globalconfig["settingfontsize"] + 4)
|
||||
fn.setFamily(globalconfig["settingfonttype"])
|
||||
fm = QFontMetrics(fn)
|
||||
for title in _TRL(self.tab_widget.titles):
|
||||
width = max(fm.size(0, title).width(), width)
|
||||
width += 50
|
||||
self.tab_widget.splitter.setStretchFactor(0, 0)
|
||||
self.tab_widget.splitter.setStretchFactor(1, 1)
|
||||
self.tab_widget.splitter.setSizes([width, self.tab_widget.width() - width])
|
||||
|
||||
if globalconfig.get("setting_split"):
|
||||
self.tab_widget.splitter.setSizes(globalconfig["setting_split"])
|
||||
else:
|
||||
width = 0
|
||||
fn = QFont()
|
||||
fn.setPointSizeF(globalconfig["settingfontsize"] + 4)
|
||||
fn.setFamily(globalconfig["settingfonttype"])
|
||||
fm = QFontMetrics(fn)
|
||||
for title in _TRL(self.tab_widget.titles):
|
||||
width = max(fm.size(0, title).width(), width)
|
||||
width += 50
|
||||
self.tab_widget.splitter.setSizes([width, self.tab_widget.width() - width])
|
||||
|
||||
def __(_):
|
||||
globalconfig["setting_split"] = self.tab_widget.splitter.sizes()
|
||||
|
||||
self.tab_widget.splitter.splitterMoved.connect(__)
|
||||
|
@ -147,6 +147,11 @@ class ScrollArea(QScrollArea):
|
||||
visible_rect = QRect(x, y, width, height)
|
||||
self.scrolled.emit(visible_rect)
|
||||
|
||||
def keyPressEvent(self, e: QKeyEvent):
|
||||
if e.key() == Qt.Key.Key_Left or e.key() == Qt.Key.Key_Right:
|
||||
return e.ignore()
|
||||
super().keyPressEvent(e)
|
||||
|
||||
|
||||
class ScrollFlow(QWidget):
|
||||
bgclicked = pyqtSignal()
|
||||
@ -345,10 +350,10 @@ class lazyscrollflow(ScrollArea):
|
||||
if not region.intersects(geo):
|
||||
continue
|
||||
|
||||
widfunc, _ = self.widgets[i]
|
||||
widfunc = self.widgets[i]
|
||||
if not widfunc:
|
||||
continue
|
||||
self.widgets[i] = (None, _)
|
||||
self.widgets[i] = None
|
||||
needdos.append((i, widfunc))
|
||||
for i, widfunc in needdos:
|
||||
try:
|
||||
@ -425,48 +430,58 @@ class lazyscrollflow(ScrollArea):
|
||||
else:
|
||||
return None
|
||||
|
||||
def setsize(self, size: QSize):
|
||||
self._size = size
|
||||
|
||||
def spacing(self):
|
||||
return self._spacing
|
||||
|
||||
def anylyze(self, effective_rect: QRect, space_x, N):
|
||||
x = effective_rect.x()
|
||||
for _ in range(N):
|
||||
next_x = x + self._size.width() + space_x
|
||||
if next_x > effective_rect.right():
|
||||
return x
|
||||
x = next_x
|
||||
return x
|
||||
|
||||
def fakeresize(self):
|
||||
if self.verticalScrollBar().isVisible():
|
||||
scrollw = self.verticalScrollBar().width()
|
||||
else:
|
||||
scrollw = 0
|
||||
with self.lock:
|
||||
# m = self.contentsMargins()
|
||||
rect = QRect()
|
||||
rect.setSize(self.size())
|
||||
effective_rect = rect.adjusted(
|
||||
self._margin, self._margin, -self._margin, -self._margin
|
||||
) # (+m.left(), +m.top(), -m.right(), -m.bottom())
|
||||
scrollw = (
|
||||
self.verticalScrollBar().width()
|
||||
if self.verticalScrollBar().isVisible()
|
||||
else 0
|
||||
)
|
||||
effective_rect = QRect(
|
||||
self._margin,
|
||||
self._margin,
|
||||
self.width() - 2 * self._margin - scrollw,
|
||||
self.height() - 2 * self._margin,
|
||||
)
|
||||
x = effective_rect.x()
|
||||
y = effective_rect.y()
|
||||
line_height = 0
|
||||
space_x = self.spacing()
|
||||
space_y = self.spacing()
|
||||
dx = (
|
||||
effective_rect.right()
|
||||
- self.anylyze(effective_rect, space_x, len(self.widgets))
|
||||
) // 2
|
||||
for i, wid in enumerate(self.widgets):
|
||||
|
||||
space_x = self.spacing()
|
||||
space_y = self.spacing()
|
||||
|
||||
if isinstance(wid, QWidget):
|
||||
sz = wid.size()
|
||||
resize = True
|
||||
else:
|
||||
_, sz = wid
|
||||
resize = False
|
||||
next_x = x + sz.width() + space_x
|
||||
if next_x > effective_rect.right() - scrollw and line_height > 0:
|
||||
next_x = x + self._size.width() + space_x
|
||||
if next_x > effective_rect.right() and i:
|
||||
x = effective_rect.x()
|
||||
y = y + line_height + space_y
|
||||
next_x = x + sz.width() + space_x
|
||||
line_height = 0
|
||||
y = y + self._size.height() + space_y
|
||||
next_x = x + self._size.width() + space_x
|
||||
if resize:
|
||||
wid.setGeometry(QRect(QPoint(x, y), sz))
|
||||
self.fakegeos[i] = QRect(QPoint(x, y), sz)
|
||||
wid.setGeometry(QRect(QPoint(x + dx, y), self._size))
|
||||
self.fakegeos[i] = QRect(QPoint(x + dx, y), self._size)
|
||||
x = next_x
|
||||
line_height = max(line_height, sz.height())
|
||||
|
||||
new_height = y + line_height - rect.y() + self._margin
|
||||
new_height = y + self._size.height() + self._margin
|
||||
self.internalwid.setFixedHeight(new_height)
|
||||
|
||||
|
||||
@ -481,9 +496,17 @@ def has_intersection(interval1, interval2):
|
||||
|
||||
|
||||
class delayloadvbox(QWidget):
|
||||
def __init__(self):
|
||||
|
||||
def setheight(self, h):
|
||||
self._h = h
|
||||
self.setFixedHeight(len(self.internal_widgets) * self._h)
|
||||
for _ in self.internal_widgets:
|
||||
if isinstance(_, QWidget):
|
||||
_.resize(_.width(), h)
|
||||
|
||||
def __init__(self, h=1):
|
||||
super().__init__()
|
||||
self.internal_itemH = []
|
||||
self._h = h
|
||||
self.internal_widgets = []
|
||||
self.lock = threading.Lock()
|
||||
self.nowvisregion = QRect()
|
||||
@ -505,9 +528,9 @@ class delayloadvbox(QWidget):
|
||||
ydiff = self.y()
|
||||
needdos = []
|
||||
with self.lock:
|
||||
for i, h in enumerate(self.internal_itemH):
|
||||
for i in range(len(self.internal_widgets)):
|
||||
ystart = ylastend
|
||||
yend = ystart + h
|
||||
yend = ystart + self._h
|
||||
ylastend = yend
|
||||
if isinstance(self.internal_widgets[i], QWidget):
|
||||
self.internal_widgets[i].move(0, ystart - ydiff)
|
||||
@ -519,7 +542,7 @@ class delayloadvbox(QWidget):
|
||||
if not widfunc:
|
||||
continue
|
||||
self.internal_widgets[i] = None
|
||||
needdos.append((i, widfunc, ystart - ydiff, h))
|
||||
needdos.append((i, widfunc, ystart - ydiff, self._h))
|
||||
|
||||
for i, widfunc, ystart, h in needdos:
|
||||
try:
|
||||
@ -541,7 +564,6 @@ class delayloadvbox(QWidget):
|
||||
def switchidx(self, idx1, idx2):
|
||||
with self.lock:
|
||||
self.internal_widgets.insert(idx2, self.internal_widgets.pop(idx1))
|
||||
self.internal_itemH.insert(idx2, self.internal_itemH.pop(idx1))
|
||||
self._dovisinternal(False, self.nowvisregion)
|
||||
|
||||
def popw(self, i):
|
||||
@ -552,8 +574,7 @@ class delayloadvbox(QWidget):
|
||||
w.setParent(None)
|
||||
w.deleteLater()
|
||||
self.internal_widgets.pop(i)
|
||||
self.internal_itemH.pop(i)
|
||||
self.setFixedHeight(sum(self.internal_itemH))
|
||||
self.setFixedHeight(len(self.internal_widgets) * self._h)
|
||||
# setFixedHeight会导致上面的闪烁
|
||||
self._dovisinternal(False, self.nowvisregion)
|
||||
|
||||
@ -562,18 +583,16 @@ class delayloadvbox(QWidget):
|
||||
return
|
||||
with self.lock:
|
||||
self.internal_widgets.insert(0, self.internal_widgets.pop(i))
|
||||
self.internal_itemH.insert(0, self.internal_itemH.pop(i))
|
||||
self._dovisinternal(False, self.nowvisregion)
|
||||
|
||||
def insertw(self, i, wf, height):
|
||||
def insertw(self, i, wf):
|
||||
refresh = True
|
||||
with self.lock:
|
||||
if i == -1:
|
||||
refresh = False
|
||||
i = self.len()
|
||||
self.internal_itemH.insert(i, height)
|
||||
self.internal_widgets.insert(i, wf)
|
||||
self.setFixedHeight(sum(self.internal_itemH))
|
||||
self.setFixedHeight(len(self.internal_widgets) * self._h)
|
||||
if refresh:
|
||||
self._dovisinternal(False, self.nowvisregion)
|
||||
|
||||
@ -639,6 +658,7 @@ class shrinkableitem(QWidget):
|
||||
self.items.setVisible(opened)
|
||||
shrinker.setChecked(opened)
|
||||
self._ref_p_stackedlist = p
|
||||
self._h = 1
|
||||
|
||||
def visheight(self):
|
||||
hh = self.btn.height()
|
||||
@ -666,8 +686,8 @@ class shrinkableitem(QWidget):
|
||||
def switchidx(self, idx1, idx2):
|
||||
self.items.switchidx(idx1, idx2)
|
||||
|
||||
def insertw(self, i, wf, height):
|
||||
self.items.insertw(i, wf, height)
|
||||
def insertw(self, i, wf):
|
||||
self.items.insertw(i, wf)
|
||||
|
||||
def torank1(self, i):
|
||||
self.items.torank1(i)
|
||||
@ -684,13 +704,24 @@ class shrinkableitem(QWidget):
|
||||
def button(self):
|
||||
return self.btn
|
||||
|
||||
def setheight(self, h):
|
||||
self.items.setheight(h)
|
||||
|
||||
|
||||
class stackedlist(ScrollArea):
|
||||
bgclicked = pyqtSignal()
|
||||
|
||||
def setheight(self, h):
|
||||
for i in range(self.len()):
|
||||
self.w(i).setheight(h)
|
||||
self._h = h
|
||||
|
||||
def mousePressEvent(self, _2) -> None:
|
||||
self.bgclicked.emit()
|
||||
|
||||
def directshow_1(self):
|
||||
self.doshowlazywidget(True, self.internal.visibleRegion().boundingRect())
|
||||
|
||||
def directshow(self):
|
||||
QApplication.processEvents()
|
||||
self.doshowlazywidget(True, self.internal.visibleRegion().boundingRect())
|
||||
@ -704,6 +735,7 @@ class stackedlist(ScrollArea):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._h = 1
|
||||
self.setStyleSheet(
|
||||
"""QWidget#shit{background-color:transparent;}QScrollArea{background-color:transparent;border:0px}"""
|
||||
)
|
||||
@ -739,6 +771,7 @@ class stackedlist(ScrollArea):
|
||||
region.setHeight(region.height() - self.w(i).visheight())
|
||||
|
||||
def insertw(self, i, w: shrinkableitem):
|
||||
w.setheight(self._h)
|
||||
self.lay.insertWidget(i, w)
|
||||
|
||||
def popw(self, i) -> shrinkableitem:
|
||||
|
@ -532,8 +532,10 @@
|
||||
"transparent": 25,
|
||||
"transparentselect": 25,
|
||||
"transparentnotexits": 25,
|
||||
"listitemheight": 40,
|
||||
"listitemwidth": 300
|
||||
"listitemwidth_2": [
|
||||
300,
|
||||
500
|
||||
]
|
||||
},
|
||||
"gamemanageruseversion": 0,
|
||||
"gamemanager_integrated_internal_layout": 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user