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

Caolán McNamara caolanm at redhat.com
Thu May 17 20:16:35 UTC 2018


 uui/source/authfallbackdlg.cxx       |   69 +++++----------
 uui/source/authfallbackdlg.hxx       |   36 +++-----
 uui/source/iahndl-authentication.cxx |    8 -
 uui/uiconfig/ui/authfallback.ui      |  156 +++++++++++++++++------------------
 4 files changed, 122 insertions(+), 147 deletions(-)

New commits:
commit bf09cd79d3414d88ea6c1d348ed191a77e8c413e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 17 10:16:55 2018 +0100

    AuthFallbackDlg
    
    Change-Id: I69676dd437caefca63805e86f4707527183f622f
    Reviewed-on: https://gerrit.libreoffice.org/54487
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/uui/source/authfallbackdlg.cxx b/uui/source/authfallbackdlg.cxx
index b5d8b4f1c5a4..b7190107da2a 100644
--- a/uui/source/authfallbackdlg.cxx
+++ b/uui/source/authfallbackdlg.cxx
@@ -13,77 +13,60 @@
 
 using namespace boost;
 
-AuthFallbackDlg::AuthFallbackDlg(Window* pParent, const OUString& instructions,
+AuthFallbackDlg::AuthFallbackDlg(weld::Window* pParent, const OUString& instructions,
                                  const OUString& url)
-    : ModalDialog(pParent, "AuthFallbackDlg", "uui/ui/authfallback.ui")
+    : GenericDialogController(pParent, "uui/ui/authfallback.ui", "AuthFallbackDlg")
     , m_bGoogleMode( false )
+    , m_xTVInstructions(m_xBuilder->weld_label("instructions"))
+    , m_xEDUrl(m_xBuilder->weld_entry("url"))
+    , m_xEDCode(m_xBuilder->weld_entry("code"))
+    , m_xEDGoogleCode(m_xBuilder->weld_entry("google_code"))
+    , m_xBTOk(m_xBuilder->weld_button("ok"))
+    , m_xBTCancel(m_xBuilder->weld_button("cancel"))
+    , m_xGoogleBox(m_xBuilder->weld_widget("GDrive"))
+    , m_xOneDriveBox(m_xBuilder->weld_widget("OneDrive"))
 {
-    get( m_pTVInstructions, "instructions" );
-    get( m_pEDUrl, "url" );
-    get( m_pEDCode, "code" );
-    get( m_pEDGoogleCode, "google_code" );
-    get( m_pBTOk, "ok" );
-    get( m_pBTCancel, "cancel" );
-    get( m_pGoogleBox, "GDrive" );
-    get( m_pOneDriveBox, "OneDrive" );
+    m_xBTOk->connect_clicked( LINK( this, AuthFallbackDlg, OKHdl) );
+    m_xBTCancel->connect_clicked( LINK( this, AuthFallbackDlg, CancelHdl) );
+    m_xBTOk->set_sensitive(true);
 
-    m_pBTOk->SetClickHdl( LINK( this, AuthFallbackDlg, OKHdl) );
-    m_pBTCancel->SetClickHdl( LINK( this, AuthFallbackDlg, CancelHdl) );
-    m_pBTOk->Enable();
-
-    m_pTVInstructions->SetText( instructions );
-    m_pTVInstructions->SetPaintTransparent(true);
+    m_xTVInstructions->set_label(instructions);
     if( url.isEmpty() )
     {
         // Google 2FA
         m_bGoogleMode = true;
-        m_pGoogleBox->Show();
-        m_pOneDriveBox->Hide();
-        m_pEDUrl->Hide();
+        m_xGoogleBox->show();
+        m_xOneDriveBox->hide();
+        m_xEDUrl->hide();
     }
     else
     {
         // OneDrive
         m_bGoogleMode = false;
-        m_pGoogleBox->Hide();
-        m_pOneDriveBox->Show();
-        m_pEDUrl->SetText( url );
+        m_xGoogleBox->hide();
+        m_xOneDriveBox->show();
+        m_xEDUrl->set_text( url );
     }
 }
 
 AuthFallbackDlg::~AuthFallbackDlg()
 {
-    disposeOnce();
 }
 
 OUString AuthFallbackDlg::GetCode() const
 {
     if( m_bGoogleMode )
-        return m_pEDGoogleCode->GetText();
+        return m_xEDGoogleCode->get_text();
     else
-        return m_pEDCode->GetText();
-}
-
-
-void AuthFallbackDlg::dispose()
-{
-    m_pTVInstructions.clear();
-    m_pEDUrl.clear();
-    m_pEDCode.clear();
-    m_pEDGoogleCode.clear();
-    m_pBTOk.clear();
-    m_pBTCancel.clear();
-    m_pGoogleBox.clear();
-    m_pOneDriveBox.clear();
-    ModalDialog::dispose();
+        return m_xEDCode->get_text();
 }
 
-IMPL_LINK_NOARG ( AuthFallbackDlg,  OKHdl, Button *, void)
+IMPL_LINK_NOARG(AuthFallbackDlg,  OKHdl, weld::Button&, void)
 {
-    EndDialog( RET_OK );
+    m_xDialog->response(RET_OK);
 }
 
-IMPL_LINK_NOARG ( AuthFallbackDlg,  CancelHdl, Button *, void)
+IMPL_LINK_NOARG(AuthFallbackDlg,  CancelHdl, weld::Button&, void)
 {
-    EndDialog();
+    m_xDialog->response(RET_CANCEL);
 }
diff --git a/uui/source/authfallbackdlg.hxx b/uui/source/authfallbackdlg.hxx
index ff10407265b5..206cd87274a7 100644
--- a/uui/source/authfallbackdlg.hxx
+++ b/uui/source/authfallbackdlg.hxx
@@ -10,38 +10,32 @@
 #ifndef INCLUDED_SVTOOLS_AUTHFALLBACKDLG_HXX
 #define INCLUDED_SVTOOLS_AUTHFALLBACKDLG_HXX
 
-#include <vcl/button.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/vclmedit.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/layout.hxx>
-
-class AuthFallbackDlg : public ModalDialog
+#include <vcl/weld.hxx>
+
+class AuthFallbackDlg : public weld::GenericDialogController
 {
 private:
-    VclPtr<VclMultiLineEdit> m_pTVInstructions;
-    VclPtr<Edit> m_pEDUrl;
-    VclPtr<Edit> m_pEDCode;
-    VclPtr<Edit> m_pEDGoogleCode;
-    VclPtr<PushButton> m_pBTOk;
-    VclPtr<PushButton> m_pBTCancel;
-    VclPtr<VclVBox> m_pGoogleBox;
-    VclPtr<VclVBox> m_pOneDriveBox;
     bool m_bGoogleMode;
 
+    std::unique_ptr<weld::Label> m_xTVInstructions;
+    std::unique_ptr<weld::Entry> m_xEDUrl;
+    std::unique_ptr<weld::Entry> m_xEDCode;
+    std::unique_ptr<weld::Entry> m_xEDGoogleCode;
+    std::unique_ptr<weld::Button> m_xBTOk;
+    std::unique_ptr<weld::Button> m_xBTCancel;
+    std::unique_ptr<weld::Widget> m_xGoogleBox;
+    std::unique_ptr<weld::Widget> m_xOneDriveBox;
+
 public:
-    AuthFallbackDlg(Window* pParent, const OUString& instructions,
+    AuthFallbackDlg(weld::Window* pParent, const OUString& instructions,
                     const OUString& url);
     virtual ~AuthFallbackDlg() override;
-    virtual void dispose() override;
 
     OUString GetCode() const;
 
 private:
-
-    DECL_LINK ( OKHdl, Button *, void );
-    DECL_LINK ( CancelHdl, Button *, void );
+    DECL_LINK(OKHdl, weld::Button&, void);
+    DECL_LINK(CancelHdl, weld::Button&, void);
 };
 
 #endif // INCLUDED_SVTOOLS_AUTHFALLBACKDLG_HXX
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx
index 673a6e441f52..ddaaf10e5e52 100644
--- a/uui/source/iahndl-authentication.cxx
+++ b/uui/source/iahndl-authentication.cxx
@@ -728,16 +728,16 @@ UUIInteractionHelper::handleAuthFallbackRequest( OUString & instructions,
         OUString & url,
         uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations )
 {
-    vcl::Window * pParent = getParentProperty( );
-    VclPtrInstance<AuthFallbackDlg> dlg( pParent, instructions, url );
-    int retCode = dlg->Execute( );
+    uno::Reference<awt::XWindow> xParent = getParentXWindow();
+    AuthFallbackDlg dlg(Application::GetFrameWeld(xParent), instructions, url);
+    int retCode = dlg.run();
     uno::Reference< task::XInteractionAbort > xAbort;
     uno::Reference< ucb::XInteractionAuthFallback > xAuthFallback;
     getContinuations(rContinuations, &xAbort, &xAuthFallback);
 
     if( retCode == RET_OK && xAuthFallback.is( ) )
     {
-        xAuthFallback->setCode( dlg->GetCode( ) );
+        xAuthFallback->setCode(dlg.GetCode());
         xAuthFallback->select( );
     }
 
diff --git a/uui/uiconfig/ui/authfallback.ui b/uui/uiconfig/ui/authfallback.ui
index 3080cbecca13..c10cbe515890 100644
--- a/uui/uiconfig/ui/authfallback.ui
+++ b/uui/uiconfig/ui/authfallback.ui
@@ -1,15 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="uui">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkDialog" id="AuthFallbackDlg">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="authfallback|AuthFallbackDlg">Authentication Code</property>
-    <property name="default_width">400</property>
-    <property name="default_height">270</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">dialog</property>
     <property name="skip_taskbar_hint">True</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="messagedialog-vbox">
         <property name="can_focus">False</property>
@@ -58,124 +62,118 @@
           </packing>
         </child>
         <child>
-          <object class="GtkBox" id="box">
+          <object class="GtkGrid">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
             <child>
-              <object class="GtkBox" id="OneDrive">
+              <object class="GtkGrid" id="GDrive">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
+                <property name="row_spacing">6</property>
                 <child>
-                  <object class="GtkTextView" id="instructions">
+                  <object class="GtkBox" id="box2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="pixels_below_lines">4</property>
-                    <property name="editable">False</property>
-                    <property name="wrap_mode">word</property>
-                    <property name="cursor_visible">False</property>
+                    <property name="halign">center</property>
+                    <child>
+                      <object class="GtkLabel" id="google_prefix_label">
+                        <property name="can_focus">False</property>
+                        <property name="label">G-</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="google_code">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="max_length">6</property>
+                        <property name="activates_default">True</property>
+                        <property name="width_chars">6</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkEntry" id="url">
+                  <object class="GtkLabel" id="label1">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="editable">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" context="authfallback|label1">Enter the 6 digit PIN:</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
                   </packing>
                 </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkGrid" id="OneDrive">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="row_spacing">6</property>
                 <child>
                   <object class="GtkEntry" id="code">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="activates_default">True</property>
                     <property name="width_chars">0</property>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">2</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
                   </packing>
                 </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkBox" id="GDrive">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
                 <child>
-                  <object class="GtkLabel" id="label1">
+                  <object class="GtkEntry" id="url">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes" context="authfallback|label1">Enter the 6 digit PIN:</property>
-                    <property name="xalign">0</property>
+                    <property name="can_focus">True</property>
+                    <property name="editable">False</property>
+                    <property name="activates_default">True</property>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkBox" id="box2">
+                  <object class="GtkLabel" id="instructions">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="halign">center</property>
-                    <child>
-                      <object class="GtkLabel" id="google_prefix_label">
-                        <property name="can_focus">False</property>
-                        <property name="margin_right">3</property>
-                        <property name="label" translatable="no">G-</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkEntry" id="google_code">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="max_length">6</property>
-                        <property name="width_chars">6</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
+                    <property name="wrap">True</property>
+                    <property name="wrap_mode">word-char</property>
+                    <property name="width_chars">70</property>
+                    <property name="max_width_chars">70</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
               </packing>
             </child>
           </object>


More information about the Libreoffice-commits mailing list