diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-05 16:11:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-08 20:21:35 +0200 |
commit | cd384e2d31f74223948ea70d8aa3c318d3ceeb50 (patch) | |
tree | 49ae5191c2bd4b13c3cd547951933fbc37cda0fa /cui/source/customize | |
parent | c3669c8bd62ecf5eaa6b5e95289825bc11b2688a (diff) |
rework treeview initial toggle button col to be like expander col
cause this assumption is baked into the vcl one making it hard
to adapt remaining cases
Change-Id: I75dd5264c65b1ffbf4d26c9a86f6d4d08b400d90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95622
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source/customize')
-rw-r--r-- | cui/source/customize/SvxMenuConfigPage.cxx | 24 | ||||
-rw-r--r-- | cui/source/customize/SvxNotebookbarConfigPage.cxx | 40 | ||||
-rw-r--r-- | cui/source/customize/SvxToolbarConfigPage.cxx | 49 | ||||
-rw-r--r-- | cui/source/customize/cfg.cxx | 28 |
4 files changed, 46 insertions, 95 deletions
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx index c40c07dd3ce6..90f421013fba 100644 --- a/cui/source/customize/SvxMenuConfigPage.cxx +++ b/cui/source/customize/SvxMenuConfigPage.cxx @@ -115,22 +115,10 @@ IMPL_LINK(SvxMenuConfigPage, MenuEntriesSizeAllocHdl, const Size&, rSize, void) weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); std::vector<int> aWidths; - int nExpectedSize = 16; - int nStandardImageColWidth = rTreeView.get_checkbox_column_width(); - int nMargin = nStandardImageColWidth - nExpectedSize; - if (nMargin < 16) - nMargin = 16; - - if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_LARGE) - nExpectedSize = 24; - else if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_32) - nExpectedSize = 32; - - int nImageColWidth = nExpectedSize + nMargin; + int nMargin = 16; - aWidths.push_back(nImageColWidth); - aWidths.push_back(rSize.Width() - (nImageColWidth + nStandardImageColWidth)); + aWidths.push_back(rSize.Width() - (nMargin + nStandardImageColWidth)); rTreeView.set_column_fixed_widths(aWidths); } @@ -279,7 +267,7 @@ void SvxMenuConfigPage::SelectElement() auto const& entry = (*pEntries)[nIdx]; OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry))); rTreeView.set_id(rIter, sId); - InsertEntryIntoUI(entry, rTreeView, rIter, 0); + InsertEntryIntoUI(entry, rTreeView, rIter, true); }); } @@ -369,7 +357,7 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, weld::Button&, void ) weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); SvxConfigEntry* pEntry = reinterpret_cast<SvxConfigEntry*>(rTreeView.get_id(nPos).toInt64()); - InsertEntryIntoUI(pEntry, rTreeView, nPos, 0); + InsertEntryIntoUI(pEntry, rTreeView, nPos, true); } IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, weld::Button&, void ) @@ -389,7 +377,7 @@ IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void) SvxConfigEntry* pNewEntryData = new SvxConfigEntry; pNewEntryData->SetUserDefined(); int nPos = AppendEntry(pNewEntryData, -1); - InsertEntryIntoUI(pNewEntryData, rTreeView, nPos, 0); + InsertEntryIntoUI(pNewEntryData, rTreeView, nPos, true); } else if (rIdent == "insertsubmenu") { @@ -410,7 +398,7 @@ IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void) pNewEntryData->SetUserDefined(); int nPos = AppendEntry(pNewEntryData, -1); - InsertEntryIntoUI(pNewEntryData, rTreeView, nPos, 0); + InsertEntryIntoUI(pNewEntryData, rTreeView, nPos, true); ReloadTopLevelListBox(); diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index b8c3a8d72a49..7354f1c821ba 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -124,29 +124,10 @@ SvxNotebookbarConfigPage::SvxNotebookbarConfigPage(weld::Container* pPage, new SvxNotebookbarEntriesListBox(m_xBuilder->weld_tree_view("toolcontents"), this)); m_xDropTargetHelper.reset( new SvxConfigPageFunctionDropTarget(*this, m_xContentsListBox->get_widget())); - std::vector<int> aWidths; weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); Size aSize(m_xFunctions->get_size_request()); rTreeView.set_size_request(aSize.Width(), aSize.Height()); - int nExpectedSize = 16; - - int nStandardImageColWidth = rTreeView.get_checkbox_column_width(); - int nMargin = nStandardImageColWidth - nExpectedSize; - if (nMargin < 16) - nMargin = 16; - - if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_LARGE) - nExpectedSize = 24; - else if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_32) - nExpectedSize = 32; - - int nImageColWidth = nExpectedSize + nMargin; - - aWidths.push_back(nStandardImageColWidth); - aWidths.push_back(nImageColWidth); - rTreeView.set_column_fixed_widths(aWidths); - rTreeView.set_hexpand(true); rTreeView.set_vexpand(true); rTreeView.set_help_id(HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS); @@ -219,7 +200,7 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(const OUString& sClassId, const OUString& sUIItemId, const OUString& sUIItemCommand, weld::TreeView& rTreeView, - weld::TreeIter& rIter, int nStartCol) + weld::TreeIter& rIter) { css::uno::Reference<css::container::XNameAccess> m_xCommandToLabelMap; uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); @@ -249,7 +230,7 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(const OUString& sClassId, if (sClassId == "GtkSeparatorMenuItem" || sClassId == "GtkSeparator") { - rTreeView.set_text(rIter, "--------------------------------------------", nStartCol + 1); + rTreeView.set_text(rIter, "--------------------------------------------", 0); } else { @@ -257,8 +238,8 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(const OUString& sClassId, aName = sUIItemId; auto xImage = GetSaveInData()->GetImage(sUIItemCommand); if (xImage.is()) - rTreeView.set_image(rIter, xImage, nStartCol); - rTreeView.set_text(rIter, aName, nStartCol + 1); + rTreeView.set_image(rIter, xImage, -1); + rTreeView.set_text(rIter, aName, 0); rTreeView.set_id(rIter, sUIItemId); } } @@ -465,15 +446,15 @@ void SvxNotebookbarConfigPage::SelectElement() { if (aEntries[nIdx].sVisibleValue == "True") { - rTreeView.set_toggle(rIter, TRISTATE_TRUE, 0); + rTreeView.set_toggle(rIter, TRISTATE_TRUE); } else { - rTreeView.set_toggle(rIter, TRISTATE_FALSE, 0); + rTreeView.set_toggle(rIter, TRISTATE_FALSE); } } InsertEntryIntoNotebookbarTabUI(aEntries[nIdx].sClassId, aEntries[nIdx].sDisplayName, - aEntries[nIdx].sActionName, rTreeView, rIter, 1); + aEntries[nIdx].sActionName, rTreeView, rIter); }); aEntries.clear(); @@ -532,7 +513,7 @@ void SvxNotebookbarEntriesListBox::ChangedVisibility(int nRow) OUString sNotebookbarInterface = getFileName(m_pPage->GetFileName()); OUString sVisible; - if (m_xControl->get_toggle(nRow, 0) == TRISTATE_TRUE) + if (m_xControl->get_toggle(nRow) == TRISTATE_TRUE) sVisible = "True"; else sVisible = "False"; @@ -556,9 +537,8 @@ IMPL_LINK(SvxNotebookbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, if (rKeyEvent.GetKeyCode() == KEY_SPACE) { int nRow = m_xControl->get_selected_index(); - m_xControl->set_toggle( - nRow, m_xControl->get_toggle(nRow, 0) == TRISTATE_TRUE ? TRISTATE_FALSE : TRISTATE_TRUE, - 0); + m_xControl->set_toggle(nRow, m_xControl->get_toggle(nRow) == TRISTATE_TRUE ? TRISTATE_FALSE + : TRISTATE_TRUE); ChangedVisibility(nRow); return true; } diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx index 5efa3283498b..08540446e7ff 100644 --- a/cui/source/customize/SvxToolbarConfigPage.cxx +++ b/cui/source/customize/SvxToolbarConfigPage.cxx @@ -53,29 +53,10 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage, weld::DialogC m_xContentsListBox.reset(new SvxToolbarEntriesListBox(m_xBuilder->weld_tree_view("toolcontents"), this)); m_xDropTargetHelper.reset(new SvxConfigPageFunctionDropTarget(*this, m_xContentsListBox->get_widget())); - std::vector<int> aWidths; weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); Size aSize(m_xFunctions->get_size_request()); rTreeView.set_size_request(aSize.Width(), aSize.Height()); - int nExpectedSize = 16; - - int nStandardImageColWidth = rTreeView.get_checkbox_column_width(); - int nMargin = nStandardImageColWidth - nExpectedSize; - if (nMargin < 16) - nMargin = 16; - - if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_LARGE) - nExpectedSize = 24; - else if (SvxConfigPageHelper::GetImageType() & css::ui::ImageType::SIZE_32) - nExpectedSize = 32; - - int nImageColWidth = nExpectedSize + nMargin; - - aWidths.push_back(nStandardImageColWidth); - aWidths.push_back(nImageColWidth); - rTreeView.set_column_fixed_widths(aWidths); - rTreeView.set_hexpand(true); rTreeView.set_vexpand(true); rTreeView.set_help_id( HID_SVX_CONFIG_TOOLBAR_CONTENTS ); @@ -467,7 +448,7 @@ IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OString&, rIdent, void) pNewEntryData->SetUserDefined(); int nPos = AppendEntry(pNewEntryData, -1); - InsertEntryIntoUI(pNewEntryData, m_xContentsListBox->get_widget(), nPos, 1); + InsertEntryIntoUI(pNewEntryData, m_xContentsListBox->get_widget(), nPos); static_cast<ToolbarSaveInData*>( GetSaveInData())->ApplyToolbar( pToolbar ); @@ -516,7 +497,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) else pEntry->SetName( aNewName ); - m_xContentsListBox->set_text(nActEntry, aNewName, 2); + m_xContentsListBox->set_text(nActEntry, aNewName, 0); bNeedsApply = true; } } @@ -564,8 +545,8 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); m_xContentsListBox->insert(nActEntry, sId); - m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE, 0); - InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry, 1); + m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); + InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry); m_xContentsListBox->select(nActEntry); m_xContentsListBox->scroll_to_row(nActEntry); @@ -604,8 +585,8 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); m_xContentsListBox->insert(nActEntry, sId); - m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE, 0); - InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry, 1); + m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); + InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry); m_xContentsListBox->select(nActEntry); m_xContentsListBox->scroll_to_row(nActEntry); @@ -638,7 +619,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) { pEntry->SetName( aSystemName ); m_xContentsListBox->set_text( - nActEntry, SvxConfigPageHelper::stripHotKey(aSystemName), 2); + nActEntry, SvxConfigPageHelper::stripHotKey(aSystemName), 0); bNeedsApply = true; } @@ -661,8 +642,8 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); m_xContentsListBox->insert(nActEntry, sId); m_xContentsListBox->set_toggle(nActEntry, - pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE, 0); - InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry, 1); + pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); + InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry); m_xContentsListBox->select(nActEntry); m_xContentsListBox->scroll_to_row(nActEntry); @@ -793,8 +774,8 @@ void SvxToolbarConfigPage::SelectElement() OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry))); m_xContentsListBox->insert(i, sId); if (entry->IsBinding() && !entry->IsSeparator()) - m_xContentsListBox->set_toggle(i, entry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE, 0); - InsertEntryIntoUI(entry, m_xContentsListBox->get_widget(), i, 1); + m_xContentsListBox->set_toggle(i, entry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); + InsertEntryIntoUI(entry, m_xContentsListBox->get_widget(), i); ++i; } @@ -820,10 +801,10 @@ void SvxToolbarConfigPage::AddFunction(int nTarget) if ( pEntry->IsBinding() ) //TODO sep ? { pEntry->SetVisible(true); - m_xContentsListBox->set_toggle(nNewLBEntry, TRISTATE_TRUE, 0); + m_xContentsListBox->set_toggle(nNewLBEntry, TRISTATE_TRUE); } - InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nNewLBEntry, 1); + InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nNewLBEntry); // Changes are not visible on the toolbar until this point // TODO: Figure out a way to show the changes on the toolbar, but revert if @@ -854,7 +835,7 @@ void SvxToolbarEntriesListBox::ChangedVisibility(int nRow) if (pEntryData->IsBinding()) { - pEntryData->SetVisible(m_xControl->get_toggle(nRow, 0) == TRISTATE_TRUE); + pEntryData->SetVisible(m_xControl->get_toggle(nRow) == TRISTATE_TRUE); SvxConfigEntry* pToolbar = m_pPage->GetTopLevelSelection(); @@ -879,7 +860,7 @@ IMPL_LINK(SvxToolbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, boo SvxConfigEntry* pEntryData = reinterpret_cast<SvxConfigEntry*>(m_xControl->get_id(nRow).toInt64()); if (pEntryData->IsBinding() && !pEntryData->IsSeparator()) { - m_xControl->set_toggle(nRow, m_xControl->get_toggle(nRow, 0) == TRISTATE_TRUE ? TRISTATE_FALSE : TRISTATE_TRUE, 0); + m_xControl->set_toggle(nRow, m_xControl->get_toggle(nRow) == TRISTATE_TRUE ? TRISTATE_FALSE : TRISTATE_TRUE); ChangedVisibility(nRow); } return true; diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 412ecf3fe5f6..e7cea5f48d97 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -926,6 +926,7 @@ SvxMenuEntriesListBox::SvxMenuEntriesListBox(std::unique_ptr<weld::TreeView> xCo , m_xDropDown(m_xControl->create_virtual_device()) , m_pPage(pPg) { + m_xControl->enable_toggle_buttons(weld::ColumnToggleType::Check); CreateDropDown(); m_xControl->connect_key_press(LINK(this, SvxMenuEntriesListBox, KeyInputHdl)); } @@ -1507,7 +1508,8 @@ int SvxConfigPage::AppendEntry( namespace { - template<typename itertype> void TmplInsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, itertype& rIter, int nStartCol, SaveInData* pSaveInData, VirtualDevice& rDropDown) + template<typename itertype> void TmplInsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, itertype& rIter, SaveInData* pSaveInData, + VirtualDevice& rDropDown, bool bMenu) { OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData))); @@ -1515,37 +1517,37 @@ namespace if (pNewEntryData->IsSeparator()) { - rTreeView.set_text(rIter, "----------------------------------", nStartCol + 1); + rTreeView.set_text(rIter, "----------------------------------", 0); } else { auto xImage = pSaveInData->GetImage(pNewEntryData->GetCommand()); if (xImage.is()) - rTreeView.set_image(rIter, xImage, nStartCol); + rTreeView.set_image(rIter, xImage, -1); OUString aName = SvxConfigPageHelper::stripHotKey( pNewEntryData->GetName() ); - rTreeView.set_text(rIter, aName, nStartCol + 1); + rTreeView.set_text(rIter, aName, 0); } - if (nStartCol == 0) // menus + if (bMenu) // menus { if (pNewEntryData->IsPopup() || pNewEntryData->GetStyle() & css::ui::ItemStyle::DROP_DOWN) - rTreeView.set_image(rIter, rDropDown, nStartCol + 2); + rTreeView.set_image(rIter, rDropDown, 1); else - rTreeView.set_image(rIter, css::uno::Reference<css::graphic::XGraphic>(), nStartCol + 2); + rTreeView.set_image(rIter, css::uno::Reference<css::graphic::XGraphic>(), 1); } } } -void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, int nPos, int nStartCol) +void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, int nPos, bool bMenu) { - TmplInsertEntryIntoUI<int>(pNewEntryData, rTreeView, nPos, nStartCol, - GetSaveInData(), m_xContentsListBox->get_dropdown_image()); + TmplInsertEntryIntoUI<int>(pNewEntryData, rTreeView, nPos, GetSaveInData(), + m_xContentsListBox->get_dropdown_image(), bMenu); } -void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, weld::TreeIter& rIter, int nStartCol) +void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, weld::TreeIter& rIter, bool bMenu) { - TmplInsertEntryIntoUI<weld::TreeIter>(pNewEntryData, rTreeView, rIter, nStartCol, - GetSaveInData(), m_xContentsListBox->get_dropdown_image()); + TmplInsertEntryIntoUI<weld::TreeIter>(pNewEntryData, rTreeView, rIter, GetSaveInData(), + m_xContentsListBox->get_dropdown_image(), bMenu); } IMPL_LINK(SvxConfigPage, MoveHdl, weld::Button&, rButton, void) |