include/vcl/weld.hxx | 68 ++++++++++++++++----------------- sw/source/ui/dialog/ascfldlg.cxx | 6 +- vcl/inc/qt5/QtInstanceCheckButton.hxx | 2 vcl/inc/qt5/QtInstanceToggleButton.hxx | 3 - vcl/inc/salvtables.hxx | 18 -------- vcl/jsdialog/executor.cxx | 2 vcl/qt5/QtInstanceCheckButton.cxx | 4 - vcl/qt5/QtInstanceToggleButton.cxx | 12 ----- vcl/source/app/salvtables.cxx | 11 ----- vcl/unx/gtk3/gtkinst.cxx | 53 +++++-------------------- 10 files changed, 54 insertions(+), 125 deletions(-)
New commits: commit 1b9da9b63436d522f6792b4dd739ade34e334630 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jul 17 12:23:23 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 18 07:07:52 2025 +0200 tdf#130857 weld: No longer let RadioButton subclass CheckButton Doing so was likely inspired by the fact that in GTK 3, GtkRadioButton subclasses GtkCheckButton. In GTK 4, the two have been merged into GtkCheckButton, and neither the VCL nor the Qt implementation has any such inheritance for the implementations. Drop it and instead explicitly define the 3 methods both have in common in addition to the weld::Toggleable base class methods. With previous commit Change-Id: I8de7add52f3ff4275fe8c7f077d4ac84a0a07e39 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Wed Jul 16 19:52:54 2025 +0200 tdf#130857 weld: Make indeterminate logic specific to CheckButton in place, this also means that there is no more need to have dummy implementations/overrides for the weld::CheckButton::set_inconsistent/ weld::CheckButton::get_inconsistent base class methods, with the inconsistent state not actually being supported, as having such methods is no longer mandated by a base class. Switch the few callers of (the now no more existing) weld::RadioButton::set_state to use weld::Toggleable::set_active instead. This cleans up the API a bit and prevents from any accidental attempt to set the unsupported TRISTATE_INDET state for radio buttons. Change-Id: Iefa7d03a1380861f3936e797592d6c461ff3ff2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188004 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index af7ae5384812..bd4927a401c6 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1727,16 +1727,12 @@ struct VCL_DLLPUBLIC TriStateEnabled void CheckButtonToggled(CheckButton& rToggle); }; -class VCL_DLLPUBLIC RadioButton : virtual public CheckButton +class VCL_DLLPUBLIC RadioButton : virtual public Toggleable { public: - // radio button doesn't support inconsistent state - void set_inconsistent() override - { - assert(false && "Radio button doesn't support inconsistent state"); - } - - bool get_inconsistent() const override { return false; } + virtual void set_label(const OUString& rText) = 0; + virtual OUString get_label() const = 0; + virtual void set_label_wrap(bool wrap) = 0; }; class VCL_DLLPUBLIC LinkButton : virtual public Widget diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index 4efba9159e6f..ef2eb019f74c 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -427,9 +427,9 @@ IMPL_LINK_NOARG(SwAsciiFilterDlg, CharSetSelHdl, weld::ComboBox&, void) else { // restore old user choice (not the automatic!) - m_xCRLF_RB->set_state(m_xCRLF_RB->get_saved_state()); - m_xCR_RB->set_state(m_xCR_RB->get_saved_state()); - m_xLF_RB->set_state(m_xLF_RB->get_saved_state()); + m_xCRLF_RB->set_active(m_xCRLF_RB->get_saved_state() == TRISTATE_TRUE); + m_xCR_RB->set_active(m_xCR_RB->get_saved_state() == TRISTATE_TRUE); + m_xLF_RB->set_active(m_xLF_RB->get_saved_state() == TRISTATE_TRUE); } m_bSaveLineStatus = true; diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 67afbc73ec82..a629101a84e9 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -740,7 +740,7 @@ bool ExecuteAction(const OUString& nWindowId, const OUString& rWidget, const Str if (sAction == "change") { bool bChecked = rData.at(u"data"_ustr) == "true"; - pRadioButton->set_state(bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); + pRadioButton->set_active(bChecked); LOKTrigger::trigger_toggled(*static_cast<weld::Toggleable*>(pRadioButton)); return true; } diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index edc4d130dc1b..15f9d92a9613 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -12878,9 +12878,17 @@ public: { } - void set_inconsistent() override { weld::RadioButton::set_inconsistent(); } + virtual void set_label(const OUString& rText) override + { + GtkInstanceCheckButton::set_label(rText); + } - bool get_inconsistent() const override { return weld::RadioButton::get_inconsistent(); } + virtual OUString get_label() const override { return GtkInstanceCheckButton::get_label(); } + + virtual void set_label_wrap(bool wrap) override + { + GtkInstanceCheckButton::set_label_wrap(wrap); + } }; } commit 30af525966abe4c64bc4f3b645823b2f362306fe Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Jul 17 12:11:40 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 18 07:07:46 2025 +0200 tdf#130857 weld: Drop CheckButton::set_inconsistent param Drop the bool param to CheckButton::set_inconsistent and only call the method when the state should be set. Clearing the state/Switching to another one already happens when calling weld::CheckButton::set_active for all 3 ipmlementations (GTK, VCL, Qt). That method gets called for both code paths in weld::CheckButton::set_state that were previously the only ones calling CheckButton::set_inconsistent with a param of false. No longer explicitly calling CheckButton::set_inconsistent(false) from weld::CheckButton::set_state also prevents toggling the state back and forth for the SalInstanceCheckButton::set_inconsistent and QtInstanceCheckButton::set_inconsistent implementations that would explicitly set the checkbox to unchecked (i.e. toggle the state from checked to unchecked if that was the previous state). Change-Id: Ibf4085f24f694f67254291177c5e7ca7bc5b0d7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188003 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index ff61ee481b41..af7ae5384812 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1695,14 +1695,12 @@ public: switch (eState) { case TRISTATE_INDET: - set_inconsistent(true); + set_inconsistent(); break; case TRISTATE_TRUE: - set_inconsistent(false); set_active(true); break; case TRISTATE_FALSE: - set_inconsistent(false); set_active(false); break; } @@ -1713,7 +1711,7 @@ public: virtual void set_label_wrap(bool wrap) = 0; protected: - virtual void set_inconsistent(bool inconsistent) = 0; + virtual void set_inconsistent() = 0; virtual bool get_inconsistent() const = 0; }; @@ -1733,10 +1731,9 @@ class VCL_DLLPUBLIC RadioButton : virtual public CheckButton { public: // radio button doesn't support inconsistent state - void set_inconsistent(bool bInconsistent) override + void set_inconsistent() override { - assert(!bInconsistent && "Radio button doesn't support inconsistent state"); - (void)bInconsistent; + assert(false && "Radio button doesn't support inconsistent state"); } bool get_inconsistent() const override { return false; } diff --git a/vcl/inc/qt5/QtInstanceCheckButton.hxx b/vcl/inc/qt5/QtInstanceCheckButton.hxx index a929dfe5e465..df88c32ed3db 100644 --- a/vcl/inc/qt5/QtInstanceCheckButton.hxx +++ b/vcl/inc/qt5/QtInstanceCheckButton.hxx @@ -26,7 +26,7 @@ public: // weld::Toggleable methods virtual void set_active(bool bActive) override; virtual bool get_active() const override; - virtual void set_inconsistent(bool bInconsistent) override; + virtual void set_inconsistent() override; virtual bool get_inconsistent() const override; // weld::CheckButton methods diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index d5c4f75bb1de..cfb17e112279 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1245,7 +1245,7 @@ public: virtual bool get_active() const override; - virtual void set_inconsistent(bool inconsistent) override; + virtual void set_inconsistent() override; virtual bool get_inconsistent() const override; diff --git a/vcl/qt5/QtInstanceCheckButton.cxx b/vcl/qt5/QtInstanceCheckButton.cxx index 1a5e63408de7..747191171a37 100644 --- a/vcl/qt5/QtInstanceCheckButton.cxx +++ b/vcl/qt5/QtInstanceCheckButton.cxx @@ -37,12 +37,12 @@ bool QtInstanceCheckButton::get_active() const return bActive; } -void QtInstanceCheckButton::set_inconsistent(bool bInconsistent) +void QtInstanceCheckButton::set_inconsistent() { SolarMutexGuard g; GetQtInstance().RunInMainThread([&] { m_pCheckBox->setTristate(true); - m_pCheckBox->setCheckState(bInconsistent ? Qt::PartiallyChecked : Qt::Unchecked); + m_pCheckBox->setCheckState(Qt::PartiallyChecked); }); } diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index f13be7260869..e338e42c8789 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3216,11 +3216,11 @@ void SalInstanceCheckButton::set_active(bool active) bool SalInstanceCheckButton::get_active() const { return m_xCheckButton->IsChecked(); } -void SalInstanceCheckButton::set_inconsistent(bool inconsistent) +void SalInstanceCheckButton::set_inconsistent() { disable_notify_events(); m_xCheckButton->EnableTriState(true); - m_xCheckButton->SetState(inconsistent ? TRISTATE_INDET : TRISTATE_FALSE); + m_xCheckButton->SetState(TRISTATE_INDET); enable_notify_events(); } diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 91c6bf369412..edc4d130dc1b 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -12804,12 +12804,12 @@ public: #endif } - virtual void set_inconsistent(bool inconsistent) override + virtual void set_inconsistent() override { #if GTK_CHECK_VERSION(4, 0, 0) - gtk_check_button_set_inconsistent(m_pCheckButton, inconsistent); + gtk_check_button_set_inconsistent(m_pCheckButton, true); #else - gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(m_pCheckButton), inconsistent); + gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(m_pCheckButton), true); #endif } @@ -12878,10 +12878,7 @@ public: { } - void set_inconsistent(bool bInconsistent) override - { - weld::RadioButton::set_inconsistent(bInconsistent); - } + void set_inconsistent() override { weld::RadioButton::set_inconsistent(); } bool get_inconsistent() const override { return weld::RadioButton::get_inconsistent(); } }; commit 6f4f720eb6da90ca9c703150787ec1aa144841f9 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jul 16 19:52:54 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 18 07:07:39 2025 +0200 tdf#130857 weld: Make indeterminate logic specific to CheckButton So far, the weld::Toggleable API included support for TRISTATE_INDET, i.e. some indeterminate/inconsistent was supposed to be supported by all subclasses. In practice, that was not the case for all subclasses, however, see e.g. SalInstanceMenuButton::set_inconsistent and QtInstanceToggleButton::set_inconsistent, both dropped in this commit. GTK 4 also dropped explicit support for the indeterminate state for GtkToolButton, see GTK commit [1] commit 2aea8dfee97b514e1fca7f577fefdac4e449e906 Author: Timm Bäder <m...@baedert.org> Date: Sat Jan 28 08:11:14 2017 +0100 togglebutton: Move :inconsistent to GtkCheckButton The only use of an indeterminate state for a weld::Toggleable subclass used to be in Svx3DWin. That one has been ported to a separate helper class by now, see previous commit Change-Id: Ib781e9108d526f90282a203b53065111a9d12236 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Thu Jul 17 11:14:01 2025 +0200 tdf#130857 svx Svx3DWin: Stop relying on weld::ToggleButton indeterminate state Therefore, make support for the indeterminate state specific to weld::CheckButton by moving the corresponding logic from weld::Toggleable to weld::CheckButton. Drop now obsolete overrides from weld::Toggleable (subclass) implementations. If there were a desparate need to still make use of an indeterminate state for other classes, the TriStateToggleButton helper class used in Svx3DWin could be made available for wider use. Change-Id: I8de7add52f3ff4275fe8c7f077d4ac84a0a07e39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188002 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index d12c065bbfe2..ff61ee481b41 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1606,42 +1606,18 @@ public: virtual void set_active(bool active) = 0; virtual bool get_active() const = 0; - TriState get_state() const + virtual TriState get_state() const { - if (get_inconsistent()) - return TRISTATE_INDET; - else if (get_active()) + if (get_active()) return TRISTATE_TRUE; return TRISTATE_FALSE; } - void set_state(TriState eState) - { - switch (eState) - { - case TRISTATE_INDET: - set_inconsistent(true); - break; - case TRISTATE_TRUE: - set_inconsistent(false); - set_active(true); - break; - case TRISTATE_FALSE: - set_inconsistent(false); - set_active(false); - break; - } - } - void save_state() { m_eSavedValue = get_state(); } TriState get_saved_state() const { return m_eSavedValue; } bool get_state_changed_from_saved() const { return m_eSavedValue != get_state(); } virtual void connect_toggled(const Link<Toggleable&, void>& rLink) { m_aToggleHdl = rLink; } - -protected: - virtual void set_inconsistent(bool inconsistent) = 0; - virtual bool get_inconsistent() const = 0; }; class VCL_DLLPUBLIC ToggleButton : virtual public Button, virtual public Toggleable @@ -1707,9 +1683,38 @@ class VCL_DLLPUBLIC MenuToggleButton : virtual public MenuButton class VCL_DLLPUBLIC CheckButton : virtual public Toggleable { public: + virtual TriState get_state() const override + { + if (get_inconsistent()) + return TRISTATE_INDET; + return weld::Toggleable::get_state(); + } + + void set_state(TriState eState) + { + switch (eState) + { + case TRISTATE_INDET: + set_inconsistent(true); + break; + case TRISTATE_TRUE: + set_inconsistent(false); + set_active(true); + break; + case TRISTATE_FALSE: + set_inconsistent(false); + set_active(false); + break; + } + } + virtual void set_label(const OUString& rText) = 0; virtual OUString get_label() const = 0; virtual void set_label_wrap(bool wrap) = 0; + +protected: + virtual void set_inconsistent(bool inconsistent) = 0; + virtual bool get_inconsistent() const = 0; }; struct VCL_DLLPUBLIC TriStateEnabled diff --git a/vcl/inc/qt5/QtInstanceToggleButton.hxx b/vcl/inc/qt5/QtInstanceToggleButton.hxx index c7da7454f4d6..ca3c89a56239 100644 --- a/vcl/inc/qt5/QtInstanceToggleButton.hxx +++ b/vcl/inc/qt5/QtInstanceToggleButton.hxx @@ -23,9 +23,6 @@ public: virtual void set_active(bool bActive) override; virtual bool get_active() const override; - virtual void set_inconsistent(bool bInconsistent) override; - virtual bool get_inconsistent() const override; - private Q_SLOTS: void signalToggled(); }; diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 0934d4d06309..d5c4f75bb1de 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1128,18 +1128,6 @@ public: virtual bool get_active() const override { return m_xToggleButton->IsChecked(); } - virtual void set_inconsistent(bool inconsistent) override - { - disable_notify_events(); - m_xToggleButton->SetState(inconsistent ? TRISTATE_INDET : TRISTATE_FALSE); - enable_notify_events(); - } - - virtual bool get_inconsistent() const override - { - return m_xToggleButton->GetState() == TRISTATE_INDET; - } - virtual ~SalInstanceToggleButton() override { if (m_aToggleHdl.IsSet()) @@ -2071,10 +2059,6 @@ public: virtual bool get_active() const override; - virtual void set_inconsistent(bool /*inconsistent*/) override; - - virtual bool get_inconsistent() const override; - virtual void insert_item(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface, TriState eCheckRadioFalse) override; diff --git a/vcl/qt5/QtInstanceToggleButton.cxx b/vcl/qt5/QtInstanceToggleButton.cxx index eca59aa95f4a..cb63c32b8fa4 100644 --- a/vcl/qt5/QtInstanceToggleButton.cxx +++ b/vcl/qt5/QtInstanceToggleButton.cxx @@ -36,18 +36,6 @@ bool QtInstanceToggleButton::get_active() const return bActive; }; -void QtInstanceToggleButton::set_inconsistent(bool bInconsistent) -{ - assert(!bInconsistent && "Inconsistent state not supported (yet?)"); - (void)bInconsistent; -}; - -bool QtInstanceToggleButton::get_inconsistent() const -{ - assert(false && "Not implemented yet"); - return false; -}; - void QtInstanceToggleButton::signalToggled() { SolarMutexGuard g; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 4035f772c5bd..f13be7260869 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3018,13 +3018,6 @@ void SalInstanceMenuButton::set_active(bool active) bool SalInstanceMenuButton::get_active() const { return m_xMenuButton->InPopupMode(); } -void SalInstanceMenuButton::set_inconsistent(bool /*inconsistent*/) -{ - //not available -} - -bool SalInstanceMenuButton::get_inconsistent() const { return false; } - void SalInstanceMenuButton::insert_item(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface, TriState eCheckRadioFalse) diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 51eea482eea5..91c6bf369412 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -10276,7 +10276,6 @@ public: virtual void set_active(bool active) override { disable_notify_events(); - set_inconsistent(false); gtk_toggle_button_set_active(m_pToggleButton, active); enable_notify_events(); } @@ -10286,27 +10285,6 @@ public: return gtk_toggle_button_get_active(m_pToggleButton); } - virtual void set_inconsistent(bool inconsistent) override - { -#if GTK_CHECK_VERSION(4, 0, 0) - if (inconsistent) - gtk_widget_set_state_flags(GTK_WIDGET(m_pToggleButton), GTK_STATE_FLAG_INCONSISTENT, false); - else - gtk_widget_unset_state_flags(GTK_WIDGET(m_pToggleButton), GTK_STATE_FLAG_INCONSISTENT); -#else - gtk_toggle_button_set_inconsistent(m_pToggleButton, inconsistent); -#endif - } - - virtual bool get_inconsistent() const override - { -#if GTK_CHECK_VERSION(4, 0, 0) - return gtk_widget_get_state_flags(GTK_WIDGET(m_pToggleButton)) & GTK_STATE_FLAG_INCONSISTENT; -#else - return gtk_toggle_button_get_inconsistent(m_pToggleButton); -#endif - } - virtual void disable_notify_events() override { g_signal_handler_block(m_pToggleButton, m_nToggledSignalId); @@ -10958,23 +10936,9 @@ public: m_aCustomBackground.use_custom_content(pDevice); } - virtual void set_inconsistent(bool inconsistent) override - { - if (inconsistent) - gtk_widget_set_state_flags(GTK_WIDGET(m_pMenuButton), GTK_STATE_FLAG_INCONSISTENT, false); - else - gtk_widget_unset_state_flags(GTK_WIDGET(m_pMenuButton), GTK_STATE_FLAG_INCONSISTENT); - } - - virtual bool get_inconsistent() const override - { - return gtk_widget_get_state_flags(GTK_WIDGET(m_pMenuButton)) & GTK_STATE_FLAG_INCONSISTENT; - } - virtual void set_active(bool active) override { disable_notify_events(); - set_inconsistent(false); if (active) gtk_menu_button_popup(m_pMenuButton); else