diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-12 10:33:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-12 21:33:40 +0200 |
commit | 1e9e78bde0e659c89ea96b259845539dab500195 (patch) | |
tree | 90762931ad03373399992508ac39161c28596809 /vcl | |
parent | 47da2b3ef35b87964218374282f6add41076af9a (diff) |
weld RTSPWDialog
Change-Id: I822c15bb4326d1b7b96b2af9aefbb3deecc7b229
Reviewed-on: https://gerrit.libreoffice.org/52770
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/uiconfig/ui/cupspassworddialog.ui | 16 | ||||
-rw-r--r-- | vcl/unx/generic/printer/cupsmgr.cxx | 61 |
2 files changed, 34 insertions, 43 deletions
diff --git a/vcl/uiconfig/ui/cupspassworddialog.ui b/vcl/uiconfig/ui/cupspassworddialog.ui index 7b2cb5d0232d..9b37d3eacc2d 100644 --- a/vcl/uiconfig/ui/cupspassworddialog.ui +++ b/vcl/uiconfig/ui/cupspassworddialog.ui @@ -1,11 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="vcl"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="CUPSPasswordDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="cupspassworddialog|CUPSPasswordDialog">Authentication Request</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">normal</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -66,10 +69,10 @@ <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="cupspassworddialog|label1">_User:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">user</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -80,10 +83,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="cupspassworddialog|label2">_Password:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">pass</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -94,11 +97,11 @@ <object class="GtkLabel" id="text"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="cupspassworddialog|text">Please enter your authentication data for server “%s”</property> <property name="use_underline">True</property> <property name="wrap">True</property> <property name="max_width_chars">56</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -111,6 +114,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">1</property> @@ -123,6 +127,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">1</property> @@ -142,5 +147,8 @@ <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index 328e9246e9f5..a6cae038aa36 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -34,9 +34,8 @@ #include <officecfg/Office/Common.hxx> -#include <vcl/button.hxx> -#include <vcl/dialog.hxx> -#include <vcl/fixed.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <algorithm> @@ -827,66 +826,50 @@ bool CUPSManager::writePrinterConfig() namespace { - class RTSPWDialog : public ModalDialog + class RTSPWDialog : public weld::GenericDialogController { - VclPtr<FixedText> m_pText; - VclPtr<Edit> m_pUserEdit; - VclPtr<Edit> m_pPassEdit; + std::unique_ptr<weld::Label> m_xText; + std::unique_ptr<weld::Entry> m_xUserEdit; + std::unique_ptr<weld::Entry> m_xPassEdit; public: - RTSPWDialog(const OString& rServer, const OString& rUserName, vcl::Window* pParent); - virtual ~RTSPWDialog() override; - virtual void dispose() override; + RTSPWDialog(const OString& rServer, const OString& rUserName, weld::Window* pParent); OString getUserName() const; OString getPassword() const; }; - RTSPWDialog::RTSPWDialog( const OString& rServer, const OString& rUserName, vcl::Window* pParent ) - : ModalDialog(pParent, "CUPSPasswordDialog", - "vcl/ui/cupspassworddialog.ui") + RTSPWDialog::RTSPWDialog( const OString& rServer, const OString& rUserName, weld::Window* pParent ) + : GenericDialogController(pParent, "vcl/ui/cupspassworddialog.ui", "CUPSPasswordDialog") + , m_xText(m_xBuilder->weld_label("text")) + , m_xUserEdit(m_xBuilder->weld_entry("user")) + , m_xPassEdit(m_xBuilder->weld_entry("pass")) { - get(m_pText, "text"); - get(m_pUserEdit, "user"); - get(m_pPassEdit, "pass"); - - OUString aText(m_pText->GetText()); + OUString aText(m_xText->get_label()); aText = aText.replaceFirst("%s", OStringToOUString(rServer, osl_getThreadTextEncoding())); - m_pText->SetText(aText); - m_pUserEdit->SetText( OStringToOUString(rUserName, osl_getThreadTextEncoding())); - } - - RTSPWDialog::~RTSPWDialog() - { - disposeOnce(); - } - - void RTSPWDialog::dispose() - { - m_pText.clear(); - m_pUserEdit.clear(); - m_pPassEdit.clear(); - ModalDialog::dispose(); + m_xText->set_label(aText); + m_xUserEdit->set_text(OStringToOUString(rUserName, osl_getThreadTextEncoding())); } OString RTSPWDialog::getUserName() const { - return OUStringToOString( m_pUserEdit->GetText(), osl_getThreadTextEncoding() ); + return OUStringToOString( m_xUserEdit->get_text(), osl_getThreadTextEncoding() ); } OString RTSPWDialog::getPassword() const { - return OUStringToOString( m_pPassEdit->GetText(), osl_getThreadTextEncoding() ); + return OUStringToOString( m_xPassEdit->get_text(), osl_getThreadTextEncoding() ); } bool AuthenticateQuery(const OString& rServer, OString& rUserName, OString& rPassword) { bool bRet = false; - ScopedVclPtrInstance<RTSPWDialog> aDialog(rServer, rUserName, nullptr); - if (aDialog->Execute()) + vcl::Window* pWin = Application::GetDefDialogParent(); + RTSPWDialog aDialog(rServer, rUserName, pWin ? pWin->GetFrameWeld() : nullptr); + if (aDialog.run() == RET_OK) { - rUserName = aDialog->getUserName(); - rPassword = aDialog->getPassword(); + rUserName = aDialog.getUserName(); + rPassword = aDialog.getPassword(); bRet = true; } |