File indexing completed on 2024-04-28 15:40:26

0001 /* SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org>
0002 
0003    SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef SHOWBUSYCURSOR_H
0007 #define SHOWBUSYCURSOR_H
0008 
0009 #include <qnamespace.h>
0010 
0011 namespace Utilities
0012 {
0013 
0014 /**
0015    \brief Utility class to set/unset the busy cursor
0016 
0017    When setting the busy cursor, you also need to remember to unset it
0018    again, otherwise you will have a busy cursor for the rest of the
0019    lifetime of the application.
0020 
0021    This class helps you avoid not getting it unset due to an early return
0022    in a function (much similar to \ref BooleanGuard). The code looks like
0023    this:
0024 
0025    <pre>
0026    void f() {
0027        ...
0028        ShowBusyCursor dummy;
0029        ... // cursor will be busy until the end of this function.
0030    }
0031    </pre>
0032 **/
0033 
0034 class ShowBusyCursor
0035 {
0036 
0037 public:
0038     explicit ShowBusyCursor(Qt::CursorShape shape = Qt::WaitCursor);
0039     ~ShowBusyCursor();
0040     void stop();
0041 
0042 private:
0043     bool m_active;
0044 };
0045 }
0046 
0047 #endif /* SHOWBUSYCURSOR_H */
0048 
0049 // vi:expandtab:tabstop=4 shiftwidth=4: