Commit 740beb76 authored by Marco Martin's avatar Marco Martin

add icons in the menu

parent 2656bad0
......@@ -52,7 +52,14 @@ K_PLUGIN_FACTORY( SidebarModeFactory, registerPlugin<SidebarMode>(); )
class SidebarMode::Private {
public:
Private() : quickWidget( 0 ), moduleView( 0 ), activeCategory( -1 ), activeSubCategory( -1 ) {}
Private()
: quickWidget( nullptr ),
moduleView( nullptr ),
collection( nullptr ),
activeCategory( -1 ),
activeSubCategory( -1 )
{}
virtual ~Private() {
delete aboutIcon;
}
......@@ -67,7 +74,7 @@ public:
MenuProxyModel * proxyModel;
KAboutData * aboutIcon;
ModuleView * moduleView;
QList<QObject *> globalActions;
KActionCollection *collection;
int activeCategory;
int activeSubCategory;
};
......@@ -119,11 +126,6 @@ QAbstractItemModel * SidebarMode::subCategoryModel() const
return d->subCategoryModel;
}
QList<QObject *> SidebarMode::globalActions() const
{
return d->globalActions;
}
QList<QAbstractItemView*> SidebarMode::views() const
{
QList<QAbstractItemView*> list;
......@@ -155,6 +157,18 @@ void SidebarMode::initEvent()
moduleView()->setFaceType(KPageView::Plain);
}
void SidebarMode::triggerGlobalAction(const QString &name)
{
if (!d->collection) {
return;
}
QAction *action = d->collection->action(name);
if (action) {
action->trigger();
}
}
void SidebarMode::requestToolTip(int index, const QRectF &rect)
{
d->toolTipManager->requestToolTip(d->proxyModel->index(index, 0), rect.toRect());
......@@ -232,11 +246,7 @@ void SidebarMode::initWidget()
if (!KMainWindow::memberList().isEmpty()) {
KXmlGuiWindow *mainWindow = qobject_cast<KXmlGuiWindow *>(KMainWindow::memberList().first());
if (mainWindow) {
KActionCollection *collection = mainWindow->actionCollection();
d->globalActions << collection->action("configure")
<< collection->action("help_contents")
<< collection->action("help_about_app")
<< collection->action("help_about_kde");
d->collection = mainWindow->actionCollection();
}
}
......
......@@ -34,7 +34,6 @@ class SidebarMode : public BaseMode
Q_PROPERTY(QAbstractItemModel *categoryModel READ categoryModel CONSTANT)
Q_PROPERTY(QAbstractItemModel *subCategoryModel READ subCategoryModel CONSTANT)
Q_PROPERTY(QList<QObject *> globalActions READ globalActions CONSTANT)
Q_PROPERTY(int activeCategory READ activeCategory WRITE setActiveCategory NOTIFY activeCategoryChanged)
Q_PROPERTY(int activeSubCategory READ activeSubCategory WRITE setActiveSubCategory NOTIFY activeSubCategoryChanged)
......@@ -49,7 +48,6 @@ public:
ModuleView * moduleView() const;
QAbstractItemModel *categoryModel() const;
QAbstractItemModel *subCategoryModel() const;
QList<QObject *> globalActions() const;
int activeCategory() const;
void setActiveCategory(int cat);
......@@ -57,6 +55,7 @@ public:
int activeSubCategory() const;
void setActiveSubCategory(int cat);
Q_INVOKABLE void triggerGlobalAction(const QString &name);
Q_INVOKABLE void requestToolTip(int index, const QRectF &rect);
Q_INVOKABLE void hideToolTip();
......
......@@ -39,15 +39,25 @@ Kirigami.ScrollablePage {
iconName: "application-menu"
menu: QtControls.Menu {
id: globalMenu
Instantiator {
model: systemsettings.globalActions
QtControls.MenuItem {
text: modelData.text
property QtObject action: modelData
onTriggered: action.trigger();
}
onObjectAdded: globalMenu.insertItem(index, object)
onObjectRemoved: globalMenu.removeItem(object)
QtControls.MenuItem {
text: i18n("Configure")
iconName: "settings-configure"
onTriggered: systemsettings.triggerGlobalAction("configure");
}
QtControls.MenuItem {
text: i18n("System Settings Handbook")
iconName: "help-contents"
onTriggered: systemsettings.triggerGlobalAction("help_contents");
}
QtControls.MenuItem {
text: i18n("About System Settings")
iconName: "help-about"
onTriggered: systemsettings.triggerGlobalAction("help_about_app");
}
QtControls.MenuItem {
text: i18n("About KDE")
iconName: "kde"
onTriggered: systemsettings.triggerGlobalAction("help_about_kde");
}
}
}
......
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