swift
Static Public Member Functions | List of all members
swift::gui::CGuiUtility Class Reference

GUI utilities. More...

Static Public Member Functions

static CEnableForFramelessWindowmainFramelessEnabledWindow ()
 Main (frameless enabled) application window.
 
static void registerMainApplicationWidget (QWidget *mainWidget)
 Register main application window widget if this is known. More...
 
static QWidget * mainApplicationWidget ()
 Main application window widget.
 
static qreal mainApplicationWidgetPixelRatio ()
 Device pixel ratio.
 
static QSize desktopSize ()
 Desktop size. More...
 
static QSize physicalScreenSizeOs ()
 Qt independent implementation. More...
 
static bool isMainWindowFrameless ()
 Is main window frameless?
 
static QString screenInformation (const QString &separator="\n")
 Info about screens.
 
static const QString & orientationAsString (Qt::ScreenOrientation orientation)
 Orientation as string.
 
static QWidgetList topLevelApplicationWidgetsWithName ()
 Top level widgets with names.
 
static QPoint mainWidgetGlobalPosition ()
 Position of main widget.
 
static QString replaceTabCountValue (const QString &oldName, int count)
 Replace count in name such as "stations (4)".
 
static void deleteLayout (QLayout *layout, bool deleteWidgets)
 Delete hierarchy of layouts.
 
static bool lenientTitleComparison (const QString &title, const QString &comparison)
 Lenient / relaxed.
 
static bool setComboBoxValueByStartingString (QComboBox *box, const QString &candidate, const QString &unspecified=QString())
 Find best match in comboBox.
 
static bool setComboBoxValueByContainingString (QComboBox *box, const QString &candidate, const QString &unspecified=QString())
 Find best match in comboBox.
 
static bool hasSwiftVariantMimeType (const QMimeData *mime)
 Mime data with swift type.
 
static swift::misc::CVariant fromSwiftDragAndDropData (const QMimeData *mime)
 From text dropped.
 
static swift::misc::CVariant fromSwiftDragAndDropData (const QByteArray &utf8Data)
 From text dropped.
 
static int metaTypeIdFromSwiftDragAndDropData (const QMimeData *mime)
 Meta type id from dropped data.
 
static QFileInfo representedMimeFile (const QMimeData *mime)
 Represented file if any.
 
static bool isMimeRepresentingReadableFile (const QMimeData *mime)
 Is representing existing file.
 
static bool isMimeRepresentingReadableJsonFile (const QMimeData *mime)
 Is representing existing JSON file.
 
template<class OverlayWidget >
static OverlayWidget * nextOverlayMessageWidget (QWidget *widget, int maxLevels=10)
 Find next swift::gui::COverlayMessages QFrame or other implementing widget.
 
static COverlayMessagesFramenextOverlayMessageFrame (QWidget *widget, int maxLevels=10)
 Find next COverlayMessagesFrame.
 
static COverlayMessagesTabWidgetnextOverlayMessageTabWidget (QWidget *widget, int maxLevels=10)
 Find next COverlayMessagesTabWidget.
 
static COverlayMessagesWizardPagenextOverlayMessageWizardPage (QWidget *widget, int maxLevels=10)
 Find next COverlayMessagesWizardPage.
 
static const QString & swiftJsonDragAndDropMimeType ()
 Metatype.
 
static void checkBoxReadOnly (QCheckBox *checkBox, bool readOnly)
 Pseudo readonly state for checkbox. More...
 
static void checkBoxesReadOnly (QWidget *parent, bool readOnly)
 Pseudo readonly state for checkboxes of widget.
 
static void tempUnhidePassword (QLineEdit *lineEdit, int unhideMs=5000)
 Temp. unhide password.
 
template<class WIDGET >
static void childrenSetEnabled (QWidget *parent, bool enabled)
 Enable/disable all child widgets.
 
static bool toggleStayOnTop (QWidget *widget)
 Toggle window flags / stay on top.
 
static bool stayOnTop (bool onTop, QWidget *widget)
 Window flags / stay on top.
 
static bool staysOnTop (QWidget *widget)
 Window on top?
 
static QTabWidget * parentTabWidget (QWidget *widget, int maxLevels=5)
 From a given widget try to find parent tab widget (where widget is embedded)
 
static QString marginsToString (const QMargins &margins)
 Convert to string.
 
static QMargins stringToMargins (const QString &str)
 Convert from string.
 
static QList< int > indexToUniqueRows (const QModelIndexList &indexes)
 Only the row part and unique (so no rows is twice in the list)
 
static int clearModel (QAbstractItemModel *model)
 Clear a model.
 
static bool isTopLevelWidget (QWidget *widget)
 Is top level widget?
 
static bool isTopLevelWindow (QWidget *widget)
 Is top level window?
 
static void disableMinMaxCloseButtons (QWidget *window)
 Disable close button on window.
 
static QGraphicsOpacityEffect * fadeInWidget (int durationMs, QWidget *widget, double startValue=0.0, double endValue=1.0)
 Fade in a widget.
 
static QGraphicsOpacityEffect * fadeOutWidget (int durationMs, QWidget *widget, double startValue=1.0, double endValue=0.0)
 Fade out a widget.
 
static QFontMetrics currentFontMetrics ()
 Main window font metrics or default metrics.
 
static QFontMetricsF currentFontMetricsF ()
 Main window font metrics or default metrics.
 
static QFont currentFont ()
 Main window font or default font.
 
