[Libreoffice-commits] core.git: dbaccess/source dbaccess/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 12 09:38:54 UTC 2018


 dbaccess/source/ui/dlg/UserAdmin.cxx |   87 +++++++++++++++--------------------
 dbaccess/uiconfig/ui/password.ui     |   20 ++++++--
 2 files changed, 54 insertions(+), 53 deletions(-)

New commits:
commit cf47926c3191edfff9e943286c8d87820a1ab3c8
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Oct 12 09:27:15 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Oct 12 11:38:27 2018 +0200

    weld OPasswordDialog
    
    Change-Id: Id08853ec1789a7a3a361263a4a61329a849f8658
    Reviewed-on: https://gerrit.libreoffice.org/61704
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx
index 77c3ac836a93..74a1db8723f1 100644
--- a/dbaccess/source/ui/dlg/UserAdmin.cxx
+++ b/dbaccess/source/ui/dlg/UserAdmin.cxx
@@ -48,72 +48,61 @@ using namespace dbaui;
 using namespace ucbhelper;
 using namespace comphelper;
 
-class OPasswordDialog : public ModalDialog
+class OPasswordDialog : public weld::GenericDialogController
 {
-    VclPtr<VclFrame> m_pUser;
-    VclPtr<Edit>     m_pEDOldPassword;
-    VclPtr<Edit>     m_pEDPassword;
-    VclPtr<Edit>     m_pEDPasswordRepeat;
-    VclPtr<OKButton> m_pOKBtn;
+    std::unique_ptr<weld::Frame> m_xUser;
+    std::unique_ptr<weld::Entry> m_xEDOldPassword;
+    std::unique_ptr<weld::Entry> m_xEDPassword;
+    std::unique_ptr<weld::Entry> m_xEDPasswordRepeat;
+    std::unique_ptr<weld::Button> m_xOKBtn;
 
-    DECL_LINK( OKHdl_Impl, Button*, void );
-    DECL_LINK( ModifiedHdl, Edit&, void );
+    DECL_LINK(OKHdl_Impl, weld::Button&, void);
+    DECL_LINK(ModifiedHdl, weld::Entry&, void);
 
 public:
-    OPasswordDialog( vcl::Window* pParent,const OUString& _sUserName);
-    virtual ~OPasswordDialog() override { disposeOnce(); }
-    virtual void dispose() override
-    {
-        m_pUser.clear();
-        m_pEDOldPassword.clear();
-        m_pEDPassword.clear();
-        m_pEDPasswordRepeat.clear();
-        m_pOKBtn.clear();
-        ModalDialog::dispose();
-    }
+    OPasswordDialog(weld::Window* pParent,const OUString& rUserName);
 
-    OUString        GetOldPassword() const { return m_pEDOldPassword->GetText(); }
-    OUString        GetNewPassword() const { return m_pEDPassword->GetText(); }
+    OUString        GetOldPassword() const { return m_xEDOldPassword->get_text(); }
+    OUString        GetNewPassword() const { return m_xEDPassword->get_text(); }
 };
 
-OPasswordDialog::OPasswordDialog(vcl::Window* _pParent,const OUString& _sUserName)
-    : ModalDialog(_pParent, "PasswordDialog", "dbaccess/ui/password.ui")
+OPasswordDialog::OPasswordDialog(weld::Window* _pParent,const OUString& rUserName)
+    : GenericDialogController(_pParent, "dbaccess/ui/password.ui", "PasswordDialog")
+    , m_xUser(m_xBuilder->weld_frame("userframe"))
+    , m_xEDOldPassword(m_xBuilder->weld_entry("oldpassword"))
+    , m_xEDPassword(m_xBuilder->weld_entry("newpassword"))
+    , m_xEDPasswordRepeat(m_xBuilder->weld_entry("confirmpassword"))
+    , m_xOKBtn(m_xBuilder->weld_button("ok"))
 {
-    get(m_pUser, "userframe");
-    get(m_pEDOldPassword, "oldpassword");
-    get(m_pEDPassword, "newpassword");
-    get(m_pEDPasswordRepeat, "confirmpassword");
-    get(m_pOKBtn, "ok");
-
-    OUString sUser = m_pUser->get_label();
-    sUser = sUser.replaceFirst("$name$:  $",_sUserName);
-    m_pUser->set_label(sUser);
-    m_pOKBtn->Disable();
-
-    m_pOKBtn->SetClickHdl( LINK( this, OPasswordDialog, OKHdl_Impl ) );
-    m_pEDOldPassword->SetModifyHdl( LINK( this, OPasswordDialog, ModifiedHdl ) );
+    OUString sUser = m_xUser->get_label();
+    sUser = sUser.replaceFirst("$name$:  $", rUserName);
+    m_xUser->set_label(sUser);
+    m_xOKBtn->set_sensitive(false);
+
+    m_xOKBtn->connect_clicked( LINK( this, OPasswordDialog, OKHdl_Impl ) );
+    m_xEDOldPassword->connect_changed( LINK( this, OPasswordDialog, ModifiedHdl ) );
 }
 
