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",
|
||||
&QCompleter::currentCompletion,
|
||||
"completionMode",
|
||||
sol::property(&QCompleter::completionMode,
|
||||
[](QCompleter *c, QCompleter::CompletionMode mode) {
|
||||
c->setCompletionMode(mode);
|
||||
}),
|
||||
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);
|
||||
});})
|
||||
);
|
||||
QObject::connect(
|
||||
&obj,
|
||||
QOverload<const QString &>::of(&QCompleter::activated),
|
||||
guard->connectionGuard.get(),
|
||||
[callback](const QString &arg) { void_safe_call(callback, arg); });
|
||||
}));
|
||||
|
||||
qt.new_usertype<QClipboard>(
|
||||
"QClipboard",
|
||||
sol::call_constructor,
|
||||
&QApplication::clipboard,
|
||||
sol::no_constructor,
|
||||
"text",
|
||||
sol::property([](QClipboard &self) { return self.text(); },
|
||||
[](QClipboard &self, const QString &value) { self.setText(value); })
|
||||
);
|
||||
sol::property(
|
||||
[](QClipboard &self) { return self.text(); },
|
||||
[](QClipboard &self, const QString &value) { self.setText(value); }));
|
||||
|
||||
qt["clipboard"] = &QApplication::clipboard;
|
||||
|
||||
mirrorEnum(qt, QMetaEnum::fromType<QCompleter::CompletionMode>(), "QCompleterCompletionMode");
|
||||
|
||||
|
@@ -11,27 +11,28 @@ qt.CompleterCompletionMode = {
|
||||
UnfilteredPopupCompletion = 2,
|
||||
};
|
||||
|
||||
---Creates QCompleter.
|
||||
---@class QCompleter
|
||||
---@field completionMode CompleterCompletionMode The completion mode.
|
||||
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.
|
||||
---@return string
|
||||
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.
|
||||
---@return QCompleter Created Completer.
|
||||
function qt.QCompleter.create(params) end
|
||||
---@class QClipboard A Lua wrapper for the Qt `QClipboard` class.
|
||||
---@field text string The text content of the clipboard. Gets or sets the text content of the clipboard.
|
||||
qt.QClipboard = {}
|
||||
|
||||
---@param function The function to be called when user choice is selected from popup.
|
||||
function qt.QCompleter.onActivated(function) 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.
|
||||
---Returns the global clipboard object.
|
||||
---@return QClipboard globalClipboard The global clipboard object.
|
||||
function qt.clipboard() end
|
||||
|
||||
---@enum TextElideMode
|
||||
qt.TextElideMode = {
|
||||
|
Reference in New Issue
Block a user