From 45112bfd091b8a14729f1010d2662c9064ba03e6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 17 May 2018 09:51:42 +0100 Subject: weld NameClashDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4c68bc92fa90ca4a9723f2664549f34b50213bfb Reviewed-on: https://gerrit.libreoffice.org/54471 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- uui/source/iahndl.cxx | 23 +++++++------- uui/source/nameclashdlg.cxx | 64 ++++++++++++++++---------------------- uui/source/nameclashdlg.hxx | 37 ++++++++++------------ uui/uiconfig/ui/simplenameclash.ui | 11 +++++-- 4 files changed, 62 insertions(+), 73 deletions(-) (limited to 'uui') diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index 63e3fbdea28a..fa017aabadab 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -1019,18 +1019,18 @@ executeMessageBox( return aResult; } -NameClashResolveDialogResult executeSimpleNameClashResolveDialog( vcl::Window *pParent, - OUString const & rTargetFolderURL, - OUString const & rClashingName, - OUString & rProposedNewName, - bool bAllowOverwrite ) +NameClashResolveDialogResult executeSimpleNameClashResolveDialog(weld::Window *pParent, + OUString const & rTargetFolderURL, + OUString const & rClashingName, + OUString & rProposedNewName, + bool bAllowOverwrite) { std::locale aResLocale = Translate::Create("uui"); - ScopedVclPtrInstance aDialog(pParent, aResLocale, rTargetFolderURL, - rClashingName, rProposedNewName, bAllowOverwrite); + NameClashDialog aDialog(pParent, aResLocale, rTargetFolderURL, + rClashingName, rProposedNewName, bAllowOverwrite); - NameClashResolveDialogResult eResult = static_cast(aDialog->Execute()); - rProposedNewName = aDialog->getNewName(); + NameClashResolveDialogResult eResult = static_cast(aDialog.run()); + rProposedNewName = aDialog.getNewName(); return eResult; } @@ -1063,11 +1063,12 @@ UUIInteractionHelper::handleNameClashResolveRequest( NameClashResolveDialogResult eResult = ABORT; OUString aProposedNewName( rRequest.ProposedNewName ); - eResult = executeSimpleNameClashResolveDialog( getParentProperty(), + uno::Reference xParent = getParentXWindow(); + eResult = executeSimpleNameClashResolveDialog(Application::GetFrameWeld(xParent), rRequest.TargetFolderURL, rRequest.ClashingName, aProposedNewName, - xReplaceExistingData.is() ); + xReplaceExistingData.is()); switch ( eResult ) { diff --git a/uui/source/nameclashdlg.cxx b/uui/source/nameclashdlg.cxx index 9403c21af606..5c64583da46d 100644 --- a/uui/source/nameclashdlg.cxx +++ b/uui/source/nameclashdlg.cxx @@ -27,48 +27,47 @@ // NameClashDialog --------------------------------------------------------- -IMPL_LINK( NameClashDialog, ButtonHdl_Impl, Button *, pBtn, void ) +IMPL_LINK(NameClashDialog, ButtonHdl_Impl, weld::Button&, rBtn, void) { long nRet = long(ABORT); - if ( m_pBtnRename == pBtn ) + if (m_xBtnRename.get() == &rBtn) { nRet = long(RENAME); - OUString aNewName = m_pEDNewName->GetText(); - if ( ( aNewName == maNewName ) || aNewName.isEmpty() ) + OUString aNewName = m_xEDNewName->get_text(); + if ( ( aNewName == m_aNewName ) || aNewName.isEmpty() ) { - std::unique_ptr xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xErrorBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, - maSameName)); + m_aSameName)); xErrorBox->run(); return; } - maNewName = aNewName; + m_aNewName = aNewName; } - else if ( m_pBtnOverwrite == pBtn ) + else if (m_xBtnOverwrite.get() == &rBtn) nRet = long(OVERWRITE); - EndDialog( nRet ); + m_xDialog->response(nRet); } -NameClashDialog::NameClashDialog( vcl::Window* pParent, const std::locale& rResLocale, +NameClashDialog::NameClashDialog( weld::Window* pParent, const std::locale& rResLocale, OUString const & rTargetFolderURL, OUString const & rClashingName, OUString const & rProposedNewName, bool bAllowOverwrite ) - : ModalDialog( pParent, "SimpleNameClashDialog", "uui/ui/simplenameclash.ui" ), - maNewName ( rClashingName ) + : GenericDialogController(pParent, "uui/ui/simplenameclash.ui", "SimpleNameClashDialog") + , m_aNewName(rClashingName) + , m_xFTMessage(m_xBuilder->weld_label("warning")) + , m_xEDNewName(m_xBuilder->weld_entry("newname")) + , m_xBtnOverwrite(m_xBuilder->weld_button("replace")) + , m_xBtnRename(m_xBuilder->weld_button("rename")) + , m_xBtnCancel(m_xBuilder->weld_button("cancel")) { - get(m_pFTMessage, "warning"); - get(m_pEDNewName, "newname"); - get(m_pBtnOverwrite, "replace"); - get(m_pBtnRename, "rename"); - get(m_pBtnCancel, "cancel"); - - Link aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) ); - m_pBtnOverwrite->SetClickHdl( aLink ); - m_pBtnRename->SetClickHdl( aLink ); - m_pBtnCancel->SetClickHdl( aLink ); + Link aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) ); + m_xBtnOverwrite->connect_clicked( aLink ); + m_xBtnRename->connect_clicked( aLink ); + m_xBtnCancel->connect_clicked( aLink ); OUString aInfo; if ( bAllowOverwrite ) @@ -78,37 +77,26 @@ NameClashDialog::NameClashDialog( vcl::Window* pParent, const std::locale& rResL else { aInfo = Translate::get(STR_NAME_CLASH_RENAME_ONLY, rResLocale); - m_pBtnOverwrite->Hide(); + m_xBtnOverwrite->hide(); } OUString aPath; if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) ) aPath = rTargetFolderURL; - maSameName = Translate::get(STR_SAME_NAME_USED, rResLocale); + m_aSameName = Translate::get(STR_SAME_NAME_USED, rResLocale); aInfo = aInfo.replaceFirst( "%NAME", rClashingName ); aInfo = aInfo.replaceFirst( "%FOLDER", aPath ); - m_pFTMessage->SetText( aInfo ); + m_xFTMessage->set_label(aInfo); if ( !rProposedNewName.isEmpty() ) - m_pEDNewName->SetText( rProposedNewName ); + m_xEDNewName->set_text( rProposedNewName ); else - m_pEDNewName->SetText( rClashingName ); + m_xEDNewName->set_text( rClashingName ); } NameClashDialog::~NameClashDialog() { - disposeOnce(); -} - -void NameClashDialog::dispose() -{ - m_pFTMessage.clear(); - m_pEDNewName.clear(); - m_pBtnOverwrite.clear(); - m_pBtnRename.clear(); - m_pBtnCancel.clear(); - ModalDialog::dispose(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/uui/source/nameclashdlg.hxx b/uui/source/nameclashdlg.hxx index 9b357b3803e6..39d9af835f58 100644 --- a/uui/source/nameclashdlg.hxx +++ b/uui/source/nameclashdlg.hxx @@ -20,36 +20,31 @@ #ifndef INCLUDED_UUI_SOURCE_NAMECLASHDLG_HXX #define INCLUDED_UUI_SOURCE_NAMECLASHDLG_HXX -#include -#include -#include -#include - +#include enum NameClashResolveDialogResult { ABORT, RENAME, OVERWRITE }; -class NameClashDialog : public ModalDialog +class NameClashDialog : public weld::GenericDialogController { - VclPtr m_pFTMessage; - VclPtr m_pEDNewName; - VclPtr m_pBtnOverwrite; - VclPtr m_pBtnRename; - VclPtr m_pBtnCancel; + OUString m_aSameName; + OUString m_aNewName; - OUString maSameName; - OUString maNewName; + std::unique_ptr m_xFTMessage; + std::unique_ptr m_xEDNewName; + std::unique_ptr m_xBtnOverwrite; + std::unique_ptr m_xBtnRename; + std::unique_ptr m_xBtnCancel; - DECL_LINK( ButtonHdl_Impl, Button *, void ); + DECL_LINK(ButtonHdl_Impl, weld::Button&, void); public: - NameClashDialog( vcl::Window* pParent, const std::locale& rLocale, - OUString const & rTargetFolderURL, - OUString const & rClashingName, - OUString const & rProposedNewName, - bool bAllowOverwrite ); + NameClashDialog(weld::Window* pParent, const std::locale& rLocale, + OUString const & rTargetFolderURL, + OUString const & rClashingName, + OUString const & rProposedNewName, + bool bAllowOverwrite); virtual ~NameClashDialog() override; - virtual void dispose() override; - const OUString& getNewName() const { return maNewName; } + const OUString& getNewName() const { return m_aNewName; } }; #endif // UUI_COOKIEDG_HXX diff --git a/uui/uiconfig/ui/simplenameclash.ui b/uui/uiconfig/ui/simplenameclash.ui index e276083fa732..e332548c01e0 100644 --- a/uui/uiconfig/ui/simplenameclash.ui +++ b/uui/uiconfig/ui/simplenameclash.ui @@ -1,12 +1,18 @@ - + False 6 File Exists + True + 0 + 0 dialog + + + False @@ -109,6 +115,7 @@ True True True + True False @@ -127,8 +134,6 @@ help - replace - rename cancel -- cgit