Commit b4eedbb4 authored by Marco Martin's avatar Marco Martin
Browse files

Support for a landing page

parent 9844a816
......@@ -279,6 +279,8 @@ void SettingsBase::initMenuList(MenuItem *parent)
infoItem->setService(entry);
if (m_mode == BaseMode::InfoCenter && entry->pluginKeyword() == QStringLiteral("kcm-about-distro")) {
homeModule = infoItem;
} else if (m_mode == BaseMode::SystemSettings && entry->pluginKeyword() == QStringLiteral("kcm_landingpage")) {
homeModule = infoItem;
}
}
......
......@@ -75,12 +75,18 @@ bool MenuProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_
QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
MenuItem *mItem = index.data(Qt::UserRole).value<MenuItem *>();
if (mItem->service()->library() == QLatin1String("kcm_landingpage")) {
return false;
}
// accept only systemsettings categories that have children
if (mItem->children().isEmpty() && mItem->service()->serviceTypes().contains(QLatin1String("SystemSettingsCategory"))) {
return false;
} else {
return true; // Items matching the regexp are disabled, not hidden
}
}
void MenuProxyModel::setFilterHighlightsEntries(bool highlight)
......
......@@ -434,7 +434,8 @@ void ModuleView::activeModuleChanged(KPageWidgetItem *current, KPageWidgetItem *
KCModuleProxy *activeModule = d->mPages.value(d->mPageWidget->currentPage());
if (activeModule || activeModuleInfo) {
// TODO: if we'll ever need statistics for kinfocenter modules, save them with an URL like "kinfo:"
if (activeModule && d->mSaveStatistics) {
if (activeModule && d->mSaveStatistics && activeModule->moduleInfo().service()->desktopEntryName() != QStringLiteral("kcm_landingpage")) {
KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("kcm:") + activeModule->moduleInfo().service()->storageId()),
QStringLiteral("org.kde.systemsettings"));
}
......
......@@ -602,6 +602,10 @@ void SidebarMode::moduleLoaded()
void SidebarMode::updateDefaults()
{
// When the landing page is loaded, we don't have activeCategoryRow
if (d->activeCategoryRow < 0) {
return;
}
QModelIndex categoryIdx = d->categorizedModel->index(d->activeCategoryRow, 0);
auto item = categoryIdx.data(Qt::UserRole).value<MenuItem *>();
Q_ASSERT(item);
......@@ -641,7 +645,17 @@ void SidebarMode::setIntroPageVisible(const bool &introPageVisible)
d->placeHolderWidget->hide();
d->moduleView->show();
if (introPageVisible) {
loadModule(d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem())));
QModelIndex index = d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem()));
if (index.isValid()) {
loadModule(index);
} else {
d->moduleView->closeModules();
d->moduleView->loadModule( d->model->indexForItem(homeItem()), QStringList() );
d->activeCategoryRow = -1;
d->activeSubCategoryRow = -1;
emit activeCategoryRowChanged();
emit activeSubCategoryRowChanged();
}
}
} else {
if (introPageVisible) {
......@@ -814,17 +828,20 @@ void SidebarMode::initWidget()
d->mostUsedModel->setResultModel(new ResultModel(AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this));
if (homeItem()) {
d->placeHolderWidget->hide();
d->moduleView->show();
loadModule(d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem())));
}
if (!startupModule().isEmpty()) {
MenuItem *item = rootItem()->descendantForModule(startupModule());
if (item) {
loadModule(d->model->indexForItem(item), startupModuleArgs());
}
} else if (homeItem()) {
d->placeHolderWidget->hide();
d->moduleView->show();
QModelIndex index = d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem()));
if (index.isValid()) {
loadModule(index);
} else {
d->moduleView->loadModule( d->model->indexForItem(homeItem()), QStringList() );
}
}
}
......
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