diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-23 22:26:10 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-24 09:09:34 +0200 |
commit | 8c8a48eb06c692ded03e29c1ab493935e2a12228 (patch) | |
tree | d2b73bac477b9488b1d821bfe7a8d4e3443f60e0 /vcl | |
parent | c8ff967c4996318d25bcc0642b14cbc5e6d981bb (diff) |
tdf#130857 qt weld: Signal when current combobox item changes
Connect to the QComboBox::currentIndexChanged signal and
call `weld::ComboBox::signal_changed` to notify of that change.
This is in preparation for upcoming
Change-Id: I7806688102f690faa02fb5e712943d6ae216ff9a
Author: Michael Weghorn <m.weghorn@posteo.de>
tdf#130857 qt weld: Declare support for "Printer Settings" dialog
and causes the infos for the printer previously selected
in the combobox in the "File" -> "Printer Settings" dialog
to be shown after selecting a printer other than the initially
selected one in the combobox, then clicking the "Properties"
button in that dialog.
(Without this, properties of the initially selected printer would
always be shown.)
Change-Id: I9a8609e172fd1d6783a86395ff58e64b7cf5c4d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175521
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/CustomTarget_qt5_moc.mk | 1 | ||||
-rw-r--r-- | vcl/CustomTarget_qt6_moc.mk | 1 | ||||
-rw-r--r-- | vcl/inc/qt5/QtInstanceComboBox.hxx | 7 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceComboBox.cxx | 6 |
4 files changed, 14 insertions, 1 deletions
diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk index ec580d76358a..857b3eb41a65 100644 --- a/vcl/CustomTarget_qt5_moc.mk +++ b/vcl/CustomTarget_qt5_moc.mk @@ -14,6 +14,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \ $(gb_CustomTarget_workdir)/vcl/qt5/QtFilePicker.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtFrame.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstance.moc \ + $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceComboBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDialog.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceMessageDialog.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtMainWindow.moc \ diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk index 28fb0100f40e..a58f79a2bbf4 100644 --- a/vcl/CustomTarget_qt6_moc.mk +++ b/vcl/CustomTarget_qt6_moc.mk @@ -14,6 +14,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \ $(gb_CustomTarget_workdir)/vcl/qt6/QtFilePicker.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtFrame.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstance.moc \ + $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceComboBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDialog.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceMessageDialog.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtMainWindow.moc \ diff --git a/vcl/inc/qt5/QtInstanceComboBox.hxx b/vcl/inc/qt5/QtInstanceComboBox.hxx index 53d81bc9aadc..2c1ea133df23 100644 --- a/vcl/inc/qt5/QtInstanceComboBox.hxx +++ b/vcl/inc/qt5/QtInstanceComboBox.hxx @@ -13,8 +13,10 @@ #include <QtWidgets/QComboBox> -class QtInstanceComboBox : public QtInstanceWidget, public virtual weld::ComboBox +class QtInstanceComboBox : public QObject, public QtInstanceWidget, public virtual weld::ComboBox { + Q_OBJECT + QComboBox* m_pComboBox; bool m_bSorted; @@ -83,6 +85,9 @@ public: private: void sortItems(); + +private slots: + void handleCurrentIndexChanged(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtInstanceComboBox.cxx b/vcl/qt5/QtInstanceComboBox.cxx index e2284b33ef4a..296370ebf292 100644 --- a/vcl/qt5/QtInstanceComboBox.cxx +++ b/vcl/qt5/QtInstanceComboBox.cxx @@ -8,6 +8,7 @@ */ #include <QtInstanceComboBox.hxx> +#include <QtInstanceComboBox.moc> QtInstanceComboBox::QtInstanceComboBox(QComboBox* pComboBox) : QtInstanceWidget(pComboBox) @@ -15,6 +16,9 @@ QtInstanceComboBox::QtInstanceComboBox(QComboBox* pComboBox) , m_bSorted(false) { assert(pComboBox); + + QObject::connect(m_pComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &QtInstanceComboBox::handleCurrentIndexChanged); } void QtInstanceComboBox::insert(int nPos, const OUString& rStr, const OUString* pId, @@ -249,4 +253,6 @@ void QtInstanceComboBox::set_max_drop_down_rows(int) { assert(false && "Not impl void QtInstanceComboBox::sortItems() { m_pComboBox->model()->sort(0, Qt::AscendingOrder); } +void QtInstanceComboBox::handleCurrentIndexChanged() { signal_changed(); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |