Qt: fix initial pad settings dialog size and position

This commit is contained in:
Megamouse 2021-11-11 21:59:43 +01:00
parent 48ad7ca3a0
commit 8b3ed7b599
3 changed files with 19 additions and 11 deletions

View File

@ -232,13 +232,13 @@ bool debugger_frame::eventFilter(QObject* object, QEvent* event)
return false;
}
void debugger_frame::closeEvent(QCloseEvent *event)
void debugger_frame::closeEvent(QCloseEvent* event)
{
QDockWidget::closeEvent(event);
Q_EMIT DebugFrameClosed();
}
void debugger_frame::showEvent(QShowEvent * event)
void debugger_frame::showEvent(QShowEvent* event)
{
// resize splitter widgets
if (!m_splitter->restoreState(m_gui_settings->GetValue(gui::d_splitterState).toByteArray()))
@ -251,7 +251,7 @@ void debugger_frame::showEvent(QShowEvent * event)
QDockWidget::showEvent(event);
}
void debugger_frame::hideEvent(QHideEvent * event)
void debugger_frame::hideEvent(QHideEvent* event)
{
// save splitter state or it will resume its initial state on next show
m_gui_settings->SetValue(gui::d_splitterState, m_splitter->saveState());

View File

@ -196,17 +196,9 @@ pad_settings_dialog::pad_settings_dialog(std::shared_ptr<gui_settings> gui_setti
ui->left_stack->setCurrentIndex(0);
ui->right_stack->setCurrentIndex(0);
RepaintPreviewLabel(ui->preview_stick_left, ui->slider_stick_left->value(), ui->slider_stick_left->size().width(), 0, 0, 0, 0);
RepaintPreviewLabel(ui->preview_stick_right, ui->slider_stick_right->value(), ui->slider_stick_right->size().width(), 0, 0, 0, 0);
show();
// Set up first tab
OnTabChanged(0);
ChangeProfile(ui->chooseProfile->currentText());
// Resize in order to fit into our scroll area
ResizeDialog();
}
pad_settings_dialog::~pad_settings_dialog()
@ -221,6 +213,20 @@ pad_settings_dialog::~pad_settings_dialog()
pad::set_enabled(true);
}
void pad_settings_dialog::showEvent(QShowEvent* event)
{
RepaintPreviewLabel(ui->preview_stick_left, ui->slider_stick_left->value(), ui->slider_stick_left->size().width(), 0, 0, 0, 0);
RepaintPreviewLabel(ui->preview_stick_right, ui->slider_stick_right->value(), ui->slider_stick_right->size().width(), 0, 0, 0, 0);
// Resize in order to fit into our scroll area
ResizeDialog();
// Restrict our inner layout size. This is necessary because redrawing things will slow down the dialog otherwise.
ui->mainLayout->setSizeConstraint(QLayout::SizeConstraint::SetFixedSize);
QDialog::showEvent(event);
}
void pad_settings_dialog::InitButtons()
{
m_pad_buttons = new QButtonGroup(this);

View File

@ -204,6 +204,8 @@ private:
void SubscribeTooltips();
protected:
void showEvent(QShowEvent* event) override;
/** Handle keyboard handler input */
void keyPressEvent(QKeyEvent *keyEvent) override;
void mouseReleaseEvent(QMouseEvent *event) override;