From a7388a70bed983865797ac22b98eb34673406c19 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 11 Mar 2022 12:53:23 +0100 Subject: [PATCH] Use standard buttons where possible Standard buttons are ordered in the right way and sometimes have an icon. Bug: https://matrix.to/#/%23nheko%3Anheko.im/%2476PZ2m6YftX8mqGIe9ettKbh_-pEYeVRQSJBfwFzWi0?via=pixie.town&via=matrix.org&via=matrix.flexinos.tech&via=half-shot.uk --- .../qml/dialogs/ImagePackEditorDialog.qml | 19 +++++-------------- resources/qml/dialogs/JoinRoomDialog.qml | 6 +----- src/dialogs/CreateRoom.cpp | 16 +++++----------- src/dialogs/CreateRoom.h | 3 ++- 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/resources/qml/dialogs/ImagePackEditorDialog.qml b/resources/qml/dialogs/ImagePackEditorDialog.qml index 49c9ea07..891d9c3d 100644 --- a/resources/qml/dialogs/ImagePackEditorDialog.qml +++ b/resources/qml/dialogs/ImagePackEditorDialog.qml @@ -329,21 +329,12 @@ ApplicationWindow { footer: DialogButtonBox { id: buttons - Button { - text: qsTr("Cancel") - DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole - onClicked: win.close() + standardButtons: DialogButtonBox.Save | DialogButtonBox.Cancel + onAccepted: { + imagePack.save(); + win.close(); } - - Button { - text: qsTr("Save") - DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole - onClicked: { - imagePack.save(); - win.close(); - } - } - + onRejected: win.close() } } diff --git a/resources/qml/dialogs/JoinRoomDialog.qml b/resources/qml/dialogs/JoinRoomDialog.qml index e49f538d..263481aa 100644 --- a/resources/qml/dialogs/JoinRoomDialog.qml +++ b/resources/qml/dialogs/JoinRoomDialog.qml @@ -54,6 +54,7 @@ ApplicationWindow { footer: DialogButtonBox { id: dbb + standardButtons: DialogButtonBox.Cancel onAccepted: { Nheko.joinRoom(input.text); joinRoomRoot.close(); @@ -68,11 +69,6 @@ ApplicationWindow { DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole } - Button { - text: "Cancel" - DialogButtonBox.buttonRole: DialogButtonBox.RejectRole - } - } } diff --git a/src/dialogs/CreateRoom.cpp b/src/dialogs/CreateRoom.cpp index 038289e8..e828ae7c 100644 --- a/src/dialogs/CreateRoom.cpp +++ b/src/dialogs/CreateRoom.cpp @@ -38,16 +38,10 @@ CreateRoom::CreateRoom(QWidget *parent) conf::modals::WIDGET_MARGIN, conf::modals::WIDGET_MARGIN); - auto buttonLayout = new QHBoxLayout(); - buttonLayout->setSpacing(15); - + buttonBox_ = new QDialogButtonBox(QDialogButtonBox::Cancel); confirmBtn_ = new QPushButton(tr("Create room"), this); confirmBtn_->setDefault(true); - cancelBtn_ = new QPushButton(tr("Cancel"), this); - - buttonLayout->addStretch(1); - buttonLayout->addWidget(cancelBtn_); - buttonLayout->addWidget(confirmBtn_); + buttonBox_->addButton(confirmBtn_, QDialogButtonBox::AcceptRole); QFont font; font.setPointSizeF(font.pointSizeF() * 1.3); @@ -101,9 +95,9 @@ CreateRoom::CreateRoom(QWidget *parent) layout->addLayout(visibilityLayout); layout->addLayout(presetLayout); layout->addLayout(directLayout); - layout->addLayout(buttonLayout); + layout->addWidget(buttonBox_); - connect(confirmBtn_, &QPushButton::clicked, this, [this]() { + connect(buttonBox_, &QDialogButtonBox::accepted, this, [this]() { request_.name = nameInput_->text().toStdString(); request_.topic = topicInput_->text().toStdString(); request_.room_alias_name = aliasInput_->text().toStdString(); @@ -114,7 +108,7 @@ CreateRoom::CreateRoom(QWidget *parent) emit close(); }); - connect(cancelBtn_, &QPushButton::clicked, this, [this]() { + connect(buttonBox_, &QDialogButtonBox::rejected, this, [this]() { clearFields(); emit close(); }); diff --git a/src/dialogs/CreateRoom.h b/src/dialogs/CreateRoom.h index 54936dfe..c395941d 100644 --- a/src/dialogs/CreateRoom.h +++ b/src/dialogs/CreateRoom.h @@ -5,6 +5,7 @@ #pragma once +#include #include #include @@ -37,7 +38,7 @@ private: Toggle *directToggle_; QPushButton *confirmBtn_; - QPushButton *cancelBtn_; + QDialogButtonBox *buttonBox_; TextField *nameInput_; TextField *topicInput_;