Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qhaikucursor.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qhaikucursor.h"
5
7
8#include <Cursor.h>
9
11{
12 m_cursorIds.insert(Qt::ArrowCursor, B_CURSOR_ID_SYSTEM_DEFAULT);
13 m_cursorIds.insert(Qt::UpArrowCursor, B_CURSOR_ID_RESIZE_NORTH);
14 m_cursorIds.insert(Qt::CrossCursor, B_CURSOR_ID_CROSS_HAIR);
15 m_cursorIds.insert(Qt::WaitCursor, B_CURSOR_ID_PROGRESS);
16 m_cursorIds.insert(Qt::IBeamCursor, B_CURSOR_ID_I_BEAM);
17 m_cursorIds.insert(Qt::SizeVerCursor, B_CURSOR_ID_RESIZE_NORTH_SOUTH);
18 m_cursorIds.insert(Qt::SizeHorCursor, B_CURSOR_ID_RESIZE_EAST_WEST);
19 m_cursorIds.insert(Qt::SizeBDiagCursor, B_CURSOR_ID_RESIZE_NORTH_EAST_SOUTH_WEST);
20 m_cursorIds.insert(Qt::SizeFDiagCursor, B_CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST);
21 m_cursorIds.insert(Qt::SizeAllCursor, B_CURSOR_ID_MOVE);
22 m_cursorIds.insert(Qt::BlankCursor, B_CURSOR_ID_NO_CURSOR);
23 m_cursorIds.insert(Qt::SplitVCursor, B_CURSOR_ID_RESIZE_NORTH_SOUTH);
24 m_cursorIds.insert(Qt::SplitHCursor, B_CURSOR_ID_RESIZE_EAST_WEST);
25 m_cursorIds.insert(Qt::PointingHandCursor, B_CURSOR_ID_FOLLOW_LINK);
26 m_cursorIds.insert(Qt::ForbiddenCursor, B_CURSOR_ID_NOT_ALLOWED);
27 m_cursorIds.insert(Qt::OpenHandCursor, B_CURSOR_ID_GRAB);
28 m_cursorIds.insert(Qt::ClosedHandCursor, B_CURSOR_ID_GRABBING);
29 m_cursorIds.insert(Qt::WhatsThisCursor, B_CURSOR_ID_HELP);
30 m_cursorIds.insert(Qt::BusyCursor, B_CURSOR_ID_PROGRESS);
31}
32
33#ifndef QT_NO_CURSOR
35{
36 if (!window)
37 return;
38
39 BWindow *haikuWindow = reinterpret_cast<BWindow*>(window->winId());
40
41 // We expect that every BWindow has exactly one BView as child,
42 // so we can use CurrentFocus to retrieve it and call SetViewCursor
43 // to change the cursor for the whole window.
44 if (!windowCursor) {
45 BView *view = haikuWindow->CurrentFocus();
46 if (view) {
47 view->SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
48 }
49 } else {
50 const Qt::CursorShape shape = windowCursor->shape();
51 if (!m_cursors.contains(shape))
52 m_cursors.insert(shape, new BCursor(m_cursorIds.value(shape)));
53
54 BView *view = haikuWindow->CurrentFocus();
55 if (view) {
56 view->LockLooper();
57 view->SetViewCursor(m_cursors.value(shape));
58 view->UnlockLooper();
59 }
60 }
61}
62#endif
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
void changeCursor(QCursor *windowCursor, QWindow *window) override
This method is called by Qt whenever the cursor graphic should be changed.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
Definition qhash.h:1007
T value(const Key &key) const noexcept
Definition qhash.h:1054
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
\inmodule QtGui
Definition qwindow.h:63
CursorShape
@ BlankCursor
@ CrossCursor
@ PointingHandCursor
@ SizeHorCursor
@ SizeAllCursor
@ WaitCursor
@ SizeVerCursor
@ OpenHandCursor
@ SizeFDiagCursor
@ WhatsThisCursor
@ ArrowCursor
@ SplitVCursor
@ UpArrowCursor
@ ClosedHandCursor
@ IBeamCursor
@ SizeBDiagCursor
@ ForbiddenCursor
@ BusyCursor
@ SplitHCursor
aWidget window() -> setWindowTitle("New Window Title")
[2]
QQuickView * view
[0]