Kaydet (Commit) 6682a47d authored tarafından Caolán McNamara's avatar Caolán McNamara

weld LibDialog

Change-Id: I40df84d476b50f245c6d0849269006300e93f54a
Reviewed-on: https://gerrit.libreoffice.org/67497
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 17e50280
...@@ -786,7 +786,7 @@ void LibPage::InsertLib() ...@@ -786,7 +786,7 @@ void LibPage::InsertLib()
if ( !xModLibContImport.is() && !xDlgLibContImport.is() ) if ( !xModLibContImport.is() && !xDlgLibContImport.is() )
return; return;
VclPtr<LibDialog> pLibDlg; std::shared_ptr<LibDialog> xLibDlg;
Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY ); Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY );
Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY ); Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY );
...@@ -796,11 +796,10 @@ void LibPage::InsertLib() ...@@ -796,11 +796,10 @@ void LibPage::InsertLib()
for ( sal_Int32 i = 0 ; i < nLibCount ; i++ ) for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{ {
// library import dialog // library import dialog
if ( !pLibDlg ) if (!xLibDlg)
{ {
pLibDlg.reset(VclPtr<LibDialog>::Create( this )); xLibDlg.reset(new LibDialog(GetFrameWeld()));
pLibDlg->SetStorageName( aURLObj.getName() ); xLibDlg->SetStorageName( aURLObj.getName() );
pLibDlg->GetLibBox().SetMode(ObjectMode::Library);
} }
// libbox entries // libbox entries
...@@ -808,13 +807,16 @@ void LibPage::InsertLib() ...@@ -808,13 +807,16 @@ void LibPage::InsertLib()
if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) || if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) ||
( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) ) ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) )
{ {
SvTreeListEntry* pEntry = pLibDlg->GetLibBox().DoInsertEntry( aLibName ); weld::TreeView& rView = xLibDlg->GetLibBox();
sal_uInt16 nPos = static_cast<sal_uInt16>(pLibDlg->GetLibBox().GetModel()->GetAbsPos( pEntry )); rView.insert(nullptr, -1, nullptr, nullptr, nullptr,
pLibDlg->GetLibBox().CheckEntryPos(nPos); nullptr, nullptr, false);
const int nRow = rView.n_children() - 1;
rView.set_toggle(nRow, true, 0);
rView.set_text(nRow, aLibName, 1);
} }
} }
if ( !pLibDlg ) if (!xLibDlg)
{ {
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_NOLIBINSTORAGE))); VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_NOLIBINSTORAGE)));
...@@ -828,9 +830,9 @@ void LibPage::InsertLib() ...@@ -828,9 +830,9 @@ void LibPage::InsertLib()
// disable reference checkbox for documents and sbls // disable reference checkbox for documents and sbls
if ( aExtension != aLibExtension && aExtension != aContExtension ) if ( aExtension != aLibExtension && aExtension != aContExtension )
pLibDlg->EnableReference(false); xLibDlg->EnableReference(false);
pLibDlg->StartExecuteAsync([aContExtension, aDlgURLObj, aExtension, aLibExtension, aModURLObj, pLibDlg, xDlgLibContImport, xModLibContImp, xModLibContImport, this](sal_Int32 nResult) weld::DialogController::runAsync(xLibDlg, [aContExtension, aDlgURLObj, aExtension, aLibExtension, aModURLObj, xLibDlg, xDlgLibContImport, xModLibContImp, xModLibContImport, this](sal_Int32 nResult)
{ {
if (!nResult ) if (!nResult )
return; return;
...@@ -838,15 +840,14 @@ void LibPage::InsertLib() ...@@ -838,15 +840,14 @@ void LibPage::InsertLib()
bool bChanges = false; bool bChanges = false;
sal_uLong nNewPos = m_pLibBox->GetEntryCount(); sal_uLong nNewPos = m_pLibBox->GetEntryCount();
bool bRemove = false; bool bRemove = false;
bool bReplace = pLibDlg->IsReplace(); bool bReplace = xLibDlg->IsReplace();
bool bReference = pLibDlg->IsReference(); bool bReference = xLibDlg->IsReference();
for ( sal_uLong nLib = 0; nLib < pLibDlg->GetLibBox().GetEntryCount(); nLib++ ) weld::TreeView& rView = xLibDlg->GetLibBox();
for (int nLib = 0, nChildren = rView.n_children(); nLib < nChildren; ++nLib)
{ {
if ( pLibDlg->GetLibBox().IsChecked( nLib ) ) if (rView.get_toggle(nLib, 0))
{ {
SvTreeListEntry* pEntry = pLibDlg->GetLibBox().GetEntry( nLib ); OUString aLibName(rView.get_text(nLib, 1));
DBG_ASSERT( pEntry, "Entry?!" );
OUString aLibName( SvTabListBox::GetEntryText( pEntry, 0 ) );
Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
......
...@@ -917,7 +917,6 @@ void ObjectPage::DeleteCurrent() ...@@ -917,7 +917,6 @@ void ObjectPage::DeleteCurrent()
} }
} }
void ObjectPage::EndTabDialog() void ObjectPage::EndTabDialog()
{ {
DBG_ASSERT( pTabDlg, "TabDlg not set!" ); DBG_ASSERT( pTabDlg, "TabDlg not set!" );
...@@ -925,36 +924,25 @@ void ObjectPage::EndTabDialog() ...@@ -925,36 +924,25 @@ void ObjectPage::EndTabDialog()
pTabDlg->EndDialog( 1 ); pTabDlg->EndDialog( 1 );
} }
LibDialog::LibDialog( vcl::Window* pParent ) LibDialog::LibDialog(weld::Window* pParent)
: ModalDialog(pParent, "ImportLibDialog", "modules/BasicIDE/ui/importlibdialog.ui") : GenericDialogController(pParent, "modules/BasicIDE/ui/importlibdialog.ui", "ImportLibDialog")
, m_xStorageFrame(m_xBuilder->weld_frame("storageframe"))
, m_xLibBox(m_xBuilder->weld_tree_view("entries"))
, m_xReferenceBox(m_xBuilder->weld_check_button("ref"))
, m_xReplaceBox(m_xBuilder->weld_check_button("replace"))
{ {
get(m_pStorageFrame, "storageframe"); m_xLibBox->set_size_request(m_xLibBox->get_approximate_digit_width() * 28,
get(m_pReferenceBox, "ref"); m_xLibBox->get_height_rows(8));
get(m_pReplaceBox, "replace");
get(m_pLibBox, "entries");
m_pLibBox->set_height_request(m_pLibBox->GetTextHeight() * 8);
m_pLibBox->set_width_request(m_pLibBox->approximate_char_width() * 32);
} }
LibDialog::~LibDialog() LibDialog::~LibDialog()
{ {
disposeOnce();
}
void LibDialog::dispose()
{
m_pStorageFrame.clear();
m_pLibBox.clear();
m_pReferenceBox.clear();
m_pReplaceBox.clear();
ModalDialog::dispose();
} }
void LibDialog::SetStorageName( const OUString& rName ) void LibDialog::SetStorageName( const OUString& rName )
{ {
OUString aName = IDEResId(RID_STR_FILENAME) + rName; OUString aName = IDEResId(RID_STR_FILENAME) + rName;
m_pStorageFrame->set_label(aName); m_xStorageFrame->set_label(aName);
} }
// Helper function // Helper function
......
...@@ -135,26 +135,25 @@ public: ...@@ -135,26 +135,25 @@ public:
void SetMode(ObjectMode); void SetMode(ObjectMode);
}; };
class LibDialog: public ModalDialog class LibDialog : public weld::GenericDialogController
{ {
private: private:
VclPtr<VclFrame> m_pStorageFrame; std::unique_ptr<weld::Frame> m_xStorageFrame;
VclPtr<CheckBox> m_pLibBox; std::unique_ptr<weld::TreeView> m_xLibBox;
VclPtr< ::CheckBox> m_pReferenceBox; std::unique_ptr<weld::CheckButton> m_xReferenceBox;
VclPtr< ::CheckBox> m_pReplaceBox; std::unique_ptr<weld::CheckButton> m_xReplaceBox;
public: public:
explicit LibDialog(vcl::Window* pParent); explicit LibDialog(weld::Window* pParent);
virtual ~LibDialog() override; virtual ~LibDialog() override;
virtual void dispose() override;
void SetStorageName( const OUString& rName ); void SetStorageName( const OUString& rName );
CheckBox& GetLibBox() { return *m_pLibBox; } weld::TreeView& GetLibBox() { return *m_xLibBox; }
bool IsReference() const { return m_pReferenceBox->IsChecked(); } bool IsReference() const { return m_xReferenceBox->get_active(); }
bool IsReplace() const { return m_pReplaceBox->IsChecked(); } bool IsReplace() const { return m_xReplaceBox->get_active(); }
void EnableReference (bool b) { m_pReferenceBox->Enable(b); } void EnableReference (bool b) { m_xReferenceBox->set_sensitive(b); }
}; };
class OrganizeDialog : public TabDialog class OrganizeDialog : public TabDialog
......
<?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="basctl"> <interface domain="basctl">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/> <object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name check1 -->
<column type="gboolean"/>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name checkvis1 -->
<column type="gboolean"/>
</columns>
</object>
<object class="GtkDialog" id="ImportLibDialog"> <object class="GtkDialog" id="ImportLibDialog">
<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="importlibdialog|ImportLibDialog">Import Libraries</property> <property name="title" translatable="yes" context="importlibdialog|ImportLibDialog">Import Libraries</property>
<property name="resizable">False</property> <property name="resizable">False</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>
...@@ -75,6 +92,8 @@ ...@@ -75,6 +92,8 @@
<object class="GtkGrid" id="grid1"> <object class="GtkGrid" id="grid1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">12</property> <property name="row_spacing">12</property>
<child> <child>
<object class="GtkFrame" id="frame1"> <object class="GtkFrame" id="frame1">
...@@ -160,13 +179,53 @@ ...@@ -160,13 +179,53 @@
<property name="top_padding">6</property> <property name="top_padding">6</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<object class="basctllo-CheckBox" id="entries: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>
<child internal-child="selection"> <property name="shadow_type">in</property>
<object class="GtkTreeSelection" id="treeview-selection2"/> <child>
<object class="GtkTreeView" id="entries">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">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="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Macro Library List-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="alignment">0.5</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderer5"/>
<attributes>
<attribute name="visible">3</attribute>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
<property name="resizable">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer4"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child> </child>
</object> </object>
</child> </child>
......
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