[Libreoffice-commits] core.git: include/svx svx/source svx/uiconfig

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 13 17:32:38 UTC 2020


 include/svx/TextUnderlinePopup.hxx               |    1 
 svx/source/sidebar/text/TextUnderlineControl.cxx |  113 +++++++++--------------
 svx/source/sidebar/text/TextUnderlineControl.hxx |   42 ++++----
 svx/source/sidebar/text/TextUnderlinePopup.cxx   |   14 ++
 svx/uiconfig/ui/textunderlinecontrol.ui          |   35 ++-----
 5 files changed, 96 insertions(+), 109 deletions(-)

New commits:
commit e08f680c78d4f73ddeda658cea713fdecf7a4a1b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jan 13 15:12:39 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jan 13 18:32:03 2020 +0100

    weld TextUnderlineControl
    
    Change-Id: I9ebf3b1e9c4509c0568d26370d5a97c5c60baedd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86699
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/TextUnderlinePopup.hxx b/include/svx/TextUnderlinePopup.hxx
index 6dc64face2b1..2132cbec94a2 100644
--- a/include/svx/TextUnderlinePopup.hxx
+++ b/include/svx/TextUnderlinePopup.hxx
@@ -30,6 +30,7 @@ public:
     TextUnderlinePopup(const css::uno::Reference<css::uno::XComponentContext>& rContext);
     virtual ~TextUnderlinePopup() override;
 
+    virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
     using svt::ToolboxController::createPopupWindow;
     virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override;
 
diff --git a/svx/source/sidebar/text/TextUnderlineControl.cxx b/svx/source/sidebar/text/TextUnderlineControl.cxx
index f8bac8dc99d4..1d8770c91e0c 100644
--- a/svx/source/sidebar/text/TextUnderlineControl.cxx
+++ b/svx/source/sidebar/text/TextUnderlineControl.cxx
@@ -30,83 +30,69 @@
 
 namespace svx {
 
-TextUnderlineControl::TextUnderlineControl(TextUnderlinePopup* pControl, vcl::Window* pParent)
-    : ToolbarPopup(pControl->getFrameInterface(), pParent, "TextUnderlineControl", "svx/ui/textunderlinecontrol.ui")
+TextUnderlineControl::TextUnderlineControl(TextUnderlinePopup* pControl, weld::Widget* pParent)
+    : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/textunderlinecontrol.ui", "TextUnderlineControl")
+    , mxNone(m_xBuilder->weld_button("none"))
+    , mxSingle(m_xBuilder->weld_button("single"))
+    , mxDouble(m_xBuilder->weld_button("double"))
+    , mxBold(m_xBuilder->weld_button("bold"))
+    , mxDot(m_xBuilder->weld_button("dot"))
+    , mxDotBold(m_xBuilder->weld_button("dotbold"))
+    , mxDash(m_xBuilder->weld_button("dash"))
+    , mxDashLong(m_xBuilder->weld_button("dashlong"))
+    , mxDashDot(m_xBuilder->weld_button("dashdot"))
+    , mxDashDotDot(m_xBuilder->weld_button("dashdotdot"))
+    , mxWave(m_xBuilder->weld_button("wave"))
+    , mxMoreOptions(m_xBuilder->weld_button("moreoptions"))
+    , mxControl(pControl)
 {
-    get(maNone, "none");
-    get(maSingle, "single");
-    get(maDouble, "double");
-    get(maBold, "bold");
-    get(maDot, "dot");
-    get(maDotBold, "dotbold");
-    get(maDash, "dash");
-    get(maDashLong, "dashlong");
-    get(maDashDot, "dashdot");
-    get(maDashDotDot, "dashdotdot");
-    get(maWave, "wave");
-    get(maMoreOptions, "moreoptions");
-
-    maMoreOptions->SetHelpId(HID_UNDERLINE_BTN);
-
-    Link<Button*,void> aLink = LINK(this, TextUnderlineControl, PBClickHdl);
-    maNone->SetClickHdl(aLink);
-    maSingle->SetClickHdl(aLink);
-    maDouble->SetClickHdl(aLink);
-    maBold->SetClickHdl(aLink);
-    maDot->SetClickHdl(aLink);
-    maDotBold->SetClickHdl(aLink);
-    maDash->SetClickHdl(aLink);
-    maDashLong->SetClickHdl(aLink);
-    maDashDot->SetClickHdl(aLink);
-    maDashDotDot->SetClickHdl(aLink);
-    maWave->SetClickHdl(aLink);
-    maMoreOptions->SetClickHdl(aLink);
+    mxMoreOptions->set_help_id(HID_UNDERLINE_BTN);
+
+    Link<weld::Button&,void> aLink = LINK(this, TextUnderlineControl, PBClickHdl);
+    mxNone->connect_clicked(aLink);
+    mxSingle->connect_clicked(aLink);
+    mxDouble->connect_clicked(aLink);
+    mxBold->connect_clicked(aLink);
+    mxDot->connect_clicked(aLink);
+    mxDotBold->connect_clicked(aLink);
+    mxDash->connect_clicked(aLink);
+    mxDashLong->connect_clicked(aLink);
+    mxDashDot->connect_clicked(aLink);
+    mxDashDotDot->connect_clicked(aLink);
+    mxWave->connect_clicked(aLink);
+    mxMoreOptions->connect_clicked(aLink);
 }
 
-TextUnderlineControl::~TextUnderlineControl()
+void TextUnderlineControl::GrabFocus()
 {
-    disposeOnce();
+    mxNone->grab_focus();
 }
 
-void TextUnderlineControl::dispose()
+TextUnderlineControl::~TextUnderlineControl()
 {
-    maNone.clear();
-    maSingle.clear();
-    maDouble.clear();
-    maBold.clear();
-    maDot.clear();
-    maDotBold.clear();
-    maDash.clear();
-    maDashLong.clear();
-    maDashDot.clear();
-    maDashDotDot.clear();
-    maWave.clear();
-    maMoreOptions.clear();
-
-    ToolbarPopup::dispose();
 }
 
-FontLineStyle TextUnderlineControl::getLineStyle(Button const * pButton)
+FontLineStyle TextUnderlineControl::getLineStyle(const weld::Button& rButton)
 {
-    if(pButton == maSingle)
+    if (&rButton == mxSingle.get())
         return LINESTYLE_SINGLE;
-    else if(pButton == maDouble)
+    else if (&rButton == mxDouble.get())
         return LINESTYLE_DOUBLE;
-    else if(pButton == maBold)
+    else if (&rButton == mxBold.get())
         return LINESTYLE_BOLD;
-    else if(pButton == maDot)
+    else if (&rButton == mxDot.get())
         return LINESTYLE_DOTTED;
-    else if(pButton == maDotBold)
+    else if (&rButton == mxDotBold.get())
         return LINESTYLE_BOLDDOTTED;
-    else if(pButton == maDash)
+    else if (&rButton == mxDash.get())
         return LINESTYLE_DASH;
-    else if(pButton == maDashLong)
+    else if (&rButton == mxDashLong.get())
         return LINESTYLE_LONGDASH;
-    else if(pButton == maDashDot)
+    else if (&rButton == mxDashDot.get())
         return LINESTYLE_DASHDOT;
-    else if(pButton == maDashDotDot)
+    else if (&rButton == mxDashDotDot.get())
         return LINESTYLE_DASHDOTDOT;
-    else if(pButton == maWave)
+    else if (&rButton == mxWave.get())
         return LINESTYLE_WAVE;
 
     return LINESTYLE_NONE;
@@ -129,27 +115,24 @@ Color GetUnderlineColor()
 
 }
 
-IMPL_LINK(TextUnderlineControl, PBClickHdl, Button*, pButton, void)
+IMPL_LINK(TextUnderlineControl, PBClickHdl, weld::Button&, rButton, void)
 {
-    if(pButton == maMoreOptions)
+    if (&rButton == mxMoreOptions.get())
     {
         SfxDispatcher* pDisp = SfxViewFrame::Current()->GetBindings().GetDispatcher();
         pDisp->Execute(SID_CHAR_DLG_EFFECT, SfxCallMode::ASYNCHRON);
-
-        EndPopupMode();
     }
     else
     {
-        const FontLineStyle eUnderline = getLineStyle(pButton);
+        const FontLineStyle eUnderline = getLineStyle(rButton);
 
         SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
         aLineItem.SetColor(GetUnderlineColor());
 
         SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_UNDERLINE,
                SfxCallMode::RECORD, { &aLineItem });
-
-        EndPopupMode();
     }
+    mxControl->EndPopupMode();
 }
 
 }
diff --git a/svx/source/sidebar/text/TextUnderlineControl.hxx b/svx/source/sidebar/text/TextUnderlineControl.hxx
index 48ba6d63e059..1dea62fdbef5 100644
--- a/svx/source/sidebar/text/TextUnderlineControl.hxx
+++ b/svx/source/sidebar/text/TextUnderlineControl.hxx
@@ -21,39 +21,39 @@
 #define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTUNDERLINECONTROL_HXX
 
 #include <sfx2/bindings.hxx>
-#include <vcl/button.hxx>
 #include <vcl/vclenum.hxx>
 #include <svtools/toolbarmenu.hxx>
-#include <svtools/valueset.hxx>
 
 namespace svx {
 
 class TextUnderlinePopup;
 
-class TextUnderlineControl final : public svtools::ToolbarPopup
+class TextUnderlineControl final : public WeldToolbarPopup
 {
 public:
-    explicit TextUnderlineControl(TextUnderlinePopup* pControl, vcl::Window* pParent);
+    explicit TextUnderlineControl(TextUnderlinePopup* pControl, weld::Widget* pParent);
+    virtual void GrabFocus() override;
     virtual ~TextUnderlineControl() override;
-    virtual void dispose() override;
 
 private:
-    VclPtr<PushButton> maNone;
-    VclPtr<PushButton> maSingle;
-    VclPtr<PushButton> maDouble;
-    VclPtr<PushButton> maBold;
-    VclPtr<PushButton> maDot;
-    VclPtr<PushButton> maDotBold;
-    VclPtr<PushButton> maDash;
-    VclPtr<PushButton> maDashLong;
-    VclPtr<PushButton> maDashDot;
-    VclPtr<PushButton> maDashDotDot;
-    VclPtr<PushButton> maWave;
-    VclPtr<PushButton> maMoreOptions;
-
-    FontLineStyle getLineStyle(Button const * pButton);
-
-    DECL_LINK(PBClickHdl, Button*, void);
+    std::unique_ptr<weld::Button> mxNone;
+    std::unique_ptr<weld::Button> mxSingle;
+    std::unique_ptr<weld::Button> mxDouble;
+    std::unique_ptr<weld::Button> mxBold;
+    std::unique_ptr<weld::Button> mxDot;
+    std::unique_ptr<weld::Button> mxDotBold;
+    std::unique_ptr<weld::Button> mxDash;
+    std::unique_ptr<weld::Button> mxDashLong;
+    std::unique_ptr<weld::Button> mxDashDot;
+    std::unique_ptr<weld::Button> mxDashDotDot;
+    std::unique_ptr<weld::Button> mxWave;
+    std::unique_ptr<weld::Button> mxMoreOptions;
+
+    rtl::Reference<TextUnderlinePopup> mxControl;
+
+    FontLineStyle getLineStyle(const weld::Button& rButton);
+
+    DECL_LINK(PBClickHdl, weld::Button&, void);
 };
 }
 
diff --git a/svx/source/sidebar/text/TextUnderlinePopup.cxx b/svx/source/sidebar/text/TextUnderlinePopup.cxx
index 5aebdbbdb4e1..4532f09a8a44 100644
--- a/svx/source/sidebar/text/TextUnderlinePopup.cxx
+++ b/svx/source/sidebar/text/TextUnderlinePopup.cxx
@@ -42,9 +42,19 @@ void TextUnderlinePopup::initialize( const css::uno::Sequence< css::uno::Any >&
         pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
 }
 
-VclPtr<vcl::Window> TextUnderlinePopup::createPopupWindow(vcl::Window* pParent)
+std::unique_ptr<WeldToolbarPopup> TextUnderlinePopup::weldPopupWindow()
 {
-    return VclPtr<TextUnderlineControl>::Create(this, pParent);
+    return std::make_unique<TextUnderlineControl>(this, m_pToolbar);
+}
+
+VclPtr<vcl::Window> TextUnderlinePopup::createPopupWindow( vcl::Window* pParent )
+{
+    mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
+        std::make_unique<TextUnderlineControl>(this, pParent->GetFrameWeld()));
+
+    mxInterimPopover->Show();
+
+    return mxInterimPopover;
 }
 
 OUString TextUnderlinePopup::getImplementationName()
diff --git a/svx/uiconfig/ui/textunderlinecontrol.ui b/svx/uiconfig/ui/textunderlinecontrol.ui
index 044d78692bbf..ed93e8003f58 100644
--- a/svx/uiconfig/ui/textunderlinecontrol.ui
+++ b/svx/uiconfig/ui/textunderlinecontrol.ui
@@ -1,22 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="svx">
   <requires lib="gtk+" version="3.18"/>
-  <object class="GtkWindow" id="TextUnderlineControl">
+  <object class="GtkPopover" id="TextUnderlineControl">
     <property name="can_focus">False</property>
-    <property name="hexpand">True</property>
-    <property name="vexpand">True</property>
+    <property name="no_show_all">True</property>
     <property name="border_width">4</property>
-    <property name="resizable">False</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="type_hint">popup-menu</property>
-    <property name="skip_pager_hint">True</property>
-    <property name="deletable">False</property>
     <child>
-      <object class="GtkBox" id="box">
+      <object class="GtkBox" id="container">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="margin_right">6</property>
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
         <property name="orientation">vertical</property>
@@ -231,51 +224,51 @@
   <object class="GtkImage" id="image_spacing_1">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line1.png</property>
+    <property name="icon_name">svx/res/symphony/line1.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_10">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line10.png</property>
+    <property name="icon_name">svx/res/symphony/line10.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_2">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line2.png</property>
+    <property name="icon_name">svx/res/symphony/line2.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_3">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line3.png</property>
+    <property name="icon_name">svx/res/symphony/line3.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_4">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line4.png</property>
+    <property name="icon_name">svx/res/symphony/line4.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_5">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line5.png</property>
+    <property name="icon_name">svx/res/symphony/line5.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_6">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line6.png</property>
+    <property name="icon_name">svx/res/symphony/line6.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_7">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line7.png</property>
+    <property name="icon_name">svx/res/symphony/line7.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_8">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line8.png</property>
+    <property name="icon_name">svx/res/symphony/line8.png</property>
   </object>
   <object class="GtkImage" id="image_spacing_9">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="pixbuf">svx/res/symphony/line9.png</property>
+    <property name="icon_name">svx/res/symphony/line9.png</property>
   </object>
 </interface>


More information about the Libreoffice-commits mailing list