mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Merge pull request #986 from tastytea/use-standard-buttons
Use standard buttons where possible
This commit is contained in:
commit
8309ad2f83
4 changed files with 13 additions and 31 deletions
|
@ -329,21 +329,12 @@ ApplicationWindow {
|
||||||
footer: DialogButtonBox {
|
footer: DialogButtonBox {
|
||||||
id: buttons
|
id: buttons
|
||||||
|
|
||||||
Button {
|
standardButtons: DialogButtonBox.Save | DialogButtonBox.Cancel
|
||||||
text: qsTr("Cancel")
|
onAccepted: {
|
||||||
DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole
|
|
||||||
onClicked: win.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
text: qsTr("Save")
|
|
||||||
DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole
|
|
||||||
onClicked: {
|
|
||||||
imagePack.save();
|
imagePack.save();
|
||||||
win.close();
|
win.close();
|
||||||
}
|
}
|
||||||
}
|
onRejected: win.close()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ ApplicationWindow {
|
||||||
footer: DialogButtonBox {
|
footer: DialogButtonBox {
|
||||||
id: dbb
|
id: dbb
|
||||||
|
|
||||||
|
standardButtons: DialogButtonBox.Cancel
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
Nheko.joinRoom(input.text);
|
Nheko.joinRoom(input.text);
|
||||||
joinRoomRoot.close();
|
joinRoomRoot.close();
|
||||||
|
@ -68,11 +69,6 @@ ApplicationWindow {
|
||||||
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
|
||||||
text: "Cancel"
|
|
||||||
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,16 +38,10 @@ CreateRoom::CreateRoom(QWidget *parent)
|
||||||
conf::modals::WIDGET_MARGIN,
|
conf::modals::WIDGET_MARGIN,
|
||||||
conf::modals::WIDGET_MARGIN);
|
conf::modals::WIDGET_MARGIN);
|
||||||
|
|
||||||
auto buttonLayout = new QHBoxLayout();
|
buttonBox_ = new QDialogButtonBox(QDialogButtonBox::Cancel);
|
||||||
buttonLayout->setSpacing(15);
|
|
||||||
|
|
||||||
confirmBtn_ = new QPushButton(tr("Create room"), this);
|
confirmBtn_ = new QPushButton(tr("Create room"), this);
|
||||||
confirmBtn_->setDefault(true);
|
confirmBtn_->setDefault(true);
|
||||||
cancelBtn_ = new QPushButton(tr("Cancel"), this);
|
buttonBox_->addButton(confirmBtn_, QDialogButtonBox::AcceptRole);
|
||||||
|
|
||||||
buttonLayout->addStretch(1);
|
|
||||||
buttonLayout->addWidget(cancelBtn_);
|
|
||||||
buttonLayout->addWidget(confirmBtn_);
|
|
||||||
|
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPointSizeF(font.pointSizeF() * 1.3);
|
font.setPointSizeF(font.pointSizeF() * 1.3);
|
||||||
|
@ -101,9 +95,9 @@ CreateRoom::CreateRoom(QWidget *parent)
|
||||||
layout->addLayout(visibilityLayout);
|
layout->addLayout(visibilityLayout);
|
||||||
layout->addLayout(presetLayout);
|
layout->addLayout(presetLayout);
|
||||||
layout->addLayout(directLayout);
|
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_.name = nameInput_->text().toStdString();
|
||||||
request_.topic = topicInput_->text().toStdString();
|
request_.topic = topicInput_->text().toStdString();
|
||||||
request_.room_alias_name = aliasInput_->text().toStdString();
|
request_.room_alias_name = aliasInput_->text().toStdString();
|
||||||
|
@ -114,7 +108,7 @@ CreateRoom::CreateRoom(QWidget *parent)
|
||||||
emit close();
|
emit close();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(cancelBtn_, &QPushButton::clicked, this, [this]() {
|
connect(buttonBox_, &QDialogButtonBox::rejected, this, [this]() {
|
||||||
clearFields();
|
clearFields();
|
||||||
emit close();
|
emit close();
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
#include <mtx/requests.hpp>
|
#include <mtx/requests.hpp>
|
||||||
|
@ -37,7 +38,7 @@ private:
|
||||||
Toggle *directToggle_;
|
Toggle *directToggle_;
|
||||||
|
|
||||||
QPushButton *confirmBtn_;
|
QPushButton *confirmBtn_;
|
||||||
QPushButton *cancelBtn_;
|
QDialogButtonBox *buttonBox_;
|
||||||
|
|
||||||
TextField *nameInput_;
|
TextField *nameInput_;
|
||||||
TextField *topicInput_;
|
TextField *topicInput_;
|
||||||
|
|
Loading…
Reference in a new issue