[Libreoffice-commits] core.git: dbaccess/source dbaccess/uiconfig dbaccess/UIConfig_dbaccess.mk solenv/sanitizers

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 16 14:58:19 UTC 2021


 dbaccess/UIConfig_dbaccess.mk                       |    1 
 dbaccess/source/ui/inc/TableWindow.hxx              |    1 
 dbaccess/source/ui/inc/TableWindowTitle.hxx         |   18 --
 dbaccess/source/ui/querydesign/TableWindow.cxx      |   31 ++---
 dbaccess/source/ui/querydesign/TableWindowTitle.cxx |  122 ++------------------
 dbaccess/uiconfig/ui/tabletitle.ui                  |   39 ++++++
 solenv/sanitizers/ui/dbaccess.suppr                 |    1 
 7 files changed, 80 insertions(+), 133 deletions(-)

New commits:
commit 807317255a655372e3b602a80cec2989776804c5
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Feb 16 09:42:07 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Feb 16 15:57:32 2021 +0100

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

diff --git a/dbaccess/UIConfig_dbaccess.mk b/dbaccess/UIConfig_dbaccess.mk
index 1e655af2ec2a..c0e6a28f895f 100644
--- a/dbaccess/UIConfig_dbaccess.mk
+++ b/dbaccess/UIConfig_dbaccess.mk
@@ -81,6 +81,7 @@ $(eval $(call gb_UIConfig_add_uifiles,dbaccess, \
     dbaccess/uiconfig/ui/tablesfilterdialog \
     dbaccess/uiconfig/ui/tablesfilterpage \
     dbaccess/uiconfig/ui/tablesjoindialog \
+    dbaccess/uiconfig/ui/tabletitle \
     dbaccess/uiconfig/ui/taskwindow \
     dbaccess/uiconfig/ui/textconnectionsettings \
     dbaccess/uiconfig/ui/textpage \
diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx
index 9e616e9fc135..cb8a210f527a 100644
--- a/dbaccess/source/ui/inc/TableWindow.hxx
+++ b/dbaccess/source/ui/inc/TableWindow.hxx
@@ -25,6 +25,7 @@
 #include "TableWindowData.hxx"
 #include "TableWindowListBox.hxx"
 #include <vector>
+#include <vcl/fixed.hxx>
 #include <vcl/window.hxx>
 
 #include <comphelper/containermultiplexer.hxx>
diff --git a/dbaccess/source/ui/inc/TableWindowTitle.hxx b/dbaccess/source/ui/inc/TableWindowTitle.hxx
index d60f7389a4f8..04e612de58ad 100644
--- a/dbaccess/source/ui/inc/TableWindowTitle.hxx
+++ b/dbaccess/source/ui/inc/TableWindowTitle.hxx
@@ -18,30 +18,24 @@
  */
 #pragma once
 
-#include <vcl/fixed.hxx>
+#include <vcl/InterimItemWindow.hxx>
 
 namespace dbaui
 {
     class OTableWindow;
-    class OTableWindowTitle : public FixedText
+    class OTableWindowTitle final : public InterimItemWindow
     {
         VclPtr<OTableWindow> m_pTabWin;
+        std::unique_ptr<weld::Label> m_xLabel;
 
-    protected:
-        virtual void Command(const CommandEvent& rEvt) override;
-        virtual void MouseButtonDown( const MouseEvent& rEvt ) override;
-        virtual void KeyInput( const KeyEvent& rEvt ) override;
-        virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
+        DECL_LINK(MousePressHdl, const MouseEvent&, bool);
 
     public:
         OTableWindowTitle( OTableWindow* pParent );
         virtual ~OTableWindowTitle() override;
         virtual void dispose() override;
-        virtual void LoseFocus() override;
-        virtual void GetFocus() override;
-        virtual void RequestHelp( const HelpEvent& rHEvt ) override;
-        // window override
-        virtual void StateChanged( StateChangedType nStateChange ) override;
+
+        weld::Label& GetLabel() { return *m_xLabel; }
     };
 }
 
diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx
index 200c39ebe006..db0119ce89da 100644
--- a/dbaccess/source/ui/querydesign/TableWindow.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindow.cxx
@@ -87,16 +87,15 @@ void Draw3DBorder(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR
 }
 
 OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_type& pTabWinData )
-          : ::comphelper::OContainerListener(m_aMutex)
-          ,Window( pParent, WB_3DLOOK|WB_MOVEABLE )
-          ,m_aTypeImage( VclPtr<FixedImage>::Create(this) )
-          ,m_xTitle( VclPtr<OTableWindowTitle>::Create(this) )
-          ,m_pData( pTabWinData )
-          ,m_nMoveCount(0)
-          ,m_nMoveIncrement(1)
-          ,m_nSizingFlags( SizingFlags::NONE )
+    : ::comphelper::OContainerListener(m_aMutex)
+    , Window( pParent, WB_3DLOOK|WB_MOVEABLE )
+    , m_aTypeImage( VclPtr<FixedImage>::Create(this) )
+    , m_xTitle( VclPtr<OTableWindowTitle>::Create(this) )
+    , m_pData( pTabWinData )
+    , m_nMoveCount(0)
+    , m_nMoveIncrement(1)
+    , m_nSizingFlags( SizingFlags::NONE )
 {
-
     // Set position and size
     if( GetData()->HasPosition() )
         SetPosPixel( GetData()->GetPosition() );
@@ -294,7 +293,9 @@ bool OTableWindow::Init()
     }
 
     // Set the title
-    m_xTitle->SetText( m_pData->GetWinName() );
+    weld::Label& rLabel = m_xTitle->GetLabel();
+    rLabel.set_label(m_pData->GetWinName());
+    rLabel.set_tooltip_text(GetComposedName());
     m_xTitle->Show();
 
     m_xListBox->Show();
@@ -459,10 +460,10 @@ void OTableWindow::Resize()
 
 void OTableWindow::SetBoldTitle( bool bBold )
 {
-    vcl::Font aFont = m_xTitle->GetFont();
-    aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL );
-    m_xTitle->SetFont( aFont );
-    m_xTitle->Invalidate();
+    weld::Label& rLabel = m_xTitle->GetLabel();
+    vcl::Font aFont = rLabel.get_font();
+    aFont.SetWeight(bBold ? WEIGHT_BOLD : WEIGHT_NORMAL);
+    rLabel.set_font(aFont);
 }
 
 void OTableWindow::GetFocus()
@@ -710,7 +711,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt)
 
 OUString OTableWindow::getTitle() const
 {
-    return m_xTitle->GetText();
+    return m_xTitle->GetLabel().get_label();
 }
 
 void OTableWindow::_elementInserted( const container::ContainerEvent& /*_rEvent*/ )
diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
index 5157db77eda4..a2a569fc8679 100644
--- a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
@@ -31,18 +31,12 @@
 using namespace dbaui;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::uno;
-OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) :
-     FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER )
-    ,m_pTabWin( pParent )
+OTableWindowTitle::OTableWindowTitle(OTableWindow* pParent)
+    : InterimItemWindow(pParent, "dbaccess/ui/tabletitle.ui", "TableTitle")
+    , m_pTabWin( pParent )
+    , m_xLabel(m_xBuilder->weld_label("label"))
 {
-    // set background- and text colour
-    StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
-    SetBackground(Wallpaper(aSystemStyle.GetFaceColor()));
-    SetTextColor(aSystemStyle.GetButtonTextColor());
-
-    vcl::Font aFont( GetFont() );
-    aFont.SetTransparent( true );
-    SetFont( aFont );
+    m_xLabel->connect_mouse_press(LINK(this, OTableWindowTitle, MousePressHdl));
 }
 
 OTableWindowTitle::~OTableWindowTitle()
@@ -52,75 +46,14 @@ OTableWindowTitle::~OTableWindowTitle()
 
 void OTableWindowTitle::dispose()
 {
+    m_xLabel.reset();
     m_pTabWin.clear();
-    FixedText::dispose();
-}
-
-void OTableWindowTitle::GetFocus()
-{
-    if(m_pTabWin)
-        m_pTabWin->GetFocus();
-    else
-        FixedText::GetFocus();
-}
-
-void OTableWindowTitle::LoseFocus()
-{
-    if (m_pTabWin)
-        m_pTabWin->LoseFocus();
-    else
-        FixedText::LoseFocus();
-}
-
-void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt )
-{
-    if(!m_pTabWin)
-        return;
-
-    OUString aHelpText = m_pTabWin->GetComposedName();
-    if( aHelpText.isEmpty())
-        return;
-
-    // show help
-    tools::Rectangle aItemRect(Point(0,0),GetSizePixel());
-    aItemRect = LogicToPixel( aItemRect );
-    Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
-    aItemRect.SetLeft( aPt.X() );
-    aItemRect.SetTop( aPt.Y() );
-    aPt = OutputToScreenPixel( aItemRect.BottomRight() );
-    aItemRect.SetRight( aPt.X() );
-    aItemRect.SetBottom( aPt.Y() );
-    if( rHEvt.GetMode() == HelpEventMode::BALLOON )
-        Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
-    else
-        Help::ShowQuickHelp( this, aItemRect, aHelpText );
-}
-
-void OTableWindowTitle::Command( const CommandEvent& rEvt )
-{
-    if ( rEvt.GetCommand() == CommandEventId::ContextMenu )
-    {
-        GrabFocus();
-        if ( m_pTabWin )
-        {
-            // tdf#94709 - protect shutdown code-path.
-            VclPtr<OTableWindow> xTabWin(m_pTabWin);
-            xTabWin->Command( rEvt );
-        }
-        else
-            Control::Command(rEvt);
-    }
+    InterimItemWindow::dispose();
 }
 
-void OTableWindowTitle::KeyInput( const KeyEvent& rEvt )
+IMPL_LINK(OTableWindowTitle, MousePressHdl, const MouseEvent&, rEvt, bool)
 {
-    if ( m_pTabWin )
-        m_pTabWin->KeyInput( rEvt );
-}
-
-void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
-{
-    if( rEvt.IsLeft() )
+    if (rEvt.IsLeft())
     {
         if( rEvt.GetClicks() == 2)
         {
@@ -129,7 +62,7 @@ void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
 
             weld::TreeView& rTreeView = m_pTabWin->GetListBox()->get_widget();
             aSize.AdjustHeight(rTreeView.get_height_rows(rTreeView.n_children() + 2));
-            if(m_pTabWin->GetSizePixel() != aSize)
+            if (m_pTabWin->GetSizePixel() != aSize)
             {
                 m_pTabWin->SetSizePixel(aSize);
 
@@ -151,38 +84,15 @@ void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
             OSL_ENSURE(pView,"No OJoinTableView!");
             pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos );
         }
-        GrabFocus();
     }
-    else
-        Control::MouseButtonDown( rEvt );
-}
-
-void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt)
-{
-    if (rDCEvt.GetType() == DataChangedEventType::SETTINGS)
+    else if (rEvt.IsRight())
     {
-        // assume worst-case: colours have changed, therefore I have to adept
-        StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
-        SetBackground(Wallpaper(aSystemStyle.GetFaceColor()));
-        SetTextColor(aSystemStyle.GetButtonTextColor());
-    }
-}
-
-void OTableWindowTitle::StateChanged( StateChangedType nType )
-{
-    Window::StateChanged( nType );
-
-    if ( nType == StateChangedType::Zoom )
-    {
-        const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
-        vcl::Font aFont = rStyleSettings.GetGroupFont();
-        if ( IsControlFont() )
-            aFont.Merge( GetControlFont() );
-        SetZoomedPointFont(*this, aFont);
-
-        Resize();
+        CommandEvent aCEvt(rEvt.GetPosPixel(), CommandEventId::ContextMenu, true);
+        // tdf#94709 - protect shutdown code-path.
+        VclPtr<OTableWindow> xTabWin(m_pTabWin);
+        xTabWin->Command(aCEvt);
     }
+    return false;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/uiconfig/ui/tabletitle.ui b/dbaccess/uiconfig/ui/tabletitle.ui
new file mode 100644
index 000000000000..3e1275e36950
--- /dev/null
+++ b/dbaccess/uiconfig/ui/tabletitle.ui
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface domain="dba">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkBox" id="TableTitle">
+    <property name="visible">True</property>
+    <property name="can-focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkImage" id="image">
+        <property name="can-focus">False</property>
+        <property name="no-show-all">True</property>
+        <property name="icon-name">missing-image</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+        <property name="hexpand">True</property>
+        <property name="label">label</property>
+        <property name="xalign">0</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/solenv/sanitizers/ui/dbaccess.suppr b/solenv/sanitizers/ui/dbaccess.suppr
index 42fc1d16202b..6fa645fe9915 100644
--- a/solenv/sanitizers/ui/dbaccess.suppr
+++ b/solenv/sanitizers/ui/dbaccess.suppr
@@ -71,6 +71,7 @@ dbaccess/uiconfig/ui/sortdialog.ui://GtkComboBoxText[@id='value3'] no-labelled-b
 dbaccess/uiconfig/ui/tablesfilterpage.ui://GtkLabel[@id='label2'] orphan-label
 dbaccess/uiconfig/ui/tablesjoindialog.ui://GtkLabel[@id='title'] orphan-label
 dbaccess/uiconfig/ui/tablesjoindialog.ui://GtkLabel[@id='alttitle'] orphan-label
+dbaccess/uiconfig/ui/tabletitle.ui://GtkImage[@id='image'] no-labelled-by
 dbaccess/uiconfig/ui/taskwindow.ui://GtkTreeView[@id='treeview'] no-labelled-by
 dbaccess/uiconfig/ui/textpage.ui://GtkEntry[@id='extension'] no-labelled-by
 dbaccess/uiconfig/ui/textpage.ui://GtkLabel[@id='example'] orphan-label


More information about the Libreoffice-commits mailing list