ui advanced settings show and hide is acceptable. qt size hint and
scaling ((((features)))) are dumb
This commit is contained in:
@@ -998,29 +998,20 @@ void MainWindow::on_actionErase_Device_triggered()
|
||||
|
||||
void MainWindow::on_checkBoxAdvancedMode_stateChanged(int state)
|
||||
{
|
||||
int heightShrinkSize = ui->groupBoxAdvanced->height() + ui->groupBoxAdvanced->parentWidget()->layout()->spacing();
|
||||
QSize cWidgetFinalSize(ui->centralWidget->width(), ui->centralWidget->height() - heightShrinkSize);
|
||||
QSize windowFinalSize(width(), height() - heightShrinkSize);
|
||||
|
||||
ui->groupBoxAdvanced->setVisible(state != 0);
|
||||
ui->centralWidget->updateGeometry();
|
||||
|
||||
// handle adjustment of window height when advanced controls are hidden
|
||||
if (state == 0)
|
||||
{
|
||||
/*
|
||||
* Qt's adjustSize() method on widget objects will scale the widget to only fit its' children.
|
||||
* This is useful for "collapsing" the window when the advanced controls are hidden, but will
|
||||
* scale both the height and the width. We want to retain the current width but change the
|
||||
* height, so first we will back up the min and max width values then set the current width as
|
||||
* the fixed width to prevent it from being scaled.
|
||||
*/
|
||||
int minWidthBackup = minimumWidth();
|
||||
int maxWidthBackup = maximumWidth();
|
||||
setFixedWidth(width());
|
||||
|
||||
// perform the size adjustments
|
||||
ui->centralWidget->adjustSize();
|
||||
adjustSize();
|
||||
|
||||
// restore the min/max width values so the width is no longer fixed
|
||||
setMinimumWidth(minWidthBackup);
|
||||
setMaximumWidth(maxWidthBackup);
|
||||
QTimer::singleShot(0, ui->centralWidget, [this,cWidgetFinalSize,windowFinalSize]() {
|
||||
ui->centralWidget->resize(cWidgetFinalSize);
|
||||
resize(windowFinalSize);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user