QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsguiutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsguiutils.h - Constants used throughout the QGIS GUI.
3 ------------
4 Date : 11-Jan-2006
5 Copyright : (C) 2006 by Tom Elwertowski
6 Email : telwertowski at users dot sourceforge dot net
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSGUIUTILS_H
16#define QGSGUIUTILS_H
17
18#include <QPair>
19#include <QWidget>
20#include <QStringList>
21#include "qgis_gui.h"
22#include "qgis.h"
23
24#define SIP_NO_FILE
25
26class QFont;
27
34namespace QgsGuiUtils
35{
36
54 static const Qt::WindowFlags ModalDialogFlags = Qt::WindowFlags();
55
61 constexpr double CANVAS_MAGNIFICATION_MIN = 0.1;
62
68 // Must be a factor of 2, so zooming in to max from 100% then zooming back out will result in 100% mag
69 constexpr double CANVAS_MAGNIFICATION_MAX = 16.0;
70
93 bool GUI_EXPORT openFilesRememberingFilter( QString const &filterName,
94 QString const &filters, QStringList &selectedFiles, QString &enc, QString &title,
95 bool cancelAll = false );
96
106 QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget *parent, const QString &message, const QString &defaultFilename = QString() );
107
116 QString GUI_EXPORT createFileFilter_( QString const &longName, QString const &glob );
117
124 QString GUI_EXPORT createFileFilter_( QString const &format );
125
137 QFont GUI_EXPORT getFont( bool &ok, const QFont &initial, const QString &title = QString() );
138
146 bool GUI_EXPORT restoreGeometry( QWidget *widget, const QString &keyName = QString() );
147
154 void GUI_EXPORT saveGeometry( QWidget *widget, const QString &keyName = QString() );
155
163 QString createWidgetKey( QWidget *widget, const QString &keyName = QString() );
164
174 int GUI_EXPORT scaleIconSize( int standardSize );
175
182 QSize GUI_EXPORT iconSize( bool dockableToolbar = false );
183
190 QSize GUI_EXPORT panelIconSize( QSize size );
191
201 QString GUI_EXPORT displayValueWithMaximumDecimals( const Qgis::DataType dataType, const double value, bool displayTrailingZeroes = false );
202
207 int GUI_EXPORT significantDigits( const Qgis::DataType rasterDataType );
208
209}
210
219class GUI_EXPORT QWidgetUpdateBlocker
220{
221 public:
222
228 QWidgetUpdateBlocker( QWidget *widget );
229
234
236
240 void release();
241
242 private:
243
244 QWidget *mWidget = nullptr;
245};
246
257{
258 public:
259
264 QgsTemporaryCursorOverride( const QCursor &cursor );
265
267
271 void release();
272
273 private:
274
275 bool mHasOverride = true;
276
277};
278
289{
290 public:
291
297
299
303 void restore();
304
305 private:
306
307 std::vector< QCursor > mCursors;
308
309};
310
311#endif // QGSGUIUTILS_H
Temporarily disables updates for a QWidget for the lifetime of the object.
QWidgetUpdateBlocker(const QWidgetUpdateBlocker &other)=delete
QWidgetUpdateBlocker cannot be copied.
QWidgetUpdateBlocker & operator=(const QWidgetUpdateBlocker &other)=delete
QWidgetUpdateBlocker cannot be copied.
DataType
Raster data types.
Definition qgis.h:269
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Temporarily removes all cursor overrides for the QApplication for the lifetime of the object.
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI.
constexpr double CANVAS_MAGNIFICATION_MIN
Minimum magnification level allowed in map canvases.
Definition qgsguiutils.h:61
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
QString createWidgetKey(QWidget *widget, const QString &keyName)
Creates a key for the given widget that can be used to store related data in settings.
QPair< QString, QString > GUI_EXPORT getSaveAsImageName(QWidget *parent, const QString &message, const QString &defaultFilename)
A helper function to get an image name from the user.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
int significantDigits(const Qgis::DataType rasterDataType)
Returns the maximum number of significant digits a for the given rasterDataType.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
QFont getFont(bool &ok, const QFont &initial, const QString &title)
Show font selection dialog.
bool GUI_EXPORT openFilesRememberingFilter(QString const &filterName, QString const &filters, QStringList &selectedFiles, QString &enc, QString &title, bool cancelAll)
Open files, preferring to have the default file selector be the last one used, if any; also,...
QString createFileFilter_(QString const &longName, QString const &glob)
Convenience function for readily creating file filters.
QSize panelIconSize(QSize size)
Returns dockable panel toolbar icon width based on the provided window toolbar width.
constexpr double CANVAS_MAGNIFICATION_MAX
Maximum magnification level allowed in map canvases.
Definition qgsguiutils.h:69
QString displayValueWithMaximumDecimals(const Qgis::DataType dataType, const double value, bool displayTrailingZeroes)
Returns a localized string representation of the value with the appropriate number of decimals suppor...