forked from qt-creator/qt-creator
Lua: Add Action icon option
Change-Id: I18d928f490fc908b0a4f170957a7f37266509b50 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "../luaengine.h"
|
#include "../luaengine.h"
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
@@ -51,6 +53,10 @@ void setupActionModule()
|
|||||||
[](ScriptCommand *cmd) { return cmd->m_contextAction->text(); },
|
[](ScriptCommand *cmd) { return cmd->m_contextAction->text(); },
|
||||||
[](ScriptCommand *cmd, const QString &text) {
|
[](ScriptCommand *cmd, const QString &text) {
|
||||||
cmd->m_contextAction->setText(text);
|
cmd->m_contextAction->setText(text);
|
||||||
|
}),
|
||||||
|
"icon",
|
||||||
|
sol::property([](ScriptCommand *cmd, const FilePathOrString &&icon) {
|
||||||
|
cmd->m_contextAction->setIcon(QIcon(toFilePath(icon).toFSPathString()));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
result["create"] = [parent = std::make_unique<QObject>()](
|
result["create"] = [parent = std::make_unique<QObject>()](
|
||||||
@@ -93,6 +99,8 @@ void setupActionModule()
|
|||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"asMode needs an integer argument for the priority");
|
"asMode needs an integer argument for the priority");
|
||||||
}
|
}
|
||||||
|
} else if (key == "icon") {
|
||||||
|
b.setIcon(QIcon(toFilePath(v.as<FilePathOrString>()).toFSPathString()));
|
||||||
} else
|
} else
|
||||||
throw std::runtime_error("Unknown key: " + key.toStdString());
|
throw std::runtime_error("Unknown key: " + key.toStdString());
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ action.CommandAttribute = {
|
|||||||
---@class ActionOptions
|
---@class ActionOptions
|
||||||
---@field context? string The context in which the action is available.
|
---@field context? string The context in which the action is available.
|
||||||
---@field text? string The text to display for the action.
|
---@field text? string The text to display for the action.
|
||||||
|
---@field icon? FilePath|string The icon to display for the action.
|
||||||
---@field iconText? string The icon text to display for the action.
|
---@field iconText? string The icon text to display for the action.
|
||||||
---@field toolTip? string The tooltip to display for the action.
|
---@field toolTip? string The tooltip to display for the action.
|
||||||
---@field onTrigger? function The callback to call when the action is triggered.
|
---@field onTrigger? function The callback to call when the action is triggered.
|
||||||
|
Reference in New Issue
Block a user