4 # include <QCoreApplication> 6 # include <QGuiApplication> 11 # include <QApplication> 12 # include <QDesktopWidget> 27 switch(documentStatus) {
29 if(documentPath.isEmpty()) {
30 return QCoreApplication::translate(
"Utilities::windowTitle",
"Unsaved - %1").arg(QCoreApplication::applicationName());
32 QFileInfo file(documentPath);
33 return QCoreApplication::translate(
"Utilities::windowTitle",
"%1 - %2 - %3").arg(file.fileName(), file.dir().path(), QCoreApplication::applicationName());
36 if(documentPath.isEmpty()) {
37 return QCoreApplication::translate(
"Utilities::windowTitle",
"*Unsaved - %1").arg(QCoreApplication::applicationName());
39 QFileInfo file(documentPath);
40 return QCoreApplication::translate(
"Utilities::windowTitle",
"*%1 - %2 - %3").arg(file.fileName(), file.dir().path(), QCoreApplication::applicationName());
43 return QCoreApplication::applicationName();
56 QColor windowFrameColor()
58 return QGuiApplication::palette().window().color().darker(108);
64 QColor instructionTextColor()
66 const auto baseColor = QGuiApplication::palette().base().color();
67 return (baseColor.value() > 204 && baseColor.saturation() < 63) ? QColor(0x00, 0x33, 0x99) : QGuiApplication::palette().text().color();
78 static const auto style = QStringLiteral(
"#mainWidget { color: palette(text); background-color: palette(base); border: none; }" 79 "#bottomWidget { background-color: palette(window); color: palette(window-text); border-top: 1px solid %1; }" 80 "QMessageBox QLabel, QInputDialog QLabel, *[classNames~=\"heading\"] { font-size: 12pt; color: %2; }" 81 "*[classNames~=\"input-invalid\"] { color: red; }").arg(
82 windowFrameColor().name(), instructionTextColor().name());
84 static const auto style = QStringLiteral(
"*[classNames~=\"heading\"] { font-weight: bold; }" 85 "*[classNames~=\"input-invalid\"] { color: red; }");
96 void centerWidget(QWidget *widget)
103 QApplication::desktop()->availableGeometry(QCursor::pos())
112 void cornerWidget(QWidget *widget)
114 const QPoint cursorPos(QCursor::pos());
115 const QRect availableGeometry(QApplication::desktop()->availableGeometry(cursorPos));
116 Qt::Alignment alignment = 0;
117 alignment |= (cursorPos.x() - availableGeometry.left() < availableGeometry.right() - cursorPos.x() ? Qt::AlignLeft : Qt::AlignRight);
118 alignment |= (cursorPos.y() - availableGeometry.top() < availableGeometry.bottom() - cursorPos.y() ? Qt::AlignTop : Qt::AlignBottom);
132 void makeHeading(QWidget *widget)
134 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.
const QString QT_UTILITIES_EXPORT & dialogStyle()
Returns the stylesheet for dialogs and other windows used in my applications.