diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-07 12:21:01 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-07 15:46:52 +0100 |
commit | 6682a47deea5523b58dca37976f0f0fb30fb0a11 (patch) | |
tree | 60fdd763dda759e9c18585f8363dbf1ce6e63681 /basctl | |
parent | 17e5028044edef2b959b73ce1dbe2c9627d1a799 (diff) |
weld LibDialog
Change-Id: I40df84d476b50f245c6d0849269006300e93f54a
Reviewed-on: https://gerrit.libreoffice.org/67497
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/moduldl2.cxx | 37 | ||||
-rw-r--r-- | basctl/source/basicide/moduldlg.cxx | 30 | ||||
-rw-r--r-- | basctl/source/basicide/moduldlg.hxx | 21 | ||||
-rw-r--r-- | basctl/uiconfig/basicide/ui/importlibdialog.ui | 69 |
4 files changed, 102 insertions, 55 deletions
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index be3c042a7f66..dec80d59d2c0 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -786,7 +786,7 @@ void LibPage::InsertLib() if ( !xModLibContImport.is() && !xDlgLibContImport.is() ) return; - VclPtr<LibDialog> pLibDlg; + std::shared_ptr<LibDialog> xLibDlg; Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY ); Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY ); @@ -796,11 +796,10 @@ void LibPage::InsertLib() for ( sal_Int32 i = 0 ; i < nLibCount ; i++ ) { // library import dialog - if ( !pLibDlg ) + if (!xLibDlg) { - pLibDlg.reset(VclPtr<LibDialog>::Create( this )); - pLibDlg->SetStorageName( aURLObj.getName() ); - pLibDlg->GetLibBox().SetMode(ObjectMode::Library); + xLibDlg.reset(new LibDialog(GetFrameWeld())); + xLibDlg->SetStorageName( aURLObj.getName() ); } // libbox entries @@ -808,13 +807,16 @@ void LibPage::InsertLib() if ( !( ( xModLibContImport.is() && xModLibContImport->hasByName( aLibName ) && xModLibContImport->isLibraryLink( aLibName ) ) || ( xDlgLibContImport.is() && xDlgLibContImport->hasByName( aLibName ) && xDlgLibContImport->isLibraryLink( aLibName ) ) ) ) { - SvTreeListEntry* pEntry = pLibDlg->GetLibBox().DoInsertEntry( aLibName ); - sal_uInt16 nPos = static_cast<sal_uInt16>(pLibDlg->GetLibBox().GetModel()->GetAbsPos( pEntry )); - pLibDlg->GetLibBox().CheckEntryPos(nPos); + weld::TreeView& rView = xLibDlg->GetLibBox(); + rView.insert(nullptr, -1, nullptr, nullptr, nullptr, + 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(), VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_NOLIBINSTORAGE))); @@ -828,9 +830,9 @@ void LibPage::InsertLib() // disable reference checkbox for documents and sbls 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 ) return; @@ -838,15 +840,14 @@ void LibPage::InsertLib() bool bChanges = false; sal_uLong nNewPos = m_pLibBox->GetEntryCount(); bool bRemove = false; - bool bReplace = pLibDlg->IsReplace(); - bool bReference = pLibDlg->IsReference(); - for ( sal_uLong nLib = 0; nLib < pLibDlg->GetLibBox().GetEntryCount(); nLib++ ) + bool bReplace = xLibDlg->IsReplace(); + bool bReference = xLibDlg->IsReference(); + 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 ); - DBG_ASSERT( pEntry, "Entry?!" ); - OUString aLibName( SvTabListBox::GetEntryText( pEntry, 0 ) ); + OUString aLibName(rView.get_text(nLib, 1)); Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index ff02dbf7522d..d1455ff99a70 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -917,7 +917,6 @@ void ObjectPage::DeleteCurrent() } } - void ObjectPage::EndTabDialog() { DBG_ASSERT( pTabDlg, "TabDlg not set!" ); @@ -925,36 +924,25 @@ void ObjectPage::EndTabDialog() pTabDlg->EndDialog( 1 ); } -LibDialog::LibDialog( vcl::Window* pParent ) - : ModalDialog(pParent, "ImportLibDialog", "modules/BasicIDE/ui/importlibdialog.ui") +LibDialog::LibDialog(weld::Window* pParent) + : 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"); - get(m_pReferenceBox, "ref"); - 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); + m_xLibBox->set_size_request(m_xLibBox->get_approximate_digit_width() * 28, + m_xLibBox->get_height_rows(8)); } 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 ) { OUString aName = IDEResId(RID_STR_FILENAME) + rName; - m_pStorageFrame->set_label(aName); + m_xStorageFrame->set_label(aName); } // Helper function diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx index 6758b8f94a9e..9c72b87e1a21 100644 --- a/basctl/source/basicide/moduldlg.hxx +++ b/basctl/source/basicide/moduldlg.hxx @@ -135,26 +135,25 @@ public: void SetMode(ObjectMode); }; -class LibDialog: public ModalDialog +class LibDialog : public weld::GenericDialogController { private: - VclPtr<VclFrame> m_pStorageFrame; - VclPtr<CheckBox> m_pLibBox; - VclPtr< ::CheckBox> m_pReferenceBox; - VclPtr< ::CheckBox> m_pReplaceBox; + std::unique_ptr<weld::Frame> m_xStorageFrame; + std::unique_ptr<weld::TreeView> m_xLibBox; + std::unique_ptr<weld::CheckButton> m_xReferenceBox; + std::unique_ptr<weld::CheckButton> m_xReplaceBox; public: - explicit LibDialog(vcl::Window* pParent); + explicit LibDialog(weld::Window* pParent); virtual ~LibDialog() override; - virtual void dispose() override; void SetStorageName( const OUString& rName ); - CheckBox& GetLibBox() { return *m_pLibBox; } - bool IsReference() const { return m_pReferenceBox->IsChecked(); } - bool IsReplace() const { return m_pReplaceBox->IsChecked(); } + weld::TreeView& GetLibBox() { return *m_xLibBox; } + bool IsReference() const { return m_xReferenceBox->get_active(); } + 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 diff --git a/basctl/uiconfig/basicide/ui/importlibdialog.ui b/basctl/uiconfig/basicide/ui/importlibdialog.ui index a13849b75743..6bde14b65152 100644 --- a/basctl/uiconfig/basicide/ui/importlibdialog.ui +++ b/basctl/uiconfig/basicide/ui/importlibdialog.ui @@ -1,14 +1,31 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="basctl"> <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"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="importlibdialog|ImportLibDialog">Import Libraries</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> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -75,6 +92,8 @@ <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="row_spacing">12</property> <child> <object class="GtkFrame" id="frame1"> @@ -160,13 +179,53 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="basctllo-CheckBox" id="entries:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection2"/> + <property name="shadow_type">in</property> + <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> </object> </child> |