diff options
author | Mert Tumer <mert.tumer@collabora.com> | 2022-09-12 12:58:20 +0300 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-11-21 11:45:10 +0100 |
commit | 67eb60672936a10fba840078e6aca918c3331f52 (patch) | |
tree | be75c38f175d682aa4834d9064cb11171604c13a /cui | |
parent | 2adaac8bf01a6caffd0eedb9f456eeadc43f1759 (diff) |
lok: make properties>change password dialog async
* We now can set a password through properties->change password
without having to have a password initially only for online
because it needs a created file already, online works with files
that are created before loading but the desktop does not need this.
* The same dialog is still used as non-async for desktop version
because it goes through an InteractionHandler and the result is
expected not from the dialog but from the interaction handler.
Therefore, making it async there did not make sense.
Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: I3d02822be0b71836b1592abca191b3b1c5f6374e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139884
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142991
Tested-by: Jenkins
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/passwdomdlg.cxx | 47 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.cxx | 7 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.hxx | 3 | ||||
-rw-r--r-- | cui/source/inc/passwdomdlg.hxx | 2 |
4 files changed, 38 insertions, 21 deletions
diff --git a/cui/source/dialogs/passwdomdlg.cxx b/cui/source/dialogs/passwdomdlg.cxx index 8a8fcb35842f..163f3961f22e 100644 --- a/cui/source/dialogs/passwdomdlg.cxx +++ b/cui/source/dialogs/passwdomdlg.cxx @@ -29,10 +29,10 @@ IMPL_LINK_NOARG(PasswordToOpenModifyDialog, OkBtnClickHdl, weld::Button&, void) m_xPasswdToModifyED->get_text().isEmpty(); if (bInvalidState) { - std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(), + m_xErrorBox.reset(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, m_bIsPasswordToModify? m_aInvalidStateForOkButton : m_aInvalidStateForOkButton_v2)); - xErrorBox->run(); + m_xErrorBox->runAsync(m_xErrorBox, [](sal_Int32 /*nResult*/) {}); } else // check for mismatched passwords... { @@ -41,26 +41,27 @@ IMPL_LINK_NOARG(PasswordToOpenModifyDialog, OkBtnClickHdl, weld::Button&, void) const int nMismatch = (bToOpenMatch? 0 : 1) + (bToModifyMatch? 0 : 1); if (nMismatch > 0) { - std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(), + m_xErrorBox.reset(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, nMismatch == 1 ? m_aOneMismatch : m_aTwoMismatch)); - xErrorBox->run(); - - weld::Entry* pEdit = !bToOpenMatch ? m_xPasswdToOpenED.get() : m_xPasswdToModifyED.get(); - weld::Entry* pRepeatEdit = !bToOpenMatch? m_xReenterPasswdToOpenED.get() : m_xReenterPasswdToModifyED.get(); - if (nMismatch == 1) - { - pEdit->set_text( "" ); - pRepeatEdit->set_text( "" ); - } - else if (nMismatch == 2) + m_xErrorBox->runAsync(m_xErrorBox, [this, bToOpenMatch, nMismatch](sal_Int32 /*nResult*/) { - m_xPasswdToOpenED->set_text( "" ); - m_xReenterPasswdToOpenED->set_text( "" ); - m_xPasswdToModifyED->set_text( "" ); - m_xReenterPasswdToModifyED->set_text( "" ); - } - pEdit->grab_focus(); + weld::Entry* pEdit = !bToOpenMatch ? m_xPasswdToOpenED.get() : m_xPasswdToModifyED.get(); + weld::Entry* pRepeatEdit = !bToOpenMatch? m_xReenterPasswdToOpenED.get() : m_xReenterPasswdToModifyED.get(); + if (nMismatch == 1) + { + pEdit->set_text( "" ); + pRepeatEdit->set_text( "" ); + } + else if (nMismatch == 2) + { + m_xPasswdToOpenED->set_text( "" ); + m_xReenterPasswdToOpenED->set_text( "" ); + m_xPasswdToModifyED->set_text( "" ); + m_xReenterPasswdToModifyED->set_text( "" ); + } + pEdit->grab_focus(); + }); } else { @@ -136,6 +137,14 @@ PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, s ReadonlyOnOffHdl(*m_xOpenReadonlyCB); } +PasswordToOpenModifyDialog::~PasswordToOpenModifyDialog() +{ + if (m_xErrorBox) + { + m_xErrorBox->response(RET_CANCEL); + } +} + OUString PasswordToOpenModifyDialog::GetPasswordToOpen() const { const bool bPasswdOk = diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 0cd8d39688ad..9bd3f0229be4 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -114,7 +114,6 @@ IMPL_ABSTDLG_CLASS(AbstractGraphicFilterDialog) IMPL_ABSTDLG_CLASS(AbstractHangulHanjaConversionDialog) IMPL_ABSTDLG_CLASS(AbstractInsertObjectDialog) IMPL_ABSTDLG_CLASS(AbstractLinksDialog) -IMPL_ABSTDLG_CLASS(AbstractPasswordToOpenModifyDialog) IMPL_ABSTDLG_CLASS(AbstractQrCodeGenDialog) IMPL_ABSTDLG_CLASS(AbstractScreenshotAnnotationDlg) IMPL_ABSTDLG_CLASS(AbstractSignatureLineDialog) @@ -133,6 +132,7 @@ IMPL_ABSTDLG_CLASS(AbstractSvxSearchSimilarityDialog) IMPL_ABSTDLG_CLASS(AbstractSvxZoomDialog) IMPL_ABSTDLG_CLASS(AbstractTitleDialog) IMPL_ABSTDLG_CLASS(AbstractURLDlg) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractPasswordToOpenModifyDialog,weld::DialogController) IMPL_ABSTDLG_CLASS_ASYNC(AbstractPasteDialog,SfxDialogController) IMPL_ABSTDLG_CLASS_ASYNC(AbstractScriptSelectorDialog,SfxDialogController) IMPL_ABSTDLG_CLASS_ASYNC(AbstractSpellDialog,SfxDialogController) @@ -804,6 +804,11 @@ bool AbstractPasswordToOpenModifyDialog_Impl::IsRecommendToOpenReadonly() const return m_xDlg->IsRecommendToOpenReadonly(); } +void AbstractPasswordToOpenModifyDialog_Impl::Response(sal_Int32 nResult) +{ + m_xDlg->response(nResult); +} + // Create dialogs with simplest interface VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateVclDialog(weld::Window* pParent, sal_uInt32 nResId) { diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index eb52630d0199..071c71592b50 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -383,10 +383,11 @@ private: }; // AbstractPasswordToOpenModifyDialog_Impl -DECL_ABSTDLG_CLASS(AbstractPasswordToOpenModifyDialog,PasswordToOpenModifyDialog) +DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractPasswordToOpenModifyDialog,AbstractPasswordToOpenModifyDialog, PasswordToOpenModifyDialog) virtual OUString GetPasswordToOpen() const override; virtual OUString GetPasswordToModify() const override; virtual bool IsRecommendToOpenReadonly() const override; + virtual void Response(sal_Int32) override; }; // AbstractSvxCharacterMapDialog_Impl diff --git a/cui/source/inc/passwdomdlg.hxx b/cui/source/inc/passwdomdlg.hxx index 2e13cc1b616c..9b1cd460ea7c 100644 --- a/cui/source/inc/passwdomdlg.hxx +++ b/cui/source/inc/passwdomdlg.hxx @@ -36,6 +36,7 @@ class PasswordToOpenModifyDialog : public SfxDialogController std::unique_ptr<weld::Label> m_xReenterPasswdToModifyFT; std::unique_ptr<weld::Entry> m_xReenterPasswdToModifyED; std::unique_ptr<weld::Label> m_xReenterPasswdToModifyInd; + std::shared_ptr<weld::MessageDialog> m_xErrorBox; OUString m_aOneMismatch; OUString m_aTwoMismatch; @@ -57,6 +58,7 @@ public: PasswordToOpenModifyDialog(weld::Window* pParent, sal_uInt16 nMaxPasswdLen /* 0 -> no max len enforced */, bool bIsPasswordToModify ); + ~PasswordToOpenModifyDialog(); // AbstractPasswordToOpenModifyDialog OUString GetPasswordToOpen() const; |