tdf#130857 qt weld: Signal when tool button is clicked
Change-Id: I07c406d6257912a64eeaa781edf245ad16c87862
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Sat Apr 12 00:32:01 2025 +0200
tdf#130857 qt weld: Add initial tool button support
implemented support for "GtkToolButton" objects in .ui files
and inserts the created QToolButtons in the QToolBar parent
if there is one.
Build upon this and signal when one of the tool buttons
inside a toolbar is clicked by calling weld::Toolbar::signal_clicked.
Set the GtkBuilder ID as the QObject::objectName for
all created objects in QtBuilder::makeObject.
Connect to the QToolButton::clicked signal for all
tool buttons in the toolbar, and retrieve their ID
using the QObject::objectName to be able to notify what
is the ID of the clicked button.
In an experimental/WIP branch to support the spelling dialog
that contains more changes, this commit results in the
clipboard content to be pasted when clicking the corresponding
button in the spelling dialog toolbar, and clicking the special
characters button now results in the special character dialog
to open as expected, while nothing would happen previously.
Change-Id: I75b5136c85d4d2c44a312e55624c36a12e87dc7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184085
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -62,6 +62,9 @@ public:
|
||||
virtual sal_uInt16 get_modifier_state() const override;
|
||||
|
||||
virtual int get_drop_index(const Point& rPoint) const override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void toolButtonClicked(const QString& rId);
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
@@ -468,6 +468,9 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, std:
|
||||
pParentGridLayout->addLayout(pLayout, pParentGridLayout->rowCount(), 0);
|
||||
}
|
||||
|
||||
if (pObject)
|
||||
pObject->setObjectName(toQString(sID));
|
||||
|
||||
if (pWidget)
|
||||
m_aWidgets[sID] = pWidget;
|
||||
|
||||
|
||||
@@ -10,11 +10,23 @@
|
||||
#include <QtInstanceToolbar.hxx>
|
||||
#include <QtInstanceToolbar.moc>
|
||||
|
||||
#include <QtWidgets/QToolButton>
|
||||
|
||||
QtInstanceToolbar::QtInstanceToolbar(QToolBar* pToolBar)
|
||||
: QtInstanceWidget(pToolBar)
|
||||
, m_pToolBar(pToolBar)
|
||||
{
|
||||
assert(m_pToolBar);
|
||||
|
||||
const QList<QAction*> aActions = m_pToolBar->actions();
|
||||
for (QAction* pAction : aActions)
|
||||
{
|
||||
if (QToolButton* pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(pAction)))
|
||||
{
|
||||
connect(pButton, &QToolButton::clicked, pButton,
|
||||
[this, pButton] { toolButtonClicked(pButton->objectName()); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtInstanceToolbar::set_item_sensitive(const OUString&, bool)
|
||||
@@ -189,4 +201,11 @@ int QtInstanceToolbar::get_drop_index(const Point&) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
void QtInstanceToolbar::toolButtonClicked(const QString& rId)
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
signal_clicked(toOUString(rId));
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
Reference in New Issue
Block a user