-IMPL_LINK_NOARG(OPasswordDialog, OKHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(OPasswordDialog, OKHdl_Impl, weld::Button&, void)
 {
-    if( m_pEDPassword->GetText() == m_pEDPasswordRepeat->GetText() )
-        EndDialog( RET_OK );
+    if (m_xEDPassword->get_text() == m_xEDPasswordRepeat->get_text())
+        m_xDialog->response(RET_OK);
     else
     {
         OUString aErrorMsg( DBA_RES( STR_ERROR_PASSWORDS_NOT_IDENTICAL));
-        std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+        std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
                                                        VclMessageType::Warning, VclButtonsType::Ok,
                                                        aErrorMsg));
         xErrorBox->run();
-        m_pEDPassword->SetText( OUString() );
-        m_pEDPasswordRepeat->SetText( OUString() );
-        m_pEDPassword->GrabFocus();
+        m_xEDPassword->set_text(OUString());
+        m_xEDPasswordRepeat->set_text(OUString());
+        m_xEDPassword->grab_focus();
     }
 }
 
-IMPL_LINK( OPasswordDialog, ModifiedHdl, Edit&, rEdit, void )
+IMPL_LINK(OPasswordDialog, ModifiedHdl, weld::Entry&, rEdit, void)
 {
-    m_pOKBtn->Enable(!rEdit.GetText().isEmpty());
+    m_xOKBtn->set_sensitive(!rEdit.get_text().isEmpty());
 }
 
 // OUserAdmin
@@ -239,11 +228,11 @@ IMPL_LINK( OUserAdmin, UserHdl, Button *, pButton, void )
                 if(xUser.is())
                 {
                     OUString sNewPassword,sOldPassword;
-                    ScopedVclPtrInstance< OPasswordDialog > aDlg(this,sName);
-                    if(aDlg->Execute() == RET_OK)
+                    OPasswordDialog aDlg(GetDialogFrameWeld(), sName);
+                    if (aDlg.run() == RET_OK)
                     {
-                        sNewPassword = aDlg->GetNewPassword();
-                        sOldPassword = aDlg->GetOldPassword();
+                        sNewPassword = aDlg.GetNewPassword();
+                        sOldPassword = aDlg.GetOldPassword();
 
                         if(!sNewPassword.isEmpty())
                             xUser->changePassword(sOldPassword,sNewPassword);
diff --git a/dbaccess/uiconfig/ui/password.ui b/dbaccess/uiconfig/ui/password.ui
index b24bc42188ef..ebb606f892a4 100644
--- a/dbaccess/uiconfig/ui/password.ui
+++ b/dbaccess/uiconfig/ui/password.ui
@@ -1,12 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="dba">
   <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">Change 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>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -94,6 +100,8 @@
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
                         <property name="visibility">False</property>
+                        <property name="activates_default">True</property>
+                        <property name="input_purpose">password</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -106,6 +114,8 @@
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
                         <property name="visibility">False</property>
+                        <property name="activates_default">True</property>
+                        <property name="input_purpose">password</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -116,10 +126,10 @@
                       <object class="GtkLabel" id="label2">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="password|label2">Old p_assword:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">oldpassword</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -130,10 +140,10 @@
                       <object class="GtkLabel" id="label3">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="password|label3">_Password:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">newpassword</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -144,10 +154,10 @@
                       <object class="GtkLabel" id="label4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="password|label4">_Confirm password:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">confirmpassword</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -160,6 +170,8 @@
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
                         <property name="visibility">False</property>
+                        <property name="activates_default">True</property>
+                        <property name="input_purpose">password</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>


More information about the Libreoffice-commits mailing list