Commit eaf352e9 authored by Marco Martin's avatar Marco Martin

add tooltips management back

parent e57fd6d2
......@@ -3,6 +3,7 @@ set( sidebar_mode_srcs
CategoryDrawer.cpp
CategorizedView.cpp
SidebarDelegate.cpp
ToolTips/tooltipmanager.cpp
)
add_library(systemsettings_sidebar_mode MODULE ${sidebar_mode_srcs})
......
......@@ -27,6 +27,7 @@
#include "MenuProxyModel.h"
#include "BaseData.h"
#include "SidebarDelegate.h"
#include "ToolTips/tooltipmanager.h"
#include <QHBoxLayout>
......@@ -35,7 +36,6 @@
#include <KStandardAction>
#include <KLocalizedString>
#include <KIconLoader>
#include <KLineEdit>
#include <KServiceTypeTrader>
#include <KXmlGuiWindow>
#include <KActionCollection>
......@@ -46,7 +46,6 @@
#include <QQuickWidget>
#include <QQmlEngine>
#include <QQmlContext>
#include <QMenu>
#include <QDebug>
K_PLUGIN_FACTORY( SidebarModeFactory, registerPlugin<SidebarMode>(); )
......@@ -58,6 +57,7 @@ public:
delete aboutIcon;
}
ToolTipManager *toolTipManager;
QQuickWidget * quickWidget;
KPackage::Package package;
QStandardItemModel * subCategoryModel;
......@@ -155,6 +155,16 @@ void SidebarMode::initEvent()
moduleView()->setFaceType(KPageView::Plain);
}
void SidebarMode::requestToolTip(int index, const QRectF &rect)
{
d->toolTipManager->requestToolTip(d->proxyModel->index(index, 0), rect.toRect());
}
void SidebarMode::hideToolTip()
{
d->toolTipManager->hideToolTip();
}
void SidebarMode::changeModule( const QModelIndex& activeModule )
{
d->moduleView->closeModules();
......@@ -243,6 +253,8 @@ void SidebarMode::initWidget()
d->quickWidget->setFixedWidth(240);
d->quickWidget->installEventFilter(this);
d->toolTipManager = new ToolTipManager(d->proxyModel, d->quickWidget);
d->mainLayout->addWidget( d->quickWidget );
d->mainLayout->addWidget( d->moduleView );
emit changeToolBarItems(BaseMode::NoItems);
......
......@@ -57,6 +57,9 @@ public:
int activeSubCategory() const;
void setActiveSubCategory(int cat);
Q_INVOKABLE void requestToolTip(int index, const QRectF &rect);
Q_INVOKABLE void hideToolTip();
protected:
QList<QAbstractItemView*> views() const;
bool eventFilter(QObject* watched, QEvent* event);
......
......@@ -80,6 +80,7 @@ Kirigami.ApplicationItem {
anchors.fill: parent
model: systemsettings.categoryModel
currentIndex: systemsettings.activeCategory
onContentYChanged: systemsettings.hideToolTip();
section {
property: "categoryDisplayRole"
delegate: Item {
......@@ -123,6 +124,11 @@ Kirigami.ApplicationItem {
subCategoryColumn.title = model.display;
}
}
onHoveredChanged: {
if (hovered) {
systemsettings.requestToolTip(index, delegate.mapToItem(root, 0, 0, width, height));
}
}
checked: systemsettings.activeCategory == index
Keys.onPressed: {
switch (event.key) {
......
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