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
This commit is contained in:
parent
e1b6dcc97d
commit
f895570392
6 changed files with 73 additions and 5 deletions
|
@ -52,6 +52,10 @@ public:
|
|||
virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id,
|
||||
bool bTakeOwnership = false) override;
|
||||
|
||||
static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent,
|
||||
VclMessageType eMessageType,
|
||||
VclButtonsType eButtonType,
|
||||
const OUString& rPrimaryMessage);
|
||||
static weld::Widget* FindWeldWidgetsMap(vcl::LOKWindowId nWindowId, const OString& rWidget);
|
||||
};
|
||||
|
||||
|
@ -146,4 +150,14 @@ public:
|
|||
virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override;
|
||||
};
|
||||
|
||||
class VCL_DLLPUBLIC JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender
|
||||
{
|
||||
public:
|
||||
JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
|
||||
|
||||
virtual void set_primary_text(const OUString& rText) override;
|
||||
|
||||
virtual void set_secondary_text(const OUString& rText) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1062,7 +1062,7 @@ public:
|
|||
|
||||
class SalInstanceMessageDialog : public SalInstanceDialog, public virtual weld::MessageDialog
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
VclPtr<::MessageDialog> m_xMessageDialog;
|
||||
|
||||
public:
|
||||
|
|
|
@ -1332,7 +1332,8 @@ public:
|
|||
static weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile); //for the duration of vcl parent windows
|
||||
|
||||
static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType,
|
||||
VclButtonsType eButtonType, const OUString& rPrimaryMessage);
|
||||
VclButtonsType eButtonType, const OUString& rPrimaryMessage,
|
||||
bool bMobile = false);
|
||||
|
||||
static weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow);
|
||||
private:
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#include <tokenarray.hxx>
|
||||
#include <scmatrix.hxx>
|
||||
#include <cellvalue.hxx>
|
||||
#include <comphelper/lok.hxx>
|
||||
#include <sfx2/lokhelper.hxx>
|
||||
|
||||
#include <math.h>
|
||||
#include <memory>
|
||||
|
@ -405,8 +407,11 @@ bool ScValidationData::DoError(weld::Window* pParent, const OUString& rInput,
|
|||
break;
|
||||
}
|
||||
|
||||
bool bIsMobile = comphelper::LibreOfficeKit::isActive()
|
||||
&& SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone();
|
||||
|
||||
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, eType,
|
||||
eStyle, aMessage));
|
||||
eStyle, aMessage, bIsMobile));
|
||||
xBox->set_title(aTitle);
|
||||
|
||||
switch (eErrorStyle)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue