QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 <Qt>
19 #include <QPair>
20 #include <QWidget>
21 #include <QStringList>
22 #include "qgis_gui.h"
23 #include "qgis.h"
24 
25 #define SIP_NO_FILE
26 
27 class QFont;
28 
35 namespace QgsGuiUtils
36 {
37 
55  static const Qt::WindowFlags ModalDialogFlags = Qt::WindowFlags();
56 
62  constexpr double CANVAS_MAGNIFICATION_MIN = 0.1;
63 
69  // Must be a factor of 2, so zooming in to max from 100% then zooming back out will result in 100% mag
70  constexpr double CANVAS_MAGNIFICATION_MAX = 16.0;
71 
95  bool GUI_EXPORT openFilesRememberingFilter( QString const &filterName,
96  QString const &filters, QStringList &selectedFiles, QString &enc, QString &title,
97  bool cancelAll = false );
98 
108  QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget *parent, const QString &message, const QString &defaultFilename = QString() );
109 
118  QString GUI_EXPORT createFileFilter_( QString const &longName, QString const &glob );
119 
126  QString GUI_EXPORT createFileFilter_( QString const &format );
127 
139  QFont GUI_EXPORT getFont( bool &ok, const QFont &initial, const QString &title = QString() );
140 
148  bool GUI_EXPORT restoreGeometry( QWidget *widget, const QString &keyName = QString() );
149 
156  void GUI_EXPORT saveGeometry( QWidget *widget, const QString &keyName = QString() );
157 
165  QString createWidgetKey( QWidget *widget, const QString &keyName = QString() );
166 
176  int GUI_EXPORT scaleIconSize( int standardSize );
177 
184  QSize GUI_EXPORT iconSize( bool dockableToolbar = false );
185 
192  QSize GUI_EXPORT panelIconSize( QSize size );
193 
202  QString displayValueWithMaximumDecimals( const Qgis::DataType rasterDataType, const double value );
203 
208  int significantDigits( const Qgis::DataType rasterDataType );
209 
210 }
211 
222 {
223  public:
224 
229  QgsTemporaryCursorOverride( const QCursor &cursor );
230 
232 
236  void release();
237 
238  private:
239 
240  bool mHasOverride = true;
241 
242 };
243 
254 {
255  public:
256 
262 
264 
268  void restore();
269 
270  private:
271 
272  std::vector< QCursor > mCursors;
273 
274 };
275 
276 #endif // QGSGUIUTILS_H
Qgis::DataType
DataType
Raster data types.
Definition: qgis.h:102
QgsGuiUtils::getFont
QFont getFont(bool &ok, const QFont &initial, const QString &title)
Show font selection dialog.
Definition: qgsguiutils.cpp:196
QgsGuiUtils::CANVAS_MAGNIFICATION_MIN
constexpr double CANVAS_MAGNIFICATION_MIN
Minimum magnification level allowed in map canvases.
Definition: qgsguiutils.h:62
qgis.h
QgsGuiUtils::saveGeometry
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
Definition: qgsguiutils.cpp:212
QgsGuiUtils::restoreGeometry
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
Definition: qgsguiutils.cpp:219
QgsGuiUtils::displayValueWithMaximumDecimals
QString displayValueWithMaximumDecimals(const Qgis::DataType rasterDataType, const double value)
Returns a localized string representation of the value with the appropriate number of decimals suppor...
Definition: qgsguiutils.cpp:278
QgsGuiUtils::CANVAS_MAGNIFICATION_MAX
constexpr double CANVAS_MAGNIFICATION_MAX
Maximum magnification level allowed in map canvases.
Definition: qgsguiutils.h:70
QgsGuiUtils::iconSize
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
Definition: qgsguiutils.cpp:250
QgsGuiUtils
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI.
Definition: qgsguiutils.cpp:30
QgsGuiUtils::getSaveAsImageName
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.
Definition: qgsguiutils.cpp:90
QgsGuiUtils::createWidgetKey
QString createWidgetKey(QWidget *widget, const QString &keyName)
Creates a key for the given widget that can be used to store related data in settings.
Definition: qgsguiutils.cpp:226
QgsGuiUtils::significantDigits
int significantDigits(const Qgis::DataType rasterDataType)
Returns the maximum number of significant digits a for the given rasterDataType.
Definition: qgsguiutils.cpp:285
QgsTemporaryCursorRestoreOverride
Temporarily removes all cursor overrides for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:254
QgsGuiUtils::scaleIconSize
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
Definition: qgsguiutils.cpp:245
QgsGuiUtils::openFilesRememberingFilter
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,...
Definition: qgsguiutils.cpp:32
QgsTemporaryCursorOverride
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:222
QgsGuiUtils::createFileFilter_
QString createFileFilter_(QString const &longName, QString const &glob)
Convenience function for readily creating file filters.
Definition: qgsguiutils.cpp:184
QgsGuiUtils::panelIconSize
QSize panelIconSize(QSize size)
Returns dockable panel toolbar icon width based on the provided window toolbar width.
Definition: qgsguiutils.cpp:264