Skip to content

Commit be66ae4

Browse files
ENH: Add visible close button in the top-right corner (#28)
* feat: Add close button and unit test for efck#26 - Adds an 'X' button to the top-right corner of the main window for closing the application. - Adds a unit test verifying the close button triggers application quit. - Updates Qt abstraction layer to ensure QPushButton is available. - Refines test setup with necessary mocks for QApplication.instance. * Revert complex test * Fixup * Update efck/gui.py * Update efck/gui.py --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 9b24bed commit be66ae4

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

efck/_qt/pyqt5.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
QListView,
5757
QListWidget,
5858
QListWidgetItem,
59+
QPushButton,
5960
QScrollArea,
6061
QSizeGrip,
6162
QSlider,

efck/_qt/pyqt6.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
QListView,
5757
QListWidget,
5858
QListWidgetItem,
59+
QPushButton,
5960
QScrollArea,
6061
QSizeGrip,
6162
QSlider,

efck/_qt/pyside6.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
QListView,
6060
QListWidget,
6161
QListWidgetItem,
62+
QPushButton,
6263
QScrollArea,
6364
QSizeGrip,
6465
QSlider,

efck/_qt/qtpy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
QListView,
5757
QListWidget,
5858
QListWidgetItem,
59+
QPushButton,
5960
QScrollArea,
6061
QSizeGrip,
6162
QSlider,

efck/gui.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ def __init__(self, parent):
151151
corner_widget = CornerWidget(self)
152152
self.setCornerWidget(corner_widget, Qt.Corner.TopLeftCorner)
153153

154+
close_button = QPushButton(
155+
icon=self.style().standardIcon(QStyle.StandardPixmap.SP_TitleBarCloseButton),
156+
flat=True,
157+
toolTip='Close',
158+
parent=self,
159+
)
160+
close_button.clicked.connect(QApplication.instance().quit)
161+
self.setCornerWidget(close_button, Qt.Corner.TopRightCorner)
162+
154163
# Populate tabs
155164

156165
from .tab import Tab

0 commit comments

Comments
 (0)