vcl/inc/qt5/QtData.hxx | 7 - vcl/inc/qt5/QtTools.hxx | 3 vcl/qt5/QtData.cxx | 167 -------------------------------------- vcl/qt5/QtFrame.cxx | 2 vcl/qt5/QtInstanceDrawingArea.cxx | 3 vcl/qt5/QtTools.cxx | 150 +++++++++++++++++++++++++++++++++- 6 files changed, 153 insertions(+), 179 deletions(-)
New commits: commit a646d15496719957c2278ceb35102789f55f1b3d Author: Michael Weghorn <[email protected]> AuthorDate: Wed Feb 25 11:50:55 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Feb 27 08:20:14 2026 +0100 qt: Move cursor mapping logic from QtData to QtTools QtTools.hxx/.cxx already hosts a lot of other helper functions to map/convert between Qt and LO/vcl types. Move the logic to retrieve a QCursor for a vcl PointerStyle there as well, since this is nothing specific to QtData (or related to the purpose of its subclasses otherwise). Change-Id: I9431e853cb430c97944b0c124b356d719d15de66 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200333 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/qt5/QtData.hxx b/vcl/inc/qt5/QtData.hxx index de8062624b8b..44404b2b7c09 100644 --- a/vcl/inc/qt5/QtData.hxx +++ b/vcl/inc/qt5/QtData.hxx @@ -21,23 +21,16 @@ #include <unx/gendata.hxx> -#include <o3tl/enumarray.hxx> -#include <vcl/ptrstyle.hxx> -#include <memory> #include <vclpluginapi.h> class QCursor; class VCLPLUG_QT_PUBLIC QtData final : public GenericUnixSalData { - o3tl::enumarray<PointerStyle, std::unique_ptr<QCursor>> m_aCursors; - public: explicit QtData(); virtual ~QtData() override; - QCursor& getCursor(PointerStyle ePointerStyle); - static bool noNativeControls(); static bool noWeldedWidgets(); diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx index edf9f3428c65..064246a53645 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -37,6 +37,7 @@ #include <tools/gen.hxx> #include <vcl/bitmap/BitmapTypes.hxx> #include <vcl/event.hxx> +#include <vcl/ptrstyle.hxx> #include <vcl/qt/QtUtils.hxx> #include <vcl/vclenum.hxx> @@ -174,6 +175,8 @@ QFont toQtFont(const vcl::Font& rVclFont); bool toVclFont(const QFont& rQFont, const css::lang::Locale& rLocale, vcl::Font& rVclFont); +const QCursor& toQCursor(PointerStyle ePointerStyle); + QMessageBox::Icon vclMessageTypeToQtIcon(VclMessageType eType); QString vclMessageTypeToQtTitle(VclMessageType eType); diff --git a/vcl/qt5/QtData.cxx b/vcl/qt5/QtData.cxx index e0c0eb169472..3570dae95209 100644 --- a/vcl/qt5/QtData.cxx +++ b/vcl/qt5/QtData.cxx @@ -18,21 +18,10 @@ */ #include <QtData.hxx> -#include <QtTools.hxx> -#include <QtGui/QBitmap> -#include <QtGui/QCursor> #include <QtWidgets/QApplication> #include <QtWidgets/QStyle> -#include <i18nlangtag/languagetag.hxx> -#include <sal/log.hxx> -#include <tools/stream.hxx> -#include <vcl/ImageTree.hxx> - -#include <bitmaps.hlst> -#include <cursor_hotspots.hxx> - QtData::QtData() : GenericUnixSalData() { @@ -54,149 +43,6 @@ QtData::QtData() // outline dtor b/c of FreetypeManager incomplete type QtData::~QtData() {} -static QCursor* getQCursorFromIconTheme(const OUString& rIconName, int nXHot, int nYHot) -{ - QPixmap aPixmap = loadQPixmapIcon(rIconName); - return new QCursor(aPixmap, nXHot, nYHot); -} - -#define MAKE_CURSOR(vcl_name, name, icon_name) \ - case vcl_name: \ - pCursor = getQCursorFromIconTheme(icon_name, name##curs_x_hot, name##curs_y_hot); \ - break - -#define MAP_BUILTIN(vcl_name, qt_enum) \ - case vcl_name: \ - pCursor = new QCursor(qt_enum); \ - break - -QCursor& QtData::getCursor(PointerStyle ePointerStyle) -{ - if (!m_aCursors[ePointerStyle]) - { - QCursor* pCursor = nullptr; - - switch (ePointerStyle) - { - MAP_BUILTIN(PointerStyle::Arrow, Qt::ArrowCursor); - MAP_BUILTIN(PointerStyle::Text, Qt::IBeamCursor); - MAP_BUILTIN(PointerStyle::Help, Qt::WhatsThisCursor); - MAP_BUILTIN(PointerStyle::Cross, Qt::CrossCursor); - MAP_BUILTIN(PointerStyle::Wait, Qt::WaitCursor); - MAP_BUILTIN(PointerStyle::NSize, Qt::SizeVerCursor); - MAP_BUILTIN(PointerStyle::SSize, Qt::SizeVerCursor); - MAP_BUILTIN(PointerStyle::WSize, Qt::SizeHorCursor); - MAP_BUILTIN(PointerStyle::ESize, Qt::SizeHorCursor); - - MAP_BUILTIN(PointerStyle::NWSize, Qt::SizeFDiagCursor); - MAP_BUILTIN(PointerStyle::NESize, Qt::SizeBDiagCursor); - MAP_BUILTIN(PointerStyle::SWSize, Qt::SizeBDiagCursor); - MAP_BUILTIN(PointerStyle::SESize, Qt::SizeFDiagCursor); - MAP_BUILTIN(PointerStyle::WindowNSize, Qt::SizeVerCursor); - MAP_BUILTIN(PointerStyle::WindowSSize, Qt::SizeVerCursor); - MAP_BUILTIN(PointerStyle::WindowWSize, Qt::SizeHorCursor); - MAP_BUILTIN(PointerStyle::WindowESize, Qt::SizeHorCursor); - MAP_BUILTIN(PointerStyle::WindowNWSize, Qt::SizeFDiagCursor); - MAP_BUILTIN(PointerStyle::WindowNESize, Qt::SizeBDiagCursor); - MAP_BUILTIN(PointerStyle::WindowSWSize, Qt::SizeBDiagCursor); - MAP_BUILTIN(PointerStyle::WindowSESize, Qt::SizeFDiagCursor); - - MAP_BUILTIN(PointerStyle::HSizeBar, Qt::SizeHorCursor); - MAP_BUILTIN(PointerStyle::VSizeBar, Qt::SizeVerCursor); - - MAP_BUILTIN(PointerStyle::RefHand, Qt::PointingHandCursor); - MAP_BUILTIN(PointerStyle::Hand, Qt::OpenHandCursor); -#if 0 - MAP_BUILTIN( PointerStyle::Pen, GDK_PENCIL ); -#endif - MAP_BUILTIN(PointerStyle::HSplit, Qt::SizeHorCursor); - MAP_BUILTIN(PointerStyle::VSplit, Qt::SizeVerCursor); - - MAP_BUILTIN(PointerStyle::Move, Qt::SizeAllCursor); - - MAP_BUILTIN(PointerStyle::Null, Qt::BlankCursor); - MAKE_CURSOR(PointerStyle::Magnify, magnify_, RID_CURSOR_MAGNIFY); - MAKE_CURSOR(PointerStyle::Fill, fill_, RID_CURSOR_FILL); - MAKE_CURSOR(PointerStyle::MoveData, movedata_, RID_CURSOR_MOVE_DATA); - MAKE_CURSOR(PointerStyle::CopyData, copydata_, RID_CURSOR_COPY_DATA); - MAKE_CURSOR(PointerStyle::MoveFile, movefile_, RID_CURSOR_MOVE_FILE); - MAKE_CURSOR(PointerStyle::CopyFile, copyfile_, RID_CURSOR_COPY_FILE); - MAKE_CURSOR(PointerStyle::MoveFiles, movefiles_, RID_CURSOR_MOVE_FILES); - MAKE_CURSOR(PointerStyle::CopyFiles, copyfiles_, RID_CURSOR_COPY_FILES); - MAKE_CURSOR(PointerStyle::NotAllowed, nodrop_, RID_CURSOR_NOT_ALLOWED); - MAKE_CURSOR(PointerStyle::Rotate, rotate_, RID_CURSOR_ROTATE); - MAKE_CURSOR(PointerStyle::HShear, hshear_, RID_CURSOR_H_SHEAR); - MAKE_CURSOR(PointerStyle::VShear, vshear_, RID_CURSOR_V_SHEAR); - MAKE_CURSOR(PointerStyle::DrawLine, drawline_, RID_CURSOR_DRAW_LINE); - MAKE_CURSOR(PointerStyle::DrawRect, drawrect_, RID_CURSOR_DRAW_RECT); - MAKE_CURSOR(PointerStyle::DrawPolygon, drawpolygon_, RID_CURSOR_DRAW_POLYGON); - MAKE_CURSOR(PointerStyle::DrawBezier, drawbezier_, RID_CURSOR_DRAW_BEZIER); - MAKE_CURSOR(PointerStyle::DrawArc, drawarc_, RID_CURSOR_DRAW_ARC); - MAKE_CURSOR(PointerStyle::DrawPie, drawpie_, RID_CURSOR_DRAW_PIE); - MAKE_CURSOR(PointerStyle::DrawCircleCut, drawcirclecut_, RID_CURSOR_DRAW_CIRCLE_CUT); - MAKE_CURSOR(PointerStyle::DrawEllipse, drawellipse_, RID_CURSOR_DRAW_ELLIPSE); - MAKE_CURSOR(PointerStyle::DrawConnect, drawconnect_, RID_CURSOR_DRAW_CONNECT); - MAKE_CURSOR(PointerStyle::DrawText, drawtext_, RID_CURSOR_DRAW_TEXT); - MAKE_CURSOR(PointerStyle::Mirror, mirror_, RID_CURSOR_MIRROR); - MAKE_CURSOR(PointerStyle::Crook, crook_, RID_CURSOR_CROOK); - MAKE_CURSOR(PointerStyle::Crop, crop_, RID_CURSOR_CROP); - MAKE_CURSOR(PointerStyle::MovePoint, movepoint_, RID_CURSOR_MOVE_POINT); - MAKE_CURSOR(PointerStyle::MoveBezierWeight, movebezierweight_, - RID_CURSOR_MOVE_BEZIER_WEIGHT); - MAKE_CURSOR(PointerStyle::DrawFreehand, drawfreehand_, RID_CURSOR_DRAW_FREEHAND); - MAKE_CURSOR(PointerStyle::DrawCaption, drawcaption_, RID_CURSOR_DRAW_CAPTION); - MAKE_CURSOR(PointerStyle::LinkData, linkdata_, RID_CURSOR_LINK_DATA); - MAKE_CURSOR(PointerStyle::MoveDataLink, movedlnk_, RID_CURSOR_MOVE_DATA_LINK); - MAKE_CURSOR(PointerStyle::CopyDataLink, copydlnk_, RID_CURSOR_COPY_DATA_LINK); - MAKE_CURSOR(PointerStyle::LinkFile, linkfile_, RID_CURSOR_LINK_FILE); - MAKE_CURSOR(PointerStyle::MoveFileLink, moveflnk_, RID_CURSOR_MOVE_FILE_LINK); - MAKE_CURSOR(PointerStyle::CopyFileLink, copyflnk_, RID_CURSOR_COPY_FILE_LINK); - MAKE_CURSOR(PointerStyle::Chart, chart_, RID_CURSOR_CHART); - MAKE_CURSOR(PointerStyle::Detective, detective_, RID_CURSOR_DETECTIVE); - MAKE_CURSOR(PointerStyle::PivotCol, pivotcol_, RID_CURSOR_PIVOT_COLUMN); - MAKE_CURSOR(PointerStyle::PivotRow, pivotrow_, RID_CURSOR_PIVOT_ROW); - MAKE_CURSOR(PointerStyle::PivotField, pivotfld_, RID_CURSOR_PIVOT_FIELD); - MAKE_CURSOR(PointerStyle::PivotDelete, pivotdel_, RID_CURSOR_PIVOT_DELETE); - MAKE_CURSOR(PointerStyle::Chain, chain_, RID_CURSOR_CHAIN); - MAKE_CURSOR(PointerStyle::ChainNotAllowed, chainnot_, RID_CURSOR_CHAIN_NOT_ALLOWED); - MAKE_CURSOR(PointerStyle::AutoScrollN, asn_, RID_CURSOR_AUTOSCROLL_N); - MAKE_CURSOR(PointerStyle::AutoScrollS, ass_, RID_CURSOR_AUTOSCROLL_S); - MAKE_CURSOR(PointerStyle::AutoScrollW, asw_, RID_CURSOR_AUTOSCROLL_W); - MAKE_CURSOR(PointerStyle::AutoScrollE, ase_, RID_CURSOR_AUTOSCROLL_E); - MAKE_CURSOR(PointerStyle::AutoScrollNW, asnw_, RID_CURSOR_AUTOSCROLL_NW); - MAKE_CURSOR(PointerStyle::AutoScrollNE, asne_, RID_CURSOR_AUTOSCROLL_NE); - MAKE_CURSOR(PointerStyle::AutoScrollSW, assw_, RID_CURSOR_AUTOSCROLL_SW); - MAKE_CURSOR(PointerStyle::AutoScrollSE, asse_, RID_CURSOR_AUTOSCROLL_SE); - MAKE_CURSOR(PointerStyle::AutoScrollNS, asns_, RID_CURSOR_AUTOSCROLL_NS); - MAKE_CURSOR(PointerStyle::AutoScrollWE, aswe_, RID_CURSOR_AUTOSCROLL_WE); - MAKE_CURSOR(PointerStyle::AutoScrollNSWE, asnswe_, RID_CURSOR_AUTOSCROLL_NSWE); - MAKE_CURSOR(PointerStyle::TextVertical, vertcurs_, RID_CURSOR_TEXT_VERTICAL); - - MAKE_CURSOR(PointerStyle::TabSelectS, tblsels_, RID_CURSOR_TAB_SELECT_S); - MAKE_CURSOR(PointerStyle::TabSelectE, tblsele_, RID_CURSOR_TAB_SELECT_E); - MAKE_CURSOR(PointerStyle::TabSelectSE, tblselse_, RID_CURSOR_TAB_SELECT_SE); - MAKE_CURSOR(PointerStyle::TabSelectW, tblselw_, RID_CURSOR_TAB_SELECT_W); - MAKE_CURSOR(PointerStyle::TabSelectSW, tblselsw_, RID_CURSOR_TAB_SELECT_SW); - - MAKE_CURSOR(PointerStyle::HideWhitespace, hidewhitespace_, RID_CURSOR_HIDE_WHITESPACE); - MAKE_CURSOR(PointerStyle::ShowWhitespace, showwhitespace_, RID_CURSOR_SHOW_WHITESPACE); - - MAKE_CURSOR(PointerStyle::FatCross, fatcross_, RID_CURSOR_FATCROSS); - default: - break; - } - if (!pCursor) - { - pCursor = new QCursor(Qt::ArrowCursor); - SAL_WARN("vcl.qt", "pointer " << static_cast<int>(ePointerStyle) << " not implemented"); - } - - m_aCursors[ePointerStyle].reset(pCursor); - } - - return *m_aCursors[ePointerStyle]; -} - bool QtData::noNativeControls() { static const bool bNoNative = (getenv("SAL_VCL_QT_NO_NATIVE") != nullptr); diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 021ae4f5d9ea..7c87daff9c33 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -799,7 +799,7 @@ void QtFrame::SetPointer(PointerStyle ePointerStyle) return; m_ePointerStyle = ePointerStyle; - m_pQWidget->setCursor(GetQtData()->getCursor(ePointerStyle)); + m_pQWidget->setCursor(toQCursor(ePointerStyle)); }); } diff --git a/vcl/qt5/QtInstanceDrawingArea.cxx b/vcl/qt5/QtInstanceDrawingArea.cxx index 1aa528be322d..c7db3c83de81 100644 --- a/vcl/qt5/QtInstanceDrawingArea.cxx +++ b/vcl/qt5/QtInstanceDrawingArea.cxx @@ -59,8 +59,7 @@ void QtInstanceDrawingArea::enable_drag_source(rtl::Reference<TransferDataContai void QtInstanceDrawingArea::set_cursor(PointerStyle ePointerStyle) { SolarMutexGuard g; - GetQtInstance().RunInMainThread( - [&] { getQWidget()->setCursor(GetQtData()->getCursor(ePointerStyle)); }); + GetQtInstance().RunInMainThread([&] { getQWidget()->setCursor(toQCursor(ePointerStyle)); }); } Point QtInstanceDrawingArea::get_pointer_position() const diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx index 56978054c308..cda318dc0332 100644 --- a/vcl/qt5/QtTools.cxx +++ b/vcl/qt5/QtTools.cxx @@ -17,15 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <QtTools.hxx> - +#include <bitmaps.hlst> +#include <cursor_hotspots.hxx> #include <QtFont.hxx> #include <QtFontFace.hxx> +#include <QtTools.hxx> #include <QtTransferable.hxx> #include <unx/fontmanager.hxx> #include <cairo.h> +#include <o3tl/enumarray.hxx> #include <tools/stream.hxx> #include <vcl/event.hxx> #include <vcl/image.hxx> @@ -359,6 +361,150 @@ bool toVclFont(const QFont& rQFont, const css::lang::Locale& rLocale, vcl::Font& return true; } +static QCursor* getQCursorFromIconTheme(const OUString& rIconName, int nXHot, int nYHot) +{ + QPixmap aPixmap = loadQPixmapIcon(rIconName); + return new QCursor(aPixmap, nXHot, nYHot); +} + +#define MAKE_CURSOR(vcl_name, name, icon_name) \ + case vcl_name: \ + pCursor = getQCursorFromIconTheme(icon_name, name##curs_x_hot, name##curs_y_hot); \ + break + +#define MAP_BUILTIN(vcl_name, qt_enum) \ + case vcl_name: \ + pCursor = new QCursor(qt_enum); \ + break + +const QCursor& toQCursor(PointerStyle ePointerStyle) +{ + static o3tl::enumarray<PointerStyle, std::unique_ptr<QCursor>> aCursors; + if (!aCursors[ePointerStyle]) + { + QCursor* pCursor = nullptr; + + switch (ePointerStyle) + { + MAP_BUILTIN(PointerStyle::Arrow, Qt::ArrowCursor); + MAP_BUILTIN(PointerStyle::Text, Qt::IBeamCursor); + MAP_BUILTIN(PointerStyle::Help, Qt::WhatsThisCursor); + MAP_BUILTIN(PointerStyle::Cross, Qt::CrossCursor); + MAP_BUILTIN(PointerStyle::Wait, Qt::WaitCursor); + MAP_BUILTIN(PointerStyle::NSize, Qt::SizeVerCursor); + MAP_BUILTIN(PointerStyle::SSize, Qt::SizeVerCursor); + MAP_BUILTIN(PointerStyle::WSize, Qt::SizeHorCursor); + MAP_BUILTIN(PointerStyle::ESize, Qt::SizeHorCursor); + + MAP_BUILTIN(PointerStyle::NWSize, Qt::SizeFDiagCursor); + MAP_BUILTIN(PointerStyle::NESize, Qt::SizeBDiagCursor); + MAP_BUILTIN(PointerStyle::SWSize, Qt::SizeBDiagCursor); + MAP_BUILTIN(PointerStyle::SESize, Qt::SizeFDiagCursor); + MAP_BUILTIN(PointerStyle::WindowNSize, Qt::SizeVerCursor); + MAP_BUILTIN(PointerStyle::WindowSSize, Qt::SizeVerCursor); + MAP_BUILTIN(PointerStyle::WindowWSize, Qt::SizeHorCursor); + MAP_BUILTIN(PointerStyle::WindowESize, Qt::SizeHorCursor); + MAP_BUILTIN(PointerStyle::WindowNWSize, Qt::SizeFDiagCursor); + MAP_BUILTIN(PointerStyle::WindowNESize, Qt::SizeBDiagCursor); + MAP_BUILTIN(PointerStyle::WindowSWSize, Qt::SizeBDiagCursor); + MAP_BUILTIN(PointerStyle::WindowSESize, Qt::SizeFDiagCursor); + + MAP_BUILTIN(PointerStyle::HSizeBar, Qt::SizeHorCursor); + MAP_BUILTIN(PointerStyle::VSizeBar, Qt::SizeVerCursor); + + MAP_BUILTIN(PointerStyle::RefHand, Qt::PointingHandCursor); + MAP_BUILTIN(PointerStyle::Hand, Qt::OpenHandCursor); +#if 0 + MAP_BUILTIN( PointerStyle::Pen, GDK_PENCIL ); +#endif + MAP_BUILTIN(PointerStyle::HSplit, Qt::SizeHorCursor); + MAP_BUILTIN(PointerStyle::VSplit, Qt::SizeVerCursor); + + MAP_BUILTIN(PointerStyle::Move, Qt::SizeAllCursor); + + MAP_BUILTIN(PointerStyle::Null, Qt::BlankCursor); + MAKE_CURSOR(PointerStyle::Magnify, magnify_, RID_CURSOR_MAGNIFY); + MAKE_CURSOR(PointerStyle::Fill, fill_, RID_CURSOR_FILL); + MAKE_CURSOR(PointerStyle::MoveData, movedata_, RID_CURSOR_MOVE_DATA); + MAKE_CURSOR(PointerStyle::CopyData, copydata_, RID_CURSOR_COPY_DATA); + MAKE_CURSOR(PointerStyle::MoveFile, movefile_, RID_CURSOR_MOVE_FILE); + MAKE_CURSOR(PointerStyle::CopyFile, copyfile_, RID_CURSOR_COPY_FILE); + MAKE_CURSOR(PointerStyle::MoveFiles, movefiles_, RID_CURSOR_MOVE_FILES); + MAKE_CURSOR(PointerStyle::CopyFiles, copyfiles_, RID_CURSOR_COPY_FILES); + MAKE_CURSOR(PointerStyle::NotAllowed, nodrop_, RID_CURSOR_NOT_ALLOWED); + MAKE_CURSOR(PointerStyle::Rotate, rotate_, RID_CURSOR_ROTATE); + MAKE_CURSOR(PointerStyle::HShear, hshear_, RID_CURSOR_H_SHEAR); + MAKE_CURSOR(PointerStyle::VShear, vshear_, RID_CURSOR_V_SHEAR); + MAKE_CURSOR(PointerStyle::DrawLine, drawline_, RID_CURSOR_DRAW_LINE); + MAKE_CURSOR(PointerStyle::DrawRect, drawrect_, RID_CURSOR_DRAW_RECT); + MAKE_CURSOR(PointerStyle::DrawPolygon, drawpolygon_, RID_CURSOR_DRAW_POLYGON); + MAKE_CURSOR(PointerStyle::DrawBezier, drawbezier_, RID_CURSOR_DRAW_BEZIER); + MAKE_CURSOR(PointerStyle::DrawArc, drawarc_, RID_CURSOR_DRAW_ARC); + MAKE_CURSOR(PointerStyle::DrawPie, drawpie_, RID_CURSOR_DRAW_PIE); + MAKE_CURSOR(PointerStyle::DrawCircleCut, drawcirclecut_, RID_CURSOR_DRAW_CIRCLE_CUT); + MAKE_CURSOR(PointerStyle::DrawEllipse, drawellipse_, RID_CURSOR_DRAW_ELLIPSE); + MAKE_CURSOR(PointerStyle::DrawConnect, drawconnect_, RID_CURSOR_DRAW_CONNECT); + MAKE_CURSOR(PointerStyle::DrawText, drawtext_, RID_CURSOR_DRAW_TEXT); + MAKE_CURSOR(PointerStyle::Mirror, mirror_, RID_CURSOR_MIRROR); + MAKE_CURSOR(PointerStyle::Crook, crook_, RID_CURSOR_CROOK); + MAKE_CURSOR(PointerStyle::Crop, crop_, RID_CURSOR_CROP); + MAKE_CURSOR(PointerStyle::MovePoint, movepoint_, RID_CURSOR_MOVE_POINT); + MAKE_CURSOR(PointerStyle::MoveBezierWeight, movebezierweight_, + RID_CURSOR_MOVE_BEZIER_WEIGHT); + MAKE_CURSOR(PointerStyle::DrawFreehand, drawfreehand_, RID_CURSOR_DRAW_FREEHAND); + MAKE_CURSOR(PointerStyle::DrawCaption, drawcaption_, RID_CURSOR_DRAW_CAPTION); + MAKE_CURSOR(PointerStyle::LinkData, linkdata_, RID_CURSOR_LINK_DATA); + MAKE_CURSOR(PointerStyle::MoveDataLink, movedlnk_, RID_CURSOR_MOVE_DATA_LINK); + MAKE_CURSOR(PointerStyle::CopyDataLink, copydlnk_, RID_CURSOR_COPY_DATA_LINK); + MAKE_CURSOR(PointerStyle::LinkFile, linkfile_, RID_CURSOR_LINK_FILE); + MAKE_CURSOR(PointerStyle::MoveFileLink, moveflnk_, RID_CURSOR_MOVE_FILE_LINK); + MAKE_CURSOR(PointerStyle::CopyFileLink, copyflnk_, RID_CURSOR_COPY_FILE_LINK); + MAKE_CURSOR(PointerStyle::Chart, chart_, RID_CURSOR_CHART); + MAKE_CURSOR(PointerStyle::Detective, detective_, RID_CURSOR_DETECTIVE); + MAKE_CURSOR(PointerStyle::PivotCol, pivotcol_, RID_CURSOR_PIVOT_COLUMN); + MAKE_CURSOR(PointerStyle::PivotRow, pivotrow_, RID_CURSOR_PIVOT_ROW); + MAKE_CURSOR(PointerStyle::PivotField, pivotfld_, RID_CURSOR_PIVOT_FIELD); + MAKE_CURSOR(PointerStyle::PivotDelete, pivotdel_, RID_CURSOR_PIVOT_DELETE); + MAKE_CURSOR(PointerStyle::Chain, chain_, RID_CURSOR_CHAIN); + MAKE_CURSOR(PointerStyle::ChainNotAllowed, chainnot_, RID_CURSOR_CHAIN_NOT_ALLOWED); + MAKE_CURSOR(PointerStyle::AutoScrollN, asn_, RID_CURSOR_AUTOSCROLL_N); + MAKE_CURSOR(PointerStyle::AutoScrollS, ass_, RID_CURSOR_AUTOSCROLL_S); + MAKE_CURSOR(PointerStyle::AutoScrollW, asw_, RID_CURSOR_AUTOSCROLL_W); + MAKE_CURSOR(PointerStyle::AutoScrollE, ase_, RID_CURSOR_AUTOSCROLL_E); + MAKE_CURSOR(PointerStyle::AutoScrollNW, asnw_, RID_CURSOR_AUTOSCROLL_NW); + MAKE_CURSOR(PointerStyle::AutoScrollNE, asne_, RID_CURSOR_AUTOSCROLL_NE); + MAKE_CURSOR(PointerStyle::AutoScrollSW, assw_, RID_CURSOR_AUTOSCROLL_SW); + MAKE_CURSOR(PointerStyle::AutoScrollSE, asse_, RID_CURSOR_AUTOSCROLL_SE); + MAKE_CURSOR(PointerStyle::AutoScrollNS, asns_, RID_CURSOR_AUTOSCROLL_NS); + MAKE_CURSOR(PointerStyle::AutoScrollWE, aswe_, RID_CURSOR_AUTOSCROLL_WE); + MAKE_CURSOR(PointerStyle::AutoScrollNSWE, asnswe_, RID_CURSOR_AUTOSCROLL_NSWE); + MAKE_CURSOR(PointerStyle::TextVertical, vertcurs_, RID_CURSOR_TEXT_VERTICAL); + + MAKE_CURSOR(PointerStyle::TabSelectS, tblsels_, RID_CURSOR_TAB_SELECT_S); + MAKE_CURSOR(PointerStyle::TabSelectE, tblsele_, RID_CURSOR_TAB_SELECT_E); + MAKE_CURSOR(PointerStyle::TabSelectSE, tblselse_, RID_CURSOR_TAB_SELECT_SE); + MAKE_CURSOR(PointerStyle::TabSelectW, tblselw_, RID_CURSOR_TAB_SELECT_W); + MAKE_CURSOR(PointerStyle::TabSelectSW, tblselsw_, RID_CURSOR_TAB_SELECT_SW); + + MAKE_CURSOR(PointerStyle::HideWhitespace, hidewhitespace_, RID_CURSOR_HIDE_WHITESPACE); + MAKE_CURSOR(PointerStyle::ShowWhitespace, showwhitespace_, RID_CURSOR_SHOW_WHITESPACE); + + MAKE_CURSOR(PointerStyle::FatCross, fatcross_, RID_CURSOR_FATCROSS); + default: + break; + } + if (!pCursor) + { + pCursor = new QCursor(Qt::ArrowCursor); + SAL_WARN("vcl.qt", "pointer " << static_cast<int>(ePointerStyle) << " not implemented"); + } + + aCursors[ePointerStyle].reset(pCursor); + } + + return *aCursors[ePointerStyle]; +} + QMessageBox::Icon vclMessageTypeToQtIcon(VclMessageType eType) { QMessageBox::Icon eRet = QMessageBox::Information; commit a4b9166093600dabc95c3fb9ddb9b82a1f7f3882 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Feb 25 11:32:18 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Feb 27 08:20:01 2026 +0100 qt: Use existing loadQPixmapIcon helper in getQCursorFromIconTheme Assume all the icon names that can be passed are valid. Otherwise, an assert will be triggered now, but that would be a case that should actually be looked into. Change-Id: Ia01e66af2a109761c2e93de3790775dea5c2d714 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200332 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/vcl/qt5/QtData.cxx b/vcl/qt5/QtData.cxx index 46036f568d0d..e0c0eb169472 100644 --- a/vcl/qt5/QtData.cxx +++ b/vcl/qt5/QtData.cxx @@ -18,6 +18,7 @@ */ #include <QtData.hxx> +#include <QtTools.hxx> #include <QtGui/QBitmap> #include <QtGui/QCursor> @@ -55,21 +56,7 @@ QtData::~QtData() {} static QCursor* getQCursorFromIconTheme(const OUString& rIconName, int nXHot, int nYHot) { - const OUString sIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); - const OUString sUILang = Application::GetSettings().GetUILanguageTag().getBcp47(); - auto xMemStream = ImageTree::get().getImageStream(rIconName, sIconTheme, sUILang); - if (!xMemStream) - return nullptr; - auto nLength = xMemStream->TellEnd(); - if (!nLength) - { - SAL_WARN("vcl.qt", "Cannot load cursor pixmap from empty stream."); - return nullptr; - } - - const unsigned char* pData = static_cast<const unsigned char*>(xMemStream->GetData()); - QPixmap aPixmap; - aPixmap.loadFromData(pData, nLength); + QPixmap aPixmap = loadQPixmapIcon(rIconName); return new QCursor(aPixmap, nXHot, nYHot); }
