summaryrefslogtreecommitdiff
path: root/uui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-17 09:51:42 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-05-17 14:29:09 +0200
commit45112bfd091b8a14729f1010d2662c9064ba03e6 (patch)
tree6a196e3f63957248c16d4cd6b03b3dc3c6bafc32 /uui
parent27c9370b5fd00b851582e4163907656286e8c581 (diff)
weld NameClashDialog
Change-Id: I4c68bc92fa90ca4a9723f2664549f34b50213bfb Reviewed-on: https://gerrit.libreoffice.org/54471 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'uui')
-rw-r--r--uui/source/iahndl.cxx23
-rw-r--r--uui/source/nameclashdlg.cxx64
-rw-r--r--uui/source/nameclashdlg.hxx37
-rw-r--r--uui/uiconfig/ui/simplenameclash.ui11
4 files changed, 62 insertions, 73 deletions
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<NameClashDialog> aDialog(pParent, aResLocale, rTargetFolderURL,
- rClashingName, rProposedNewName, bAllowOverwrite);
+ NameClashDialog aDialog(pParent, aResLocale, rTargetFolderURL,
+ rClashingName, rProposedNewName, bAllowOverwrite);
- NameClashResolveDialogResult eResult = static_cast<NameClashResolveDialogResult>(aDialog->Execute());
- rProposedNewName = aDialog->getNewName();
+ NameClashResolveDialogResult eResult = static_cast<NameClashResolveDialogResult>(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<awt::XWindow> 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<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> 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<Button*,void> aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) );
- m_pBtnOverwrite->SetClickHdl( aLink );
- m_pBtnRename->SetClickHdl( aLink );
- m_pBtnCancel->SetClickHdl( aLink );
+ Link<weld::Button&,void> 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 <vcl/button.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/edit.hxx>
-
+#include <vcl/weld.hxx>
enum NameClashResolveDialogResult { ABORT, RENAME, OVERWRITE };
-class NameClashDialog : public ModalDialog
+class NameClashDialog : public weld::GenericDialogController
{
- VclPtr<FixedText> m_pFTMessage;
- VclPtr<Edit> m_pEDNewName;
- VclPtr<PushButton> m_pBtnOverwrite;
- VclPtr<PushButton> m_pBtnRename;
- VclPtr<CancelButton> m_pBtnCancel;
+ OUString m_aSameName;
+ OUString m_aNewName;
- OUString maSameName;
- OUString maNewName;
+ std::unique_ptr<weld::Label> m_xFTMessage;
+ std::unique_ptr<weld::Entry> m_xEDNewName;
+ std::unique_ptr<weld::Button> m_xBtnOverwrite;
+ std::unique_ptr<weld::Button> m_xBtnRename;
+ std::unique_ptr<weld::Button> 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 @@
<?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="SimpleNameClashDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="simplenameclash|SimpleNameClashDialog">File Exists</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>
@@ -109,6 +115,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>
@@ -127,8 +134,6 @@
</child>
<action-widgets>
<action-widget response="-11">help</action-widget>
- <action-widget response="0">replace</action-widget>
- <action-widget response="0">rename</action-widget>
<action-widget response="-6">cancel</action-widget>
</action-widgets>
</object>