3 #if !defined(QT_UTILITIES_GUI_QTWIDGETS) && !defined(QT_UTILITIES_GUI_QTQUICK) 4 #include <QCoreApplication> 6 #include <QGuiApplication> 10 #ifdef QT_UTILITIES_GUI_QTWIDGETS 11 #include <QApplication> 13 #include <QDesktopWidget> 27 switch (documentStatus) {
29 if (documentPath.isEmpty()) {
30 return QCoreApplication::translate(
"Utilities::windowTitle",
"Unsaved - %1").arg(QCoreApplication::applicationName());
32 const QFileInfo file(documentPath);
33 return QCoreApplication::translate(
"Utilities::windowTitle",
"%1 - %2 - %3")
34 .arg(file.fileName(), file.dir().path(), QCoreApplication::applicationName());
37 if (documentPath.isEmpty()) {
38 return QCoreApplication::translate(
"Utilities::windowTitle",
"*Unsaved - %1").arg(QCoreApplication::applicationName());
40 const QFileInfo file(documentPath);
41 return QCoreApplication::translate(
"Utilities::windowTitle",
"*%1 - %2 - %3")
42 .arg(file.fileName(), file.dir().path(), QCoreApplication::applicationName());
45 return QCoreApplication::applicationName();
52 #if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) 59 QColor windowFrameColor()
61 return QGuiApplication::palette().window().color().darker(108);
67 QColor instructionTextColor()
69 const auto baseColor = QGuiApplication::palette().base().color();
70 return (baseColor.value() > 204 && baseColor.saturation() < 63) ? QColor(0x00, 0x33, 0x99) : QGuiApplication::palette().text().color();
79 const QString &dialogStyle()
82 static const auto style = QStringLiteral(
"#mainWidget { color: palette(text); background-color: " 83 "palette(base); border: none; }" 84 "#bottomWidget { background-color: palette(window); " 85 "color: palette(window-text); border-top: 1px solid %1; }" 86 "QMessageBox QLabel, QInputDialog QLabel, " 87 "*[classNames~=\"heading\"] { font-size: 12pt; color: %2; " 89 "*[classNames~=\"input-invalid\"] { color: red; }")
90 .arg(windowFrameColor().name(), instructionTextColor().name());
92 static const auto style = QStringLiteral(
"*[classNames~=\"heading\"] { font-weight: bold; }" 93 "*[classNames~=\"input-invalid\"] { color: red; }");
98 #ifdef QT_UTILITIES_GUI_QTWIDGETS 106 void centerWidget(QWidget *widget)
109 QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, widget->size(), QApplication::desktop()->availableGeometry(QCursor::pos())));
118 void cornerWidget(QWidget *widget)
120 const QPoint cursorPos(QCursor::pos());
121 const QRect availableGeometry(QApplication::desktop()->availableGeometry(cursorPos));
122 Qt::Alignment alignment = 0;
123 alignment |= (cursorPos.x() - availableGeometry.left() < availableGeometry.right() - cursorPos.x() ? Qt::AlignLeft : Qt::AlignRight);
124 alignment |= (cursorPos.y() - availableGeometry.top() < availableGeometry.bottom() - cursorPos.y() ? Qt::AlignTop : Qt::AlignBottom);
125 widget->setGeometry(QStyle::alignedRect(Qt::LeftToRight, alignment, widget->size(), availableGeometry));
131 void makeHeading(QWidget *widget)
133 widget->setProperty(
"classNames", widget->property(
"classNames").toStringList() << QStringLiteral(
"heading"));
142 void updateStyle(QWidget *widget)
144 widget->style()->unpolish(widget);
145 widget->style()->polish(widget);
QString QT_UTILITIES_EXPORT generateWindowTitle(DocumentStatus documentStatus, const QString &documentPath)
Generates the window title string for the specified documentStatus and documentPath.
DocumentStatus
The DocumentStatus enum specifies the status of the document in a window.
Provides common dialogs such as AboutDialog, EnterPasswordDialog and SettingsDialog.