diff --git a/sidebar/SidebarMode.h b/sidebar/SidebarMode.h --- a/sidebar/SidebarMode.h +++ b/sidebar/SidebarMode.h @@ -76,7 +76,9 @@ // QML doesn't understand QIcon, otherwise we could get it from the QAction itself Q_INVOKABLE QString actionIconName(const QString &name) const; Q_INVOKABLE void requestToolTip(int index, const QRectF &rect); + Q_INVOKABLE void requestSubCategoryToolTip(int index, const QRectF &rect); Q_INVOKABLE void hideToolTip(); + Q_INVOKABLE void hideSubCategoryToolTip(); Q_INVOKABLE void loadMostUsed(int index); protected: diff --git a/sidebar/SidebarMode.cpp b/sidebar/SidebarMode.cpp --- a/sidebar/SidebarMode.cpp +++ b/sidebar/SidebarMode.cpp @@ -235,6 +235,7 @@ } ToolTipManager *toolTipManager = nullptr; + ToolTipManager *subCategoryToolTipManager = nullptr; QQuickWidget * quickWidget = nullptr; KPackage::Package package; SubcategoryModel * subCategoryModel = nullptr; @@ -375,11 +376,23 @@ } } +void SidebarMode::requestSubCategoryToolTip(int index, const QRectF &rect) +{ + if (showToolTips()) { + d->subCategoryToolTipManager->requestToolTip(d->subCategoryModel->index(index, 0), rect.toRect()); + } +} + void SidebarMode::hideToolTip() { d->toolTipManager->hideToolTip(); } +void SidebarMode::hideSubCategoryToolTip() +{ + d->subCategoryToolTipManager->hideToolTip(); +} + void SidebarMode::loadMostUsed(int index) { const QModelIndex idx = d->mostUsedModel->index(index, 0); @@ -511,6 +524,7 @@ d->quickWidget->installEventFilter(this); d->toolTipManager = new ToolTipManager(d->searchModel, d->quickWidget); + d->subCategoryToolTipManager = new ToolTipManager(d->subCategoryModel, d->quickWidget); d->placeHolderWidget = new QQuickWidget(d->mainWidget); d->placeHolderWidget->quickWindow()->setTitle(i18n("Most Used")); diff --git a/sidebar/package/contents/ui/SubCategoryPage.qml b/sidebar/package/contents/ui/SubCategoryPage.qml --- a/sidebar/package/contents/ui/SubCategoryPage.qml +++ b/sidebar/package/contents/ui/SubCategoryPage.qml @@ -94,6 +94,7 @@ anchors.fill: parent model: systemsettings.subCategoryModel currentIndex: systemsettings.activeSubCategory + onContentYChanged: systemsettings.hideSubCategoryToolTip(); activeFocusOnTab: true keyNavigationWraps: true Accessible.role: Accessible.List @@ -124,6 +125,13 @@ label: model.display separatorVisible: false onClicked: systemsettings.activeSubCategory = index + onHoveredChanged: { + if (hovered) { + systemsettings.requestSubCategoryToolTip(index, delegate.mapToItem(root, 0, 0, width, height)); + } else { + systemsettings.hideSubCategoryToolTip(); + } + } onFocusChanged: { if (focus) { onCurrentIndexChanged: subCategoryView.positionViewAtIndex(index, ListView.Contain);