diff --git a/sidebar/SidebarMode.h b/sidebar/SidebarMode.h --- a/sidebar/SidebarMode.h +++ b/sidebar/SidebarMode.h @@ -52,6 +52,7 @@ 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 @@ 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; @@ -99,6 +103,7 @@ void activeSubCategoryChanged(); void widthChanged(); void actionMenuVisibleChanged(); + void introPageVisibleChanged(); private: class Private; diff --git a/sidebar/SidebarMode.cpp b/sidebar/SidebarMode.cpp --- a/sidebar/SidebarMode.cpp +++ b/sidebar/SidebarMode.cpp @@ -259,6 +259,7 @@ m_actionMenuVisible = actionMenuVisible; emit sidebarMode->actionMenuVisibleChanged(); } + bool m_introPageVisible = true; }; SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) @@ -404,6 +405,7 @@ const QModelIndex idx = d->mostUsedModel->index(index, 0); d->moduleView->closeModules(); d->moduleView->loadModule( idx ); + setIntroPageVisible(false); } void SidebarMode::showActionMenu(const QPoint &position) @@ -425,6 +427,10 @@ { d->moduleView->closeModules(); + if (!activeModule.isValid()) { + return; + } + const int subRows = d->searchModel->rowCount(activeModule); if ( subRows < 2) { d->moduleView->loadModule( activeModule ); @@ -449,7 +455,13 @@ 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; @@ -483,6 +495,25 @@ emit activeSubCategoryChanged(); } +void SidebarMode::setIntroPageVisible(const bool &introPageVisible) +{ + if (d->m_introPageVisible == introPageVisible) { + return; + } + + if (introPageVisible) { + setActiveCategory(-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(); @@ -498,6 +529,11 @@ return d->activeSubCategory; } +bool SidebarMode::introPageVisible() const +{ + return (d->m_introPageVisible); +} + void SidebarMode::initWidget() { // Create the widgets diff --git a/sidebar/package/contents/ui/CategoriesPage.qml b/sidebar/package/contents/ui/CategoriesPage.qml --- a/sidebar/package/contents/ui/CategoriesPage.qml +++ b/sidebar/package/contents/ui/CategoriesPage.qml @@ -41,19 +41,18 @@ } 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 @@ systemsettings.categoryModel.filterRegExp = text; } } + + 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 {