6 #ifndef SWIFT_GUI_GUIUTILITY_H
7 #define SWIFT_GUI_GUIUTILITY_H
10 #include <QDockWidget>
12 #include <QFontMetrics>
13 #include <QFontMetricsF>
14 #include <QModelIndexList>
19 #include <QWidgetList>
43 class CEnableForFramelessWindow;
44 class COverlayMessagesFrame;
45 class COverlayMessagesWizardPage;
46 class COverlayMessagesTabWidget;
57 static void registerMainApplicationWidget(
QWidget *mainWidget);
60 static QWidget *mainApplicationWidget();
63 static qreal mainApplicationWidgetPixelRatio();
67 static QSize desktopSize();
71 static QSize physicalScreenSizeOs();
74 static bool isMainWindowFrameless();
91 static QWidgetList topLevelApplicationWidgetsWithName();
94 static QPoint mainWidgetGlobalPosition();
97 static QString replaceTabCountValue(
const QString &oldName,
int count);
100 static void deleteLayout(
QLayout *layout,
bool deleteWidgets);
103 static bool lenientTitleComparison(
const QString &title,
const QString &comparison);
106 static bool setComboBoxValueByStartingString(
QComboBox *box,
const QString &candidate,
110 static bool setComboBoxValueByContainingString(
QComboBox *box,
const QString &candidate,
114 static bool hasSwiftVariantMimeType(
const QMimeData *mime);
123 static int metaTypeIdFromSwiftDragAndDropData(
const QMimeData *mime);
129 static bool isMimeRepresentingReadableFile(
const QMimeData *mime);
132 static bool isMimeRepresentingReadableJsonFile(
const QMimeData *mime);
135 template <
class OverlayW
idget>
138 if (!widget || maxLevels < 1) {
return nullptr; }
139 OverlayWidget *o = qobject_cast<OverlayWidget *>(widget);
143 while (cl < maxLevels && cw)
145 o = qobject_cast<OverlayWidget *>(cw);
163 static const QString &swiftJsonDragAndDropMimeType();
166 static void checkBoxReadOnly(
QCheckBox *checkBox,
bool readOnly);
169 static void checkBoxesReadOnly(
QWidget *parent,
bool readOnly);
172 static void tempUnhidePassword(
QLineEdit *lineEdit,
int unhideMs = 5000);
175 template <
class WIDGET>
178 if (!parent) {
return; }
180 for (WIDGET *w : children) { w->setEnabled(enabled); }
184 static bool toggleStayOnTop(
QWidget *widget);
187 static bool stayOnTop(
bool onTop,
QWidget *widget);
190 static bool staysOnTop(
QWidget *widget);
202 static QList<int> indexToUniqueRows(
const QModelIndexList &indexes);
208 static bool isTopLevelWidget(
QWidget *widget);
211 static bool isTopLevelWindow(
QWidget *widget);
215 static bool isQMainWindow(
const QWidget *widget);
216 static bool isDialog(
const QWidget *widget);
220 static void disableMinMaxCloseButtons(
QWidget *window);
224 double endValue = 1.0);
228 double endValue = 0.0);
234 static QFont currentFont();
237 static QSizeF fontMetrics80Chars(
bool withRatio =
false);
240 static QSizeF fontMetricsLazyDog43Chars(
bool withRatio =
false);
243 static QSizeF fontMetricsEstimateSize(
int xCharacters,
int yCharacters,
bool withRatio =
false);
246 static void centerWidget(
QWidget *widget);
255 static void forceStyleSheetUpdate(
QWidget *widget);
258 static void superviseMainWindowMinSizes(qreal wRatio = 0.85, qreal hRatio = 0.85);
280 static void setWizardButtonWidths(
QWizard *wizard);
283 static QWidgetList getAllModallWidgets();
286 static QStringList getAllWidgetTitles(
const QWidgetList &widgets);
289 static QStringList getAllWidgetNames(
const QWidgetList &widgets);
298 static QWidgetList closeAllModalWidgets();
301 static QStringList closeAllModalWidgetsGetTitles();
317 static QStringList deleteLaterAllDockWidgetsGetTitles(
QWidget *parent,
bool floatingOnly);
323 static QWidget *s_mainApplicationWidget;
Main window which can be frameless.
static void childrenSetEnabled(QWidget *parent, bool enabled)
Enable/disable all child widgets.
static OverlayWidget * nextOverlayMessageWidget(QWidget *widget, int maxLevels=10)
Find next swift::gui::COverlayMessages QFrame or other implementing widget.
Using this class provides a QFrame with the overlay functionality already integrated.
Using this class provides a QWizardPage with the overlay functionality already integrated.
Value object for icons. An icon is stored in the global icon repository and identified by its index....
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Free functions in swift::misc.
QList< T > findChildren(QAnyStringView name, Qt::FindChildOptions options) const const
#define SWIFT_GUI_EXPORT
Export a class or function from the library.