QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 
24 #define SIP_NO_FILE
25 
26 class QFont;
27 
34 namespace QgsGuiUtils
35 {
36 
54  static const Qt::WindowFlags ModalDialogFlags = nullptr;
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 
94  bool GUI_EXPORT openFilesRememberingFilter( QString const &filterName,
95  QString const &filters, QStringList &selectedFiles, QString &enc, QString &title,
96  bool cancelAll = false );
97 
107  QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget *parent, const QString &message, const QString &defaultFilename = QString() );
108 
117  QString GUI_EXPORT createFileFilter_( QString const &longName, QString const &glob );
118 
125  QString GUI_EXPORT createFileFilter_( QString const &format );
126 
138  QFont GUI_EXPORT getFont( bool &ok, const QFont &initial, const QString &title = QString() );
139 
147  bool GUI_EXPORT restoreGeometry( QWidget *widget, const QString &keyName = QString() );
148 
155  void GUI_EXPORT saveGeometry( QWidget *widget, const QString &keyName = QString() );
156 
164  QString createWidgetKey( QWidget *widget, const QString &keyName = QString() );
165 
175  int GUI_EXPORT scaleIconSize( int standardSize );
176 
183  QSize GUI_EXPORT iconSize( bool dockableToolbar = false );
184 
191  QSize GUI_EXPORT panelIconSize( QSize size );
192 }
193 
204 {
205  public:
206 
211  QgsTemporaryCursorOverride( const QCursor &cursor );
212 
214 
218  void release();
219 
220  private:
221 
222  bool mHasOverride = true;
223 
224 };
225 
236 {
237  public:
238 
244 
246 
250  void restore();
251 
252  private:
253 
254  std::vector< QCursor > mCursors;
255 
256 };
257 
258 #endif // QGSGUIUTILS_H
QString createFileFilter_(QString const &longName, QString const &glob)
Convenience function for readily creating file filters.
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:203
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
constexpr double CANVAS_MAGNIFICATION_MAX
Maximum magnification level allowed in map canvases.
Definition: qgsguiutils.h:69
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:89
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
QSize panelIconSize(QSize size)
Returns dockable panel toolbar icon width based on the provided window toolbar width.
The QgsGuiUtils namespace contains constants and helper functions used throughout the QGIS GUI...
Definition: qgsguiutils.cpp:28
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window&#39;s toolbar icons.
constexpr double CANVAS_MAGNIFICATION_MIN
Minimum magnification level allowed in map canvases.
Definition: qgsguiutils.h:61
QString createWidgetKey(QWidget *widget, const QString &keyName)
Creates a key for the given widget that can be used to store related data in settings.
Temporarily removes all cursor overrides for the QApplication for the lifetime of the object...
Definition: qgsguiutils.h:235
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:31
QFont getFont(bool &ok, const QFont &initial, const QString &title)
Show font selection dialog.