diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-01-19 09:19:03 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-02-05 05:27:51 +0100 |
commit | d25609cbd53404d3e53739a5fa3ccd9aeee10f21 (patch) | |
tree | 83c3fcbe05201f688b9708a1b47950dda190284a /vcl | |
parent | 413c6ea09b1be588e64d8f10fa096f7375949467 (diff) |
jsdialog: implemented RadioButton
Change-Id: Iad182d96cb4ff86b1a3fc8bfcca37ea62763fe67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109615
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109610
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 11 | ||||
-rw-r--r-- | vcl/jsdialog/executor.cxx | 21 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 27 |
3 files changed, 57 insertions, 2 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 4693393bdabb..4e6ce0d2f909 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -206,6 +206,8 @@ public: bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::IconView> weld_icon_view(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::RadioButton> + weld_radio_button(const OString& id, bool bTakeOwnership = false) override; static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, @@ -494,4 +496,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 834962561acb..75a474b08433 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -122,8 +122,10 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat if (separatorPos > 0) { // x;y - OString clickPosX = OUStringToOString(rData["data"].copy(0, separatorPos), RTL_TEXTENCODING_ASCII_US); - OString clickPosY = OUStringToOString(rData["data"].copy(separatorPos + 1), RTL_TEXTENCODING_ASCII_US); + OString clickPosX = OUStringToOString(rData["data"].copy(0, separatorPos), + RTL_TEXTENCODING_ASCII_US); + OString clickPosY = OUStringToOString(rData["data"].copy(separatorPos + 1), + RTL_TEXTENCODING_ASCII_US); if (!clickPosX.isEmpty() && !clickPosY.isEmpty()) { double posX = std::atof(clickPosX.getStr()); @@ -332,6 +334,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 765177ad8a9d..dca72aa5ebf1 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -688,6 +688,20 @@ 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, + bool bTakeOwnership) +{ + ::RadioButton* pRadioButton = m_xBuilder->get<::RadioButton>(id); + auto pWeldWidget + = pRadioButton ? std::make_unique<JSRadioButton>(this, pRadioButton, this, bTakeOwnership) + : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, @@ -1118,4 +1132,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: */ |