Kaydet (Commit) 2410cce3 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld BrokenRecoveryDialog

Change-Id: I6bcc067eba0648f0f4c000d1fbb811d9235c8707
Reviewed-on: https://gerrit.libreoffice.org/61870
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst d29d759b
......@@ -449,6 +449,7 @@ void SAL_CALL RecoveryCore::statusChanged(const css::frame::FeatureStateEvent& a
if (sURL.isEmpty())
sURL = aNew.TemplateURL;
INetURLObject aURL(sURL);
aNew.StandardImageId = SvFileInformationManager::GetFileImageId(aURL);
aNew.StandardImage = SvFileInformationManager::GetFileImage(aURL);
/* set the right UI state for this item to NOT_RECOVERED_YET... because nDocState shows the state of
......@@ -959,14 +960,13 @@ short RecoveryDialog::Execute()
// failed recovery documents. They must be saved to
// a user selected directory.
short nRet = DLG_RET_UNKNOWN;
ScopedVclPtrInstance< BrokenRecoveryDialog > pBrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
OUString sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); // get the default dir
if (pBrokenRecoveryDialog->isExecutionNeeded())
BrokenRecoveryDialog aBrokenRecoveryDialog(GetFrameWeld(), m_pCore, !m_bWasRecoveryStarted);
OUString sSaveDir = aBrokenRecoveryDialog.getSaveDirURL(); // get the default dir
if (aBrokenRecoveryDialog.isExecutionNeeded())
{
nRet = pBrokenRecoveryDialog->Execute();
sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
nRet = aBrokenRecoveryDialog.run();
sSaveDir = aBrokenRecoveryDialog.getSaveDirURL();
}
pBrokenRecoveryDialog.disposeAndClear();
switch(nRet)
{
......@@ -1027,18 +1027,17 @@ short RecoveryDialog::Execute()
// They should be saved to a user defined location.
// If no temp files exists or user decided to ignore it ...
// we have to remove all recovery/session data anyway!
short nRet = DLG_RET_UNKNOWN;
ScopedVclPtrInstance< BrokenRecoveryDialog > pBrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
OUString sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); // get the default save location
short nRet = DLG_RET_UNKNOWN;
BrokenRecoveryDialog aBrokenRecoveryDialog(GetFrameWeld(), m_pCore, !m_bWasRecoveryStarted);
OUString sSaveDir = aBrokenRecoveryDialog.getSaveDirURL(); // get the default save location
// dialog itself checks if there is a need to copy files for this mode.
// It uses the information m_bWasRecoveryStarted doing so.
if (pBrokenRecoveryDialog->isExecutionNeeded())
if (aBrokenRecoveryDialog.isExecutionNeeded())
{
nRet = pBrokenRecoveryDialog->Execute();
sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
nRet = aBrokenRecoveryDialog.run();
sSaveDir = aBrokenRecoveryDialog.getSaveDirURL();
}
pBrokenRecoveryDialog.disposeAndClear();
// Possible states:
// a) nRet == DLG_RET_UNKNOWN
......@@ -1109,7 +1108,6 @@ void RecoveryDialog::updateItems()
m_pFileListLB->Update();
}
void RecoveryDialog::stepNext(TURLInfo* pItem)
{
sal_uIntPtr c = m_pFileListLB->GetEntryCount();
......@@ -1206,49 +1204,36 @@ OUString RecoveryDialog::impl_getStatusString( const TURLInfo& rInfo ) const
return sStatus;
}
BrokenRecoveryDialog::BrokenRecoveryDialog(vcl::Window* pParent ,
RecoveryCore* pCore ,
bool bBeforeRecovery)
: ModalDialog ( pParent, "DocRecoveryBrokenDialog", "svx/ui/docrecoverybrokendialog.ui" )
, m_pCore ( pCore )
, m_bBeforeRecovery (bBeforeRecovery)
BrokenRecoveryDialog::BrokenRecoveryDialog(weld::Window* pParent,
RecoveryCore* pCore,
bool bBeforeRecovery)
: GenericDialogController(pParent, "svx/ui/docrecoverybrokendialog.ui", "DocRecoveryBrokenDialog")
, m_pCore(pCore)
, m_bBeforeRecovery(bBeforeRecovery)
, m_bExecutionNeeded(false)
, m_xFileListLB(m_xBuilder->weld_tree_view("filelist"))
, m_xSaveDirED(m_xBuilder->weld_entry("savedir"))
, m_xSaveDirBtn(m_xBuilder->weld_button("change"))
, m_xOkBtn(m_xBuilder->weld_button("ok"))
, m_xCancelBtn(m_xBuilder->weld_button("cancel"))
{
get(m_pFileListLB, "filelist");
get(m_pSaveDirED, "savedir");
get(m_pSaveDirBtn, "change");
get(m_pOkBtn, "save");
get(m_pCancelBtn, "cancel");
m_pSaveDirBtn->SetClickHdl( LINK( this, BrokenRecoveryDialog, SaveButtonHdl ) );
m_pOkBtn->SetClickHdl( LINK( this, BrokenRecoveryDialog, OkButtonHdl ) );
m_pCancelBtn->SetClickHdl( LINK( this, BrokenRecoveryDialog, CancelButtonHdl ) );
m_xSaveDirBtn->connect_clicked( LINK( this, BrokenRecoveryDialog, SaveButtonHdl ) );
m_xOkBtn->connect_clicked( LINK( this, BrokenRecoveryDialog, OkButtonHdl ) );
m_xCancelBtn->connect_clicked( LINK( this, BrokenRecoveryDialog, CancelButtonHdl ) );
m_sSavePath = SvtPathOptions().GetWorkPath();
INetURLObject aObj( m_sSavePath );
OUString sPath;
osl::FileBase::getSystemPathFromFileURL(aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), sPath);
m_pSaveDirED->SetText( sPath );
m_xSaveDirED->set_text(sPath);
impl_refresh();
}
BrokenRecoveryDialog::~BrokenRecoveryDialog()
{
disposeOnce();
}
void BrokenRecoveryDialog::dispose()
{
m_pFileListLB.clear();
m_pSaveDirED.clear();
m_pSaveDirBtn.clear();
m_pOkBtn.clear();
m_pCancelBtn.clear();
ModalDialog::dispose();
}
void BrokenRecoveryDialog::impl_refresh()
{
m_bExecutionNeeded = false;
......@@ -1277,51 +1262,44 @@ void BrokenRecoveryDialog::impl_refresh()
m_bExecutionNeeded = true;
const sal_Int32 nPos = m_pFileListLB->InsertEntry(rInfo.DisplayName, rInfo.StandardImage );
m_pFileListLB->SetEntryData( nPos, const_cast<TURLInfo *>(&rInfo) );
m_xFileListLB->append(OUString::number(reinterpret_cast<sal_IntPtr>(&rInfo)), rInfo.DisplayName, rInfo.StandardImageId);
}
m_sSavePath.clear();
m_pOkBtn->GrabFocus();
m_xOkBtn->grab_focus();
}
bool BrokenRecoveryDialog::isExecutionNeeded()
{
return m_bExecutionNeeded;
}
const OUString& BrokenRecoveryDialog::getSaveDirURL()
{
return m_sSavePath;
}
IMPL_LINK_NOARG(BrokenRecoveryDialog, OkButtonHdl, Button*, void)
IMPL_LINK_NOARG(BrokenRecoveryDialog, OkButtonHdl, weld::Button&, void)
{
OUString sPhysicalPath = comphelper::string::strip(m_pSaveDirED->GetText(), ' ');
OUString sPhysicalPath = comphelper::string::strip(m_xSaveDirED->get_text(), ' ');
OUString sURL;
osl::FileBase::getFileURLFromSystemPath( sPhysicalPath, sURL );
m_sSavePath = sURL;
while (m_sSavePath.isEmpty())
impl_askForSavePath();
EndDialog(DLG_RET_OK);
m_xDialog->response(DLG_RET_OK);
}
IMPL_LINK_NOARG(BrokenRecoveryDialog, CancelButtonHdl, Button*, void)
IMPL_LINK_NOARG(BrokenRecoveryDialog, CancelButtonHdl, weld::Button&, void)
{
EndDialog();
m_xDialog->response(RET_CANCEL);
}
IMPL_LINK_NOARG(BrokenRecoveryDialog, SaveButtonHdl, Button*, void)
IMPL_LINK_NOARG(BrokenRecoveryDialog, SaveButtonHdl, weld::Button&, void)
{
impl_askForSavePath();
}
void BrokenRecoveryDialog::impl_askForSavePath()
{
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker =
......@@ -1335,7 +1313,7 @@ void BrokenRecoveryDialog::impl_askForSavePath()
m_sSavePath = xFolderPicker->getDirectory();
OUString sPath;
osl::FileBase::getSystemPathFromFileURL(m_sSavePath, sPath);
m_pSaveDirED->SetText( sPath );
m_xSaveDirED->set_text(sPath);
}
}
......
......@@ -70,8 +70,8 @@
#define RECOVERY_OPERATIONSTATE_UPDATE "update"
#define DLG_RET_UNKNOWN -1
#define DLG_RET_OK 1
#define DLG_RET_CANCEL 0
#define DLG_RET_OK RET_OK
#define DLG_RET_CANCEL RET_CANCEL
#define DLG_RET_OK_AUTOLUNCH 101
......@@ -146,6 +146,7 @@ struct TURLInfo
/// standard icon
Image StandardImage;
OUString StandardImageId;
public:
......@@ -535,65 +536,58 @@ class RecoveryDialog : public Dialog
};
class BrokenRecoveryDialog : public ModalDialog
class BrokenRecoveryDialog : public weld::GenericDialogController
{
// member
private:
OUString m_sSavePath;
RecoveryCore* m_pCore;
bool const m_bBeforeRecovery;
bool m_bExecutionNeeded;
std::unique_ptr<weld::TreeView> m_xFileListLB;
std::unique_ptr<weld::Entry> m_xSaveDirED;
std::unique_ptr<weld::Button> m_xSaveDirBtn;
std::unique_ptr<weld::Button> m_xOkBtn;
std::unique_ptr<weld::Button> m_xCancelBtn;
// interface
public:
// member
private:
VclPtr<ListBox> m_pFileListLB;
VclPtr<Edit> m_pSaveDirED;
VclPtr<PushButton> m_pSaveDirBtn;
VclPtr<PushButton> m_pOkBtn;
VclPtr<CancelButton> m_pCancelBtn;
OUString m_sSavePath;
RecoveryCore* m_pCore;
bool const m_bBeforeRecovery;
bool m_bExecutionNeeded;
// interface
public:
/** @short TODO */
BrokenRecoveryDialog(vcl::Window* pParent ,
RecoveryCore* pCore ,
bool bBeforeRecovery);
virtual ~BrokenRecoveryDialog() override;
virtual void dispose() override;
/** @short TODO */
bool isExecutionNeeded();
/** @short TODO */
BrokenRecoveryDialog(weld::Window* pParent,
RecoveryCore* pCore,
bool bBeforeRecovery);
virtual ~BrokenRecoveryDialog() override;
/** @short TODO */
const OUString& getSaveDirURL();
/** @short TODO */
bool isExecutionNeeded();
// helper
private:
/** @short TODO */
const OUString& getSaveDirURL();
/** @short TODO */
void impl_refresh();
// helper
private:
/** @short TODO */
void impl_refresh();
/** @short TODO */
DECL_LINK(SaveButtonHdl, Button*, void);
/** @short TODO */
DECL_LINK(SaveButtonHdl, weld::Button&, void);
/** @short TODO */
DECL_LINK(OkButtonHdl, Button*, void);
/** @short TODO */
DECL_LINK(OkButtonHdl, weld::Button&, void);
/** @short TODO */
DECL_LINK(CancelButtonHdl, Button*, void);
/** @short TODO */
DECL_LINK(CancelButtonHdl, weld::Button&, void);
/** @short TODO */
void impl_askForSavePath();
/** @short TODO */
void impl_askForSavePath();
};
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.18"/>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="DocRecoveryBrokenDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="docrecoverybrokendialog|DocRecoveryBrokenDialog">%PRODUCTNAME Document Recovery</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>
......@@ -17,9 +31,8 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="save">
<object class="GtkButton" id="ok">
<property name="label" translatable="yes" context="docrecoverybrokendialog|save">_Save</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
......@@ -36,7 +49,6 @@
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......@@ -70,12 +82,12 @@
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="docrecoverybrokendialog|label1">The automatic recovery process was interrupted.
The documents listed below will be saved in the folder noted below if you click 'Save'. Click 'Cancel' to close the wizard without saving the documents.</property>
<property name="wrap">True</property>
<property name="max_width_chars">100</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -90,7 +102,7 @@ The documents listed below will be saved in the folder noted below if you click
<property name="halign">start</property>
<property name="label" translatable="yes" context="docrecoverybrokendialog|label3">Documents:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">filelist:border</property>
<property name="mnemonic_widget">filelist</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -99,14 +111,38 @@ The documents listed below will be saved in the folder noted below if you click
</packing>
</child>
<child>
<object class="GtkTreeView" id="filelist:border">
<property name="height_request">100</property>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="filelist">
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
......@@ -120,10 +156,10 @@ The documents listed below will be saved in the folder noted below if you click
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="docrecoverybrokendialog|label4">_Save to:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">savedir</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -152,7 +188,6 @@ The documents listed below will be saved in the folder noted below if you click
<child>
<object class="GtkButton" id="change">
<property name="label" translatable="yes" context="docrecoverybrokendialog|change">Chan_ge...</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......@@ -181,7 +216,7 @@ The documents listed below will be saved in the folder noted below if you click
</object>
</child>
<action-widgets>
<action-widget response="0">save</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
</action-widgets>
</object>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment