sidebar: unify LineWidthPopup with other WeldToolbarPopups

Change-Id: I9dd0d2b223972683a9066f0069e055175349526f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118023
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
diff --git a/include/svx/sidebar/LineWidthPopup.hxx b/include/svx/sidebar/LineWidthPopup.hxx
index d16f49b..262f354 100644
--- a/include/svx/sidebar/LineWidthPopup.hxx
+++ b/include/svx/sidebar/LineWidthPopup.hxx
@@ -23,6 +23,7 @@
#include <vcl/customweld.hxx>
#include <vcl/image.hxx>
#include <vcl/weld.hxx>
#include <svtools/toolbarmenu.hxx>
#include <array>

class ValueSet;
@@ -32,7 +33,7 @@ namespace svx::sidebar
class LinePropertyPanelBase;
class LineWidthValueSet;

class LineWidthPopup final
class LineWidthPopup final : public WeldToolbarPopup
{
public:
    LineWidthPopup(weld::Widget* pParent, LinePropertyPanelBase& rParent);
@@ -42,6 +43,8 @@ public:

    weld::Container* getTopLevel() const { return m_xTopLevel.get(); }

    virtual void GrabFocus() override;

private:
    LinePropertyPanelBase& m_rParent;
    std::array<OUString, 9> maStrUnits;
@@ -53,15 +56,12 @@ private:
    Image m_aIMGCus;
    Image m_aIMGCusGray;

    std::unique_ptr<weld::Builder> m_xBuilder;
    std::unique_ptr<weld::Container> m_xTopLevel;
    std::unique_ptr<weld::MetricSpinButton> m_xMFWidth;
    std::unique_ptr<LineWidthValueSet> m_xVSWidth;
    std::unique_ptr<weld::CustomWeld> m_xVSWidthWin;

    DECL_LINK(VSSelectHdl, ValueSet*, void);
    DECL_LINK(MFModifyHdl, weld::MetricSpinButton&, void);
    DECL_LINK(FocusHdl, weld::Widget&, void);
};

} // end of namespace svx::sidebar
diff --git a/svx/source/sidebar/line/LineWidthPopup.cxx b/svx/source/sidebar/line/LineWidthPopup.cxx
index 6cd19ce..347bb2a 100644
--- a/svx/source/sidebar/line/LineWidthPopup.cxx
+++ b/svx/source/sidebar/line/LineWidthPopup.cxx
@@ -32,7 +32,8 @@
namespace svx::sidebar
{
LineWidthPopup::LineWidthPopup(weld::Widget* pParent, LinePropertyPanelBase& rParent)
    : m_rParent(rParent)
    : WeldToolbarPopup(nullptr, pParent, "svx/ui/floatinglineproperty.ui", "FloatingLineProperty")
    , m_rParent(rParent)
    , m_sPt(SvxResId(RID_SVXSTR_PT))
    , m_eMapUnit(MapUnit::MapTwip)
    , m_bVSFocus(true)
@@ -40,14 +41,10 @@ LineWidthPopup::LineWidthPopup(weld::Widget* pParent, LinePropertyPanelBase& rPa
    , m_nCustomWidth(0)
    , m_aIMGCus(StockImage::Yes, RID_SVXBMP_WIDTH_CUSTOM)
    , m_aIMGCusGray(StockImage::Yes, RID_SVXBMP_WIDTH_CUSTOM_GRAY)
    , m_xBuilder(Application::CreateBuilder(pParent, "svx/ui/floatinglineproperty.ui"))
    , m_xTopLevel(m_xBuilder->weld_container("FloatingLineProperty"))
    , m_xMFWidth(m_xBuilder->weld_metric_spin_button("spin", FieldUnit::POINT))
    , m_xVSWidth(new LineWidthValueSet())
    , m_xVSWidthWin(new weld::CustomWeld(*m_xBuilder, "lineset", *m_xVSWidth))
{
    m_xTopLevel->connect_focus_in(LINK(this, LineWidthPopup, FocusHdl));

    m_xVSWidth->SetStyle(m_xVSWidth->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT);

    maStrUnits[0] = "0.5";
@@ -213,7 +210,7 @@ void LineWidthPopup::SetWidthSelect(tools::Long lValue, bool bValuable, MapUnit 
    m_xVSWidth->Invalidate();
}

IMPL_LINK_NOARG(LineWidthPopup, FocusHdl, weld::Widget&, void)
void LineWidthPopup::GrabFocus()
{
    if (m_bVSFocus)
        m_xVSWidth->GrabFocus();
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 879ae9b..e250dcf 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -223,6 +223,9 @@ JSDialogNotifyIdle::generatePopupMessage(VclPtr<vcl::Window> pWindow, OUString s
    if (!pWindow || !m_aNotifierWindow)
        return aJsonWriter;

    if (!pWindow->GetParentWithLOKNotifier())
        return aJsonWriter;

    pWindow->DumpAsPropertyTree(*aJsonWriter);

    aJsonWriter->put("jsontype", "dialog");
@@ -230,7 +233,7 @@ JSDialogNotifyIdle::generatePopupMessage(VclPtr<vcl::Window> pWindow, OUString s
    aJsonWriter->put("cancellable", true);
    aJsonWriter->put("popupParent", sParentId);
    aJsonWriter->put("clickToClose", sCloseId);
    aJsonWriter->put("id", pWindow->GetLOKWindowId());
    aJsonWriter->put("id", pWindow->GetParentWithLOKNotifier()->GetLOKWindowId());

    return aJsonWriter;
}