diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-07-02 14:44:24 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-07-16 13:24:59 +0200 |
commit | 10775fb4006dcdf3ce5b01179b4d9a6f009d8592 (patch) | |
tree | a811e2948c092487be5a71917f11e7016ce9d2b3 /vcl | |
parent | b1b95b80b54819ced62443d3c87ec6ced27f81a9 (diff) |
jsdialog: weld text view
Change-Id: Ia3bae7a8b812e791fc6a8888e63adca17b8910d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98883
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 12 | ||||
-rw-r--r-- | vcl/jsdialog/executor.cxx | 11 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 29 |
3 files changed, 52 insertions, 0 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 1622cc0f6ade..c9673e778c16 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -21,6 +21,8 @@ class ToolBox; class ComboBox; +class VclMultiLineEdit; + typedef std::map<OString, weld::Widget*> WidgetMap; class JSDialogNotifyIdle : public Idle @@ -92,6 +94,8 @@ public: bool bTakeOwnership = false) override; std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id, bool bTakeOwnership = false) override; + std::unique_ptr<weld::TextView> weld_text_view(const OString& id, + bool bTakeOwnership = false) override; static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, @@ -249,4 +253,12 @@ public: virtual void signal_clicked(const OString& rIdent) override; }; +class JSTextView : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit> +{ +public: + JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + virtual void set_text(const OUString& rText) override; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 1df6af10c9c6..53fded14e1c1 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -131,6 +131,17 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat return true; } } + + auto pTextView = dynamic_cast<weld::TextView*>(pWidget); + if (pTextView) + { + if (sAction == "change") + { + pTextView->set_text(rData["data"]); + LOKTrigger::trigger_changed(*pTextView); + return true; + } + } } } diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index e3245a40a73b..33a7b8c3c992 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -20,6 +20,7 @@ #include <o3tl/deleter.hxx> #include <memory> #include <vcl/toolbox.hxx> +#include <vcl/vclmedit.hxx> JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow) : Idle("JSDialog notify") @@ -331,6 +332,21 @@ std::unique_ptr<weld::Toolbar> JSInstanceBuilder::weld_toolbar(const OString& id return pWeldWidget; } +std::unique_ptr<weld::TextView> JSInstanceBuilder::weld_text_view(const OString& id, + bool bTakeOwnership) +{ + VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id); + auto pWeldWidget = pTextView ? std::make_unique<JSTextView>( + m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, + pTextView, this, bTakeOwnership) + : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, @@ -570,4 +586,17 @@ void JSToolbar::signal_clicked(const OString& rIdent) notifyDialogState(); } +JSTextView::JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(aOwnedToplevel, pTextView, pBuilder, + bTakeOwnership) +{ +} + +void JSTextView::set_text(const OUString& rText) +{ + SalInstanceTextView::set_text(rText); + notifyDialogState(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |