diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-12-12 10:22:32 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-12-12 13:59:33 +0100 |
commit | 30d3a5743961274d360e683eccd2756257ed5e7a (patch) | |
tree | dcfafd6f84e5babe2b01b96d698898a485397e65 /svx/source/tbxctrls | |
parent | 890effa901a1406161d80acce8c3e7209ea78989 (diff) |
tdf#158320 restore Live Preview for font hovering
a) announce Preview when a 'selected' font preview is requested
b) move EndPreview to when the dropdown popups down, rather than listen
to ESC
Change-Id: I68916769150c23c0ec18aae084cdf3cafb7352a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160609
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'svx/source/tbxctrls')
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 6253d4f4b0d4..9a3669aac56a 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -341,6 +341,7 @@ protected: bool bRelease; Reference< XFrame > m_xFrame; bool mbCheckingUnknownFont; + bool mbDropDownActive; void ReleaseFocus_Impl(); @@ -394,6 +395,8 @@ public: DECL_LINK(ActivateHdl, weld::ComboBox&, bool); DECL_LINK(FocusInHdl, weld::Widget&, void); DECL_LINK(FocusOutHdl, weld::Widget&, void); + DECL_LINK(PopupToggledHdl, weld::ComboBox&, void); + DECL_LINK(LivePreviewHdl, const FontMetric&, void); DECL_LINK(DumpAsPropertyTreeHdl, tools::JsonWriter&, void); }; @@ -1726,6 +1729,7 @@ SvxFontNameBox_Base::SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget , bRelease(true) , m_xFrame(rFrame) , mbCheckingUnknownFont(false) + , mbDropDownActive(false) { EnableControls(); @@ -1734,6 +1738,8 @@ SvxFontNameBox_Base::SvxFontNameBox_Base(std::unique_ptr<weld::ComboBox> xWidget m_xWidget->connect_entry_activate(LINK(this, SvxFontNameBox_Base, ActivateHdl)); m_xWidget->connect_focus_in(LINK(this, SvxFontNameBox_Base, FocusInHdl)); m_xWidget->connect_focus_out(LINK(this, SvxFontNameBox_Base, FocusOutHdl)); + m_xWidget->connect_popup_toggled(LINK(this, SvxFontNameBox_Base, PopupToggledHdl)); + m_xWidget->connect_live_preview(LINK(this, SvxFontNameBox_Base, LivePreviewHdl)); m_xWidget->connect_get_property_tree(LINK(this, SvxFontNameBox_Base, DumpAsPropertyTreeHdl)); m_xWidget->set_entry_width_chars(COMBO_WIDTH_IN_CHARS + 5); @@ -1849,7 +1855,6 @@ bool SvxFontNameBox_Base::DoKeyInput(const KeyEvent& rKEvt) ReleaseFocus_Impl(); bHandled = true; } - EndPreview(); break; } @@ -1871,6 +1876,30 @@ IMPL_LINK_NOARG(SvxFontNameBox_Base, FocusOutHdl, weld::Widget&, void) } } +IMPL_LINK(SvxFontNameBox_Base, LivePreviewHdl, const FontMetric&, rFontMetric, void) +{ + Sequence<PropertyValue> aArgs(1); + + SvxFontItem aFontItem(rFontMetric.GetFamilyType(), + rFontMetric.GetFamilyName(), + rFontMetric.GetStyleName(), + rFontMetric.GetPitch(), + rFontMetric.GetCharSet(), + SID_ATTR_CHAR_FONT); + PropertyValue* pArgs = aArgs.getArray(); + aFontItem.QueryValue(pArgs[0].Value); + pArgs[0].Name = "CharPreviewFontName"; + const Reference<XDispatchProvider> xProvider(m_xFrame, UNO_QUERY); + SfxToolBoxControl::Dispatch(xProvider, ".uno:CharPreviewFontName", aArgs); +} + +IMPL_LINK_NOARG(SvxFontNameBox_Base, PopupToggledHdl, weld::ComboBox&, void) +{ + mbDropDownActive = !mbDropDownActive; + if (!mbDropDownActive) + EndPreview(); +} + void SvxFontNameBox_Impl::SetOptimalSize() { // set width in chars low so the size request will not be overridden |