Kaydet (Commit) 45980b72 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SaveDialog

Change-Id: Iaef35328c0657a4538d4b4a44734146baee0346b
Reviewed-on: https://gerrit.libreoffice.org/61153
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst e3294b1b
...@@ -646,52 +646,39 @@ void SAL_CALL WeldPluginProgress::reset() ...@@ -646,52 +646,39 @@ void SAL_CALL WeldPluginProgress::reset()
m_pProgressBar->set_percentage(0); m_pProgressBar->set_percentage(0);
} }
SaveDialog::SaveDialog(vcl::Window* pParent, RecoveryCore* pCore) SaveDialog::SaveDialog(weld::Window* pParent, RecoveryCore* pCore)
: Dialog(pParent, "DocRecoverySaveDialog", : GenericDialogController(pParent, "svx/ui/docrecoverysavedialog.ui", "DocRecoverySaveDialog")
"svx/ui/docrecoverysavedialog.ui")
, m_pCore(pCore) , m_pCore(pCore)
, m_xFileListLB(m_xBuilder->weld_tree_view("filelist"))
, m_xOkBtn(m_xBuilder->weld_button("ok"))
{ {
get(m_pFileListLB, "filelist"); m_xFileListLB->set_size_request(-1, m_xFileListLB->get_height_rows(10));
m_pFileListLB->set_height_request(m_pFileListLB->GetTextHeight() * 10);
get(m_pOkBtn, "ok");
// Prepare the office for the following crash save step. // Prepare the office for the following crash save step.
// E.g. hide all open windows so the user can't influence our // E.g. hide all open windows so the user can't influence our
// operation .-) // operation .-)
m_pCore->doEmergencySavePrepare(); m_pCore->doEmergencySavePrepare();
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); m_xOkBtn->connect_clicked(LINK(this, SaveDialog, OKButtonHdl));
m_pOkBtn->SetClickHdl( LINK( this, SaveDialog, OKButtonHdl ) );
m_pFileListLB->SetControlBackground( rStyleSettings.GetDialogColor() );
// fill listbox with current open documents // fill listbox with current open documents
m_pFileListLB->Clear();
TURLList& rURLs = m_pCore->getURLListAccess(); TURLList& rURLs = m_pCore->getURLListAccess();
for (const TURLInfo& rInfo : rURLs) for (const TURLInfo& rInfo : rURLs)
{ {
m_pFileListLB->InsertEntry( rInfo.DisplayName, rInfo.StandardImage ); m_xFileListLB->append("", rInfo.DisplayName, rInfo.StandardImageId);
} }
} }
SaveDialog::~SaveDialog() SaveDialog::~SaveDialog()
{ {
disposeOnce();
}
void SaveDialog::dispose()
{
m_pFileListLB.clear();
m_pOkBtn.clear();
Dialog::dispose();
} }
IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, Button*, void) IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, weld::Button&, void)
{ {
// start crash-save with progress // start crash-save with progress
std::unique_ptr<SaveProgressDialog> xProgress(new SaveProgressDialog(GetFrameWeld(), m_pCore)); std::unique_ptr<SaveProgressDialog> xProgress(new SaveProgressDialog(m_xDialog.get(), m_pCore));
short nResult = xProgress->run(); short nResult = xProgress->run();
xProgress.reset(); xProgress.reset();
...@@ -700,7 +687,7 @@ IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, Button*, void) ...@@ -700,7 +687,7 @@ IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, Button*, void)
if (nResult == DLG_RET_OK) if (nResult == DLG_RET_OK)
nResult = DLG_RET_OK_AUTOLUNCH; nResult = DLG_RET_OK_AUTOLUNCH;
EndDialog(nResult); m_xDialog->response(nResult);
} }
SaveProgressDialog::SaveProgressDialog(weld::Window* pParent, RecoveryCore* pCore) SaveProgressDialog::SaveProgressDialog(weld::Window* pParent, RecoveryCore* pCore)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
#include <vcl/tabdlg.hxx> #include <vcl/tabdlg.hxx>
#include <vcl/tabpage.hxx> #include <vcl/tabpage.hxx>
#include <vcl/weld.hxx>
#include <svtools/simptabl.hxx> #include <svtools/simptabl.hxx>
#include <vcl/svlbitm.hxx> #include <vcl/svlbitm.hxx>
#include <svtools/svmedit2.hxx> #include <svtools/svmedit2.hxx>
...@@ -381,36 +382,35 @@ public: ...@@ -381,36 +382,35 @@ public:
virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener) override; virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener) override;
}; };
class SaveDialog : public Dialog class SaveDialog : public weld::GenericDialogController
{ {
// member // member
private: private:
VclPtr<ListBox> m_pFileListLB; RecoveryCore* m_pCore;
VclPtr<OKButton> m_pOkBtn; std::unique_ptr<weld::TreeView> m_xFileListLB;
RecoveryCore* m_pCore; std::unique_ptr<weld::Button> m_xOkBtn;
// interface // interface
public: public:
/** @short create all child controls of this dialog. /** @short create all child controls of this dialog.
@descr The dialog isn't shown nor it starts any @descr The dialog isn't shown nor it starts any
action by itself! action by itself!
@param pParent @param pParent
can point to a parent window. can point to a parent window.
If its set to 0, the defmodal-dialog-parent If its set to 0, the defmodal-dialog-parent
is used automatically. is used automatically.
@param pCore @param pCore
provides access to the recovery core service provides access to the recovery core service
and the current list of open documents, and the current list of open documents,
which should be shown inside this dialog. which should be shown inside this dialog.
*/ */
SaveDialog(vcl::Window* pParent, RecoveryCore* pCore); SaveDialog(weld::Window* pParent, RecoveryCore* pCore);
virtual ~SaveDialog() override; virtual ~SaveDialog() override;
virtual void dispose() override;
DECL_LINK(OKButtonHdl, Button*, void); DECL_LINK(OKButtonHdl, weld::Button&, void);
}; };
class SaveProgressDialog : public weld::GenericDialogController class SaveProgressDialog : public weld::GenericDialogController
......
...@@ -247,11 +247,10 @@ bool RecoveryUI::impl_doEmergencySave() ...@@ -247,11 +247,10 @@ bool RecoveryUI::impl_doEmergencySave()
rtl::Reference<svxdr::RecoveryCore> pCore = new svxdr::RecoveryCore(m_xContext, true); rtl::Reference<svxdr::RecoveryCore> pCore = new svxdr::RecoveryCore(m_xContext, true);
// create dialog for this operation and bind it to the used core service // create dialog for this operation and bind it to the used core service
ScopedVclPtrInstance<svxdr::SaveDialog> xDialog(m_pParentWindow, pCore.get()); svxdr::SaveDialog aDialog(m_pParentWindow ? m_pParentWindow->GetFrameWeld() : nullptr, pCore.get());
DialogReleaseGuard dialogReleaseGuard(m_pDialog, xDialog);
// start the dialog // start the dialog
short nRet = xDialog->Execute(); short nRet = aDialog.run();
return (nRet==DLG_RET_OK_AUTOLUNCH); return (nRet==DLG_RET_OK_AUTOLUNCH);
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 --> <!-- Generated with glade 3.22.1 -->
<interface domain="svx"> <interface domain="svx">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name image -->
<column type="GdkPixbuf"/>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="DocRecoverySaveDialog"> <object class="GtkDialog" id="DocRecoverySaveDialog">
<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="docrecoverysavedialog|DocRecoverySaveDialog">%PRODUCTNAME %PRODUCTVERSION Document Recovery</property> <property name="title" translatable="yes" context="docrecoverysavedialog|DocRecoverySaveDialog">%PRODUCTNAME %PRODUCTVERSION 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> <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>
...@@ -44,6 +60,7 @@ ...@@ -44,6 +60,7 @@
<object class="GtkGrid" id="bgrid1"> <object class="GtkGrid" id="bgrid1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="row_spacing">12</property> <property name="row_spacing">12</property>
<child> <child>
<object class="GtkGrid" id="grid1"> <object class="GtkGrid" id="grid1">
...@@ -58,7 +75,8 @@ ...@@ -58,7 +75,8 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes" context="docrecoverysavedialog|label1">Due to an unexpected error, %PRODUCTNAME crashed. All the files you were working on will now be saved. The next time %PRODUCTNAME is launched, your files will be recovered automatically.</property> <property name="label" translatable="yes" context="docrecoverysavedialog|label1">Due to an unexpected error, %PRODUCTNAME crashed. All the files you were working on will now be saved. The next time %PRODUCTNAME is launched, your files will be recovered automatically.</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="max_width_chars">87</property> <property name="width_chars">80</property>
<property name="max_width_chars">80</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
<packing> <packing>
...@@ -79,7 +97,7 @@ ...@@ -79,7 +97,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes" context="docrecoverysavedialog|label2">The following files will be recovered:</property> <property name="label" translatable="yes" context="docrecoverysavedialog|label2">The following files will be recovered:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">filelist:border</property> <property name="mnemonic_widget">filelist</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
<packing> <packing>
...@@ -88,14 +106,47 @@ ...@@ -88,14 +106,47 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkTreeView" id="filelist:border"> <object class="GtkScrolledWindow">
<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="vexpand">True</property> <property name="vexpand">True</property>
<property name="show_expanders">False</property> <property name="shadow_type">in</property>
<child internal-child="selection"> <child>
<object class="GtkTreeSelection" id="treeview-selection"/> <object class="GtkTreeView" id="filelist">
<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="treeviewcolumn1">
<child>
<object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
<attributes>
<attribute name="pixbuf">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child> </child>
</object> </object>
<packing> <packing>
......
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