Qt: use Qt standard button layout in settings_dialog

This commit is contained in:
Megamouse 2019-10-04 14:52:46 +02:00
parent 91f53a366b
commit f97ed7738d
2 changed files with 11 additions and 40 deletions

View File

@ -1,5 +1,6 @@
#include <QVBoxLayout>
#include <QButtonGroup>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QMessageBox>
#include <QInputDialog>
@ -37,7 +38,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
: QDialog(parent), xgui_settings(guiSettings), xemu_settings(emuSettings), ui(new Ui::settings_dialog), m_tab_Index(tabIndex)
{
ui->setupUi(this);
ui->cancelButton->setFocus();
ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus();
ui->tab_widget_settings->setUsesScrollButtons(false);
ui->tab_widget_settings->tabBar()->setObjectName("tab_bar_settings");
@ -117,7 +118,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
m_discord_state = xgui_settings->GetValue(gui::m_discordState).toString();
// Various connects
connect(ui->okButton, &QAbstractButton::clicked, [=, use_discord_old = m_use_discord, discord_state_old = m_discord_state]
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=, use_discord_old = m_use_discord, discord_state_old = m_discord_state]
{
std::set<std::string> selectedlle;
for (int i = 0; i<ui->lleList->count(); ++i)
@ -157,11 +158,11 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
#endif
});
connect(ui->cancelButton, &QAbstractButton::clicked, this, &QWidget::close);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
connect(ui->tab_widget_settings, &QTabWidget::currentChanged, [=]()
{
ui->cancelButton->setFocus();
ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus();
});
// _____ _____ _ _ _______ _
@ -1392,7 +1393,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
}
};
connect(ui->okButton, &QAbstractButton::clicked, [=]()
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=]()
{
ApplyGuiOptions();
});

View File

@ -2829,42 +2829,12 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="buttonLayout">
<item alignment="Qt::AlignLeft">
<widget class="QPushButton" name="okButton">
<property name="text">
<string>Save</string>
</property>
<property name="autoDefault">
<bool>false</bool>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Close</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources>