Commit d80df6d8 authored by Marco Martin's avatar Marco Martin

api for multi level kcms in base kcmodule

parent 6657decb
......@@ -56,6 +56,8 @@ public:
QList<KConfigDialogManager *> managers;
QString _quickHelp;
QString m_ExportText;
QList<QString> _levelTitles;
uint _currentLevel = 0;
bool _useRootOnlyMessage : 1;
bool _firstshow : 1;
......@@ -242,6 +244,8 @@ void KCModule::setAboutData(const KAboutData *about)
if (about != d->_about) {
delete d->_about;
d->_about = about;
d->_levelTitles.clear();
d->_levelTitles << about->productName();
}
}
......@@ -303,3 +307,48 @@ QList<KConfigDialogManager *> KCModule::configs() const
return d->managers;
}
QStringList KCModule::levelTitles() const
{
return d->_levelTitles;
}
uint KCModule::depth() const
{
return d->_levelTitles.length();
}
void KCModule::setCurrentLevel(uint level)
{
if (d->_currentLevel == level) {
return;
}
d->_currentLevel = level;
emit currentLevelChanged(level);
}
int KCModule::currentLevel() const
{
return d->_currentLevel;
}
void KCModule::pushLevel(const QString &title)
{
d->_levelTitles << title;
emit levelPushed(title);
emit depthChanged(d->_levelTitles.length());
emit levelTitlesChanged(d->_levelTitles);
}
void KCModule::popLevel()
{
d->_levelTitles.pop_back();
setCurrentLevel(qMin(d->_currentLevel, static_cast<uint>(qMax(0, d->_levelTitles.length() - 1))));
emit levelPopped();
emit depthChanged(d->_levelTitles.length());
emit levelTitlesChanged(d->_levelTitles);
}
......@@ -256,6 +256,35 @@ public:
*/
KCONFIGWIDGETS_DEPRECATED void setExportText(const QString &);
/**
* If a KCM has an internal page stack such as a QStackedWidget, it
* can export its stack levels to the outside, so the settings application can draw
* controls for them, such as a breadcrumb on top.
* (all the QML-based KCMs support this feature by default)
* @returns the titles of all the current levels.
* @since 5.49
*/
QStringList levelTitles() const;
/**
* @returns how many levels this KCM has.
* @since 5.49
*/
uint depth() const;
/**
* Sets the level which should be currently visible.
* It's responsibility of the KCM to show the proper level when this property is changed
* @since 5.49
*/
void setCurrentLevel(uint level);
/**
* @returns the currently visible level
* @since 5.49
*/
int currentLevel() const;
public Q_SLOTS:
/**
* Load the configuration data into the module.
......@@ -334,6 +363,19 @@ protected:
*/
void setQuickHelp(const QString &help);
/**
* Push a new level. Only the kcm implementation can do this
* @param title the new level title
* @since 5.49
*/
void pushLevel(const QString &title);
/**
* Remove the top-most level. Only the kcm implementation can do this
* @since 5.49
*/
void popLevel();
void showEvent(QShowEvent *ev) override;
friend class KCModuleProxy;
......@@ -369,6 +411,11 @@ Q_SIGNALS:
*/
void rootOnlyMessageChanged(bool use, QString message);
void levelTitlesChanged(const QStringList &titles);
void depthChanged(uint depth);
void currentLevelChanged(uint currentLevel);
void levelPushed(const QString &title);
void levelPopped();
protected Q_SLOTS:
/**
......
Markdown is supported
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