QGIS API Documentation 4.1.0-Master (31622b25bb0)
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 "qgis.h"
19#include "qgis_gui.h"
20#include "qgswkbtypes.h"
21
22#include <QPair>
23#include <QStringList>
24#include <QWidget>
25
26#define SIP_NO_FILE
27
28class QFont;
29class QMainWindow;
30class QDockWidget;
31
38namespace QgsGuiUtils
39{
40
58 static const Qt::WindowFlags ModalDialogFlags = Qt::WindowFlags();
59
64 constexpr double CANVAS_MAGNIFICATION_MIN = 0.1;
65
70 // Must be a factor of 2, so zooming in to max from 100% then zooming back out will result in 100% mag
71 constexpr double CANVAS_MAGNIFICATION_MAX = 16.0;
72
93 bool GUI_EXPORT openFilesRememberingFilter( QString const &filterName, QString const &filters, QStringList &selectedFiles, QString &enc, QString &title, bool cancelAll = false );
94
104 QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget *parent, const QString &message, const QString &defaultFilename = QString() );
105
114 QString GUI_EXPORT createFileFilter_( QString const &longName, QString const &glob );
115
122 QString GUI_EXPORT createFileFilter_( QString const &format );
123
135 QFont GUI_EXPORT getFont( bool &ok, const QFont &initial, const QString &title = QString() );
136
144 bool GUI_EXPORT restoreGeometry( QWidget *widget, const QString &keyName = QString() );
145
152 void GUI_EXPORT saveGeometry( QWidget *widget, const QString &keyName = QString() );
153
161 QString createWidgetKey( QWidget *widget, const QString &keyName = QString() );
162
172 int GUI_EXPORT scaleIconSize( int standardSize );
173
180 QSize GUI_EXPORT iconSize( bool dockableToolbar = false );
181
188 QSize GUI_EXPORT panelIconSize( QSize size );
189
199 QString GUI_EXPORT displayValueWithMaximumDecimals( const Qgis::DataType dataType, const double value, bool displayTrailingZeroes = false );
200
205 int GUI_EXPORT significantDigits( const Qgis::DataType rasterDataType );
206
215 bool GUI_EXPORT isNonStandardGeoPackageGeometryType( Qgis::WkbType wkbType );
216
234 bool GUI_EXPORT warnAboutNonStandardGeoPackageGeometryType( Qgis::WkbType wkbType, QWidget *parent, const QString &dialogTitle, bool showDialog = true, bool *isNonStandard = nullptr );
235
244 GUI_EXPORT void addDockWidget( QMainWindow *window, Qt::DockWidgetArea area, QDockWidget *dockwidget );
245
261 GUI_EXPORT void addTabifiedDockWidget( QMainWindow *window, Qt::DockWidgetArea area, QDockWidget *dockWidget, const QStringList &tabifyWith = QStringList(), bool raiseTab = false );
262
263
264} // namespace QgsGuiUtils
265
274class GUI_EXPORT QWidgetUpdateBlocker
275{
276 public:
282 QWidgetUpdateBlocker( QWidget *widget );
283
286
288
292 void release();
293
294 private:
295 QWidget *mWidget = nullptr;
296};
297
308{
309 public:
314 QgsTemporaryCursorOverride( const QCursor &cursor );
315
317
321 void release();
322
323 private:
324 bool mHasOverride = true;
325};
326
337{
338 public:
344
346
350 void restore();
351
352 private:
353 std::vector<QCursor> mCursors;
354};
355
356#endif // QGSGUIUTILS_H
QWidgetUpdateBlocker(const QWidgetUpdateBlocker &other)=delete
QWidgetUpdateBlocker(QWidget *widget)
Constructor for QWidgetUpdateBlocker.
void release()
Releases the update block early (i.e.
QWidgetUpdateBlocker & operator=(const QWidgetUpdateBlocker &other)=delete
DataType
Raster data types.
Definition qgis.h:393
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
QgsTemporaryCursorOverride(const QCursor &cursor)
Constructor for QgsTemporaryCursorOverride.
void release()
Releases the cursor override early (i.e.
QgsTemporaryCursorRestoreOverride()
Constructor for QgsTemporaryCursorRestoreOverride.
void restore()
Restores the cursor override early (i.e.
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI.
void addDockWidget(QMainWindow *window, Qt::DockWidgetArea area, QDockWidget *dockwidget)
Add a dock widget to a main window.
void addTabifiedDockWidget(QMainWindow *window, Qt::DockWidgetArea area, QDockWidget *dockWidget, const QStringList &tabifyWith, bool raiseTab)
Add a dock widget to the given area and tabify it (if other dock widgets exist in the same area).
constexpr double CANVAS_MAGNIFICATION_MIN
Minimum magnification level allowed in map canvases.
Definition qgsguiutils.h:64
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.
bool isNonStandardGeoPackageGeometryType(Qgis::WkbType wkbType)
Returns true if the given wkbType is a non-standard GeoPackage geometry type (PolyhedralSurface,...
bool warnAboutNonStandardGeoPackageGeometryType(Qgis::WkbType wkbType, QWidget *parent, const QString &dialogTitle, bool showDialog, bool *isNonStandard)
Checks if the given wkbType is a non-standard GeoPackage geometry type (PolyhedralSurface,...
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:71
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...