KGuiAddons

kcursorsaver.cpp
1/*
2 SPDX-License-Identifier: LGPL-2.0-or-later
3 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org>
4 SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
5*/
6
7#include "kcursorsaver.h"
8#include "kguiaddons_debug.h"
9#include <QGuiApplication>
10
11class KCursorSaverPrivate
12{
13public:
14 bool ownsCursor = true;
15};
16
18 : d(new KCursorSaverPrivate)
19{
21 d->ownsCursor = true;
22}
23
25 : d(other.d)
26{
27 *this = std::move(other);
28}
29
31{
32 if (d->ownsCursor) {
34 delete d;
35 }
36}
37
39{
40 if (!d->ownsCursor) {
41 qCWarning(KGUIADDONS_LOG) << "This KCursorSaver doesn't own the cursor anymore, invalid call to restoreCursor().";
42 return;
43 }
44 d->ownsCursor = false;
46}
47
48KCursorSaver &KCursorSaver::operator=(KCursorSaver &&other)
49{
50 if (this != &other) {
51 d->ownsCursor = false;
52 }
53 return *this;
54}
Class to temporarily set a mouse cursor and restore the previous one on destruction.
~KCursorSaver()
restore the cursor
void restoreCursor()
call this to explicitly restore the cursor
KCursorSaver(Qt::CursorShape shape)
Creates a KCursorSaver, setting the mouse cursor to shape.
void restoreOverrideCursor()
void setOverrideCursor(const QCursor &cursor)
CursorShape
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:40 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.