[Libreoffice-commits] core.git: uui/source uui/uiconfig
Caolán McNamara
caolanm at redhat.com
Fri Mar 16 20:32:32 UTC 2018
uui/source/iahndl-authentication.cxx | 12 ++---
uui/source/passworddlg.cxx | 74 +++++++++++++----------------------
uui/source/passworddlg.hxx | 27 ++++--------
uui/uiconfig/ui/password.ui | 15 +++++--
4 files changed, 56 insertions(+), 72 deletions(-)
New commits:
commit d2f95590f478a68a4de6ef05018785523e46506b
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Mar 16 16:07:22 2018 +0000
Related: tdf#115964 convert the problematic dialog to a native gtk3 one
Change-Id: I84e10f1c45dfbe267f9b350d74271ac149bdaf43
Reviewed-on: https://gerrit.libreoffice.org/51432
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx
index 12ed4ed7aff9..2d4d5362f169 100644
--- a/uui/source/iahndl-authentication.cxx
+++ b/uui/source/iahndl-authentication.cxx
@@ -518,11 +518,11 @@ executePasswordDialog(
{
if (bIsSimplePasswordRequest)
{
- ScopedVclPtrInstance<PasswordDialog> xDialog(pParent, nMode, aResLocale, aDocName,
- bIsPasswordToModify, bIsSimplePasswordRequest);
+ std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent ? pParent->GetFrameWeld() : nullptr, nMode,
+ aResLocale, aDocName, bIsPasswordToModify, bIsSimplePasswordRequest));
xDialog->SetMinLen(0);
- rInfo.SetResult(xDialog->Execute() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
+ rInfo.SetResult(xDialog->run() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
rInfo.SetPassword(xDialog->GetPassword());
}
else
@@ -541,11 +541,11 @@ executePasswordDialog(
}
else // enter password or reenter password
{
- ScopedVclPtrInstance<PasswordDialog> xDialog(pParent, nMode, aResLocale, aDocName,
- bIsPasswordToModify, bIsSimplePasswordRequest);
+ std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent ? pParent->GetFrameWeld() : nullptr, nMode,
+ aResLocale, aDocName, bIsPasswordToModify, bIsSimplePasswordRequest));
xDialog->SetMinLen(0);
- rInfo.SetResult(xDialog->Execute() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
+ rInfo.SetResult(xDialog->run() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel);
rInfo.SetPassword(bIsPasswordToModify ? OUString() : xDialog->GetPassword());
rInfo.SetPasswordToModify(bIsPasswordToModify ? xDialog->GetPassword() : OUString());
}
diff --git a/uui/source/passworddlg.cxx b/uui/source/passworddlg.cxx
index eec9540de9a8..14cb63446eae 100644
--- a/uui/source/passworddlg.cxx
+++ b/uui/source/passworddlg.cxx
@@ -27,100 +27,84 @@
using namespace ::com::sun::star;
-PasswordDialog::PasswordDialog(vcl::Window* _pParent,
+PasswordDialog::PasswordDialog(weld::Window* pParent,
task::PasswordRequestMode nDlgMode, const std::locale& rLocale,
const OUString& aDocURL, bool bOpenToModify, bool bIsSimplePasswordRequest)
- : ModalDialog(_pParent, "PasswordDialog", "uui/ui/password.ui")
+ : GenericDialogController(pParent, "uui/ui/password.ui", "PasswordDialog")
+ , m_xFTPassword(m_xBuilder->weld_label("newpassFT"))
+ , m_xEDPassword(m_xBuilder->weld_entry("newpassEntry"))
+ , m_xFTConfirmPassword(m_xBuilder->weld_label("confirmpassFT"))
+ , m_xEDConfirmPassword(m_xBuilder->weld_entry("confirmpassEntry"))
+ , m_xOKBtn(m_xBuilder->weld_button("ok"))
, nMinLen(1)
, aPasswdMismatch(Translate::get(STR_PASSWORD_MISMATCH, rLocale))
, nDialogMode(nDlgMode)
, rResLocale(rLocale)
{
- get(m_pFTPassword, "newpassFT");
- get(m_pEDPassword, "newpassEntry");
- get(m_pFTConfirmPassword, "confirmpassFT");
- get(m_pEDConfirmPassword, "confirmpassEntry");
- get(m_pOKBtn, "ok");
-
if( nDialogMode == task::PasswordRequestMode_PASSWORD_REENTER )
{
const char* pOpenToModifyErrStrId = bOpenToModify ? STR_ERROR_PASSWORD_TO_MODIFY_WRONG : STR_ERROR_PASSWORD_TO_OPEN_WRONG;
const char* pErrStrId = bIsSimplePasswordRequest ? STR_ERROR_SIMPLE_PASSWORD_WRONG : pOpenToModifyErrStrId;
OUString aErrorMsg(Translate::get(pErrStrId, rResLocale));
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(_pParent ? _pParent->GetFrameWeld() : nullptr,
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent,
VclMessageType::Warning, VclButtonsType::Ok, aErrorMsg));
xBox->run();
}
// default settings for enter password or reenter passwd...
OUString aTitle(Translate::get(STR_TITLE_ENTER_PASSWORD, rResLocale));
- m_pFTConfirmPassword->Hide();
- m_pEDConfirmPassword->Hide();
- m_pFTConfirmPassword->Enable( false );
- m_pEDConfirmPassword->Enable( false );
+ m_xFTConfirmPassword->hide();
+ m_xEDConfirmPassword->hide();
+ m_xFTConfirmPassword->set_sensitive(false);
+ m_xEDConfirmPassword->set_sensitive(false);
// settings for create password
if (nDialogMode == task::PasswordRequestMode_PASSWORD_CREATE)
{
aTitle = Translate::get(STR_TITLE_CREATE_PASSWORD, rResLocale);
- m_pFTConfirmPassword->SetText(Translate::get(STR_CONFIRM_SIMPLE_PASSWORD, rResLocale));
+ m_xFTConfirmPassword->set_label(Translate::get(STR_CONFIRM_SIMPLE_PASSWORD, rResLocale));
- m_pFTConfirmPassword->Show();
- m_pEDConfirmPassword->Show();
- m_pFTConfirmPassword->Enable();
- m_pEDConfirmPassword->Enable();
+ m_xFTConfirmPassword->show();
+ m_xEDConfirmPassword->show();
+ m_xFTConfirmPassword->set_sensitive(true);
+ m_xEDConfirmPassword->set_sensitive(true);
}
- SetText( aTitle );
+ m_xDialog->set_title(aTitle);
const char* pStrId = bOpenToModify ? STR_ENTER_PASSWORD_TO_MODIFY : STR_ENTER_PASSWORD_TO_OPEN;
OUString aMessage(Translate::get(pStrId, rResLocale));
INetURLObject url(aDocURL);
aMessage += url.HasError()
? aDocURL : url.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
- m_pFTPassword->SetText(aMessage);
+ m_xFTPassword->set_label(aMessage);
if (bIsSimplePasswordRequest)
{
DBG_ASSERT( aDocURL.isEmpty(), "A simple password request should not have a document URL! Use document password request instead." );
- m_pFTPassword->SetText(Translate::get(STR_ENTER_SIMPLE_PASSWORD, rResLocale));
+ m_xFTPassword->set_label(Translate::get(STR_ENTER_SIMPLE_PASSWORD, rResLocale));
}
- m_pOKBtn->SetClickHdl( LINK( this, PasswordDialog, OKHdl_Impl ) );
-}
-
-PasswordDialog::~PasswordDialog()
-{
- disposeOnce();
-}
-
-void PasswordDialog::dispose()
-{
- m_pFTPassword.clear();
- m_pEDPassword.clear();
- m_pFTConfirmPassword.clear();
- m_pEDConfirmPassword.clear();
- m_pOKBtn.clear();
- ModalDialog::dispose();
+ m_xOKBtn->connect_clicked(LINK(this, PasswordDialog, OKHdl_Impl));
}
-IMPL_LINK_NOARG(PasswordDialog, OKHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(PasswordDialog, OKHdl_Impl, weld::Button&, void)
{
- bool bEDPasswdValid = m_pEDPassword->GetText().getLength() >= nMinLen;
- bool bPasswdMismatch = m_pEDConfirmPassword->GetText() != m_pEDPassword->GetText();
- bool bValid = (!m_pEDConfirmPassword->IsVisible() && bEDPasswdValid) ||
- (m_pEDConfirmPassword->IsVisible() && bEDPasswdValid && !bPasswdMismatch);
+ bool bEDPasswdValid = m_xEDPassword->get_text().getLength() >= nMinLen;
+ bool bPasswdMismatch = m_xEDConfirmPassword->get_text() != m_xEDPassword->get_text();
+ bool bValid = (!m_xEDConfirmPassword->get_visible() && bEDPasswdValid) ||
+ (m_xEDConfirmPassword->get_visible() && bEDPasswdValid && !bPasswdMismatch);
- if (m_pEDConfirmPassword->IsVisible() && bPasswdMismatch)
+ if (m_xEDConfirmPassword->get_visible() && bPasswdMismatch)
{
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok,
aPasswdMismatch));
xBox->run();
}
else if (bValid)
- EndDialog( RET_OK );
+ m_xDialog->response(RET_OK);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uui/source/passworddlg.hxx b/uui/source/passworddlg.hxx
index fc067db250ba..bf865b0e8f17 100644
--- a/uui/source/passworddlg.hxx
+++ b/uui/source/passworddlg.hxx
@@ -21,34 +21,27 @@
#define INCLUDED_UUI_SOURCE_PASSWORDDLG_HXX
#include <com/sun/star/task/PasswordRequestMode.hpp>
-#include <vcl/button.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/group.hxx>
-#include <vcl/fixed.hxx>
+#include <vcl/weld.hxx>
-
-class PasswordDialog : public ModalDialog
+class PasswordDialog : public weld::GenericDialogController
{
- VclPtr<FixedText> m_pFTPassword;
- VclPtr<Edit> m_pEDPassword;
- VclPtr<FixedText> m_pFTConfirmPassword;
- VclPtr<Edit> m_pEDConfirmPassword;
- VclPtr<OKButton> m_pOKBtn;
+ std::unique_ptr<weld::Label> m_xFTPassword;
+ std::unique_ptr<weld::Entry> m_xEDPassword;
+ std::unique_ptr<weld::Label> m_xFTConfirmPassword;
+ std::unique_ptr<weld::Entry> m_xEDConfirmPassword;
+ std::unique_ptr<weld::Button> m_xOKBtn;
sal_uInt16 nMinLen;
OUString aPasswdMismatch;
- DECL_LINK(OKHdl_Impl, Button*, void);
+ DECL_LINK(OKHdl_Impl, weld::Button&, void);
public:
- PasswordDialog(vcl::Window* pParent, css::task::PasswordRequestMode nDlgMode, const std::locale& rLocale, const OUString& aDocURL,
+ PasswordDialog(weld::Window* pParent, css::task::PasswordRequestMode nDlgMode, const std::locale& rLocale, const OUString& aDocURL,
bool bOpenToModify, bool bIsSimplePasswordRequest);
- virtual ~PasswordDialog() override;
- virtual void dispose() override;
void SetMinLen( sal_uInt16 nMin ) { nMinLen = nMin; }
- OUString GetPassword() const { return m_pEDPassword->GetText(); }
+ OUString GetPassword() const { return m_xEDPassword->get_text(); }
private:
css::task::PasswordRequestMode nDialogMode;
diff --git a/uui/uiconfig/ui/password.ui b/uui/uiconfig/ui/password.ui
index 22149b7edd19..ea574d0693c2 100644
--- a/uui/uiconfig/ui/password.ui
+++ b/uui/uiconfig/ui/password.ui
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.2 -->
<interface domain="uui">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="PasswordDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="password|PasswordDialog">Set Password</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -80,9 +83,9 @@
<object class="GtkLabel" id="confirmpassFT">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">confirmpassEntry</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -93,9 +96,9 @@
<object class="GtkLabel" id="newpassFT">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">newpassEntry</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -108,6 +111,7 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
+ <property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -120,6 +124,7 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
+ <property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -136,10 +141,12 @@
</object>
</child>
<action-widgets>
- <action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
<object class="GtkSizeGroup" id="sizegroup1"/>
</interface>
More information about the Libreoffice-commits
mailing list