diff --git a/src/kcmultidialog.cpp b/src/kcmultidialog.cpp --- a/src/kcmultidialog.cpp +++ b/src/kcmultidialog.cpp @@ -89,54 +89,57 @@ Q_Q(KCMultiDialog); - KCModuleProxy *currentModule = nullptr; KCModuleProxy *previousModule = nullptr; - for (int i = 0; i < modules.count(); ++i) { - if (modules[i].item == previous) { - previousModule = modules[i].kcm; - } - if (modules[i].item == current) { - currentModule = modules[i].kcm; - } - } - Q_ASSERT(currentModule); - - // For some reason the KCModuleQml modules handle their own margin internally - // to match that we need to adjust the spacing of our page widget - // by removing the spacing between the left pane and the edge, and the layout on the right - // when we reduce the layout on the right we need to pad the buttons back to match - - // TODO KF6 Fix this situation. - - if (currentModule->realModule() && currentModule->realModule()->inherits("KCModuleQml")) { - bool padHackLeft = false; - bool padHackRight = false; - if (q->pageWidget()->model()->rowCount() < 2) { - padHackLeft = true; - padHackRight = true; - } else if (qApp->isRightToLeft()) { - padHackLeft = true; - } else { - padHackRight = true; + { + KCModuleProxy *currentModule = nullptr; + for (int i = 0; i < modules.count(); ++i) { + if (modules[i].item == previous) { + previousModule = modules[i].kcm; + } + if (modules[i].item == current) { + currentModule = modules[i].kcm; + } } - q->layout()->setContentsMargins(padHackLeft ? 0: q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin), - q->style()->pixelMetric(QStyle::PM_LayoutTopMargin), - padHackRight ? 0 : q->style()->pixelMetric(QStyle::PM_LayoutRightMargin), - q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); - q->pageWidget()->layout()->setSpacing(0); - q->buttonBox()->setContentsMargins(padHackLeft ? q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) : 0, - 0, - padHackRight ? q->style()->pixelMetric(QStyle::PM_LayoutRightMargin) : 0, - 0); - } else { - q->buttonBox()->setContentsMargins(0, 0, 0, 0); - q->pageWidget()->layout()->setSpacing(q->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing)); - q->layout()->setContentsMargins( - q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin), - q->style()->pixelMetric(QStyle::PM_LayoutTopMargin), - q->style()->pixelMetric(QStyle::PM_LayoutRightMargin), - q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); + // For some reason the KCModuleQml modules handle their own margin internally + // to match that we need to adjust the spacing of our page widget + // by removing the spacing between the left pane and the edge, and the layout on the right + // when we reduce the layout on the right we need to pad the buttons back to match + + // TODO KF6 Fix this situation. + + if (currentModule) { + if (currentModule->realModule() && currentModule->realModule()->inherits("KCModuleQml")) { + bool padHackLeft = false; + bool padHackRight = false; + if (q->pageWidget()->model()->rowCount() < 2) { + padHackLeft = true; + padHackRight = true; + } else if (qApp->isRightToLeft()) { + padHackLeft = true; + } else { + padHackRight = true; + } + + q->layout()->setContentsMargins(padHackLeft ? 0: q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin), + q->style()->pixelMetric(QStyle::PM_LayoutTopMargin), + padHackRight ? 0 : q->style()->pixelMetric(QStyle::PM_LayoutRightMargin), + q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); + q->pageWidget()->layout()->setSpacing(0); + q->buttonBox()->setContentsMargins(padHackLeft ? q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) : 0, + 0, + padHackRight ? q->style()->pixelMetric(QStyle::PM_LayoutRightMargin) : 0, + 0); + } else { + q->buttonBox()->setContentsMargins(0, 0, 0, 0); + q->pageWidget()->layout()->setSpacing(q->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing)); + q->layout()->setContentsMargins( + q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin), + q->style()->pixelMetric(QStyle::PM_LayoutTopMargin), + q->style()->pixelMetric(QStyle::PM_LayoutRightMargin), + q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); + } + } } q->blockSignals(true);