vcl/inc/jsdialog/jsdialogbuilder.hxx | 10 ++++++++++ vcl/jsdialog/executor.cxx | 15 +++++++++++++++ vcl/jsdialog/jsdialogbuilder.cxx | 25 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+)
New commits: commit 38d01e5af250fb18aa41db8eeafaa644004a0ed4 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Jan 19 09:19:03 2021 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Jan 20 15:05:47 2021 +0100 jsdialog: implemented RadioButton Change-Id: Iad182d96cb4ff86b1a3fc8bfcca37ea62763fe67 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109615 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index a1c320c16159..cefa5776c79b 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -190,6 +190,7 @@ public: virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id) override; virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id) override; virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id) override; + virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString& id) override; static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, @@ -476,4 +477,13 @@ public: virtual void unselect(int pos) override; }; +class JSRadioButton : public JSWidget<SalInstanceRadioButton, ::RadioButton> +{ +public: + JSRadioButton(JSDialogSender* pSender, ::RadioButton* pRadioButton, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_active(bool active) 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 f2d4d61ecf61..655104633410 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -316,6 +316,21 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat } } } + else if (sControlType == "radiobutton") + { + auto pRadioButton = dynamic_cast<weld::RadioButton*>(pWidget); + if (pRadioButton) + { + if (sAction == "change") + { + bool bChecked = rData["data"] == "true"; + pRadioButton->set_state(bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); + LOKTrigger::trigger_clicked(*static_cast<weld::Button*>(pRadioButton)); + LOKTrigger::trigger_toggled(*static_cast<weld::ToggleButton*>(pRadioButton)); + return true; + } + } + } } return false; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 140e3fa2b755..38ef2a44e354 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -681,6 +681,18 @@ std::unique_ptr<weld::IconView> JSInstanceBuilder::weld_icon_view(const OString& return pWeldWidget; } +std::unique_ptr<weld::RadioButton> JSInstanceBuilder::weld_radio_button(const OString& id) +{ + ::RadioButton* pRadioButton = m_xBuilder->get<::RadioButton>(id); + auto pWeldWidget + = pRadioButton ? std::make_unique<JSRadioButton>(this, pRadioButton, this, false) : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, @@ -1108,4 +1120,17 @@ void JSIconView::unselect(int pos) notifyDialogState(); } +JSRadioButton::JSRadioButton(JSDialogSender* pSender, ::RadioButton* pRadioButton, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceRadioButton, ::RadioButton>(pSender, pRadioButton, pBuilder, + bTakeOwnership) +{ +} + +void JSRadioButton::set_active(bool active) +{ + SalInstanceRadioButton::set_active(active); + notifyDialogState(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits