[Libreoffice-commits] core.git: dbaccess/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 21 21:02:35 UTC 2020


 dbaccess/source/ui/querydesign/TableWindow.cxx        |    2 -
 dbaccess/source/ui/tabledesign/TEditControl.cxx       |   36 +++++++++---------
 dbaccess/source/ui/tabledesign/TableDesignControl.cxx |   17 ++++----
 3 files changed, 28 insertions(+), 27 deletions(-)

New commits:
commit 8f92097111fcdbb5322dd87474c719b15c08308d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Dec 21 11:10:05 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Dec 21 22:01:47 2020 +0100

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

diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx
index 5334bfd76e2d..200c39ebe006 100644
--- a/dbaccess/source/ui/querydesign/TableWindow.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindow.cxx
@@ -41,8 +41,6 @@
 #include <bitmaps.hlst>
 #include <TableWindowAccess.hxx>
 #include <connectivity/dbtools.hxx>
-#include <vcl/builder.hxx>
-#include <vcl/menu.hxx>
 
 using namespace dbaui;
 using namespace ::utl;
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index fec166aa4cdb..55114d3a416a 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -41,9 +41,7 @@
 #include <UITools.hxx>
 #include "TableFieldControl.hxx"
 #include <dsntypes.hxx>
-#include <vcl/builder.hxx>
 #include <vcl/commandevent.hxx>
-#include <vcl/menu.hxx>
 #include <vcl/svapp.hxx>
 
 using namespace ::dbaui;
@@ -1399,19 +1397,24 @@ void OTableEditorCtrl::Command(const CommandEvent& rEvt)
                 }
                 else
                 {
-                    VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "dbaccess/ui/tabledesignrowmenu.ui", "");
-                    VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu"));
-
-                    aContextMenu->EnableItem(aContextMenu->GetItemId("cut"), IsCutAllowed());
-                    aContextMenu->EnableItem(aContextMenu->GetItemId("copy"), IsCopyAllowed());
-                    aContextMenu->EnableItem(aContextMenu->GetItemId("paste"), IsPasteAllowed());
-                    aContextMenu->EnableItem(aContextMenu->GetItemId("delete"), IsDeleteAllowed());
-                    aContextMenu->EnableItem(aContextMenu->GetItemId("primarykey"), IsPrimaryKeyAllowed());
-                    aContextMenu->EnableItem(aContextMenu->GetItemId("insert"), IsInsertNewAllowed(nRow));
-                    aContextMenu->CheckItem("primarykey", IsRowSelected(GetCurRow()) && IsPrimaryKey());
-
-                    // remove all the disable entries
-                    aContextMenu->RemoveDisabledEntries(true, true);
+                    ::tools::Rectangle aRect(aMenuPos, Size(1, 1));
+                    weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect);
+                    std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "dbaccess/ui/tabledesignrowmenu.ui"));
+                    std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu("menu"));
+
+                    if (!IsCutAllowed())
+                        xContextMenu->remove("cut");
+                    if (!IsCopyAllowed())
+                        xContextMenu->remove("copy");
+                    if (!IsPasteAllowed())
+                        xContextMenu->remove("paste");
+                    if (!IsDeleteAllowed())
+                        xContextMenu->remove("delete");
+                    if (!IsPrimaryKeyAllowed())
+                        xContextMenu->remove("primarykey");
+                    if (!IsInsertNewAllowed(nRow))
+                        xContextMenu->remove("insert");
+                    xContextMenu->set_active("primarykey", IsRowSelected(GetCurRow()) && IsPrimaryKey());
 
                     if( SetDataPtr(m_nDataPos) )
                         pDescrWin->SaveData( pActRow->GetActFieldDescr() );
@@ -1419,8 +1422,7 @@ void OTableEditorCtrl::Command(const CommandEvent& rEvt)
                     // All actions which change the number of rows must be run asynchronously
                     // otherwise there may be problems between the Context menu and the Browser
                     m_nDataPos = GetCurRow();
-                    aContextMenu->Execute(this, aMenuPos);
-                    OString sIdent = aContextMenu->GetCurItemIdent();
+                    OString sIdent = xContextMenu->popup_at_rect(pPopupParent, aRect);
                     if (sIdent == "cut")
                         cut();
                     else if (sIdent == "copy")
diff --git a/dbaccess/source/ui/tabledesign/TableDesignControl.cxx b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
index 40568ac9fca3..1526682eddd7 100644
--- a/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
@@ -22,9 +22,9 @@
 #include <TableController.hxx>
 #include <com/sun/star/util/URL.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
-#include <vcl/builder.hxx>
 #include <vcl/commandevent.hxx>
-#include <vcl/menu.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/weldutils.hxx>
 #include <helpids.h>
 
 using namespace ::dbaui;
@@ -109,13 +109,14 @@ void OTableRowView::Command(const CommandEvent& rEvt)
 
             if ( nColId == HANDLE_ID )
             {
-                VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "dbaccess/ui/tabledesignrowmenu.ui", "");
-                VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu"));
+                ::tools::Rectangle aRect(rEvt.GetMousePosPixel(), Size(1, 1));
+                weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect);
+                std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "dbaccess/ui/tabledesignrowmenu.ui"));
+                std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu("menu"));
                 sal_Int32 nSelectRowCount = GetSelectRowCount();
-                aContextMenu->EnableItem(aContextMenu->GetItemId("cut"), nSelectRowCount != 0);
-                aContextMenu->EnableItem(aContextMenu->GetItemId("copy"), nSelectRowCount  != 0);
-                aContextMenu->Execute(this, rEvt.GetMousePosPixel());
-                OString sIdent = aContextMenu->GetCurItemIdent();
+                xContextMenu->set_sensitive("cut", nSelectRowCount != 0);
+                xContextMenu->set_sensitive("copy", nSelectRowCount  != 0);
+                OString sIdent = xContextMenu->popup_at_rect(pPopupParent, aRect);
                 if (sIdent == "cut")
                     cut();
                 else if (sIdent == "copy")


More information about the Libreoffice-commits mailing list