diff --git a/app/SettingsBase.h b/app/SettingsBase.h --- a/app/SettingsBase.h +++ b/app/SettingsBase.h @@ -41,8 +41,9 @@ Q_OBJECT public: - explicit SettingsBase(QWidget * parent = nullptr); + explicit SettingsBase(BaseMode::ApplicationMode mode, QWidget * parent = nullptr); ~SettingsBase() override; + bool isInfoCenterMode() const; bool queryClose() override; protected: @@ -88,10 +89,12 @@ QStackedWidget * stackedWidget = nullptr; // The module list MenuItem * rootModule = nullptr; + MenuItem * homeModule = nullptr; MenuItem * lostFound = nullptr; KService::List categories; KService::List modules; // The about dialog KAboutApplicationDialog * aboutDialog = nullptr; + BaseMode::ApplicationMode m_mode = BaseMode::SystemSettings; }; #endif diff --git a/app/SettingsBase.cpp b/app/SettingsBase.cpp --- a/app/SettingsBase.cpp +++ b/app/SettingsBase.cpp @@ -43,26 +43,35 @@ #include "BaseData.h" #include "ModuleView.h" -SettingsBase::SettingsBase( QWidget * parent ) - : KXmlGuiWindow(parent) +SettingsBase::SettingsBase(BaseMode::ApplicationMode mode, QWidget * parent ) + : KXmlGuiWindow(parent), + m_mode(mode) { // Ensure delayed loading doesn't cause a crash activeView = nullptr; aboutDialog = nullptr; configDialog = nullptr; lostFound = nullptr; // Prepare the view area stackedWidget = new QStackedWidget( this ); - setWindowTitle(i18n("System Settings")); - setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system"))); setCentralWidget(stackedWidget); setWindowFlags( windowFlags() | Qt::WindowContextHelpButtonHint ); // Initialise search searchText = new KLineEdit( this ); searchText->setClearButtonEnabled( true ); searchText->setPlaceholderText( i18nc( "Search through a list of control modules", "Search" ) ); searchText->setCompletionMode( KCompletion::CompletionPopup ); + if (m_mode == BaseMode::InfoCenter) { + actionCollection()->removeAction(configureAction); + configureAction = nullptr; + setWindowTitle(i18n("Info Center")); + setWindowIcon(QIcon::fromTheme(QStringLiteral("hwinfo"))); + } else { + setWindowTitle(i18n("System Settings")); + setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system"))); + } + spacerWidget = new QWidget( this ); spacerWidget->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Maximum ); // Initialise the window so we don't flicker @@ -89,11 +98,18 @@ void SettingsBase::initApplication() { // Prepare the menu of all modules - categories = KServiceTypeTrader::self()->query(QStringLiteral("SystemSettingsCategory")); - modules = KServiceTypeTrader::self()->query(QStringLiteral("KCModule"), QStringLiteral("[X-KDE-System-Settings-Parent-Category] != ''")); - modules += KServiceTypeTrader::self()->query(QStringLiteral("SystemSettingsExternalApp")); + if (m_mode == BaseMode::InfoCenter) { + categories = KServiceTypeTrader::self()->query(QStringLiteral("KInfoCenterCategory")); + modules = KServiceTypeTrader::self()->query(QStringLiteral("KCModule"), QStringLiteral("[X-KDE-ParentApp] == 'kinfocenter'")); + } else { + categories = KServiceTypeTrader::self()->query(QStringLiteral("SystemSettingsCategory")); + modules = KServiceTypeTrader::self()->query(QStringLiteral("KCModule"), QStringLiteral("[X-KDE-System-Settings-Parent-Category] != ''")); + modules += KServiceTypeTrader::self()->query(QStringLiteral("SystemSettingsExternalApp")); + } + rootModule = new MenuItem( true, nullptr ); initMenuList(rootModule); + // Handle lost+found modules... if (lostFound) { for (int i = 0; i < modules.size(); ++i) { @@ -106,13 +122,14 @@ // Prepare the Base Data BaseData::instance()->setMenuItem( rootModule ); + BaseData::instance()->setHomeItem( homeModule ); // Load all possible views const KService::List pluginObjects = KServiceTypeTrader::self()->query( QStringLiteral("SystemSettingsView") ); const int nbPlugins = pluginObjects.count(); for( int pluginsDone = 0; pluginsDone < nbPlugins ; ++pluginsDone ) { KService::Ptr activeService = pluginObjects.at( pluginsDone ); QString error; - BaseMode * controller = activeService->createInstance(this, QVariantList(), &error); + BaseMode * controller = activeService->createInstance(this, {m_mode}, &error); if( error.isEmpty() ) { possibleViews.insert( activeService->library(), controller ); controller->init( activeService ); @@ -138,13 +155,15 @@ // Fill the toolbar with default actions // Exit is the very last action quitAction = actionCollection()->addAction( KStandardAction::Quit, QStringLiteral("quit_action"), this, SLOT(close()) ); + // Configure goes at the end configureAction = actionCollection()->addAction( KStandardAction::Preferences, QStringLiteral("configure"), this, SLOT(configShow()) ); configureAction->setText( i18n("Configure...") ); // Help after it initHelpMenu(); configureAction->setIcon(QIcon::fromTheme(QStringLiteral("settings-configure"))); + // Then a spacer so the search line-edit is kept separate spacerAction = new QWidgetAction( this ); spacerAction->setDefaultWidget(spacerWidget); @@ -207,9 +226,16 @@ // look for any categories inside this level, and recurse into them for (int i = 0; i < categories.size(); ++i) { const KService::Ptr entry = categories.at(i); - const QString parentCategory = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category")).toString(); - const QString parentCategory2 = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category-V2")).toString(); - if ( parentCategory == parent->category() || + QString parentCategory; + QString parentCategory2; + if (m_mode == BaseMode::InfoCenter) { + parentCategory = entry->property(QStringLiteral("X-KDE-KInfoCenter-Parent-Category")).toString(); + } else { + parentCategory = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category")).toString(); + parentCategory2 = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category-V2")).toString(); + } + + if (parentCategory == parent->category() || // V2 entries must not be empty if they want to become a proper category. ( !parentCategory2.isEmpty() && parentCategory2 == parent->category() ) ) { MenuItem * menuItem = new MenuItem(true, parent); @@ -227,13 +253,24 @@ // scan for any modules at this level and add them for (int i = 0; i < modules.size(); ++i) { const KService::Ptr entry = modules.at(i); - const QString category = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category")).toString(); - const QString category2 = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category-V2")).toString(); + + QString category; + QString category2; + if (m_mode == BaseMode::InfoCenter) { + category = entry->property(QStringLiteral("X-KDE-KInfoCenter-Category")).toString(); + } else { + category = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category")).toString(); + category2 = entry->property(QStringLiteral("X-KDE-System-Settings-Parent-Category-V2")).toString(); + } + if( !parent->category().isEmpty() && (category == parent->category() || category2 == parent->category()) ) { if (!entry->noDisplay() ) { // Add the module info to the menu MenuItem * infoItem = new MenuItem(false, parent); infoItem->setService( entry ); + if (m_mode == BaseMode::InfoCenter && entry->pluginKeyword() == QStringLiteral("kcm-about-distro")) { + homeModule = infoItem; + } } removeList.append( modules.at(i) ); @@ -252,6 +289,7 @@ KConfigGroup dialogConfig = KSharedConfig::openConfig()->group("ConfigDialog"); KWindowConfig::saveWindowSize(configDialog->windowHandle(), dialogConfig); BaseConfig::setActiveView( possibleViews.keys().at(viewSelection.checkedId()) ); + BaseConfig::setShowToolTips( configWidget.ChTooltips->isChecked() ); activeView->setShowToolTips( configWidget.ChTooltips->isChecked() ); activeView->saveConfiguration(); @@ -325,7 +363,7 @@ activeView->leaveModuleView(); } - const QString viewToUse = BaseConfig::activeView(); + const QString viewToUse = m_mode == BaseMode::InfoCenter ? QStringLiteral("systemsettings_sidebar_mode") : BaseConfig::activeView(); if( possibleViews.keys().contains(viewToUse) ) { // First the configuration entry activeView = possibleViews.value(viewToUse); } @@ -360,7 +398,9 @@ void SettingsBase::viewChange(bool state) { KCModuleInfo * moduleInfo = activeView->moduleView()->activeModule(); - configureAction->setDisabled(state); + if (configureAction) { + configureAction->setDisabled(state); + } if( moduleInfo ) { setCaption( moduleInfo->moduleName(), state ); } else { @@ -389,7 +429,7 @@ guiFactory()->plugActionList( this, QStringLiteral("search"), searchBarActions ); actionCollection()->setDefaultShortcut(searchAction, QKeySequence(Qt::CTRL + Qt::Key_F)); } - if ( BaseMode::Configure & toolbar ) { + if ( (BaseMode::Configure & toolbar) && configureAction) { QList configureBarActions; configureBarActions << configureAction; guiFactory()->plugActionList( this, QStringLiteral("configure"), configureBarActions ); diff --git a/app/main.cpp b/app/main.cpp --- a/app/main.cpp +++ b/app/main.cpp @@ -26,46 +26,76 @@ #include #include +#include #include #include "SystemSettingsApp.h" #include "SettingsBase.h" int main( int argc, char *argv[] ) { + // Make sure the binary name is either kinfocenter or systemsettings, + // Anything else will just be considered as "systemsettings" + QString binaryName = QString::fromUtf8(argv[0]); + BaseMode::ApplicationMode mode = BaseMode::InfoCenter; + if (binaryName != QStringLiteral("kinfocenter")) { + binaryName = QStringLiteral("systemsettings"); + mode = BaseMode::SystemSettings; + } + //exec is systemsettings5, but we need the QPT to use the right config from the qApp constructor //which is before KAboutData::setApplicationData - QCoreApplication::setApplicationName(QStringLiteral("systemsettings")); + QCoreApplication::setApplicationName(binaryName); KWorkSpace::detectPlatform(argc, argv); SystemSettingsApp application(argc, argv); KQuickAddons::QtQuickSettings::init(); KCrash::initialize(); - KLocalizedString::setApplicationDomain("systemsettings"); + KLocalizedString::setApplicationDomain(binaryName.toUtf8().constData()); - // About data - KAboutData aboutData(QStringLiteral("systemsettings"), i18n("System Settings"), QLatin1String(PROJECT_VERSION), i18n("Central configuration center by KDE."), KAboutLicense::GPL, i18n("(c) 2009, Ben Cooksley")); - aboutData.addAuthor(i18n("Ben Cooksley"), i18n("Maintainer"), QStringLiteral("bcooksley@kde.org")); - aboutData.addAuthor(i18n("Mathias Soeken"), i18n("Developer"), QStringLiteral("msoeken@informatik.uni-bremen.de")); - aboutData.addAuthor(i18n("Will Stephenson"), i18n("Internal module representation, internal module model"), QStringLiteral("wstephenson@kde.org")); + KAboutData aboutData; + + if (mode == BaseMode::InfoCenter) { + // About data + aboutData = KAboutData(QStringLiteral("kinfocenter"), i18n("Info Center"), QLatin1String(PROJECT_VERSION), i18n("Centralized and convenient overview of system information."), KAboutLicense::GPL, i18n("(c) 2009, Ben Cooksley")); + aboutData.addAuthor(i18n("Ben Cooksley"), i18n("Maintainer"), QStringLiteral("bcooksley@kde.org")); + aboutData.addAuthor(i18n("Mathias Soeken"), i18n("Developer"), QStringLiteral("msoeken@informatik.uni-bremen.de")); + aboutData.addAuthor(i18n("Will Stephenson"), i18n("Internal module representation, internal module model"), QStringLiteral("wstephenson@kde.org")); - if (qEnvironmentVariableIsSet("KDE_FULL_SESSION")) { - aboutData.setDesktopFileName(QStringLiteral("systemsettings")); } else { - aboutData.setDesktopFileName(QStringLiteral("kdesystemsettings")); + aboutData = KAboutData(QStringLiteral("systemsettings"), i18n("System Settings"), QLatin1String(PROJECT_VERSION), i18n("Central configuration center by KDE."), KAboutLicense::GPL, i18n("(c) 2009, Ben Cooksley")); + aboutData.addAuthor(i18n("Ben Cooksley"), i18n("Maintainer"), QStringLiteral("bcooksley@kde.org")); + aboutData.addAuthor(i18n("Mathias Soeken"), i18n("Developer"), QStringLiteral("msoeken@informatik.uni-bremen.de")); + aboutData.addAuthor(i18n("Will Stephenson"), i18n("Internal module representation, internal module model"), QStringLiteral("wstephenson@kde.org")); } - KAboutData::setApplicationData(aboutData); - application.setAttribute(Qt::AA_UseHighDpiPixmaps, true); - application.setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system"))); + QCommandLineParser parser; + aboutData.setupCommandLine(&parser); parser.process(application); aboutData.processCommandLine(&parser); - SettingsBase *mainWindow = new SettingsBase(); + if (mode == BaseMode::InfoCenter) { + aboutData.setDesktopFileName(QStringLiteral("org.kde.kinfocenter")); + application.setWindowIcon(QIcon::fromTheme(QStringLiteral("hwinfo"))); + + } else { + application.setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system"))); + + if (qEnvironmentVariableIsSet("KDE_FULL_SESSION")) { + aboutData.setDesktopFileName(QStringLiteral("systemsettings")); + } else { + aboutData.setDesktopFileName(QStringLiteral("kdesystemsettings")); + } + } + + KAboutData::setApplicationData(aboutData); + + + SettingsBase *mainWindow = new SettingsBase(mode); mainWindow->show(); application.setMainWindow(mainWindow); return application.exec(); diff --git a/core/BaseData.h b/core/BaseData.h --- a/core/BaseData.h +++ b/core/BaseData.h @@ -72,6 +72,21 @@ */ void setMenuItem( MenuItem * item ); + /** + * Provides the shared MenuItem that corresponds to a KCM which should be used as startup page. + * + * @returns the shared MenuItem. It may be nullptr. + */ + MenuItem * homeItem(); + + /** + * Sets the homescreen MenuItem which the Singleton will return. + * For internal use only. + * + * @param item A pointer to the MenuItem object + */ + void setHomeItem( MenuItem * item ); + /** * Returns the configuration group by the name provided in the current applications configuration file. * @@ -82,6 +97,7 @@ private: MenuItem * rootMenu; + MenuItem * m_homeItem; }; #endif diff --git a/core/BaseData.cpp b/core/BaseData.cpp --- a/core/BaseData.cpp +++ b/core/BaseData.cpp @@ -63,6 +63,16 @@ rootMenu = item; } +MenuItem * BaseData::homeItem() +{ + return m_homeItem; +} + +void BaseData::setHomeItem( MenuItem * item ) +{ + m_homeItem = item; +} + KConfigGroup BaseData::configGroup( const QString& pluginName ) { return KSharedConfig::openConfig()->group( pluginName ); diff --git a/core/BaseMode.h b/core/BaseMode.h --- a/core/BaseMode.h +++ b/core/BaseMode.h @@ -56,13 +56,22 @@ friend class SettingsBase; public: + // Main mode of the app. + // At the moment SystemSettings and InfoCenter are supported: + // Changes mainly the set of module listed on the left menu + enum ApplicationMode { + SystemSettings = 0, + InfoCenter + }; + Q_ENUM(ApplicationMode); + /** * Constructs a BaseMode for use in System Settings.\n * Plugin developers should perform all initialisation in initEvent() not here. * * @param parent The parent of this BaseMode. */ - explicit BaseMode( QObject * parent ); + explicit BaseMode( QObject * parent, const QVariantList &args ); /** * Normal destructor. Plugin developers only need destroy what they created * not what is provided by BaseMode itself. @@ -113,6 +122,11 @@ */ virtual KAboutData * aboutData(); + /** + * @returns the application mode of this systemsettings process: SystemSettings or InfoCenter + */ + ApplicationMode applicationMode() const; + /** * The state of the plugin ( position of the splitter for instance ) should be saved * to the configuration object when this is called. @@ -231,6 +245,14 @@ */ MenuItem * rootItem() const; + /** + * Returns (if present) an item that corresponds to a KCM which should be used as startup page. + * + * @warning This is shared between all views, and should not be deleted manually. + * @returns The item to load as startup page. It may be nullptr + */ + MenuItem * homeItem() const; + /** * Provides access to the configuration for the plugin. * diff --git a/core/BaseMode.cpp b/core/BaseMode.cpp --- a/core/BaseMode.cpp +++ b/core/BaseMode.cpp @@ -37,14 +37,19 @@ QList actionsList; KService::Ptr service; MenuItem *rootItem = nullptr; + MenuItem *homeItem = nullptr; KConfigGroup config; bool showToolTips = true; + BaseMode::ApplicationMode applicationMode = BaseMode::SystemSettings; }; -BaseMode::BaseMode( QObject* parent ) +BaseMode::BaseMode( QObject* parent, const QVariantList &args ) : QObject( parent ) , d( new Private() ) { + if (!args.isEmpty() && args.first().canConvert()) { + d->applicationMode = args.first().value(); + } } BaseMode::~BaseMode() @@ -55,6 +60,7 @@ void BaseMode::init( const KService::Ptr &modeService ) { d->rootItem = BaseData::instance()->menuItem(); + d->homeItem = BaseData::instance()->homeItem(); d->service = modeService; d->config = BaseData::instance()->configGroup( modeService->library() ); initEvent(); @@ -75,6 +81,11 @@ return nullptr; } +BaseMode::ApplicationMode BaseMode::applicationMode() const +{ + return d->applicationMode; +} + ModuleView * BaseMode::moduleView() const { return nullptr; @@ -135,6 +146,11 @@ return d->rootItem; } +MenuItem * BaseMode::homeItem() const +{ + return d->homeItem; +} + KConfigGroup& BaseMode::config() const { return d->config; diff --git a/core/MenuItem.cpp b/core/MenuItem.cpp --- a/core/MenuItem.cpp +++ b/core/MenuItem.cpp @@ -127,6 +127,9 @@ { d->service = service; d->category = service->property(QStringLiteral("X-KDE-System-Settings-Category")).toString(); + if (d->category.isEmpty()) { + d->category = service->property(QStringLiteral("X-KDE-KInfoCenter-Category")).toString(); + } d->name = service->name(); d->item = KCModuleInfo( service ); const QVariant itemWeight = service->property(QStringLiteral("X-KDE-Weight"), QVariant::Int ); diff --git a/core/MenuModel.h b/core/MenuModel.h --- a/core/MenuModel.h +++ b/core/MenuModel.h @@ -150,6 +150,8 @@ */ void removeException( MenuItem * exception ); + QModelIndex indexForItem( MenuItem * item ) const; + protected: /** * Provides the MenuItem which is used internally to provide information. diff --git a/core/MenuModel.cpp b/core/MenuModel.cpp --- a/core/MenuModel.cpp +++ b/core/MenuModel.cpp @@ -24,7 +24,6 @@ #include #include "MenuItem.h" - class MenuModel::Private { public: Private() {} @@ -68,7 +67,6 @@ } else { mi = d->rootItem; } - return childrenList(mi).count(); } @@ -211,6 +209,23 @@ return parent; } +QModelIndex MenuModel::indexForItem( MenuItem * item ) const +{ + MenuItem * parent = parentItem(item); + + if (!parent) { + return QModelIndex(); + } + + const int row = childrenList(parent).indexOf(item); + + if (row < 0) { + return QModelIndex(); + } + + return createIndex(row, 0, item); +} + MenuItem * MenuModel::rootItem() const { return d->rootItem; diff --git a/core/ModuleView.h b/core/ModuleView.h --- a/core/ModuleView.h +++ b/core/ModuleView.h @@ -95,6 +95,48 @@ KPageView::FaceType faceType() const; + /** + * Sets whether Systemsettings should save statisctics about + * most used modules using KActivities::Stats + */ + void setSaveStatistics(bool save); + + /** + * @returns whether Systemsettings should save statisctics about + * most used module + */ + bool saveStatistics() const; + + /** + * Shows or hides the Apply button. + */ + void setApplyVisible(bool visible); + + /** + * @returns True if the Apply button is visible. + */ + bool isApplyVisible() const; + + /** + * Shows or hides the Defaults button. + */ + void setDefaultsVisible(bool visible); + + /** + * @returns True if the Defaults button is visible. + */ + bool isDefaultsVisible() const; + + /** + * Shows or hides the Reset button. + */ + void setResetVisible(bool visible); + + /** + * @returns True if the Reset button is visible. + */ + bool isResetVisible() const; + public Q_SLOTS: /** * Loads the module specified by menuItem.\n diff --git a/core/ModuleView.cpp b/core/ModuleView.cpp --- a/core/ModuleView.cpp +++ b/core/ModuleView.cpp @@ -61,7 +61,8 @@ QPushButton* mReset = nullptr; QPushButton* mDefault = nullptr; QPushButton* mHelp = nullptr; - bool pageChangeSupressed; + bool pageChangeSupressed = false; + bool mSaveStatistics = true; }; ModuleView::ModuleView( QWidget * parent ) @@ -345,8 +346,11 @@ KCModuleProxy * activeModule = d->mPages.value( d->mPageWidget->currentPage() ); if (activeModule) { - KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("kcm:") + activeModule->moduleInfo().service()->storageId()), - QStringLiteral("org.kde.systemsettings")); + // TODO: if we'll ever need statistics for kinfocenter modules, save them with an URL like "kinfo:" + if (d->mSaveStatistics) { + KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("kcm:") + activeModule->moduleInfo().service()->storageId()), + QStringLiteral("org.kde.systemsettings")); + } if (activeModule->realModule() && activeModule->realModule()->inherits("KCModuleQml")) { d->mButtons->setContentsMargins( style()->pixelMetric(QStyle::PM_LayoutLeftMargin), @@ -429,3 +433,43 @@ return d->mPageWidget->faceType(); } +void ModuleView::setSaveStatistics(bool save) +{ + d->mSaveStatistics = save; +} + +bool ModuleView::saveStatistics() const +{ + return d->mSaveStatistics; +} + +void ModuleView::setApplyVisible(bool visible) +{ + d->mApply->setVisible(visible); +} + +bool ModuleView::isApplyVisible() const +{ + return d->mApply->isVisible(); +} + +void ModuleView::setDefaultsVisible(bool visible) +{ + d->mDefault->setVisible(visible); +} + +bool ModuleView::isDefaultsVisible() const +{ + return d->mDefault->isVisible(); +} + +void ModuleView::setResetVisible(bool visible) +{ + d->mReset->setVisible(visible); +} + +bool ModuleView::isResetVisible() const +{ + return d->mReset->isVisible(); +} + diff --git a/icons/IconMode.cpp b/icons/IconMode.cpp --- a/icons/IconMode.cpp +++ b/icons/IconMode.cpp @@ -52,8 +52,8 @@ QAction * backAction; }; -IconMode::IconMode( QObject *parent, const QVariantList& ) - : BaseMode( parent ) +IconMode::IconMode( QObject *parent, const QVariantList &args ) + : BaseMode( parent, args ) , d( new Private() ) { d->aboutIcon = new KAboutData( QStringLiteral("IconView"), i18n( "Icon View" ), diff --git a/sidebar/SidebarMode.h b/sidebar/SidebarMode.h --- a/sidebar/SidebarMode.h +++ b/sidebar/SidebarMode.h @@ -78,7 +78,7 @@ Q_PROPERTY(bool introPageVisible READ introPageVisible WRITE setIntroPageVisible NOTIFY introPageVisibleChanged) public: - SidebarMode(QObject * parent, const QVariantList& ); + SidebarMode(QObject * parent, const QVariantList &args ); ~SidebarMode() override; QWidget * mainWidget() override; void initEvent() override; diff --git a/sidebar/SidebarMode.cpp b/sidebar/SidebarMode.cpp --- a/sidebar/SidebarMode.cpp +++ b/sidebar/SidebarMode.cpp @@ -276,8 +276,8 @@ bool m_introPageVisible = true; }; -SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) - : BaseMode( parent ) +SidebarMode::SidebarMode( QObject *parent, const QVariantList &args ) + : BaseMode( parent, args ) , d( new Private() ) { qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); @@ -374,6 +374,12 @@ connect( d->moduleView, &ModuleView::moduleChanged, this, &SidebarMode::moduleLoaded ); d->quickWidget = nullptr; moduleView()->setFaceType(KPageView::Plain); + if (applicationMode() == BaseMode::InfoCenter) { + d->moduleView->setSaveStatistics(false); + d->moduleView->setApplyVisible(false); + d->moduleView->setDefaultsVisible(false); + d->moduleView->setResetVisible(false); + } } QAction *SidebarMode::action(const QString &name) const @@ -448,7 +454,13 @@ return; } - setIntroPageVisible(false); + if (homeItem()) { + d->m_introPageVisible = activeModule == d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem())); + emit introPageVisibleChanged(); + } else { + setIntroPageVisible(false); + } + if ( mi->children().length() < 1) { d->moduleView->loadModule( activeModule ); } else { @@ -574,16 +586,25 @@ return; } - if (introPageVisible) { - d->activeCategoryRow = -1; - emit activeCategoryRowChanged(); - d->activeSubCategoryRow = -1; - emit activeSubCategoryRowChanged(); - d->placeHolderWidget->show(); - d->moduleView->hide(); - } else { + // TODO: Make the intro page of SystemSettings a KCM as well + if (homeItem()) { d->placeHolderWidget->hide(); d->moduleView->show(); + if (introPageVisible) { + loadModule(d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem()))); + } + } else { + if (introPageVisible) { + d->activeCategoryRow = -1; + emit activeCategoryRowChanged(); + d->activeSubCategoryRow = -1; + emit activeSubCategoryRowChanged(); + d->placeHolderWidget->show(); + d->moduleView->hide(); + } else { + d->placeHolderWidget->hide(); + d->moduleView->show(); + } } d->m_introPageVisible = introPageVisible; @@ -681,6 +702,12 @@ d->mostUsedToolTipManager = new ToolTipManager(d->mostUsedModel, d->placeHolderWidget, ToolTipManager::ToolTipPosition::BottomCenter); 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()))); + } } bool SidebarMode::eventFilter(QObject* watched, QEvent* event)