From 39f9c0020505719517972bbf262306c2e0defd9c Mon Sep 17 00:00:00 2001 From: Darshan-upadhyay1110 Date: Thu, 7 Sep 2023 13:00:50 +0530 Subject: Enable QR and barcode dialog for online MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - enable QR and barcode genration dialog for online - Change Qr code genration dialog to async Change-Id: Ia46b8e27a3002adcc893e5ef4c2545d7edcc3e41 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156642 Reviewed-by: Szymon Kłos Tested-by: Jenkins CollaboraOffice (cherry picked from commit 6ed38adb5578d0b52d11d8f2077e345f9a8c7ade) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157728 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- cui/source/dialogs/QrCodeGenDialog.cxx | 27 +++++++++++++++++++++++++++ cui/source/factory/dlgfact.cxx | 4 ++-- cui/source/factory/dlgfact.hxx | 2 +- cui/source/inc/QrCodeGenDialog.hxx | 5 ++++- 4 files changed, 34 insertions(+), 4 deletions(-) (limited to 'cui') diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx index 0058ea362128..8a25e3b364e7 100644 --- a/cui/source/dialogs/QrCodeGenDialog.cxx +++ b/cui/source/dialogs/QrCodeGenDialog.cxx @@ -250,6 +250,33 @@ short QrCodeGenDialog::run() #endif } +bool QrCodeGenDialog::runAsync(const std::shared_ptr& rController, + const std::function& rFunc) +{ +#if ENABLE_ZXING + + weld::GenericDialogController::runAsync(rController, [rController, rFunc](sal_Int32 nResult) { + if (nResult == RET_OK) + { + try + { + rController->Apply(); + } + catch (const std::exception&) + { + std::unique_ptr xBox(Application::CreateMessageDialog( + rController->GetParent(), VclMessageType::Warning, VclButtonsType::Ok, + CuiResId(RID_CUISTR_QRCODEDATALONG))); + xBox->run(); + } + } + + rFunc(nResult); + }); +#endif + return true; +} + void QrCodeGenDialog::Apply() { #if ENABLE_ZXING diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index f558f9e4a37d..086fd01c5af3 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -113,7 +113,6 @@ IMPL_ABSTDLG_CLASS(AbstractGraphicFilterDialog) IMPL_ABSTDLG_CLASS(AbstractHangulHanjaConversionDialog) IMPL_ABSTDLG_CLASS(AbstractInsertObjectDialog) IMPL_ABSTDLG_CLASS(AbstractLinksDialog) -IMPL_ABSTDLG_CLASS(AbstractQrCodeGenDialog) IMPL_ABSTDLG_CLASS(AbstractScreenshotAnnotationDlg) IMPL_ABSTDLG_CLASS(AbstractSignatureLineDialog) IMPL_ABSTDLG_CLASS(AbstractSignSignatureLineDialog) @@ -132,6 +131,7 @@ IMPL_ABSTDLG_CLASS(AbstractSvxZoomDialog) IMPL_ABSTDLG_CLASS(AbstractTitleDialog) IMPL_ABSTDLG_CLASS(AbstractURLDlg) IMPL_ABSTDLG_CLASS_ASYNC(AbstractPasswordToOpenModifyDialog,weld::DialogController) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractQrCodeGenDialog,QrCodeGenDialog) IMPL_ABSTDLG_CLASS_ASYNC(AbstractPasteDialog,SfxDialogController) IMPL_ABSTDLG_CLASS_ASYNC(AbstractScriptSelectorDialog,SfxDialogController) IMPL_ABSTDLG_CLASS_ASYNC(AbstractSpellDialog,SfxDialogController) @@ -1495,7 +1495,7 @@ VclPtr AbstractDialogFactory_Impl::CreateQrCodeGenDialo weld::Window* pParent, const Reference xModel, bool bEditExisting) { return VclPtr::Create( - std::make_unique(pParent, xModel, bEditExisting)); + std::make_shared(pParent, xModel, bEditExisting)); } VclPtr AbstractDialogFactory_Impl::CreateAdditionsDialog( diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 4adc0d82ee47..38ca4beded0a 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -407,7 +407,7 @@ DECL_ABSTDLG_CLASS(AbstractSignatureLineDialog,SignatureLineDialog) }; // AbstractQrCodeGenDialog_Impl -DECL_ABSTDLG_CLASS(AbstractQrCodeGenDialog,QrCodeGenDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractQrCodeGenDialog,QrCodeGenDialog) }; // AbstractSignSignatureLineDialog_Impl diff --git a/cui/source/inc/QrCodeGenDialog.hxx b/cui/source/inc/QrCodeGenDialog.hxx index 001df88c5581..e477c0b44879 100644 --- a/cui/source/inc/QrCodeGenDialog.hxx +++ b/cui/source/inc/QrCodeGenDialog.hxx @@ -24,9 +24,11 @@ public: bool bEditExisting); virtual short run() override; + static bool runAsync(const std::shared_ptr& rController, + const std::function& rFunc); -protected: void Apply(); + weld::Widget* GetParent() { return mpParent; } private: css::uno::Reference m_xModel; @@ -34,6 +36,7 @@ private: std::unique_ptr m_xECC[4]; std::unique_ptr m_xSpinBorder; std::unique_ptr m_xComboType; + #if ENABLE_ZXING weld::Widget* mpParent; #endif -- cgit