diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-16 15:56:12 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-17 09:54:45 +0200 |
commit | c899ad348c375e6c59dbbc30e2458d9cbe226c12 (patch) | |
tree | b87b7f22f5790906b8550a0400e35113ffb603b6 /fpicker | |
parent | weld SvxNewToolbarDialog (diff) | |
download | core-c899ad348c375e6c59dbbc30e2458d9cbe226c12.tar.gz core-c899ad348c375e6c59dbbc30e2458d9cbe226c12.zip |
weld QueryFolderNameDialog
Change-Id: I73ff0a15010d00a353e498755755177c8e7df607
Reviewed-on: https://gerrit.libreoffice.org/54442
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 'fpicker')
-rw-r--r-- | fpicker/source/office/QueryFolderName.hxx | 22 | ||||
-rw-r--r-- | fpicker/source/office/RemoteFilesDialog.cxx | 8 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.cxx | 61 | ||||
-rw-r--r-- | fpicker/uiconfig/ui/foldernamedialog.ui | 10 |
4 files changed, 41 insertions, 60 deletions
diff --git a/fpicker/source/office/QueryFolderName.hxx b/fpicker/source/office/QueryFolderName.hxx index d3555e3fa9b3..4172aa0f9ee0 100644 --- a/fpicker/source/office/QueryFolderName.hxx +++ b/fpicker/source/office/QueryFolderName.hxx @@ -19,28 +19,22 @@ #ifndef INCLUDED_FPICKER_SOURCE_OFFICE_QUERYFOLDERNAME_HXX #define INCLUDED_FPICKER_SOURCE_OFFICE_QUERYFOLDERNAME_HXX -#include <vcl/fixed.hxx> -#include <vcl/button.hxx> -#include <vcl/edit.hxx> -#include <vcl/dialog.hxx> -#include <vcl/layout.hxx> +#include <vcl/weld.hxx> -class QueryFolderNameDialog : public ModalDialog +class QueryFolderNameDialog : public weld::GenericDialogController { private: - VclPtr<Edit> m_pNameEdit; - VclPtr<VclFrame> m_pNameLine; - VclPtr<OKButton> m_pOKBtn; + std::unique_ptr<weld::Entry> m_xNameEdit; + std::unique_ptr<weld::Button> m_xOKBtn; - DECL_LINK( OKHdl, Button*, void ); - DECL_LINK( NameHdl, Edit&, void ); + DECL_LINK( OKHdl, weld::Button&, void ); + DECL_LINK( NameHdl, weld::Entry&, void ); public: - QueryFolderNameDialog(vcl::Window* _pParent, const OUString& rTitle, + QueryFolderNameDialog(weld::Window* _pParent, const OUString& rTitle, const OUString& rDefaultText); virtual ~QueryFolderNameDialog() override; - virtual void dispose() override; - OUString GetName() const { return m_pNameEdit->GetText(); } + OUString GetName() const { return m_xNameEdit->get_text(); } }; #endif // INCLUDED_FPICKER_SOURCE_OFFICE_QUERYFOLDERNAME_HXX diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index 7cac02da7777..bf629dfe8f2a 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -1087,17 +1087,17 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, NewFolderHdl, Button*, void ) OUString aTitle; aContent.getTitle( aTitle ); - ScopedVclPtrInstance< QueryFolderNameDialog > aDlg(this, aTitle, FpsResId(STR_SVT_NEW_FOLDER)); + QueryFolderNameDialog aDlg(GetFrameWeld(), aTitle, FpsResId(STR_SVT_NEW_FOLDER)); bool bHandled = false; while( !bHandled ) { - if( aDlg->Execute() == RET_OK ) + if (aDlg.run() == RET_OK) { - OUString aUrl = aContent.createFolder( aDlg->GetName() ); + OUString aUrl = aContent.createFolder(aDlg.GetName()); if( !aUrl.isEmpty() ) { - m_pFileView->CreatedFolder( aUrl, aDlg->GetName() ); + m_pFileView->CreatedFolder(aUrl, aDlg.GetName()); bHandled = true; } } diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index ca7cc591db3f..880e27834a82 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -745,17 +745,17 @@ IMPL_LINK_NOARG( SvtFileDialog, NewFolderHdl_Impl, Button*, void) SmartContent aContent( _pFileView->GetViewURL( ) ); OUString aTitle; aContent.getTitle( aTitle ); - ScopedVclPtrInstance< QueryFolderNameDialog > aDlg(this, aTitle, FpsResId(STR_SVT_NEW_FOLDER)); + QueryFolderNameDialog aDlg(GetFrameWeld(), aTitle, FpsResId(STR_SVT_NEW_FOLDER)); bool bHandled = false; while ( !bHandled ) { - if ( aDlg->Execute() == RET_OK ) + if (aDlg.run() == RET_OK) { - OUString aUrl = aContent.createFolder( aDlg->GetName( ) ); + OUString aUrl = aContent.createFolder(aDlg.GetName()); if ( !aUrl.isEmpty( ) ) { - _pFileView->CreatedFolder( aUrl, aDlg->GetName() ); + _pFileView->CreatedFolder(aUrl, aDlg.GetName()); bHandled = true; } } @@ -2768,56 +2768,35 @@ Image SvtFileDialog::GetButtonImage(const OUString& rButtonId) return Image(BitmapEx(rButtonId)); } -QueryFolderNameDialog::QueryFolderNameDialog(vcl::Window* _pParent, +QueryFolderNameDialog::QueryFolderNameDialog(weld::Window* _pParent, const OUString& rTitle, const OUString& rDefaultText) - : ModalDialog(_pParent, "FolderNameDialog", "fps/ui/foldernamedialog.ui") -{ - get(m_pNameEdit, "entry"); - get(m_pNameLine, "frame"); - get(m_pOKBtn, "ok"); - - SetText( rTitle ); - m_pNameEdit->SetText( rDefaultText ); - m_pNameEdit->SetSelection( Selection( 0, rDefaultText.getLength() ) ); - m_pOKBtn->SetClickHdl( LINK( this, QueryFolderNameDialog, OKHdl ) ); - m_pNameEdit->SetModifyHdl( LINK( this, QueryFolderNameDialog, NameHdl ) ); + : GenericDialogController(_pParent, "fps/ui/foldernamedialog.ui", "FolderNameDialog") + , m_xNameEdit(m_xBuilder->weld_entry("entry")) + , m_xOKBtn(m_xBuilder->weld_button("ok")) +{ + m_xDialog->set_title(rTitle); + m_xNameEdit->set_text(rDefaultText); + m_xNameEdit->select_region(0, -1); + m_xOKBtn->connect_clicked(LINK(this, QueryFolderNameDialog, OKHdl)); + m_xNameEdit->connect_changed(LINK(this, QueryFolderNameDialog, NameHdl)); }; QueryFolderNameDialog::~QueryFolderNameDialog() { - disposeOnce(); -} - -void QueryFolderNameDialog::dispose() -{ - m_pNameEdit.clear(); - m_pNameLine.clear(); - m_pOKBtn.clear(); - ModalDialog::dispose(); } -IMPL_LINK_NOARG(QueryFolderNameDialog, OKHdl, Button*, void) +IMPL_LINK_NOARG(QueryFolderNameDialog, OKHdl, weld::Button&, void) { // trim the strings - m_pNameEdit->SetText(comphelper::string::strip(m_pNameEdit->GetText(), ' ')); - EndDialog( RET_OK ); + m_xNameEdit->set_text(comphelper::string::strip(m_xNameEdit->get_text(), ' ')); + m_xDialog->response(RET_OK); } - -IMPL_LINK_NOARG(QueryFolderNameDialog, NameHdl, Edit&, void) +IMPL_LINK_NOARG(QueryFolderNameDialog, NameHdl, weld::Entry&, void) { // trim the strings - OUString aName = comphelper::string::strip(m_pNameEdit->GetText(), ' '); - if ( !aName.isEmpty() ) - { - if ( !m_pOKBtn->IsEnabled() ) - m_pOKBtn->Enable(); - } - else - { - if ( m_pOKBtn->IsEnabled() ) - m_pOKBtn->Enable( false ); - } + OUString aName = comphelper::string::strip(m_xNameEdit->get_text(), ' '); + m_xOKBtn->set_sensitive(!aName.isEmpty()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/fpicker/uiconfig/ui/foldernamedialog.ui b/fpicker/uiconfig/ui/foldernamedialog.ui index a07ada6fc202..559533a9d483 100644 --- a/fpicker/uiconfig/ui/foldernamedialog.ui +++ b/fpicker/uiconfig/ui/foldernamedialog.ui @@ -1,11 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> <interface domain="fps"> - <!-- interface-requires gtk+ 3.0 --> + <requires lib="gtk+" version="3.0"/> <object class="GtkDialog" id="FolderNameDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="foldernamedialog|FolderNameDialog">Folder Name ?</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> @@ -96,6 +103,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="expand">False</property> |