From 9f93e2261b84d0cfd82627f87ef713f9118b4266 Mon Sep 17 00:00:00 2001 From: Artur Twardy Date: Tue, 1 Oct 2024 20:35:46 +0200 Subject: [PATCH] Lua: Expose QClipboard class in Qt package Change-Id: I931bf619b1f4e94ae651d7c5eb7d21e79f3dfc93 Reviewed-by: Reviewed-by: hjk --- src/plugins/lua/bindings/qt.cpp | 12 ++++++++++++ src/plugins/lua/meta/qt.lua | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/plugins/lua/bindings/qt.cpp b/src/plugins/lua/bindings/qt.cpp index 58864a5ef33..733eac85a4d 100644 --- a/src/plugins/lua/bindings/qt.cpp +++ b/src/plugins/lua/bindings/qt.cpp @@ -5,6 +5,8 @@ #include "utils.h" +#include +#include #include #include @@ -39,6 +41,16 @@ void setupQtModule() });}) ); + qt.new_usertype( + "QClipboard", + sol::call_constructor, + &QApplication::clipboard, + "text", + sol::property([](QClipboard &self) { return self.text(); }, + [](QClipboard &self, const QString &value) { self.setText(value); }) + ); + + mirrorEnum(qt, QMetaEnum::fromType(), "QCompleterCompletionMode"); // clang-format off diff --git a/src/plugins/lua/meta/qt.lua b/src/plugins/lua/meta/qt.lua index e0d04093d67..6adaa261fc3 100644 --- a/src/plugins/lua/meta/qt.lua +++ b/src/plugins/lua/meta/qt.lua @@ -27,6 +27,12 @@ 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 +---@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 qt.TextElideMode = { ElideLeft = 0,