vcl/inc/qt5/QtDoubleSpinBox.hxx | 9 -- vcl/inc/qt5/QtInstanceSpinButton.hxx | 33 ---------- vcl/inc/qt5/QtInstanceWidget.hxx | 2 vcl/qt5/QtDoubleSpinBox.cxx | 18 ----- vcl/qt5/QtInstanceBuilder.cxx | 1 vcl/qt5/QtInstanceSpinButton.cxx | 107 ----------------------------------- 6 files changed, 10 insertions(+), 160 deletions(-)
New commits: commit d765cdc515d3808898bf8bb5d78335fdee2d698b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Nov 27 23:53:58 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Nov 28 08:38:17 2024 +0100 tdf#130857 qt weld: Support "Go to Page" dialog Declare support for the "Edit" -> "Go to Page" dialog available in e.g. Writer. This means that native Qt widgets are used for that dialog now when using the qt5 or qt6 VCL plugin and starting LO with environment variable SAL_VCL_QT_USE_WELDED_WIDGETS=1 set. One issue seen with the dialog is that by using the up arrow of the spinbox to increase the value, it is currently possible to increase the value beyond the maximum value (last page number), while this is not the case when typing a number into the box manually. This is because the GotoPageDlg::PageModifiedHdl handler currently only gets called for the latter case, not the former one, despite Change-Id: Ie19bc852f4ceed0fa79565302975376db7126ea4 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Wed Nov 27 22:53:55 2024 +0100 tdf#130857 qt weld: Also notify about programmatic text changes and will be addressed in a separate commit. Change-Id: I1f24cf3925e945ae78a9f1646535e08736cd8786 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177450 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index 01aea046dc64..d3239f5cb56b 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -73,6 +73,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile) u"sfx/ui/safemodequerydialog.ui"_ustr, u"svt/ui/printersetupdialog.ui"_ustr, u"svt/ui/restartdialog.ui"_ustr, + u"svx/ui/gotopagedialog.ui"_ustr, u"svx/ui/safemodedialog.ui"_ustr, u"vcl/ui/openlockedquerybox.ui"_ustr, u"vcl/ui/printprogressdialog.ui"_ustr, commit 12fb40fd7bc771813b825806cb4151833d7cd789 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Nov 27 23:40:16 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Nov 28 08:38:10 2024 +0100 tdf#130857 qt weld: Let SpinButton derive from Entry As weld::SpinButton derives from weld::Entry, also let QtInstanceSpinButton derive from QtInstanceEntry, instead of duplicating code by reimplementing all of the weld::Entry methods anew. As the QtDoubleSpinBox derived from QDoubleSpinBox itself is not a subclass of QLineEdit, it cannot itself be passed down as the widget to the QtInstanceEntry ctor. Pass the spin box's QLineEdit instead. Make it available by adding a new QtDoubleSpinBox::lineEdit method which overrides the base class method of the same name that is protected. With this in place, QtInstanceSpinButton is now the only QtInstanceWidget subclass where the widget passed down to QtInstanceWidget is not the same as passed by QtInstanceBuilder in the QtInstanceSpinButton ctor, i.e. QtInstanceWidget::getQWidget does not return the QtDoubleSpinBox, but it's line edit. Therefore, make QtInstanceWidget::getQWidget virtual and override it in QtInstanceSpinButton to return the spin box. Drop the QtInstanceSpinButton methods of all methods already implemented in QtInstanceEntry. Change-Id: Ide2e1fe91216a5ec7f90a4f72ae34e3f63f624d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177449 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtDoubleSpinBox.hxx b/vcl/inc/qt5/QtDoubleSpinBox.hxx index 2dd2af6a4f69..5c9cac5930d7 100644 --- a/vcl/inc/qt5/QtDoubleSpinBox.hxx +++ b/vcl/inc/qt5/QtDoubleSpinBox.hxx @@ -20,13 +20,8 @@ class QtDoubleSpinBox : public QDoubleSpinBox public: QtDoubleSpinBox(QWidget* pParent); - int cursorPosition() const; - void setCursorPosition(int nCursorPos); - - void setSelection(int nStart, int nLength); - bool hasSelectedText() const; - int selectionStart() const; - int selectionEnd() const; + // public override of the protected base class method + QLineEdit* lineEdit() const; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/qt5/QtInstanceSpinButton.hxx b/vcl/inc/qt5/QtInstanceSpinButton.hxx index 1f2fde540d95..1766455a364e 100644 --- a/vcl/inc/qt5/QtInstanceSpinButton.hxx +++ b/vcl/inc/qt5/QtInstanceSpinButton.hxx @@ -10,13 +10,11 @@ #pragma once #include "QtDoubleSpinBox.hxx" -#include "QtInstanceWidget.hxx" +#include "QtInstanceEntry.hxx" #include <QtWidgets/QSpinBox> -class QtInstanceSpinButton : public QObject, - public QtInstanceWidget, - public virtual weld::SpinButton +class QtInstanceSpinButton : public QtInstanceEntry, public virtual weld::SpinButton { Q_OBJECT @@ -25,32 +23,7 @@ class QtInstanceSpinButton : public QObject, public: QtInstanceSpinButton(QtDoubleSpinBox* pSpinBox); - virtual void set_text(const OUString& rText) override; - virtual OUString get_text() const override; - virtual void set_width_chars(int nChars) override; - virtual int get_width_chars() const override; - virtual void set_max_length(int nChars) override; - virtual void select_region(int nStartPos, int nEndPos) override; - virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) override; - virtual void replace_selection(const OUString& rText) override; - virtual void set_position(int nCursorPos) override; - virtual int get_position() const override; - virtual void set_editable(bool bEditable) override; - virtual bool get_editable() const override; - virtual void set_message_type(weld::EntryMessageType eType) override; - virtual void set_placeholder_text(const OUString& rText) override; - - virtual void set_overwrite_mode(bool bOn) override; - virtual bool get_overwrite_mode() const override; - - virtual void set_font(const vcl::Font& rFont) override; - virtual void set_font_color(const Color& rColor) override; - - virtual void cut_clipboard() override; - virtual void copy_clipboard() override; - virtual void paste_clipboard() override; - - virtual void set_alignment(TxtAlign eXAlign) override; + virtual QWidget* getQWidget() const override; virtual void set_value(sal_Int64 nValue) override; virtual sal_Int64 get_value() const override; diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx index 2b9f33198b86..b63376208200 100644 --- a/vcl/inc/qt5/QtInstanceWidget.hxx +++ b/vcl/inc/qt5/QtInstanceWidget.hxx @@ -26,7 +26,7 @@ class QtInstanceWidget : public virtual weld::Widget public: QtInstanceWidget(QWidget* pWidget); - QWidget* getQWidget() const { return m_pWidget; } + virtual QWidget* getQWidget() const { return m_pWidget; } virtual void set_sensitive(bool bSensitive) override; diff --git a/vcl/qt5/QtDoubleSpinBox.cxx b/vcl/qt5/QtDoubleSpinBox.cxx index d7768e62d8f6..730b29919ee3 100644 --- a/vcl/qt5/QtDoubleSpinBox.cxx +++ b/vcl/qt5/QtDoubleSpinBox.cxx @@ -15,22 +15,6 @@ QtDoubleSpinBox::QtDoubleSpinBox(QWidget* pParent) { } -int QtDoubleSpinBox::cursorPosition() const { return lineEdit()->cursorPosition(); } - -void QtDoubleSpinBox::setCursorPosition(int nCursorPos) -{ - lineEdit()->setCursorPosition(nCursorPos); -} - -void QtDoubleSpinBox::setSelection(int nStart, int nLength) -{ - lineEdit()->setSelection(nStart, nLength); -} - -bool QtDoubleSpinBox::hasSelectedText() const { return lineEdit()->hasSelectedText(); } - -int QtDoubleSpinBox::selectionStart() const { return lineEdit()->selectionStart(); } - -int QtDoubleSpinBox::selectionEnd() const { return lineEdit()->selectionEnd(); } +QLineEdit* QtDoubleSpinBox::lineEdit() const { return QDoubleSpinBox::lineEdit(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtInstanceSpinButton.cxx b/vcl/qt5/QtInstanceSpinButton.cxx index e720caca9099..19c9754bccd0 100644 --- a/vcl/qt5/QtInstanceSpinButton.cxx +++ b/vcl/qt5/QtInstanceSpinButton.cxx @@ -13,7 +13,7 @@ #include <vcl/qt/QtUtils.hxx> QtInstanceSpinButton::QtInstanceSpinButton(QtDoubleSpinBox* pSpinBox) - : QtInstanceWidget(pSpinBox) + : QtInstanceEntry(pSpinBox->lineEdit()) , m_pSpinBox(pSpinBox) { assert(pSpinBox); @@ -22,110 +22,7 @@ QtInstanceSpinButton::QtInstanceSpinButton(QtDoubleSpinBox* pSpinBox) &QtInstanceSpinButton::handleValueChanged); } -void QtInstanceSpinButton::set_text(const OUString&) { assert(false && "Not implemented yet"); } - -OUString QtInstanceSpinButton::get_text() const -{ - SolarMutexGuard g; - OUString sText; - GetQtInstance().RunInMainThread([&] { sText = toOUString(m_pSpinBox->text()); }); - return sText; -} - -void QtInstanceSpinButton::set_width_chars(int) { assert(false && "Not implemented yet"); } - -int QtInstanceSpinButton::get_width_chars() const -{ - assert(false && "Not implemented yet"); - return -1; -} - -void QtInstanceSpinButton::set_max_length(int) { assert(false && "Not implemented yet"); } - -void QtInstanceSpinButton::select_region(int nStartPos, int nEndPos) -{ - GetQtInstance().RunInMainThread([&] { - if (nEndPos == -1) - nEndPos = m_pSpinBox->text().length(); - - const int nLength = nEndPos - nStartPos; - m_pSpinBox->setSelection(nStartPos, nLength); - }); -} - -bool QtInstanceSpinButton::get_selection_bounds(int& rStartPos, int& rEndPos) -{ - SolarMutexGuard g; - - bool bHasSelection = false; - GetQtInstance().RunInMainThread([&] { - bHasSelection = m_pSpinBox->hasSelectedText(); - rStartPos = m_pSpinBox->selectionStart(); - rEndPos = m_pSpinBox->selectionEnd(); - }); - - return bHasSelection; -} - -void QtInstanceSpinButton::replace_selection(const OUString&) -{ - assert(false && "Not implemented yet"); -} - -void QtInstanceSpinButton::set_position(int nCursorPos) -{ - SolarMutexGuard g; - if (nCursorPos == -1) - nCursorPos = m_pSpinBox->text().length(); - - GetQtInstance().RunInMainThread([&] { m_pSpinBox->setCursorPosition(nCursorPos); }); -} - -int QtInstanceSpinButton::get_position() const -{ - SolarMutexGuard g; - int nCursorPos = 0; - GetQtInstance().RunInMainThread([&] { nCursorPos = m_pSpinBox->cursorPosition(); }); - return nCursorPos; -} - -void QtInstanceSpinButton::set_editable(bool) { assert(false && "Not implemented yet"); } - -bool QtInstanceSpinButton::get_editable() const -{ - assert(false && "Not implemented yet"); - return false; -} - -void QtInstanceSpinButton::set_message_type(weld::EntryMessageType) -{ - assert(false && "Not implemented yet"); -} - -void QtInstanceSpinButton::set_placeholder_text(const OUString&) -{ - assert(false && "Not implemented yet"); -} - -void QtInstanceSpinButton::set_overwrite_mode(bool) { assert(false && "Not implemented yet"); } - -bool QtInstanceSpinButton::get_overwrite_mode() const -{ - assert(false && "Not implemented yet"); - return false; -} - -void QtInstanceSpinButton::set_font(const vcl::Font&) { assert(false && "Not implemented yet"); } - -void QtInstanceSpinButton::set_font_color(const Color&) { assert(false && "Not implemented yet"); } - -void QtInstanceSpinButton::cut_clipboard() { assert(false && "Not implemented yet"); } - -void QtInstanceSpinButton::copy_clipboard() { assert(false && "Not implemented yet"); } - -void QtInstanceSpinButton::paste_clipboard() { assert(false && "Not implemented yet"); } - -void QtInstanceSpinButton::set_alignment(TxtAlign) { assert(false && "Not implemented yet"); } +QWidget* QtInstanceSpinButton::getQWidget() const { return m_pSpinBox; } void QtInstanceSpinButton::set_value(sal_Int64 nValue) {