diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index 4eef445b..4fbfc72a 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -563,7 +563,11 @@ class dialog_setting_game(QDialog): getcolorbutton( "", "", - lambda: os.startfile('https://vndb.org/v{}'.format(savehook_new_data[exepath]["vid"])), + lambda: os.startfile( + "https://vndb.org/v{}".format( + savehook_new_data[exepath]["vid"] + ) + ), icon="fa.chrome", constcolor="#FF69B4", ), @@ -1482,9 +1486,10 @@ class dialog_savedgame_new(saveposwindow): def tagschanged(self, tags): self.currtags = tags newtags = tags - print(tags) + ItemWidget.clearfocus() self.formLayout.removeWidget(self.flow) + self.flow.deleteLater() self.idxsave.clear() self.flow = ScrollFlow() self.flow.bgclicked.connect(ItemWidget.clearfocus) @@ -1522,7 +1527,8 @@ class dialog_savedgame_new(saveposwindow): if notshow: continue self.newline(k) - QApplication.processEvents() + if len(self.idxsave) < 10 or len(self.idxsave) % 10 == 0: + QApplication.processEvents() def showmenu(self, p): menu = QMenu(self) diff --git a/LunaTranslator/LunaTranslator/gui/specialwidget.py b/LunaTranslator/LunaTranslator/gui/specialwidget.py index 58278ddc..c7ce1a5a 100644 --- a/LunaTranslator/LunaTranslator/gui/specialwidget.py +++ b/LunaTranslator/LunaTranslator/gui/specialwidget.py @@ -8,7 +8,7 @@ from PyQt5.QtWidgets import ( from PyQt5.QtCore import QPoint, QRect, QSize, Qt, pyqtSignal from PyQt5.QtWidgets import QLayout from traceback import print_exc - +from myutils.wrapper import trypass class chartwidget(QWidget): def __init__(self) -> None: @@ -128,11 +128,11 @@ class ScrollFlow(QWidget): def __init__(self): super(ScrollFlow, self).__init__() - class _QListWidget(QListWidget): + class qw(QWidget): def mousePressEvent(_, _2) -> None: self.bgclicked.emit() - self.listWidget = _QListWidget(self) + self.listWidget = qw(self) # self.listWidget.setFixedWidth(600) self.l = FlowLayout() @@ -142,20 +142,20 @@ class ScrollFlow(QWidget): self.qscrollarea = QScrollArea(self) self.qscrollarea.setWidgetResizable(True) self.qscrollarea.setWidget(self.listWidget) - + @trypass def addwidget(self, wid): self.l.addWidget(wid) - + @trypass def insertwidget(self, idx, wid): self.l.insertWidget(idx, wid) - + @trypass def removeidx(self, index): _ = self.l.takeAt(index) _.widget().hide() - + @trypass def setfocus(self, idx): self.widget(idx).setFocus() - + @trypass def widget(self, idx): idx = min(idx, len(self.l._item_list) - 1) idx = max(idx, 0) diff --git a/LunaTranslator/LunaTranslator/myutils/wrapper.py b/LunaTranslator/LunaTranslator/myutils/wrapper.py index 824c2d5e..961e23ae 100644 --- a/LunaTranslator/LunaTranslator/myutils/wrapper.py +++ b/LunaTranslator/LunaTranslator/myutils/wrapper.py @@ -85,6 +85,16 @@ def threader(func): return _wrapper +def trypass(func): + def _wrapper(*args, **kwargs): + try: + return func(*args, **kwargs) + except: + pass + + return _wrapper + + def timer(func): def _wrapper(*args, **kwargs): t = time.time()