chart2/source/controller/sidebar/ChartElementsPanel.cxx | 39 ++++++++++++ chart2/source/controller/sidebar/ChartElementsPanel.hxx | 3 chart2/uiconfig/ui/sidebarelements.ui | 49 +++++++++++++--- 3 files changed, 82 insertions(+), 9 deletions(-)
New commits: commit b9e03055d053d5cb8dbdc466ee7c67744a6433b8 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Wed Oct 14 16:18:17 2020 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Oct 16 16:21:38 2020 +0200 chart2: Add the possibility to edit title & subtitle from the sidebar. Change-Id: I4be15acbc2127ebb6eca8864a0209ba57b488100 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104313 Tested-by: Andras Timar <andras.ti...@collabora.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 28bc8c1a5469..4026b22d9898 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -284,7 +284,9 @@ ChartElementsPanel::ChartElementsPanel( mbModelValid(true) { get(mpCBTitle, "checkbutton_title"); + get(mpEditTitle, "edit_title"); get(mpCBSubtitle, "checkbutton_subtitle"); + get(mpEditSubtitle, "edit_subtitle"); get(mpCBXAxis, "checkbutton_x_axis"); get(mpCBXAxisTitle, "checkbutton_x_axis_title"); get(mpCBYAxis, "checkbutton_y_axis"); @@ -326,7 +328,9 @@ void ChartElementsPanel::dispose() css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); xBroadcaster->removeModifyListener(mxListener); mpCBTitle.clear(); + mpEditTitle.clear(); mpCBSubtitle.clear(); + mpEditSubtitle.clear(); mpCBXAxis.clear(); mpCBXAxisTitle.clear(); mpCBYAxis.clear(); @@ -381,6 +385,10 @@ void ChartElementsPanel::Initialize() mpCBGridHorizontalMinor->SetClickHdl(aLink); mpLBLegendPosition->SetSelectHdl(LINK(this, ChartElementsPanel, LegendPosHdl)); + + Link<Edit&, void> aEditLink = LINK(this, ChartElementsPanel, EditHdl); + mpEditTitle->SetModifyHdl(aEditLink); + mpEditSubtitle->SetModifyHdl(aEditLink); } namespace { @@ -423,8 +431,23 @@ void ChartElementsPanel::updateData() mpCBLegend->Check(isLegendVisible(mxModel)); mpBoxLegend->Enable( isLegendVisible(mxModel) ); - mpCBTitle->Check(isTitleVisisble(mxModel, TitleHelper::MAIN_TITLE)); - mpCBSubtitle->Check(isTitleVisisble(mxModel, TitleHelper::SUB_TITLE)); + + bool hasTitle = isTitleVisisble(mxModel, TitleHelper::MAIN_TITLE); + mpCBTitle->Check(hasTitle); + if (!mpEditTitle->HasFocus()) + { + mpEditTitle->SetText(TitleHelper::getCompleteString(TitleHelper::getTitle(TitleHelper::MAIN_TITLE, mxModel))); + mpEditTitle->Enable(hasTitle); + } + + bool hasSubtitle = isTitleVisisble(mxModel, TitleHelper::SUB_TITLE); + mpCBSubtitle->Check(hasSubtitle); + if (!mpEditSubtitle->HasFocus()) + { + mpEditSubtitle->SetText(TitleHelper::getCompleteString(TitleHelper::getTitle(TitleHelper::SUB_TITLE, mxModel))); + mpEditSubtitle->Enable(hasSubtitle); + } + mpCBXAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::X_AXIS_TITLE)); mpCBYAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::Y_AXIS_TITLE)); mpCBZAxisTitle->Check(isTitleVisisble(mxModel, TitleHelper::Z_AXIS_TITLE)); @@ -584,6 +607,18 @@ IMPL_LINK(ChartElementsPanel, CheckBoxHdl, Button*, pButton, void) setGridVisible(mxModel, GridType::HOR_MINOR, bChecked); } +IMPL_LINK(ChartElementsPanel, EditHdl, Edit&, rEdit, void) +{ + // title or subtitle? + TitleHelper::eTitleType aTitleType = TitleHelper::MAIN_TITLE; + if (&rEdit == mpEditSubtitle.get()) + aTitleType = TitleHelper::SUB_TITLE; + + // set it + OUString aText(rEdit.GetText()); + TitleHelper::setCompleteString(aText, TitleHelper::getTitle(aTitleType, mxModel), comphelper::getProcessComponentContext()); +} + IMPL_LINK_NOARG(ChartElementsPanel, LegendPosHdl, ListBox&, void) { sal_Int32 nPos = mpLBLegendPosition->GetSelectedEntryPos(); diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx index eca293645cc4..500ad77fccec 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx @@ -71,7 +71,9 @@ public: private: //ui controls VclPtr<CheckBox> mpCBTitle; + VclPtr<Edit> mpEditTitle; VclPtr<CheckBox> mpCBSubtitle; + VclPtr<Edit> mpEditSubtitle; VclPtr<CheckBox> mpCBXAxis; VclPtr<CheckBox> mpCBXAxisTitle; VclPtr<CheckBox> mpCBYAxis; @@ -110,6 +112,7 @@ private: void setTitleVisible(TitleHelper::eTitleType eTitle, bool bVisible); DECL_LINK(CheckBoxHdl, Button*, void); + DECL_LINK(EditHdl, Edit&, void); DECL_LINK(LegendPosHdl, ListBox&, void); }; diff --git a/chart2/uiconfig/ui/sidebarelements.ui b/chart2/uiconfig/ui/sidebarelements.ui index 9db51b35a5d7..2b1f57ba2d5e 100644 --- a/chart2/uiconfig/ui/sidebarelements.ui +++ b/chart2/uiconfig/ui/sidebarelements.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> +<!-- Generated with glade 3.20.4 --> <interface domain="chart"> <requires lib="gtk+" version="3.18"/> <object class="GtkGrid" id="ChartElementsPanel"> @@ -16,6 +16,7 @@ <object class="GtkFrame" id="frame1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> @@ -31,33 +32,67 @@ <property name="row_spacing">6</property> <property name="column_spacing">6</property> <child> - <object class="GtkCheckButton" id="checkbutton_subtitle"> - <property name="label" translatable="yes" context="sidebarelements|checkbutton_subtitle">Subtitle</property> + <object class="GtkCheckButton" id="checkbutton_title"> + <property name="label" translatable="yes" context="sidebarelements|checkbutton_title">Title</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> + <accessibility> + <relation type="label-for" target="edit_title"/> + </accessibility> </object> <packing> - <property name="left_attach">1</property> + <property name="left_attach">0</property> <property name="top_attach">0</property> </packing> </child> <child> - <object class="GtkCheckButton" id="checkbutton_title"> - <property name="label" translatable="yes" context="sidebarelements|checkbutton_title">Title</property> + <object class="GtkCheckButton" id="checkbutton_subtitle"> + <property name="label" translatable="yes" context="sidebarelements|checkbutton_subtitle">Subtitle</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> + <accessibility> + <relation type="label-for" target="edit_subtitle"/> + </accessibility> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="edit_title"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <accessibility> + <relation type="labelled-by" target="checkbutton_title"/> + </accessibility> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="edit_subtitle"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <accessibility> + <relation type="labelled-by" target="checkbutton_subtitle"/> + </accessibility> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> </packing> </child> </object> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits