File tree 3 files changed +41
-18
lines changed
3 files changed +41
-18
lines changed Original file line number Diff line number Diff line change 44
44
#include " qgslogger.h"
45
45
#include " qgsproperty.h"
46
46
#include " qgslayertree.h"
47
-
48
-
49
- struct CursorOverride
50
- {
51
- CursorOverride ()
52
- {
53
- QApplication::setOverrideCursor ( Qt::BusyCursor );
54
- }
55
-
56
- ~CursorOverride ()
57
- {
58
- QApplication::restoreOverrideCursor ();
59
- }
60
- };
61
-
47
+ #include " qgsguiutils.h"
62
48
63
49
QgsDwgImportDialog::QgsDwgImportDialog ( QWidget *parent, Qt::WindowFlags f )
64
50
: QDialog( parent, f )
@@ -163,7 +149,7 @@ void QgsDwgImportDialog::pbLoadDatabase_clicked()
163
149
if ( !QFileInfo::exists ( leDatabase->text () ) )
164
150
return ;
165
151
166
- CursorOverride waitCursor;
152
+ QgsTemporaryCursorOverride waitCursor ( Qt::BusyCursor ) ;
167
153
168
154
bool lblVisible = false ;
169
155
@@ -261,7 +247,7 @@ void QgsDwgImportDialog::pbBrowseDrawing_clicked()
261
247
262
248
void QgsDwgImportDialog::pbImportDrawing_clicked ()
263
249
{
264
- CursorOverride waitCursor;
250
+ QgsTemporaryCursorOverride waitCursor ( Qt::BusyCursor ) ;
265
251
266
252
QgsDwgImporter importer ( leDatabase->text (), mCrsSelector ->crs () );
267
253
@@ -457,7 +443,7 @@ void QgsDwgImportDialog::pbDeselectAll_clicked()
457
443
458
444
void QgsDwgImportDialog::buttonBox_accepted ()
459
445
{
460
- CursorOverride waitCursor;
446
+ QgsTemporaryCursorOverride waitCursor ( Qt::BusyCursor ) ;
461
447
462
448
QMap<QString, bool > layers;
463
449
bool allLayers = true ;
Original file line number Diff line number Diff line change 21
21
22
22
#include < QImageWriter>
23
23
#include < QFontDialog>
24
+ #include < QApplication>
24
25
25
26
26
27
namespace QgsGuiUtils
@@ -235,3 +236,17 @@ namespace QgsGuiUtils
235
236
return key;
236
237
}
237
238
}
239
+
240
+ //
241
+ // QgsTemporaryCursorOverride
242
+ //
243
+
244
+ QgsTemporaryCursorOverride::QgsTemporaryCursorOverride ( const QCursor &cursor )
245
+ {
246
+ QApplication::setOverrideCursor ( cursor );
247
+ }
248
+
249
+ QgsTemporaryCursorOverride::~QgsTemporaryCursorOverride ()
250
+ {
251
+ QApplication::restoreOverrideCursor ();
252
+ }
Original file line number Diff line number Diff line change @@ -164,4 +164,26 @@ namespace QgsGuiUtils
164
164
QString createWidgetKey ( QWidget *widget, const QString &keyName = QString() );
165
165
}
166
166
167
+ /* *
168
+ * Temporarily sets a cursor override for the QApplication for the lifetime of the object.
169
+ *
170
+ * When the object is deleted, the cursor override is removed.
171
+ *
172
+ * \ingroup gui
173
+ * \since QGIS 3.2
174
+ */
175
+ class GUI_EXPORT QgsTemporaryCursorOverride
176
+ {
177
+ public:
178
+
179
+ /* *
180
+ * Constructor for QgsTemporaryCursorOverride. Sets the application override
181
+ * cursor to \a cursor.
182
+ */
183
+ QgsTemporaryCursorOverride ( const QCursor &cursor );
184
+
185
+ ~QgsTemporaryCursorOverride ();
186
+
187
+ };
188
+
167
189
#endif // QGSGUIUTILS_H
You can’t perform that action at this time.
0 commit comments