diff options
author | Hubert Figuière <hub@collabora.com> | 2024-03-22 09:59:54 -0400 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-03-25 15:39:27 +0100 |
commit | 7586da84124f4aa73fd21081610de78d5d416fe6 (patch) | |
tree | eb2fbe1db75f449d37e671a54aa9c83ff2c29f31 /vcl | |
parent | f791b56325c8eac4ad321a3b927c9eb3f02baab0 (diff) |
vcl: Implement JSLevelBar
This fixes the JSDialog layout of the sheet protection dialog.
This was introduced for 24.02 to provide password strength indication
of the sheet password.
Defined a new WindowType of PROGRESSBAR.
The type property in JSDialog JSON will be "progressbar".
Change-Id: I202528a81706943e1838f3c37fb555f4a1bf889e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165168
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 10 | ||||
-rw-r--r-- | vcl/inc/salvtables.hxx | 19 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 25 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 19 | ||||
-rw-r--r-- | vcl/source/control/prgsbar.cxx | 8 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 1 |
6 files changed, 63 insertions, 19 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 066dcddfcfc8..3d98e7e61a19 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -16,6 +16,7 @@ #include <salvtables.hxx> #include <vcl/toolkit/button.hxx> #include <vcl/toolkit/fmtfield.hxx> +#include <vcl/toolkit/prgsbar.hxx> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -311,6 +312,7 @@ public: virtual std::unique_ptr<weld::Box> weld_box(const OUString& id) override; virtual std::unique_ptr<weld::Widget> weld_widget(const OUString& id) override; virtual std::unique_ptr<weld::Image> weld_image(const OUString& id) override; + virtual std::unique_ptr<weld::LevelBar> weld_level_bar(const OUString& id) override; virtual std::unique_ptr<weld::Calendar> weld_calendar(const OUString& id) override; static weld::MessageDialog* @@ -889,6 +891,14 @@ public: virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override; }; +class JSLevelBar : public JSWidget<SalInstanceLevelBar, ::ProgressBar> +{ +public: + JSLevelBar(JSDialogSender* pSender, ::ProgressBar* pProgressBar, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void set_percentage(double fPercentage) override; +}; + class JSCalendar : public JSWidget<SalInstanceCalendar, ::Calendar> { public: diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 4074e097a4f4..46aa3da22b71 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -22,6 +22,7 @@ #include <vcl/toolkit/fixedhyper.hxx> #include <vcl/toolkit/lstbox.hxx> #include <vcl/toolkit/menubtn.hxx> +#include <vcl/toolkit/prgsbar.hxx> #include <vcl/toolkit/combobox.hxx> #include <vcl/tabctrl.hxx> #include <vcl/layout.hxx> @@ -2182,6 +2183,24 @@ public: virtual ~SalInstanceScrolledWindow() override; }; +class SalInstanceLevelBar : public SalInstanceWidget, public virtual weld::LevelBar +{ +private: + VclPtr<::ProgressBar> m_xLevelBar; + +public: + SalInstanceLevelBar(::ProgressBar* pLevelBar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pLevelBar, pBuilder, bTakeOwnership) + , m_xLevelBar(pLevelBar) + { + } + + virtual void set_percentage(double fPercentage) override + { + m_xLevelBar->SetValue(static_cast<sal_uInt16>(fPercentage)); + } +}; + class SalInstanceCalendar : public SalInstanceWidget, public virtual weld::Calendar { private: diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 97675b6267c1..1704988084f1 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1269,6 +1269,19 @@ std::unique_ptr<weld::Image> JSInstanceBuilder::weld_image(const OUString& id) return pWeldWidget; } +std::unique_ptr<weld::LevelBar> JSInstanceBuilder::weld_level_bar(const OUString& id) +{ + ::ProgressBar* pLevelBar = m_xBuilder->get<::ProgressBar>(id); + + auto pWeldWidget + = pLevelBar ? std::make_unique<JSLevelBar>(this, pLevelBar, this, false) : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + std::unique_ptr<weld::Calendar> JSInstanceBuilder::weld_calendar(const OUString& id) { ::Calendar* pCalendar = m_xBuilder->get<::Calendar>(id); @@ -2353,6 +2366,18 @@ void JSImage::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImag sendUpdate(); } +JSLevelBar::JSLevelBar(JSDialogSender* pSender, ::ProgressBar* pProgressBar, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceLevelBar, ::ProgressBar>(pSender, pProgressBar, pBuilder, bTakeOwnership) +{ +} + +void JSLevelBar::set_percentage(double fPercentage) +{ + SalInstanceLevelBar::set_percentage(fPercentage); + sendUpdate(); +} + JSCalendar::JSCalendar(JSDialogSender* pSender, ::Calendar* pCalendar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceCalendar, ::Calendar>(pSender, pCalendar, pBuilder, bTakeOwnership) diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 50ecd194bdcd..9ed790a2b6ec 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -58,7 +58,6 @@ #include <vcl/toolkit/ivctrl.hxx> #include <vcl/layout.hxx> #include <vcl/toolkit/menubtn.hxx> -#include <vcl/toolkit/prgsbar.hxx> #include <vcl/ptrstyle.hxx> #include <slider.hxx> #include <vcl/sysdata.hxx> @@ -3308,24 +3307,6 @@ public: virtual void set_text(const OUString& rText) override { m_xProgressBar->SetText(rText); } }; - -class SalInstanceLevelBar : public SalInstanceWidget, public virtual weld::LevelBar -{ -private: - VclPtr<::ProgressBar> m_xLevelBar; - -public: - SalInstanceLevelBar(::ProgressBar* pLevelBar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceWidget(pLevelBar, pBuilder, bTakeOwnership) - , m_xLevelBar(pLevelBar) - { - } - - virtual void set_percentage(double fPercentage) override - { - m_xLevelBar->SetValue(static_cast<sal_uInt16>(fPercentage)); - } -}; } IMPL_LINK_NOARG(SalInstanceCalendar, SelectHdl, ::Calendar*, void) diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx index e15c7c055dbe..f4727b97ad6e 100644 --- a/vcl/source/control/prgsbar.cxx +++ b/vcl/source/control/prgsbar.cxx @@ -24,6 +24,7 @@ #include <sal/log.hxx> #include <vcl/svapp.hxx> #include <vcl/idle.hxx> +#include <tools/json_writer.hxx> #define PROGRESSBAR_OFFSET 3 #define PROGRESSBAR_WIN_OFFSET 2 @@ -35,6 +36,7 @@ void ProgressBar::ImplInit() mnPercent = 0; mnPercentCount = 0; mbCalcNew = true; + SetType(WindowType::PROGRESSBAR); ImplInitSettings( true, true, true ); } @@ -236,4 +238,10 @@ void ProgressBar::DataChanged( const DataChangedEvent& rDCEvt ) Window::DataChanged( rDCEvt ); } +void ProgressBar::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) +{ + vcl::Window::DumpAsPropertyTree(rJsonWriter); + rJsonWriter.put("value", mnPercent); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index d683f9b4156e..3da1dfe90de3 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -3345,6 +3345,7 @@ std::string_view windowTypeName(WindowType nWindowType) case WindowType::RULER: return "ruler"; case WindowType::HEADERBAR: return "headerbar"; case WindowType::VERTICALTABCONTROL: return "verticaltabcontrol"; + case WindowType::PROGRESSBAR: return "progressbar"; // nothing to do here, but for completeness case WindowType::TOOLKIT_FRAMEWINDOW: return "toolkit_framewindow"; |