diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-03-17 14:50:39 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-06-22 13:49:16 +0200 |
commit | f89557039270791e7d269460fd5cb988f9380260 (patch) | |
tree | 1b57f7b1d72bb32517e8d3f74bf01e7d62b1e2e3 /vcl | |
parent | e1b6dcc97d6b5ff15b2e9341d3943ffc05aa3236 (diff) |
jsdialog: use for message dialogs on mobile
Change-Id: Ib172dc264d7f55fef08dc474f7e6f4d1b3108085
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94431
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96836
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 44 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 8 |
2 files changed, 50 insertions, 2 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 88d84d56da94..c360eee7b9e6 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -6,6 +6,7 @@ #include <vcl/toolkit/dialog.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <vcl/toolkit/combobox.hxx> +#include <messagedialog.hxx> void JSDialogSender::notifyDialogState() { @@ -204,6 +205,30 @@ std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& return pWeldWidget; } +weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, + VclMessageType eMessageType, + VclButtonsType eButtonType, + const OUString& rPrimaryMessage) +{ + SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent); + SystemWindow* pParentWidget = pParentInstance ? pParentInstance->getSystemWindow() : nullptr; + VclPtrInstance<::MessageDialog> xMessageDialog(pParentWidget, rPrimaryMessage, eMessageType, + eButtonType); + + const vcl::ILibreOfficeKitNotifier* pNotifier = xMessageDialog->GetLOKNotifier(); + if (pNotifier) + { + std::stringstream aStream; + boost::property_tree::ptree aTree = xMessageDialog->DumpAsPropertyTree(); + aTree.put("id", xMessageDialog->GetLOKWindowId()); + boost::property_tree::write_json(aStream, aTree); + const std::string message = aStream.str(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + } + + return new JSMessageDialog(xMessageDialog, nullptr, true); +} + JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership) @@ -322,3 +347,22 @@ void JSNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int SalInstanceNotebook::insert_page(rIdent, rLabel, nPos); notifyDialogState(); } + +JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) + , JSDialogSender(m_xMessageDialog) +{ +} + +void JSMessageDialog::set_primary_text(const OUString& rText) +{ + SalInstanceMessageDialog::set_primary_text(rText); + notifyDialogState(); +} + +void JSMessageDialog::set_secondary_text(const OUString& rText) +{ + SalInstanceMessageDialog::set_secondary_text(rText); + notifyDialogState(); +} diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index e6e2d7415933..7837320d30b5 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -178,9 +178,13 @@ weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUS } weld::MessageDialog* Application::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, - VclButtonsType eButtonType, const OUString& rPrimaryMessage) + VclButtonsType eButtonType, const OUString& rPrimaryMessage, + bool bMobile) { - return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); + if (bMobile) + return JSInstanceBuilder::CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); + else + return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); } weld::Window* Application::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) |