Fixed showing plugins menu on macOS

This commit is contained in:
Eism 2022-02-21 21:46:20 +02:00
parent ab08c2568e
commit 10c5f73395
7 changed files with 24 additions and 10 deletions

View file

@ -50,8 +50,13 @@ AppWindow {
menu.addItem(menuItem)
}
item.subitemsChanged.connect(function(subitems) {
menuBar.menus[i].subitems = subitems
item.subitemsChanged.connect(function(subitems, menuId) {
for (var l in menuBar.menus) {
var menu = menuBar.menus[l]
if (menu.id === menuId) {
menuBar.menus[l].subitems = subitems
}
}
})
menuBar.addMenu(menu)
@ -61,6 +66,7 @@ AppWindow {
function makeMenu(menuInfo) {
var menu = menuComponent.createObject(menuBar)
menu.id = menuInfo.id
menu.title = menuInfo.title
menu.enabled = menuInfo.enabled
menu.subitems = menuInfo.subitems
@ -87,6 +93,7 @@ AppWindow {
id: menuComponent
PLATFORM.Menu {
property string id: ""
property var subitems: []
onAboutToShow: {

View file

@ -332,11 +332,6 @@ MenuItem* AppMenuModel::makePluginsMenu()
MenuItemList AppMenuModel::makePluginsMenuSubitems()
{
MenuItem* managePlugins = makeMenuItem("manage-plugins");
if (!managePlugins) {
return {};
}
MenuItemList subitems {
makeMenuItem("manage-plugins"),
};

View file

@ -182,7 +182,7 @@ void MenuItem::setSubitems(const QList<MenuItem*>& subitems)
}
m_subitems = subitems;
emit subitemsChanged(m_subitems);
emit subitemsChanged(m_subitems, m_id);
}
void MenuItem::setAction(const UiAction& action)

View file

@ -111,7 +111,7 @@ signals:
void selectableChanged(bool selectable);
void selectedChanged(bool selected);
void roleChanged(int role);
void subitemsChanged(QList<mu::uicomponents::MenuItem*> subitems);
void subitemsChanged(QList<mu::uicomponents::MenuItem*> subitems, const QString& menuId);
void actionChanged();
private:

View file

@ -64,6 +64,14 @@ void PluginsModule::registerExports()
ioc()->registerExport<IPluginsConfiguration>(moduleName(), s_configuration);
}
void PluginsModule::resolveImports()
{
auto ar = ioc()->resolve<ui::IUiActionsRegister>(moduleName());
if (ar) {
ar->reg(s_pluginsUiActions);
}
}
void PluginsModule::registerResources()
{
plugins_init_qrc();
@ -95,6 +103,7 @@ void PluginsModule::onDelayedInit()
auto ar = ioc()->resolve<ui::IUiActionsRegister>(moduleName());
if (ar) {
//! NOTE: Re-registration of actions for new available plugins
ar->reg(s_pluginsUiActions);
//! NOTE: Notify about plugins changed for updating actions state

View file

@ -31,6 +31,7 @@ public:
std::string moduleName() const override;
void registerExports() override;
void resolveImports() override;
void registerResources() override;
void registerUiTypes() override;
void onInit(const framework::IApplication::RunMode& mode) override;

View file

@ -25,6 +25,8 @@
#include "translation.h"
#include "log.h"
#include "shortcuts/shortcutstypes.h"
using namespace mu::plugins;
using namespace mu::framework;
using namespace mu::async;
@ -112,7 +114,7 @@ QVariant PluginsModel::data(const QModelIndex& index, int role) const
return plugin.version.toString();
case rShortcuts:
if (!plugin.shortcuts.empty()) {
return QString::fromStdString(plugin.shortcuts);
return shortcuts::sequencesToNativeText(shortcuts::Shortcut::sequencesFromString(plugin.shortcuts));
}
return qtrc("plugins", "Not defined");