Commit 9a35fd4c authored by Ismael Asensio's avatar Ismael Asensio Committed by Nate Graham
Browse files

ModuleView: Simplify and fix custom headers logic

Apart from a minimum logic refactor, this introduces two fixes:
- Only affect custom header visiblity for current page
- Do not set customHeader text when not visible

When calling `KTitleWidget::setText()`, this would set the custom
header visible again. So do it only if we want it actually visible.


(cherry picked from commit 1022d0b0)
parent 5f5a0c0c
Pipeline #146495 passed with stage
in 1 minute and 3 seconds
......@@ -141,6 +141,7 @@ ModuleView::ModuleView(QWidget *parent)
// Create the Page Widget
d->mPageWidget = new KPageWidget(this);
d->mCustomHeader = new CustomTitle(this);
d->mCustomHeader->setVisible(false);
rootLayout->addWidget(d->mCustomHeader);
rootLayout->addItem(d->mLayout);
......@@ -280,22 +281,22 @@ void ModuleView::updatePageIconHeader(KPageWidgetItem *page)
const QString moduleName = moduleProxy->metaData().name();
page->setHeader(moduleName);
d->mCustomHeader->setText(moduleName);
page->setIcon(QIcon::fromTheme(moduleProxy->metaData().iconName()));
const bool isQml = moduleProxy->realModule() && moduleProxy->realModule()->inherits("KCModuleQml");
if (isQml) {
// QML KCM: We don't use any widgets header
d->mCustomHeader->setVisible(false);
page->setHeaderVisible(false);
} else if (faceType() == KPageView::Plain) {
// QWidgets KCM on Sidebar mode: Use the custom header
d->mCustomHeader->setVisible(true);
page->setHeaderVisible(false);
} else {
// QWidgets KCM on Icons mode: Use the module's header
d->mCustomHeader->setVisible(false);
page->setHeaderVisible(true);
const bool isSidebar = faceType() == KPageView::Plain;
// Use the module's header only for QWidgets KCMs on Icons mode
page->setHeaderVisible(!isQml && !isSidebar);
// Use the custom header only for QWidgets KCMs on Sidebar mode
// Only affect visibility if it's the current page
if (d->mPageWidget->currentPage() == page) {
d->mCustomHeader->setVisible(!isQml && isSidebar);
// KTitleWidget->setText() would set the titlebar visible again
if (d->mCustomHeader->isVisible()) {
d->mCustomHeader->setText(moduleName);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment