[Libreoffice-commits] core.git: dbaccess/inc dbaccess/source include/svx svx/source svx/uiconfig
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 19 15:11:26 UTC 2021
dbaccess/inc/helpids.h | 2 -
dbaccess/source/ui/browser/sbagrid.cxx | 44 +++++++++++++--------------------
dbaccess/source/ui/inc/sbagrid.hxx | 4 +--
include/svx/fmgridcl.hxx | 2 +
include/svx/gridctrl.hxx | 6 ++--
svx/source/fmcomp/gridctrl.cxx | 32 ++++++++++++------------
svx/source/stbctrls/pszctrl.cxx | 1
svx/uiconfig/ui/functionmenu.ui | 29 +++++++++++++--------
svx/uiconfig/ui/rowsmenu.ui | 13 ++++++---
9 files changed, 68 insertions(+), 65 deletions(-)
New commits:
commit 91dffd7424a4522440a84fca2262a1701aaf4e8b
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 19 12:51:39 2021 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 19 16:10:44 2021 +0100
weld rows menu
Change-Id: I0dd56e2c236b15b057ddd0f2d93019b783d457d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111218
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/dbaccess/inc/helpids.h b/dbaccess/inc/helpids.h
index 1af25532e2c1..459cc26bef6d 100644
--- a/dbaccess/inc/helpids.h
+++ b/dbaccess/inc/helpids.h
@@ -29,8 +29,6 @@
#define HID_BROWSER_COLUMNFORMAT "DBACCESS_HID_BROWSER_COLUMNFORMAT"
#define HID_BROWSER_COLUMNWIDTH "DBACCESS_HID_BROWSER_COLUMNWIDTH"
-#define HID_BROWSER_TABLEFORMAT "DBACCESS_HID_BROWSER_TABLEFORMAT"
-#define HID_BROWSER_ROWHEIGHT "DBACCESS_HID_BROWSER_ROWHEIGHT"
#define HID_CTL_QRYSQLEDIT "DBACCESS_HID_CTL_QRYSQLEDIT"
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index a78921935f6c..093f243ca738 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -666,7 +666,7 @@ CellController* SbaGridControl::GetController(sal_Int32 nRow, sal_uInt16 nCol)
return FmGridControl::GetController(nRow, nCol);
}
-void SbaGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
+void SbaGridControl::PreExecuteRowContextMenu(weld::Menu& rMenu)
{
FmGridControl::PreExecuteRowContextMenu(rMenu);
@@ -674,18 +674,18 @@ void SbaGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
if (!IsReadOnlyDB())
{
- rMenu.InsertItem(ID_BROWSER_TABLEATTR, DBA_RES(RID_STR_TABLE_FORMAT), MenuItemBits::NONE, OString(), nPos++);
- rMenu.SetHelpId(ID_BROWSER_TABLEATTR, HID_BROWSER_TABLEFORMAT);
-
- rMenu.InsertItem(ID_BROWSER_ROWHEIGHT, DBA_RES(RID_STR_ROW_HEIGHT), MenuItemBits::NONE, OString(), nPos++);
- rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, HID_BROWSER_ROWHEIGHT);
- rMenu.InsertSeparator(OString(), nPos++);
+ rMenu.insert(nPos++, "tableattr", DBA_RES(RID_STR_TABLE_FORMAT),
+ nullptr, nullptr, nullptr, TRISTATE_INDET);
+ rMenu.insert(nPos++, "rowheight", DBA_RES(RID_STR_ROW_HEIGHT),
+ nullptr, nullptr, nullptr, TRISTATE_INDET);
+ rMenu.insert_separator(nPos++, "separator1");
}
if ( GetSelectRowCount() > 0 )
{
- rMenu.InsertItem(ID_BROWSER_COPY, DBA_RES(RID_STR_COPY), MenuItemBits::NONE, OString(), nPos++);
- rMenu.InsertSeparator(OString(), nPos++);
+ rMenu.insert(nPos++, "copy", DBA_RES(RID_STR_COPY),
+ nullptr, nullptr, nullptr, TRISTATE_INDET);
+ rMenu.insert_separator(nPos++, "separator2");
}
}
@@ -821,24 +821,16 @@ void SbaGridControl::SetBrowserAttrs()
}
}
-void SbaGridControl::PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
+void SbaGridControl::PostExecuteRowContextMenu(const OString& rExecutionResult)
{
- switch (nExecutionResult)
- {
- case ID_BROWSER_TABLEATTR:
- SetBrowserAttrs();
- break;
- case ID_BROWSER_ROWHEIGHT:
- SetRowHeight();
- break;
- case ID_BROWSER_COPY:
- CopySelectedRowsToClipboard();
- break;
-
- default:
- FmGridControl::PostExecuteRowContextMenu(rMenu, nExecutionResult);
- break;
- }
+ if (rExecutionResult == "tableattr")
+ SetBrowserAttrs();
+ else if (rExecutionResult == "rowheight")
+ SetRowHeight();
+ else if (rExecutionResult == "copy")
+ CopySelectedRowsToClipboard();
+ else
+ FmGridControl::PostExecuteRowContextMenu(rExecutionResult);
}
void SbaGridControl::Select()
diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx
index 76759de963d7..2bef1cfbbcd2 100644
--- a/dbaccess/source/ui/inc/sbagrid.hxx
+++ b/dbaccess/source/ui/inc/sbagrid.hxx
@@ -252,8 +252,8 @@ namespace dbaui
virtual ::svt::CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol) override;
// DbGridControl overridables
- virtual void PreExecuteRowContextMenu(PopupMenu& rMenu) override;
- virtual void PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult) override;
+ virtual void PreExecuteRowContextMenu(weld::Menu& rMenu) override;
+ virtual void PostExecuteRowContextMenu(const OString& rExecutionResult) override;
// DbGridControl overridables
virtual void onRowChange() override;
diff --git a/include/svx/fmgridcl.hxx b/include/svx/fmgridcl.hxx
index c9007b397ccb..9b97b4282e7c 100644
--- a/include/svx/fmgridcl.hxx
+++ b/include/svx/fmgridcl.hxx
@@ -28,6 +28,8 @@ namespace com::sun::star::beans { class XPropertySet; }
namespace com::sun::star::container { class XIndexContainer; }
namespace com::sun::star::container { class XNameAccess; }
+class PopupMenu;
+
// FmGridHeader
struct FmGridHeaderData;
diff --git a/include/svx/gridctrl.hxx b/include/svx/gridctrl.hxx
index 5b13b328ae12..f23d4455734c 100644
--- a/include/svx/gridctrl.hxx
+++ b/include/svx/gridctrl.hxx
@@ -37,9 +37,9 @@ namespace com::sun::star::sdbc { class XRowSet; }
namespace com::sun::star::sdb { class XRowsChangeListener; }
namespace com::sun::star::uno { class XComponentContext; }
namespace com::sun::star::util { class XNumberFormatter; }
+namespace weld { class Menu; }
class CursorWrapper;
-class PopupMenu;
bool CompareBookmark(const css::uno::Any& aLeft, const css::uno::Any& aRight);
@@ -345,10 +345,10 @@ protected:
All disabled entries will be removed before executing the menu, so be careful with separators
near entries you probably wish to disable ...
*/
- virtual void PreExecuteRowContextMenu(PopupMenu& rMenu);
+ virtual void PreExecuteRowContextMenu(weld::Menu& rMenu);
/** After executing the context menu for a row this method is called.
*/
- virtual void PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
+ virtual void PostExecuteRowContextMenu(const OString& rExecutionResult);
/// @throws css::uno::RuntimeException
void DataSourcePropertyChanged(const css::beans::PropertyChangeEvent& evt);
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index 3bdec10d7145..1d1108a1a88d 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -43,11 +43,11 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <tools/diagnose_ex.h>
#include <tools/debug.hxx>
-#include <vcl/builder.hxx>
-#include <vcl/menu.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/weldutils.hxx>
#include <svx/strings.hrc>
@@ -2408,14 +2408,14 @@ sal_uInt32 DbGridControl::GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId)
return 30; // FIXME magic number for default cell width
}
-void DbGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
+void DbGridControl::PreExecuteRowContextMenu(weld::Menu& rMenu)
{
bool bDelete = (m_nOptions & DbGridControlOptions::Delete) && GetSelectRowCount() && !IsCurrentAppending();
// if only a blank row is selected then do not delete
bDelete = bDelete && !((m_nOptions & DbGridControlOptions::Insert) && GetSelectRowCount() == 1 && IsRowSelected(GetRowCount() - 1));
- rMenu.EnableItem(rMenu.GetItemId("delete"), bDelete);
- rMenu.EnableItem(rMenu.GetItemId("save"), IsModified());
+ rMenu.set_visible("delete", bDelete);
+ rMenu.set_visible("save", IsModified());
// the undo is more difficult
bool bCanUndo = IsModified();
@@ -2424,21 +2424,21 @@ void DbGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
nState = m_aMasterStateProvider.Call(DbGridControlNavigationBarState::Undo);
bCanUndo &= ( 0 != nState );
- rMenu.EnableItem(rMenu.GetItemId("undo"), bCanUndo);
+ rMenu.set_visible("undo", bCanUndo);
}
-void DbGridControl::PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
+void DbGridControl::PostExecuteRowContextMenu(const OString& rExecutionResult)
{
- if (nExecutionResult == rMenu.GetItemId("delete"))
+ if (rExecutionResult == "delete")
{
// delete asynchronously
if (m_nDeleteEvent)
Application::RemoveUserEvent(m_nDeleteEvent);
m_nDeleteEvent = Application::PostUserEvent(LINK(this,DbGridControl,OnDelete), nullptr, true);
}
- else if (nExecutionResult == rMenu.GetItemId("undo"))
+ else if (rExecutionResult == "undo")
Undo();
- else if (nExecutionResult == rMenu.GetItemId("save"))
+ else if (rExecutionResult == "save")
SaveRow();
}
@@ -2531,12 +2531,14 @@ void DbGridControl::copyCellText(sal_Int32 _nRow, sal_uInt16 _nColId)
void DbGridControl::executeRowContextMenu(const Point& _rPreferredPos)
{
- VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "svx/ui/rowsmenu.ui", "");
- VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "svx/ui/rowsmenu.ui"));
+ std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu("menu"));
- PreExecuteRowContextMenu(*aContextMenu );
- aContextMenu->RemoveDisabledEntries( true, true );
- PostExecuteRowContextMenu(*aContextMenu, aContextMenu->Execute(this, _rPreferredPos));
+ tools::Rectangle aRect(_rPreferredPos, Size(1,1));
+ weld::Window* pParent = weld::GetPopupParent(*this, aRect);
+
+ PreExecuteRowContextMenu(*xContextMenu);
+ PostExecuteRowContextMenu(xContextMenu->popup_at_rect(pParent, aRect));
}
void DbGridControl::Command(const CommandEvent& rEvt)
diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx
index 2c2ef29b1574..e3539a5e7c5b 100644
--- a/svx/source/stbctrls/pszctrl.cxx
+++ b/svx/source/stbctrls/pszctrl.cxx
@@ -21,7 +21,6 @@
#include <vcl/event.hxx>
#include <vcl/fieldvalues.hxx>
#include <vcl/status.hxx>
-#include <vcl/menu.hxx>
#include <vcl/image.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
diff --git a/svx/uiconfig/ui/functionmenu.ui b/svx/uiconfig/ui/functionmenu.ui
index 6b71943aeb97..91ffdcfbff0c 100644
--- a/svx/uiconfig/ui/functionmenu.ui
+++ b/svx/uiconfig/ui/functionmenu.ui
@@ -1,65 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.38.2 -->
<interface domain="svx">
<requires lib="gtk+" version="3.20"/>
<object class="GtkMenu" id="menu">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<child>
<object class="GtkCheckMenuItem" id="avg">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|avg">Average</property>
- <property name="use_underline">True</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="counta">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|counta">CountA</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="count">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|count">Count</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="max">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|max">Maximum</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="min">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|min">Minimum</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="sum">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|sum">Sum</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="selection">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|selection">Selection count</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="none">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="functionmenu|none">None</property>
+ <property name="use-underline">True</property>
</object>
</child>
</object>
diff --git a/svx/uiconfig/ui/rowsmenu.ui b/svx/uiconfig/ui/rowsmenu.ui
index 2b016bc52824..4e3806de05a9 100644
--- a/svx/uiconfig/ui/rowsmenu.ui
+++ b/svx/uiconfig/ui/rowsmenu.ui
@@ -1,29 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.38.2 -->
<interface domain="svx">
<requires lib="gtk+" version="3.20"/>
<object class="GtkMenu" id="menu">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<child>
<object class="GtkMenuItem" id="delete">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="rowsmenu|delete">Delete Rows</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="save">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="rowsmenu|save">Save Record</property>
+ <property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="undo">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can-focus">False</property>
<property name="label" translatable="yes" context="rowsmenu|undo">Undo: Data entry</property>
+ <property name="use-underline">True</property>
</object>
</child>
</object>
More information about the Libreoffice-commits
mailing list