Commit de351c8e authored by Björn Feber's avatar Björn Feber
Browse files

Add "Show intro page" button to System Settings sidebar

Summary:
BUG: 405956
{F7262289}

Test Plan: Open System Settings and click on the "Show intro page" button.

Reviewers: #plasma, #vdg, ngraham

Reviewed By: #vdg, ngraham

Subscribers: ngraham, mart, #vdg, plasma-devel, #plasma

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D23274
parent 441444c2
......@@ -260,6 +260,7 @@ public:
m_actionMenuVisible = actionMenuVisible;
emit sidebarMode->actionMenuVisibleChanged();
}
bool m_introPageVisible = true;
};
SidebarMode::SidebarMode( QObject *parent, const QVariantList& )
......@@ -417,6 +418,7 @@ void SidebarMode::loadMostUsed(int index)
const QModelIndex idx = d->mostUsedModel->index(index, 0);
d->moduleView->closeModules();
d->moduleView->loadModule( idx );
setIntroPageVisible(false);
}
void SidebarMode::showActionMenu(const QPoint &position)
......@@ -438,6 +440,10 @@ void SidebarMode::changeModule( const QModelIndex& activeModule )
{
d->moduleView->closeModules();
if (!activeModule.isValid()) {
return;
}
const int subRows = d->searchModel->rowCount(activeModule);
if ( subRows < 2) {
d->moduleView->loadModule( activeModule );
......@@ -462,7 +468,13 @@ int SidebarMode::activeCategory() const
void SidebarMode::setActiveCategory(int cat)
{
const QModelIndex idx = d->searchModel->index(cat, 0);
const int newCategoryRow = d->searchModel->mapToSource(idx).row();
int newCategoryRow;
if (cat != -1) {
setIntroPageVisible(false);
newCategoryRow = d->searchModel->mapToSource(idx).row();
} else {
newCategoryRow = cat;
}
if (d->activeCategory == newCategoryRow) {
return;
......@@ -493,9 +505,30 @@ void SidebarMode::setActiveSubCategory(int cat)
d->activeSubCategory = cat;
d->moduleView->closeModules();
d->moduleView->loadModule( d->subCategoryModel->index(cat, 0) );
setIntroPageVisible(cat < 0);
emit activeSubCategoryChanged();
}
void SidebarMode::setIntroPageVisible(const bool &introPageVisible)
{
if (d->m_introPageVisible == introPageVisible) {
return;
}
if (introPageVisible) {
setActiveCategory(-1);
setActiveSubCategory(-1);
d->placeHolderWidget->show();
d->moduleView->hide();
} else {
d->placeHolderWidget->hide();
d->moduleView->show();
}
d->m_introPageVisible = introPageVisible;
emit introPageVisibleChanged();
}
int SidebarMode::width() const
{
return d->mainWidget->width();
......@@ -511,6 +544,11 @@ int SidebarMode::activeSubCategory() const
return d->activeSubCategory;
}
bool SidebarMode::introPageVisible() const
{
return (d->m_introPageVisible);
}
void SidebarMode::initWidget()
{
// Create the widgets
......
......@@ -52,6 +52,7 @@ class SidebarMode : public BaseMode
Q_PROPERTY(int activeSubCategory READ activeSubCategory WRITE setActiveSubCategory NOTIFY activeSubCategoryChanged)
Q_PROPERTY(int width READ width NOTIFY widthChanged)
Q_PROPERTY(bool actionMenuVisible READ actionMenuVisible NOTIFY actionMenuVisibleChanged)
Q_PROPERTY(bool introPageVisible READ introPageVisible WRITE setIntroPageVisible NOTIFY introPageVisibleChanged)
public:
SidebarMode(QObject * parent, const QVariantList& );
......@@ -75,6 +76,9 @@ public:
bool actionMenuVisible() const;
bool introPageVisible() const;
void setIntroPageVisible(const bool &introPageVisible);
Q_INVOKABLE QAction *action(const QString &name) const;
// QML doesn't understand QIcon, otherwise we could get it from the QAction itself
Q_INVOKABLE QString actionIconName(const QString &name) const;
......@@ -101,6 +105,7 @@ Q_SIGNALS:
void activeSubCategoryChanged();
void widthChanged();
void actionMenuVisibleChanged();
void introPageVisibleChanged();
private:
class Private;
......
......@@ -40,19 +40,18 @@ Kirigami.ScrollablePage {
}
QQC2.ToolButton {
id: menuButton
icon.name: "application-menu"
checkable: true
checked: systemsettings.actionMenuVisible
id: showIntroPageButton
enabled: !systemsettings.introPageVisible
icon.name: "go-home"
Layout.maximumWidth: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2
Layout.maximumHeight: width
Keys.onBacktabPressed: {
root.focusPreviousRequest()
}
onClicked: systemsettings.showActionMenu(mapToGlobal(0, height))
onClicked: systemsettings.introPageVisible = true
QQC2.ToolTip {
text: i18n("Show menu")
text: i18n("Show intro page")
}
}
......@@ -67,6 +66,23 @@ Kirigami.ScrollablePage {
}
KeyNavigation.tab: categoryView
}
QQC2.ToolButton {
id: menuButton
icon.name: "application-menu"
checkable: true
checked: systemsettings.actionMenuVisible
Layout.maximumWidth: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2
Layout.maximumHeight: width
Keys.onBacktabPressed: {
root.focusPreviousRequest()
}
onClicked: systemsettings.showActionMenu(mapToGlobal(0, height))
QQC2.ToolTip {
text: i18n("Show menu")
}
}
}
Kirigami.Separator {
anchors {
......
......@@ -125,11 +125,17 @@ Kirigami.ScrollablePage {
root.pageStack.pop(mainColumn)
}
}
Connections {
target: systemsettings
onActiveSubCategoryChanged: {
root.pageStack.currentIndex = 1;
subCategoryView.forceActiveFocus();
subCategoryView.currentIndex = systemsettings.activeSubCategory;
if (systemsettings.activeSubCategory < 0) {
root.pageStack.pop(mainColumn)
} else {
root.pageStack.currentIndex = 1;
subCategoryView.forceActiveFocus();
}
}
}
......
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