Commit 8abee08b authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Folder View] Turn MenuHelper into a singleton type

It doesn't store any state but just has methods invoked on it.
Now we create only one MenuHelper instead of one per applet.

Differential Revision: https://phabricator.kde.org/D8008
parent b30310b8
......@@ -79,10 +79,6 @@ Item {
size: "16x16"
}
Folder.MenuHelper {
id: menuHelper
}
Folder.ViewPropertiesMenu {
id: viewPropertiesMenu
......@@ -390,14 +386,14 @@ Item {
for (var i = 0; i < sharedActions.length; i++) {
actionName = sharedActions[i];
modelAction = folderView.model.action(actionName);
plasmoid.setAction(actionName, modelAction.text, menuHelper.iconName(modelAction));
plasmoid.setAction(actionName, modelAction.text, Folder.MenuHelper.iconName(modelAction));
if (actionName == "newMenu") {
menuHelper.setMenu(plasmoid.action(actionName), folderView.model.newMenu);
Folder.MenuHelper.setMenu(plasmoid.action(actionName), folderView.model.newMenu);
plasmoid.setActionSeparator("separator1");
plasmoid.setAction("viewProperties", i18n("Icons"), "preferences-desktop-icons");
menuHelper.setMenu(plasmoid.action("viewProperties"), viewPropertiesMenu.menu);
Folder.MenuHelper.setMenu(plasmoid.action("viewProperties"), viewPropertiesMenu.menu);
} else {
plasmoid.action(actionName).triggered.connect(modelAction.trigger);
}
......
......@@ -35,6 +35,13 @@
#include <QtQml>
static QObject *menuHelperSingletonProvider(QQmlEngine *engine, QJSEngine *jsEngine)
{
Q_UNUSED(engine);
Q_UNUSED(jsEngine);
return new MenuHelper();
}
void FolderPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.private.desktopcontainment.folder"));
......@@ -42,7 +49,7 @@ void FolderPlugin::registerTypes(const char *uri)
qmlRegisterType<FolderModel>(uri, 0, 1, "FolderModel");
qmlRegisterType<ItemViewAdapter>(uri, 0, 1, "ItemViewAdapter");
qmlRegisterType<LabelGenerator>(uri, 0, 1, "LabelGenerator");
qmlRegisterType<MenuHelper>(uri, 0, 1, "MenuHelper");
qmlRegisterSingletonType<MenuHelper>(uri, 0, 1, "MenuHelper", menuHelperSingletonProvider);
qmlRegisterType<MimeTypesModel>(uri, 0, 1, "MimeTypesModel");
qmlRegisterType<PlacesModel>(uri, 0, 1, "PlacesModel");
qmlRegisterType<Positioner>(uri, 0, 1, "Positioner");
......
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