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>
This commit is contained in:
@@ -1019,18 +1019,18 @@ executeMessageBox(
|
|||||||
return aResult;
|
return aResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
NameClashResolveDialogResult executeSimpleNameClashResolveDialog( vcl::Window *pParent,
|
NameClashResolveDialogResult executeSimpleNameClashResolveDialog(weld::Window *pParent,
|
||||||
OUString const & rTargetFolderURL,
|
OUString const & rTargetFolderURL,
|
||||||
OUString const & rClashingName,
|
OUString const & rClashingName,
|
||||||
OUString & rProposedNewName,
|
OUString & rProposedNewName,
|
||||||
bool bAllowOverwrite )
|
bool bAllowOverwrite)
|
||||||
{
|
{
|
||||||
std::locale aResLocale = Translate::Create("uui");
|
std::locale aResLocale = Translate::Create("uui");
|
||||||
ScopedVclPtrInstance<NameClashDialog> aDialog(pParent, aResLocale, rTargetFolderURL,
|
NameClashDialog aDialog(pParent, aResLocale, rTargetFolderURL,
|
||||||
rClashingName, rProposedNewName, bAllowOverwrite);
|
rClashingName, rProposedNewName, bAllowOverwrite);
|
||||||
|
|
||||||
NameClashResolveDialogResult eResult = static_cast<NameClashResolveDialogResult>(aDialog->Execute());
|
NameClashResolveDialogResult eResult = static_cast<NameClashResolveDialogResult>(aDialog.run());
|
||||||
rProposedNewName = aDialog->getNewName();
|
rProposedNewName = aDialog.getNewName();
|
||||||
return eResult;
|
return eResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1063,11 +1063,12 @@ UUIInteractionHelper::handleNameClashResolveRequest(
|
|||||||
NameClashResolveDialogResult eResult = ABORT;
|
NameClashResolveDialogResult eResult = ABORT;
|
||||||
OUString aProposedNewName( rRequest.ProposedNewName );
|
OUString aProposedNewName( rRequest.ProposedNewName );
|
||||||
|
|
||||||
eResult = executeSimpleNameClashResolveDialog( getParentProperty(),
|
uno::Reference<awt::XWindow> xParent = getParentXWindow();
|
||||||
|
eResult = executeSimpleNameClashResolveDialog(Application::GetFrameWeld(xParent),
|
||||||
rRequest.TargetFolderURL,
|
rRequest.TargetFolderURL,
|
||||||
rRequest.ClashingName,
|
rRequest.ClashingName,
|
||||||
aProposedNewName,
|
aProposedNewName,
|
||||||
xReplaceExistingData.is() );
|
xReplaceExistingData.is());
|
||||||
|
|
||||||
switch ( eResult )
|
switch ( eResult )
|
||||||
{
|
{
|
||||||
|
@@ -27,48 +27,47 @@
|
|||||||
|
|
||||||
// NameClashDialog ---------------------------------------------------------
|
// NameClashDialog ---------------------------------------------------------
|
||||||
|
|
||||||
IMPL_LINK( NameClashDialog, ButtonHdl_Impl, Button *, pBtn, void )
|
IMPL_LINK(NameClashDialog, ButtonHdl_Impl, weld::Button&, rBtn, void)
|
||||||
{
|
{
|
||||||
long nRet = long(ABORT);
|
long nRet = long(ABORT);
|
||||||
if ( m_pBtnRename == pBtn )
|
if (m_xBtnRename.get() == &rBtn)
|
||||||
{
|
{
|
||||||
nRet = long(RENAME);
|
nRet = long(RENAME);
|
||||||
OUString aNewName = m_pEDNewName->GetText();
|
OUString aNewName = m_xEDNewName->get_text();
|
||||||
if ( ( aNewName == maNewName ) || aNewName.isEmpty() )
|
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,
|
VclMessageType::Warning, VclButtonsType::Ok,
|
||||||
maSameName));
|
m_aSameName));
|
||||||
xErrorBox->run();
|
xErrorBox->run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
maNewName = aNewName;
|
m_aNewName = aNewName;
|
||||||
}
|
}
|
||||||
else if ( m_pBtnOverwrite == pBtn )
|
else if (m_xBtnOverwrite.get() == &rBtn)
|
||||||
nRet = long(OVERWRITE);
|
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 & rTargetFolderURL,
|
||||||
OUString const & rClashingName,
|
OUString const & rClashingName,
|
||||||
OUString const & rProposedNewName,
|
OUString const & rProposedNewName,
|
||||||
bool bAllowOverwrite )
|
bool bAllowOverwrite )
|
||||||
: ModalDialog( pParent, "SimpleNameClashDialog", "uui/ui/simplenameclash.ui" ),
|
: GenericDialogController(pParent, "uui/ui/simplenameclash.ui", "SimpleNameClashDialog")
|
||||||
maNewName ( rClashingName )
|
, 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");
|
Link<weld::Button&,void> aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) );
|
||||||
get(m_pEDNewName, "newname");
|
m_xBtnOverwrite->connect_clicked( aLink );
|
||||||
get(m_pBtnOverwrite, "replace");
|
m_xBtnRename->connect_clicked( aLink );
|
||||||
get(m_pBtnRename, "rename");
|
m_xBtnCancel->connect_clicked( aLink );
|
||||||
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 );
|
|
||||||
|
|
||||||
OUString aInfo;
|
OUString aInfo;
|
||||||
if ( bAllowOverwrite )
|
if ( bAllowOverwrite )
|
||||||
@@ -78,37 +77,26 @@ NameClashDialog::NameClashDialog( vcl::Window* pParent, const std::locale& rResL
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
aInfo = Translate::get(STR_NAME_CLASH_RENAME_ONLY, rResLocale);
|
aInfo = Translate::get(STR_NAME_CLASH_RENAME_ONLY, rResLocale);
|
||||||
m_pBtnOverwrite->Hide();
|
m_xBtnOverwrite->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
OUString aPath;
|
OUString aPath;
|
||||||
if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) )
|
if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) )
|
||||||
aPath = rTargetFolderURL;
|
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( "%NAME", rClashingName );
|
||||||
aInfo = aInfo.replaceFirst( "%FOLDER", aPath );
|
aInfo = aInfo.replaceFirst( "%FOLDER", aPath );
|
||||||
m_pFTMessage->SetText( aInfo );
|
m_xFTMessage->set_label(aInfo);
|
||||||
if ( !rProposedNewName.isEmpty() )
|
if ( !rProposedNewName.isEmpty() )
|
||||||
m_pEDNewName->SetText( rProposedNewName );
|
m_xEDNewName->set_text( rProposedNewName );
|
||||||
else
|
else
|
||||||
m_pEDNewName->SetText( rClashingName );
|
m_xEDNewName->set_text( rClashingName );
|
||||||
}
|
}
|
||||||
|
|
||||||
NameClashDialog::~NameClashDialog()
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -20,36 +20,31 @@
|
|||||||
#ifndef INCLUDED_UUI_SOURCE_NAMECLASHDLG_HXX
|
#ifndef INCLUDED_UUI_SOURCE_NAMECLASHDLG_HXX
|
||||||
#define INCLUDED_UUI_SOURCE_NAMECLASHDLG_HXX
|
#define INCLUDED_UUI_SOURCE_NAMECLASHDLG_HXX
|
||||||
|
|
||||||
#include <vcl/button.hxx>
|
#include <vcl/weld.hxx>
|
||||||
#include <vcl/dialog.hxx>
|
|
||||||
#include <vcl/fixed.hxx>
|
|
||||||
#include <vcl/edit.hxx>
|
|
||||||
|
|
||||||
|
|
||||||
enum NameClashResolveDialogResult { ABORT, RENAME, OVERWRITE };
|
enum NameClashResolveDialogResult { ABORT, RENAME, OVERWRITE };
|
||||||
|
|
||||||
class NameClashDialog : public ModalDialog
|
class NameClashDialog : public weld::GenericDialogController
|
||||||
{
|
{
|
||||||
VclPtr<FixedText> m_pFTMessage;
|
OUString m_aSameName;
|
||||||
VclPtr<Edit> m_pEDNewName;
|
OUString m_aNewName;
|
||||||
VclPtr<PushButton> m_pBtnOverwrite;
|
|
||||||
VclPtr<PushButton> m_pBtnRename;
|
|
||||||
VclPtr<CancelButton> m_pBtnCancel;
|
|
||||||
|
|
||||||
OUString maSameName;
|
std::unique_ptr<weld::Label> m_xFTMessage;
|
||||||
OUString maNewName;
|
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:
|
public:
|
||||||
NameClashDialog( vcl::Window* pParent, const std::locale& rLocale,
|
NameClashDialog(weld::Window* pParent, const std::locale& rLocale,
|
||||||
OUString const & rTargetFolderURL,
|
OUString const & rTargetFolderURL,
|
||||||
OUString const & rClashingName,
|
OUString const & rClashingName,
|
||||||
OUString const & rProposedNewName,
|
OUString const & rProposedNewName,
|
||||||
bool bAllowOverwrite );
|
bool bAllowOverwrite);
|
||||||
virtual ~NameClashDialog() override;
|
virtual ~NameClashDialog() override;
|
||||||
virtual void dispose() override;
|
const OUString& getNewName() const { return m_aNewName; }
|
||||||
const OUString& getNewName() const { return maNewName; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UUI_COOKIEDG_HXX
|
#endif // UUI_COOKIEDG_HXX
|
||||||
|
@@ -1,12 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Generated with glade 3.18.3 -->
|
<!-- Generated with glade 3.22.1 -->
|
||||||
<interface domain="uui">
|
<interface domain="uui">
|
||||||
<requires lib="gtk+" version="3.18"/>
|
<requires lib="gtk+" version="3.18"/>
|
||||||
<object class="GtkDialog" id="SimpleNameClashDialog">
|
<object class="GtkDialog" id="SimpleNameClashDialog">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
<property name="title" translatable="yes" context="simplenameclash|SimpleNameClashDialog">File Exists</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>
|
<property name="type_hint">dialog</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
<object class="GtkBox" id="dialog-vbox1">
|
<object class="GtkBox" id="dialog-vbox1">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@@ -109,6 +115,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
|
<property name="activates_default">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -127,8 +134,6 @@
|
|||||||
</child>
|
</child>
|
||||||
<action-widgets>
|
<action-widgets>
|
||||||
<action-widget response="-11">help</action-widget>
|
<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-widget response="-6">cancel</action-widget>
|
||||||
</action-widgets>
|
</action-widgets>
|
||||||
</object>
|
</object>
|
||||||
|
Reference in New Issue
Block a user