forked from qt-creator/qt-creator
Lua: Refactor Clipboard access
Clipboard is now accessed via "qt.clipboard()" to stay in line with other code that returns a global singleton. Also fixed documentation. Change-Id: I4298f036ef6558e48f36d156d6482fc0bde5d898 Reviewed-by: Artur Twardy <atw@spyro-soft.com> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -29,29 +29,27 @@ void setupQtModule()
|
|||||||
"currentCompletion",
|
"currentCompletion",
|
||||||
&QCompleter::currentCompletion,
|
&QCompleter::currentCompletion,
|
||||||
"completionMode",
|
"completionMode",
|
||||||
sol::property(&QCompleter::completionMode,
|
sol::property(
|
||||||
[](QCompleter *c, QCompleter::CompletionMode mode) {
|
&QCompleter::completionMode,
|
||||||
c->setCompletionMode(mode);
|
[](QCompleter *c, QCompleter::CompletionMode mode) { c->setCompletionMode(mode); }),
|
||||||
}),
|
|
||||||
"onActivated",
|
"onActivated",
|
||||||
sol::property([guard = pluginSpec](QCompleter &obj, sol::function callback) {
|
sol::property([guard = pluginSpec](QCompleter &obj, sol::function callback) {
|
||||||
QObject::connect(&obj,
|
QObject::connect(
|
||||||
|
&obj,
|
||||||
QOverload<const QString &>::of(&QCompleter::activated),
|
QOverload<const QString &>::of(&QCompleter::activated),
|
||||||
guard->connectionGuard.get(),
|
guard->connectionGuard.get(),
|
||||||
[callback](const QString &arg) {
|
[callback](const QString &arg) { void_safe_call(callback, arg); });
|
||||||
void_safe_call(callback, arg);
|
}));
|
||||||
});})
|
|
||||||
);
|
|
||||||
|
|
||||||
qt.new_usertype<QClipboard>(
|
qt.new_usertype<QClipboard>(
|
||||||
"QClipboard",
|
"QClipboard",
|
||||||
sol::call_constructor,
|
sol::no_constructor,
|
||||||
&QApplication::clipboard,
|
|
||||||
"text",
|
"text",
|
||||||
sol::property([](QClipboard &self) { return self.text(); },
|
sol::property(
|
||||||
[](QClipboard &self, const QString &value) { self.setText(value); })
|
[](QClipboard &self) { return self.text(); },
|
||||||
);
|
[](QClipboard &self, const QString &value) { self.setText(value); }));
|
||||||
|
|
||||||
|
qt["clipboard"] = &QApplication::clipboard;
|
||||||
|
|
||||||
mirrorEnum(qt, QMetaEnum::fromType<QCompleter::CompletionMode>(), "QCompleterCompletionMode");
|
mirrorEnum(qt, QMetaEnum::fromType<QCompleter::CompletionMode>(), "QCompleterCompletionMode");
|
||||||
|
|
||||||
|
@@ -11,27 +11,28 @@ qt.CompleterCompletionMode = {
|
|||||||
UnfilteredPopupCompletion = 2,
|
UnfilteredPopupCompletion = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
---Creates QCompleter.
|
|
||||||
---@class QCompleter
|
---@class QCompleter
|
||||||
---@field completionMode CompleterCompletionMode The completion mode.
|
---@field completionMode CompleterCompletionMode The completion mode.
|
||||||
local QCompleter = {}
|
local QCompleter = {}
|
||||||
|
|
||||||
|
---Creates a new Completer.
|
||||||
|
---@param params string[] The list of suggestions.
|
||||||
|
---@return QCompleter completer The new Completer.
|
||||||
|
function qt.QCompleter.create(params) end
|
||||||
|
|
||||||
---Returns current completion.
|
---Returns current completion.
|
||||||
---@return string
|
---@return string
|
||||||
function qt.QCompleter:currentCompletion() end
|
function qt.QCompleter:currentCompletion() end
|
||||||
|
---@param callback function The function to be called when user choice is selected from popup.
|
||||||
|
function qt.QCompleter.onActivated(callback) end
|
||||||
|
|
||||||
---@param params string list A list of suggestions.
|
---@class QClipboard A Lua wrapper for the Qt `QClipboard` class.
|
||||||
---@return QCompleter Created Completer.
|
---@field text string The text content of the clipboard. Gets or sets the text content of the clipboard.
|
||||||
function qt.QCompleter.create(params) end
|
qt.QClipboard = {}
|
||||||
|
|
||||||
---@param function The function to be called when user choice is selected from popup.
|
---Returns the global clipboard object.
|
||||||
function qt.QCompleter.onActivated(function) end
|
---@return QClipboard globalClipboard The global clipboard object.
|
||||||
|
function qt.clipboard() end
|
||||||
---@class QClipboard
|
|
||||||
--- A Lua wrapper for the Qt `QClipboard` class.
|
|
||||||
|
|
||||||
qt.QClipboard() Creates QClipboard object, which is a singleton instance of the system clipboard.
|
|
||||||
---@field text The text content of the clipboard. Gets or sets the text content of the clipboard.
|
|
||||||
|
|
||||||
---@enum TextElideMode
|
---@enum TextElideMode
|
||||||
qt.TextElideMode = {
|
qt.TextElideMode = {
|
||||||
|
Reference in New Issue
Block a user