static QSizeF fontMetrics80Chars (bool withRatio=false)
 80 characters width/height
 
static QSizeF fontMetricsLazyDog43Chars (bool withRatio=false)
 43 characters width/height "the quick brown ..."
 
static QSizeF fontMetricsEstimateSize (int xCharacters, int yCharacters, bool withRatio=false)
 Estimate size based on current font.
 
static void centerWidget (QWidget *widget)
 Center widget to host or screen.
 
static void centerWidget (QWidget *widget, QWidget *host)
 Center widget to screen.
 
static QString metricsInfo ()
 Some info about font metrics.
 
static bool isUsingHighDpiScreenSupport ()
 Using high DPI screen support.
 
static void forceStyleSheetUpdate (QWidget *widget)
 Forces a stylesheet update.
 
static void superviseMainWindowMinSizes (qreal wRatio=0.85, qreal hRatio=0.85)
 Make sure that the min.sizes to not exceed the screen resolution.
 
static QString asSimpleHtmlImageWidth (const swift::misc::CIcon &icon, int width=-1)
 CIcon as simple HTML image code segment.
 
static QString asSimpleHtmlImageHeight (const swift::misc::CIcon &icon, int height=-1)
 CIcon as simple HTML image code segment.
 
static QDialog * findParentDialog (QWidget *widget)
 Find parent dialog if there is any, otherwise null.
 
static QDialog * findParentDialog (QWidget *widget, int maxLevel)
 Find parent dialog if there is any, otherwise null.
 
static void setElidedText (QLabel *label, const QString &text, Qt::TextElideMode mode=Qt::ElideMiddle)
 Set elided text.
 
static void setElidedText (QLabel *label, const QString &shortText, const QString &longText, Qt::TextElideMode mode=Qt::ElideMiddle)
 Set elided text.
 
static void setWizardButtonWidths (QWizard *wizard)
 Set button widths for a wizard.
 
static QWidgetList getAllModallWidgets ()
 All modal widgets.
 
static QStringList getAllWidgetTitles (const QWidgetList &widgets)
 All titles.
 
static QStringList getAllWidgetNames (const QWidgetList &widgets)
 All names.
 
static QList< QDockWidget * > getAllDockWidgets (QWidget *parent, bool floatingOnly)
 Get all dock widgets.
 
static QList< QDockWidget * > getAllDockWidgets (QWindow *parent, bool floatingOnly)
 Get all dock widgets.
 
static QWidgetList closeAllModalWidgets ()
 Close all modal widgets.
 
static QStringList closeAllModalWidgetsGetTitles ()
 Close all modal widgets and get titles.
 
static QList< QDockWidget * > closeAllDockWidgets (QWidget *parent, bool floatingOnly)
 Close all dock widgets.
 
static QList< QDockWidget * > closeAllDockWidgets (QWindow *parent, bool floatingOnly)
 Close all dock widgets.
 
static QStringList closeAllDockWidgetsGetTitles (QWidget *parent, bool floatingOnly)
 Close all dock widgets.
 
static QStringList closeAllDockWidgetsGetTitles (QWindow *parent, bool floatingOnly)
 close all dock widgets
 
static QStringList deleteLaterAllDockWidgetsGetTitles (QWidget *parent, bool floatingOnly)
 "deleteLater" all dock widgets More...
 
static QString rectAsString (const QRect &rect)
 QRect, QSize as string.
 
static QString rectAsString (const QRectF &rect)
 QRect, QSize as string.
 
static QString sizeAsString (const QSize &size)
 QRect, QSize as string.
 
static QString sizeAsString (const QSizeF &size)
 QRect, QSize as string.
 
static bool isQMainWindow (const QWidget *widget)
 Check window type.
 
static bool isDialog (const QWidget *widget)
 Check window type.
 

Detailed Description

GUI utilities.

Definition at line 49 of file guiutility.h.

Member Function Documentation

◆ checkBoxReadOnly()

void swift::gui::CGuiUtility::checkBoxReadOnly ( QCheckBox *  checkBox,
bool  readOnly 
)
static

Pseudo readonly state for checkbox.

Fixme:
hardcoded stylesheet setting, should come from stylesheet

fixme hardcoded stylesheet setting

Definition at line 450 of file guiutility.cpp.

◆ deleteLaterAllDockWidgetsGetTitles()

QStringList swift::gui::CGuiUtility::deleteLaterAllDockWidgetsGetTitles ( QWidget *  parent,
bool  floatingOnly 
)
static

"deleteLater" all dock widgets

Remarks
do NOT use unless you know what you are doing

Definition at line 1094 of file guiutility.cpp.

◆ desktopSize()

QSize swift::gui::CGuiUtility::desktopSize ( )
static

Desktop size.

Remarks
might be scaled depending on CGuiUtility::mainApplicationWidgetPixelRatio

Definition at line 108 of file guiutility.cpp.

◆ physicalScreenSizeOs()

QSize swift::gui::CGuiUtility::physicalScreenSizeOs ( )
static

Qt independent implementation.

Remarks
allows to return values before QGuiApplication is initialized

Definition at line 165 of file guiutility.cpp.

◆ registerMainApplicationWidget()

void swift::gui::CGuiUtility::registerMainApplicationWidget ( QWidget *  mainWidget)
static

Register main application window widget if this is known.

Remarks
if not set, is is searched from QApplication::topLevelWidgets()

Definition at line 87 of file guiutility.cpp.


The documentation for this class was generated from the following files: