diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-04 16:54:31 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-05 09:39:31 +0200 |
commit | 71e819a2d774aa12ae9093762f5ab6fdaaa74eac (patch) | |
tree | 15b50abaf74979038330e69e03888a9f3b78ae74 /vcl/inc | |
parent | e0b4f69ef3885ab9bf1fd5a22430f1581259fb67 (diff) |
tdf#130857 qt weld: Add a QtInstanceTextView
Add a native Qt implementation for weld::TextView
QtInstanceTextView, that uses a QPlainTextEdit,
and let QtInstanceBuilder use it when it
encounters a "GtkTextView" object in a .ui file.
Implement methods which are probably the most relevant
ones. For now, trigger an assert in case any of the not yet
implemented methods gets called.
None of the .ui files currently marked as
supported by QtInstanceBuilder uses this new class
yet, but it will be needed to support more in the future,
e.g. for cui/uiconfig/ui/objecttitledescdialog.ui.
With this commit in place, adding that file to the
set of supported ones in
QtInstanceBuilder::IsUIFileSupported makes the dialog
somehow show up as a native Qt dialog with the qt6 VCL
plugin when e.g. selecting a QR code in an existing
document, then opening the context menu and choosing
"Alt Text", but there are various issues that still
need to be fixed before it can actually be claimed
as working/supported.
Change-Id: Id7217d4a8a86f953d8b289c8a09cb8d1e2040bf1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174495
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/qt5/QtInstanceBuilder.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/qt5/QtInstanceTextView.hxx | 52 | ||||
-rw-r--r-- | vcl/inc/qt6/QtInstanceTextView.hxx | 12 |
3 files changed, 65 insertions, 1 deletions
diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx b/vcl/inc/qt5/QtInstanceBuilder.hxx index 713f7c5fed6a..3b2bde087507 100644 --- a/vcl/inc/qt5/QtInstanceBuilder.hxx +++ b/vcl/inc/qt5/QtInstanceBuilder.hxx @@ -67,7 +67,7 @@ public: virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OUString&) override; virtual std::unique_ptr<weld::IconView> weld_icon_view(const OUString&) override; virtual std::unique_ptr<weld::Label> weld_label(const OUString&) override; - virtual std::unique_ptr<weld::TextView> weld_text_view(const OUString&) override; + virtual std::unique_ptr<weld::TextView> weld_text_view(const OUString& rId) override; virtual std::unique_ptr<weld::Expander> weld_expander(const OUString&) override; virtual std::unique_ptr<weld::DrawingArea> weld_drawing_area(const OUString&, const a11yref& rA11yImpl = nullptr, diff --git a/vcl/inc/qt5/QtInstanceTextView.hxx b/vcl/inc/qt5/QtInstanceTextView.hxx new file mode 100644 index 000000000000..392527db955c --- /dev/null +++ b/vcl/inc/qt5/QtInstanceTextView.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "QtInstanceWidget.hxx" + +#include <QtWidgets/QPlainTextEdit> + +class QtInstanceTextView : public QtInstanceWidget, public virtual weld::TextView +{ + QPlainTextEdit* m_pTextEdit; + +public: + QtInstanceTextView(QPlainTextEdit* pTextEdit); + + virtual void set_text(const OUString& rText) override; + virtual OUString get_text() const override; + virtual void select_region(int nStartPos, int nEndPos) override; + virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) override; + virtual void replace_selection(const OUString& rText) override; + virtual void set_editable(bool bEditable) override; + virtual bool get_editable() const override; + virtual void set_monospace(bool bMonospace) override; + virtual void set_max_length(int nChars) override; + + virtual void set_font(const vcl::Font& rFont) override; + virtual void set_font_color(const Color& rColor) override; + + virtual bool can_move_cursor_with_up() const override; + virtual bool can_move_cursor_with_down() const override; + + virtual void cut_clipboard() override; + virtual void copy_clipboard() override; + virtual void paste_clipboard() override; + + virtual void set_alignment(TxtAlign eXAlign) override; + + virtual int vadjustment_get_value() const override; + virtual int vadjustment_get_upper() const override; + virtual int vadjustment_get_lower() const override; + virtual int vadjustment_get_page_size() const override; + virtual void vadjustment_set_value(int nValue) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt6/QtInstanceTextView.hxx b/vcl/inc/qt6/QtInstanceTextView.hxx new file mode 100644 index 000000000000..c576999abb7c --- /dev/null +++ b/vcl/inc/qt6/QtInstanceTextView.hxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../qt5/QtInstanceTextView.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |