mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-11 17:28:36 +12:00
Qt: use button box for most buttons
This commit is contained in:
parent
be8980fc23
commit
ea4cc0b395
3 changed files with 57 additions and 64 deletions
|
@ -170,11 +170,27 @@ pad_settings_dialog::pad_settings_dialog(QWidget *parent, const GameInfo *game)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cancel Button
|
ui->buttonBox->button(QDialogButtonBox::Reset)->setText(tr("Filter Noise"));
|
||||||
connect(ui->b_cancel, &QAbstractButton::clicked, this, &pad_settings_dialog::CancelExit);
|
|
||||||
|
|
||||||
// Save Button
|
connect(ui->buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* button)
|
||||||
connect(ui->b_ok, &QAbstractButton::clicked, this, &pad_settings_dialog::SaveExit);
|
{
|
||||||
|
if (button == ui->buttonBox->button(QDialogButtonBox::Save))
|
||||||
|
{
|
||||||
|
SaveExit();
|
||||||
|
}
|
||||||
|
else if (button == ui->buttonBox->button(QDialogButtonBox::Cancel))
|
||||||
|
{
|
||||||
|
CancelExit();
|
||||||
|
}
|
||||||
|
else if (button == ui->buttonBox->button(QDialogButtonBox::Reset))
|
||||||
|
{
|
||||||
|
OnPadButtonClicked(button_ids::id_blacklist);
|
||||||
|
}
|
||||||
|
else if (button == ui->buttonBox->button(QDialogButtonBox::RestoreDefaults))
|
||||||
|
{
|
||||||
|
OnPadButtonClicked(button_ids::id_reset_parameters);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Refresh Button
|
// Refresh Button
|
||||||
connect(ui->b_refresh, &QPushButton::clicked, this, &pad_settings_dialog::RefreshInputTypes);
|
connect(ui->b_refresh, &QPushButton::clicked, this, &pad_settings_dialog::RefreshInputTypes);
|
||||||
|
@ -260,12 +276,8 @@ void pad_settings_dialog::InitButtons()
|
||||||
insertButton(button_ids::id_pad_rstick_right, ui->b_rstick_right);
|
insertButton(button_ids::id_pad_rstick_right, ui->b_rstick_right);
|
||||||
insertButton(button_ids::id_pad_rstick_up, ui->b_rstick_up);
|
insertButton(button_ids::id_pad_rstick_up, ui->b_rstick_up);
|
||||||
|
|
||||||
m_padButtons->addButton(ui->b_reset, button_ids::id_reset_parameters);
|
|
||||||
m_padButtons->addButton(ui->b_blacklist, button_ids::id_blacklist);
|
|
||||||
m_padButtons->addButton(ui->b_refresh, button_ids::id_refresh);
|
m_padButtons->addButton(ui->b_refresh, button_ids::id_refresh);
|
||||||
m_padButtons->addButton(ui->b_addProfile, button_ids::id_add_profile);
|
m_padButtons->addButton(ui->b_addProfile, button_ids::id_add_profile);
|
||||||
m_padButtons->addButton(ui->b_ok, button_ids::id_ok);
|
|
||||||
m_padButtons->addButton(ui->b_cancel, button_ids::id_cancel);
|
|
||||||
|
|
||||||
connect(m_padButtons, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &pad_settings_dialog::OnPadButtonClicked);
|
connect(m_padButtons, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &pad_settings_dialog::OnPadButtonClicked);
|
||||||
|
|
||||||
|
@ -560,6 +572,11 @@ void pad_settings_dialog::ReactivateButtons()
|
||||||
but->setFocusPolicy(Qt::StrongFocus);
|
but->setFocusPolicy(Qt::StrongFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto but : ui->buttonBox->buttons())
|
||||||
|
{
|
||||||
|
but->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
}
|
||||||
|
|
||||||
ui->tabWidget->setFocusPolicy(Qt::TabFocus);
|
ui->tabWidget->setFocusPolicy(Qt::TabFocus);
|
||||||
|
|
||||||
ui->chooseProfile->setFocusPolicy(Qt::WheelFocus);
|
ui->chooseProfile->setFocusPolicy(Qt::WheelFocus);
|
||||||
|
@ -894,7 +911,7 @@ void pad_settings_dialog::SwitchButtons(bool is_enabled)
|
||||||
ui->gb_mouse_accel->setEnabled(is_enabled && m_handler->m_type == pad_handler::keyboard);
|
ui->gb_mouse_accel->setEnabled(is_enabled && m_handler->m_type == pad_handler::keyboard);
|
||||||
ui->gb_mouse_dz->setEnabled(is_enabled && m_handler->m_type == pad_handler::keyboard);
|
ui->gb_mouse_dz->setEnabled(is_enabled && m_handler->m_type == pad_handler::keyboard);
|
||||||
ui->gb_stick_lerp->setEnabled(is_enabled && m_handler->m_type == pad_handler::keyboard);
|
ui->gb_stick_lerp->setEnabled(is_enabled && m_handler->m_type == pad_handler::keyboard);
|
||||||
ui->b_blacklist->setEnabled(is_enabled && m_handler->m_type != pad_handler::keyboard);
|
ui->buttonBox->button(QDialogButtonBox::Reset)->setEnabled(is_enabled && m_handler->m_type != pad_handler::keyboard);
|
||||||
|
|
||||||
for (int i = button_ids::id_pad_begin + 1; i < button_ids::id_pad_end; i++)
|
for (int i = button_ids::id_pad_begin + 1; i < button_ids::id_pad_end; i++)
|
||||||
{
|
{
|
||||||
|
@ -931,6 +948,11 @@ void pad_settings_dialog::OnPadButtonClicked(int id)
|
||||||
but->setFocusPolicy(Qt::ClickFocus);
|
but->setFocusPolicy(Qt::ClickFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto but : ui->buttonBox->buttons())
|
||||||
|
{
|
||||||
|
but->setFocusPolicy(Qt::ClickFocus);
|
||||||
|
}
|
||||||
|
|
||||||
ui->tabWidget->setFocusPolicy(Qt::ClickFocus);
|
ui->tabWidget->setFocusPolicy(Qt::ClickFocus);
|
||||||
|
|
||||||
ui->chooseProfile->setFocusPolicy(Qt::ClickFocus);
|
ui->chooseProfile->setFocusPolicy(Qt::ClickFocus);
|
||||||
|
@ -1184,7 +1206,7 @@ void pad_settings_dialog::ChangeInputType()
|
||||||
ui->b_addProfile->setEnabled(config_enabled);
|
ui->b_addProfile->setEnabled(config_enabled);
|
||||||
ui->chooseProfile->setEnabled(config_enabled);
|
ui->chooseProfile->setEnabled(config_enabled);
|
||||||
|
|
||||||
ui->b_reset->setEnabled(!is_ldd_pad);
|
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(!is_ldd_pad);
|
||||||
ui->chooseHandler->setEnabled(!is_ldd_pad);
|
ui->chooseHandler->setEnabled(!is_ldd_pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1464,10 +1486,18 @@ bool pad_settings_dialog::GetIsLddPad(int index) const
|
||||||
|
|
||||||
void pad_settings_dialog::ResizeDialog()
|
void pad_settings_dialog::ResizeDialog()
|
||||||
{
|
{
|
||||||
|
// Widgets
|
||||||
|
const QSize buttons_size(0, ui->buttonBox->sizeHint().height());
|
||||||
|
const QSize tabwidget_size = ui->tabWidget->sizeHint();
|
||||||
|
|
||||||
|
// Spacing
|
||||||
|
const int nr_of_spacings = 1; // Number of widgets - 1
|
||||||
|
const QSize spacing_size(0, layout()->spacing() * nr_of_spacings);
|
||||||
|
|
||||||
|
// Margins
|
||||||
const auto margins = layout()->contentsMargins();
|
const auto margins = layout()->contentsMargins();
|
||||||
const QSize tab_size = ui->tabWidget->sizeHint();
|
|
||||||
const QSize margin_size(margins.left() + margins.right(), margins.top() + margins.bottom());
|
const QSize margin_size(margins.left() + margins.right(), margins.top() + margins.bottom());
|
||||||
|
|
||||||
resize(tab_size + margin_size);
|
resize(tabwidget_size + buttons_size + margin_size + spacing_size);
|
||||||
setMaximumSize(size());
|
setMaximumSize(size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,6 @@ private Q_SLOTS:
|
||||||
void HandleDeviceClassChange(int index);
|
void HandleDeviceClassChange(int index);
|
||||||
/** Save the Pad Configuration to the current Pad Handler Config File */
|
/** Save the Pad Configuration to the current Pad Handler Config File */
|
||||||
void SaveProfile();
|
void SaveProfile();
|
||||||
void SaveExit();
|
|
||||||
void CancelExit();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::pad_settings_dialog *ui;
|
Ui::pad_settings_dialog *ui;
|
||||||
|
@ -151,6 +149,9 @@ private:
|
||||||
// Input timer. Its Callback handles the input
|
// Input timer. Its Callback handles the input
|
||||||
QTimer m_timer_input;
|
QTimer m_timer_input;
|
||||||
|
|
||||||
|
void SaveExit();
|
||||||
|
void CancelExit();
|
||||||
|
|
||||||
// Set vibrate data while keeping the current color
|
// Set vibrate data while keeping the current color
|
||||||
void SetPadData(u32 large_motor, u32 small_motor);
|
void SetPadData(u32 large_motor, u32 small_motor);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>848</width>
|
<width>848</width>
|
||||||
<height>697</height>
|
<height>668</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
|
@ -980,30 +980,6 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="button_layout_left">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="b_ok">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="b_cancel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Close</string>
|
|
||||||
</property>
|
|
||||||
<property name="default">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -2089,7 +2065,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="right_stack">
|
<widget class="QStackedWidget" name="right_stack">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="stick_page">
|
<widget class="QWidget" name="stick_page">
|
||||||
<layout class="QVBoxLayout" name="stick_page_layout">
|
<layout class="QVBoxLayout" name="stick_page_layout">
|
||||||
|
@ -2370,39 +2346,25 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="button_layout_right" stretch="0,1">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<item>
|
<property name="standardButtons">
|
||||||
<widget class="QPushButton" name="b_blacklist">
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Save</set>
|
||||||
<property name="text">
|
|
||||||
<string>Filter Noise</string>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="centerButtons">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="b_reset">
|
|
||||||
<property name="text">
|
|
||||||
<string>Restore Defaults</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue