Skip to content

Commit 0433908

Browse files
committed
refactor: remove QPushButtonWrapper
1 parent 9e04922 commit 0433908

4 files changed

Lines changed: 23 additions & 49 deletions

File tree

src/tagstudio/qt/mixed/migration_modal.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
QLabel,
1717
QMessageBox,
1818
QProgressDialog,
19+
QPushButton,
1920
QSizePolicy,
2021
QVBoxLayout,
2122
QWidget,
@@ -47,7 +48,6 @@
4748
from tagstudio.qt.utils.custom_runnable import CustomRunnable
4849
from tagstudio.qt.utils.function_iterator import FunctionIterator
4950
from tagstudio.qt.views.paged_body_wrapper import PagedBodyWrapper
50-
from tagstudio.qt.views.qbutton_wrapper import QPushButtonWrapper
5151
from tagstudio.qt.views.stylesheets.stylesheets import header
5252

5353
logger = structlog.get_logger(__name__)
@@ -99,8 +99,8 @@ def init_page_info(self) -> None:
9999
body_wrapper.layout().addWidget(body_label)
100100
body_wrapper.layout().setContentsMargins(0, 36, 0, 0)
101101

102-
cancel_button = QPushButtonWrapper(Translations["generic.cancel"])
103-
next_button = QPushButtonWrapper(Translations["generic.continue"])
102+
cancel_button = QPushButton(Translations["generic.cancel"])
103+
next_button = QPushButton(Translations["generic.continue"])
104104
cancel_button.clicked.connect(self.migration_cancelled.emit)
105105

106106
self.stack.append(
@@ -289,14 +289,12 @@ def init_page_convert(self) -> None:
289289
self.body_wrapper_01.layout().addWidget(desc_label)
290290
self.body_wrapper_01.layout().setSpacing(12)
291291

292-
back_button = QPushButtonWrapper(Translations["generic.navigation.back"])
293-
start_button = QPushButtonWrapper(Translations["json_migration.start_and_preview"])
292+
back_button = QPushButton(Translations["generic.navigation.back"])
293+
start_button = QPushButton(Translations["json_migration.start_and_preview"])
294294
start_button.setMinimumWidth(120)
295295
start_button.clicked.connect(self.migrate)
296296
start_button.clicked.connect(lambda: start_button.setDisabled(True))
297-
finish_button: QPushButtonWrapper = QPushButtonWrapper(
298-
Translations["json_migration.finish_migration"]
299-
)
297+
finish_button = QPushButton(Translations["json_migration.finish_migration"])
300298
finish_button.setMinimumWidth(120)
301299
finish_button.setDisabled(True)
302300
finish_button.clicked.connect(self.finish_migration)
@@ -381,7 +379,7 @@ def migration_progress(self, skip_ui: bool = False):
381379
pb.setMinimum(1),
382380
pb.setValue(1),
383381
# Enable the finish button
384-
cast(QPushButtonWrapper, self.stack[1].buttons[4]).setDisabled(False),
382+
cast(QPushButton, self.stack[1].buttons[4]).setDisabled(False),
385383
)
386384
)
387385
QThreadPool.globalInstance().start(r)

src/tagstudio/qt/mixed/pagination.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
"""A pagination widget created for TagStudio."""
66

77
from typing import cast, override
8+
from warnings import catch_warnings
89

910
from PIL import Image, ImageQt
1011
from PySide6.QtCore import QSize, Signal
1112
from PySide6.QtGui import QIntValidator, QPixmap
12-
from PySide6.QtWidgets import QHBoxLayout, QLabel, QLineEdit, QSizePolicy, QWidget
13+
from PySide6.QtWidgets import QHBoxLayout, QLabel, QLineEdit, QPushButton, QSizePolicy, QWidget
1314

1415
from tagstudio.qt.helpers.color_overlay import auto_theme_overlay
1516
from tagstudio.qt.resource_manager import ResourceManager
16-
from tagstudio.qt.views.qbutton_wrapper import QPushButtonWrapper
1717

1818

1919
class Pagination(QWidget):
2020
"""Widget containing controls for navigating between pages of items."""
2121

2222
index = Signal(int)
2323

24-
def __init__(self, parent=None) -> None:
25-
super().__init__(parent)
24+
def __init__(self, parent: QWidget | None = None) -> None:
25+
super().__init__(parent=parent)
2626
self.rm = ResourceManager()
2727
self.page_count: int = 0
2828
self.current_page_index: int = 0
@@ -43,7 +43,7 @@ def __init__(self, parent=None) -> None:
4343
self.root_layout.setSpacing(3)
4444

