forked from qt-creator/qt-creator
Lua: Expose QCompleter
Change-Id: I93f0adad78d3cff23a5431ad211e66b481360d1f Reviewed-by: <lie@spyro-soft.com> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include "../luaengine.h"
|
#include "../luaengine.h"
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <QCompleter>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
namespace Lua::Internal {
|
namespace Lua::Internal {
|
||||||
@@ -11,6 +14,32 @@ void setupQtModule()
|
|||||||
{
|
{
|
||||||
registerProvider("Qt", [](sol::state_view lua) {
|
registerProvider("Qt", [](sol::state_view lua) {
|
||||||
sol::table qt(lua, sol::create);
|
sol::table qt(lua, sol::create);
|
||||||
|
const ScriptPluginSpec *pluginSpec = lua.get<ScriptPluginSpec *>("PluginSpec");
|
||||||
|
|
||||||
|
qt.new_usertype<QCompleter>(
|
||||||
|
"QCompleter",
|
||||||
|
"create",
|
||||||
|
[](const QStringList &list) -> std::unique_ptr<QCompleter> {
|
||||||
|
return std::make_unique<QCompleter>(list);
|
||||||
|
},
|
||||||
|
"currentCompletion",
|
||||||
|
&QCompleter::currentCompletion,
|
||||||
|
"completionMode",
|
||||||
|
sol::property(&QCompleter::completionMode,
|
||||||
|
[](QCompleter *c, QCompleter::CompletionMode mode) {
|
||||||
|
c->setCompletionMode(mode);
|
||||||
|
}),
|
||||||
|
"onActivated",
|
||||||
|
sol::property([guard = pluginSpec](QCompleter &obj, sol::function callback) {
|
||||||
|
QObject::connect(&obj,
|
||||||
|
QOverload<const QString &>::of(&QCompleter::activated),
|
||||||
|
guard->connectionGuard.get(),
|
||||||
|
[callback](const QString &arg) {
|
||||||
|
void_safe_call(callback, arg);
|
||||||
|
});})
|
||||||
|
);
|
||||||
|
|
||||||
|
mirrorEnum(qt, QMetaEnum::fromType<QCompleter::CompletionMode>(), "QCompleterCompletionMode");
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
qt["TextElideMode"] = lua.create_table_with(
|
qt["TextElideMode"] = lua.create_table_with(
|
||||||
|
@@ -4,6 +4,29 @@
|
|||||||
|
|
||||||
local qt = {}
|
local qt = {}
|
||||||
|
|
||||||
|
---@enum CompleterCompletionMode
|
||||||
|
qt.CompleterCompletionMode = {
|
||||||
|
PopupCompletion = 0,
|
||||||
|
InlineCompletion = 1,
|
||||||
|
UnfilteredPopupCompletion = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
---Creates QCompleter.
|
||||||
|
---@class QCompleter
|
||||||
|
---@field completionMode CompleterCompletionMode The completion mode.
|
||||||
|
local QCompleter = {}
|
||||||
|
|
||||||
|
---Returns current completion.
|
||||||
|
---@return string
|
||||||
|
function qt.QCompleter:currentCompletion() end
|
||||||
|
|
||||||
|
---@param params string list A list of suggestions.
|
||||||
|
---@return QCompleter Created Completer.
|
||||||
|
function qt.QCompleter.create(params) end
|
||||||
|
|
||||||
|
---@param function The function to be called when user choice is selected from popup.
|
||||||
|
function qt.QCompleter.onActivated(function) end
|
||||||
|
|
||||||
---@enum TextElideMode
|
---@enum TextElideMode
|
||||||
qt.TextElideMode = {
|
qt.TextElideMode = {
|
||||||
ElideLeft = 0,
|
ElideLeft = 0,
|
||||||
|
Reference in New Issue
Block a user