44
55import structlog
66from PySide6 .QtCore import Qt
7- from PySide6 .QtWidgets import QHBoxLayout , QLabel , QPushButton , QVBoxLayout , QWidget
7+ from PySide6 .QtWidgets import QDialogButtonBox , QLabel , QVBoxLayout
88
99from tagstudio .i18n .translations import Translations
1010from tagstudio .qt .controllers .modal_content import ModalContent
@@ -28,28 +28,26 @@ def __init__(
2828 self .content_widget = content_widget
2929 self .setContentsMargins (PAD , PAD if inline_title else PAD * 2 , PAD , PAD )
3030
31- self .button_container = QWidget ()
32- self .button_layout = QHBoxLayout (self .button_container )
33- self .button_layout .setContentsMargins (PAD , PAD , PAD , PAD )
34- self .button_layout .addStretch (1 )
31+ self .button_box = QDialogButtonBox ()
32+ self .button_box .setContentsMargins (PAD , PAD , PAD , PAD )
3533
36- # [Done]
37- # - OR -
38- # [Cancel] [Save]
3934 if not is_savable :
40- done_button = QPushButton (Translations ["generic.done" ])
35+ done_button = self .button_box .addButton (
36+ Translations ["generic.done" ], QDialogButtonBox .ButtonRole .AcceptRole
37+ )
4138 done_button .setAutoDefault (True )
4239 self .content_widget .done_button = done_button
43- self .button_layout .addWidget (done_button )
4440 else :
45- cancel_button = QPushButton (Translations ["generic.cancel" ])
41+ cancel_button = self .button_box .addButton (
42+ Translations ["generic.cancel" ], QDialogButtonBox .ButtonRole .RejectRole
43+ )
4644 self .content_widget .cancel_button = cancel_button
47- self .button_layout .addWidget (cancel_button )
4845
49- save_button = QPushButton (Translations ["generic.save" ])
46+ save_button = self .button_box .addButton (
47+ Translations ["generic.save" ], QDialogButtonBox .ButtonRole .AcceptRole
48+ )
5049 save_button .setAutoDefault (True )
5150 self .content_widget .save_button = save_button
52- self .button_layout .addWidget (save_button )
5351
5452 if inline_title :
5553 self .title_label = QLabel ()
@@ -61,4 +59,4 @@ def __init__(
6159
6260 self .addWidget (content_widget )
6361 self .setStretch (1 , 2 )
64- self .addWidget (self .button_container )
62+ self .addWidget (self .button_box )
0 commit comments