4545
# [<] ----------------------------------
46-
self.prev_button = QPushButtonWrapper()
46+
self.prev_button = QPushButton()
4747
prev_icon: Image.Image = self.rm.bxs_left_arrow
4848
prev_icon = auto_theme_overlay(prev_icon, use_alpha=False)
4949
self.prev_button.setIcon(QPixmap.fromImage(ImageQt.ImageQt(prev_icon)))
@@ -52,7 +52,7 @@ def __init__(self, parent=None) -> None:
5252
self.prev_button.setMaximumSize(self.button_size)
5353

5454
# --- [1] ------------------------------
55-
self.start_button = QPushButtonWrapper()
55+
self.start_button = QPushButton()
5656
self.start_button.setMinimumSize(self.button_size)
5757
self.start_button.setMaximumSize(self.button_size)
5858

@@ -91,12 +91,12 @@ def __init__(self, parent=None) -> None:
9191
self.end_ellipses.setText(". . .")
9292

9393
# ----------------------------- [42] ---
94-
self.end_button = QPushButtonWrapper()
94+
self.end_button = QPushButton()
9595
self.end_button.setMinimumSize(self.button_size)
9696
self.end_button.setMaximumSize(self.button_size)
9797

9898
# ---------------------------------- [>]
99-
self.next_button = QPushButtonWrapper()
99+
self.next_button = QPushButton()
100100
next_icon: Image.Image = self.rm.bxs_right_arrow
101101
next_icon = auto_theme_overlay(next_icon, use_alpha=False)
102102
self.next_button.setIcon(QPixmap.fromImage(ImageQt.ImageQt(next_icon)))
@@ -223,7 +223,7 @@ def update_buttons(self, page_count: int, index: int, emit: bool = True):
223223
)
224224
self._assign_click(
225225
cast(
226-
QPushButtonWrapper,
226+
QPushButton,
227227
self.start_buffer_layout.itemAt(i - start_offset).widget(),
228228
),
229229
i,
@@ -240,7 +240,7 @@ def update_buttons(self, page_count: int, index: int, emit: bool = True):
240240
self.end_buffer_layout.itemAt(i - end_offset).widget().setText(str(i + 1)) # pyright: ignore[reportAttributeAccessIssue]
241241
self._assign_click(
242242
cast(
243-
QPushButtonWrapper,
243+
QPushButton,
244244
self.end_buffer_layout.itemAt(i - end_offset).widget(),
245245
),
246246
i,
@@ -268,21 +268,20 @@ def update_buttons(self, page_count: int, index: int, emit: bool = True):
268268
def _goto_page(self, index: int):
269269
self.update_buttons(self.page_count, index)
270270

271-
def _assign_click(self, button: QPushButtonWrapper, index):
272-
if button.is_connected:
271+
def _assign_click(self, button: QPushButton, index: int):
272+
with catch_warnings(record=True):
273273
button.clicked.disconnect()
274274
button.clicked.connect(lambda checked=False, i=index: self._goto_page(i))
275-
button.is_connected = True
276275

277276
def _populate_buffer_buttons(self):
278277
for _ in range(max(self.buffer_page_count * 2, 5)):
279-
button = QPushButtonWrapper()
278+
button = QPushButton()
280279
button.setMinimumSize(self.button_size)
281280
button.setMaximumSize(self.button_size)
282281
button.setHidden(True)
283282
self.start_buffer_layout.addWidget(button)
284283

285-
end_button = QPushButtonWrapper()
284+
end_button = QPushButton()
286285
end_button.setMinimumSize(self.button_size)
287286
end_button.setMaximumSize(self.button_size)
288287
end_button.setHidden(True)

src/tagstudio/qt/views/qbutton_wrapper.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/tagstudio/qt/views/thumb_button.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
QPalette,
1717
QPen,
1818
)
19-
from PySide6.QtWidgets import QWidget
19+
from PySide6.QtWidgets import QPushButton, QWidget
2020

21-
from tagstudio.qt.views.qbutton_wrapper import QPushButtonWrapper
2221

23-
24-
class ThumbButton(QPushButtonWrapper):
22+
class ThumbButton(QPushButton):
2523
def __init__(self, parent: QWidget, thumb_size: tuple[int, int]) -> None:
2624
super().__init__(parent)
2725
self.thumb_size: tuple[int, int] = thumb_size

0 commit comments

Comments
 (0)