Commit ca28b620 authored by Marco Martin's avatar Marco Martin

Introduce an Info Center mode

Summary:
withthe command line switch -i, start
systemsettings loading the KInfoCenter modules and hyerarchy instead.
* KAboutData and dbus service name will be the same of KInfoCenter
* The startup page is not shown but the "System Information" kcm is loaded instead
* KACtivityStats is disabled
* The home button will load the "System Information" kcm as well
* It will *always* be in sidebar mode regardless how systemsettings is configured
* Config dialog can't be open.

BUG:412975

Test Plan:
* SystemSettings mode functionality didn't change
* infocenter mode is fully functional

{F7930943}

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: meven, davidedmundson, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26895
parent 72ed5749
......@@ -43,8 +43,9 @@
#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;
......@@ -53,8 +54,6 @@ SettingsBase::SettingsBase( QWidget * parent )
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
......@@ -63,6 +62,16 @@ SettingsBase::SettingsBase( QWidget * parent )
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 @@ QSize SettingsBase::sizeHint() const
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 @@ void SettingsBase::initApplication()
// 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<BaseMode>(this, QVariantList(), &error);
BaseMode * controller = activeService->createInstance<BaseMode>(this, {m_mode}, &error);
if( error.isEmpty() ) {
possibleViews.insert( activeService->library(), controller );
controller->init( activeService );
......@@ -138,6 +155,7 @@ void SettingsBase::initToolBar()
// 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...") );
......@@ -145,6 +163,7 @@ void SettingsBase::initToolBar()
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 @@ void SettingsBase::initMenuList(MenuItem * parent)
// 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 @@ void SettingsBase::initMenuList(MenuItem * parent)
// 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 @@ void SettingsBase::configUpdated()
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 @@ void SettingsBase::changePlugin()
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::changePlugin()
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 @@ void SettingsBase::changeToolBar( BaseMode::ToolBarItems toolbar )
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<QAction*> configureBarActions;
configureBarActions << configureAction;
guiFactory()->plugActionList( this, QStringLiteral("configure"), configureBarActions );
......
......@@ -41,8 +41,9 @@ class SettingsBase : public KXmlGuiWindow
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 @@ private:
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
......@@ -26,6 +26,7 @@
#include <KCrash>
#include <kworkspace.h>
#include <kdbusservice.h>
#include <KQuickAddons/QtQuickSettings>
#include "SystemSettingsApp.h"
......@@ -33,39 +34,68 @@
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();
......
......@@ -63,6 +63,16 @@ void BaseData::setMenuItem( MenuItem * item )
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 );
......
......@@ -72,6 +72,21 @@ public:
*/
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 @@ public:
private:
MenuItem * rootMenu;
MenuItem * m_homeItem;
};
#endif
......
......@@ -37,14 +37,19 @@ public:
QList<QAction*> 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<ApplicationMode>()) {
d->applicationMode = args.first().value<ApplicationMode>();
}
}
BaseMode::~BaseMode()
......@@ -55,6 +60,7 @@ BaseMode::~BaseMode()
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 @@ KAboutData * BaseMode::aboutData()
return nullptr;
}
BaseMode::ApplicationMode BaseMode::applicationMode() const
{
return d->applicationMode;
}
ModuleView * BaseMode::moduleView() const
{
return nullptr;
......@@ -135,6 +146,11 @@ MenuItem * BaseMode::rootItem() const
return d->rootItem;
}
MenuItem * BaseMode::homeItem() const
{
return d->homeItem;
}
KConfigGroup& BaseMode::config() const
{
return d->config;
......
......@@ -56,13 +56,22 @@ class SYSTEMSETTINGSVIEW_EXPORT BaseMode : public QObject
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 @@ public:
*/
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 @@ protected:
*/
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.
*
......
......@@ -127,6 +127,9 @@ void MenuItem::setService( const KService::Ptr& service )
{
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 );
......
......@@ -24,7 +24,6 @@
#include <QIcon>
#include "MenuItem.h"
class MenuModel::Private {
public:
Private() {}
......@@ -68,7 +67,6 @@ int MenuModel::rowCount( const QModelIndex &parent ) const
} else {
mi = d->rootItem;
}
return childrenList(mi).count();
}
......@@ -211,6 +209,23 @@ MenuItem * MenuModel::parentItem( MenuItem * child ) const
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;
......
......@@ -150,6 +150,8 @@ public:
*/
void removeException( MenuItem * exception );
QModelIndex indexForItem( MenuItem * item ) const;
protected:
/**
* Provides the MenuItem which is used internally to provide information.
......
......@@ -61,7 +61,8 @@ public:
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 @@ void ModuleView::activeModuleChanged(KPageWidgetItem * current, KPageWidgetItem
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 @@ KPageView::FaceType ModuleView::faceType() const
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();
}
......@@ -95,6 +95,48 @@ public:
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
......
......@@ -52,8 +52,8 @@ public:
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" ),
......
......@@ -276,8 +276,8 @@ public:
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 @@ void SidebarMode::initEvent()
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 @@ void SidebarMode::loadModule( const QModelIndex& activeModule )
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 @@ void SidebarMode::setIntroPageVisible(const bool &introPageVisible)
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;