aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/qtguihelper.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-02-18 09:32:29 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-18 09:23:18 +0100
commitf81168387be7879f9167405b28d29ba26e7b3f14 (patch)
tree98b0bb11a86703c9621b0be2886d245fd232fa05 /sources/pyside6/PySide6/qtguihelper.h
parented6bb6cf8f8f6005309f038f16134d478f15a1f3 (diff)
Add a context manager for override cursors
[ChangeLog][PySide] A context manager for override cursors has been added. It is now possible to write code like: with QApplication.setOverrideCursor(Qt.WaitCursor):... Change-Id: I443ce82389b48656f21c98df17d97e1b3b3323b5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6/qtguihelper.h')
-rw-r--r--sources/pyside6/PySide6/qtguihelper.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/qtguihelper.h b/sources/pyside6/PySide6/qtguihelper.h
new file mode 100644
index 000000000..4fee6c53e
--- /dev/null
+++ b/sources/pyside6/PySide6/qtguihelper.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTGUIHELPER_H
+#define QTGUIHELPER_H
+
+#include <QtGui/QGuiApplication>
+
+namespace QtGuiHelper {
+
+ class QOverrideCursorGuard
+ {
+ public:
+ Q_DISABLE_COPY_MOVE(QOverrideCursorGuard)
+
+ QOverrideCursorGuard() = default;
+ ~QOverrideCursorGuard() { restoreOverrideCursor(); }
+
+ void restoreOverrideCursor()
+ {
+ if (m_guard) {
+ QGuiApplication::restoreOverrideCursor();
+ m_guard = false;
+ }
+ }
+
+ private:
+ bool m_guard = true;
+ };
+
+} // namespace QtGuiHelper
+
+#endif // QTGUIHELPER_H