Commit 2766f9b9 authored by Nate Graham's avatar Nate Graham 🔩

Show tooltips for subcategories

Summary:
Tooltips are already shown for both categories as well as top-level items
at the category level (e.g. Printers). This patch makes the tooltips
show up for subcategory items as well.

FEATURE: 402651
FIXED-IN: 5.15.0

Test Plan: {F6515354, size=full}

Reviewers: #vdg, #plasma, mart, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D17864
parent 8143d049
......@@ -235,6 +235,7 @@ public:
}
ToolTipManager *toolTipManager = nullptr;
ToolTipManager *subCategoryToolTipManager = nullptr;
QQuickWidget * quickWidget = nullptr;
KPackage::Package package;
SubcategoryModel * subCategoryModel = nullptr;
......@@ -375,11 +376,23 @@ void SidebarMode::requestToolTip(int index, const QRectF &rect)
}
}
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 @@ void SidebarMode::initWidget()
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"));
......
......@@ -76,7 +76,9 @@ public:
// 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:
......
......@@ -94,6 +94,7 @@ Kirigami.ScrollablePage {
anchors.fill: parent
model: systemsettings.subCategoryModel
currentIndex: systemsettings.activeSubCategory
onContentYChanged: systemsettings.hideSubCategoryToolTip();
activeFocusOnTab: true
keyNavigationWraps: true
Accessible.role: Accessible.List
......@@ -124,6 +125,13 @@ Kirigami.ScrollablePage {
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);
......
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