Standarddialogs example: Adapt layout for fullscreen platforms.
Insert a group box depending on style hints. Change-Id: I1b49dc31d5bd32c92d88f95be0683d5223329c11 Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com> Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
This commit is contained in:
parent
fcedf8998e
commit
b880b7e1ac
@ -98,9 +98,19 @@ int DialogOptionsWidget::value() const
|
||||
Dialog::Dialog(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
QVBoxLayout *verticalLayout;
|
||||
if (QGuiApplication::styleHints()->showIsFullScreen() || QGuiApplication::styleHints()->showIsMaximized()) {
|
||||
QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
|
||||
QGroupBox *groupBox = new QGroupBox(QGuiApplication::applicationDisplayName(), this);
|
||||
horizontalLayout->addWidget(groupBox);
|
||||
horizontalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored));
|
||||
verticalLayout = new QVBoxLayout(groupBox);
|
||||
} else {
|
||||
verticalLayout = new QVBoxLayout(this);
|
||||
}
|
||||
|
||||
QToolBox *toolbox = new QToolBox;
|
||||
mainLayout->addWidget(toolbox);
|
||||
verticalLayout->addWidget(toolbox);
|
||||
|
||||
errorMessageDialog = new QErrorMessage(this);
|
||||
|
||||
@ -291,7 +301,7 @@ Dialog::Dialog(QWidget *parent)
|
||||
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0);
|
||||
toolbox->addItem(page, tr("Message Boxes"));
|
||||
|
||||
setWindowTitle(tr("Standard Dialogs"));
|
||||
setWindowTitle(QGuiApplication::applicationDisplayName());
|
||||
}
|
||||
|
||||
void Dialog::setInteger()
|
||||
|
@ -39,6 +39,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStyleHints>
|
||||
#include <QDesktopWidget>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
@ -49,6 +50,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QGuiApplication::setApplicationDisplayName(Dialog::tr("Standard Dialogs"));
|
||||
|
||||
#ifndef QT_NO_TRANSLATION
|
||||
QString translatorFileName = QLatin1String("qt_");
|
||||
@ -59,10 +61,12 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
Dialog dialog;
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&dialog);
|
||||
dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3);
|
||||
dialog.move((availableGeometry.width() - dialog.width()) / 2,
|
||||
(availableGeometry.height() - dialog.height()) / 2);
|
||||
if (!QGuiApplication::styleHints()->showIsFullScreen() && !QGuiApplication::styleHints()->showIsMaximized()) {
|
||||
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&dialog);
|
||||
dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3);
|
||||
dialog.move((availableGeometry.width() - dialog.width()) / 2,
|
||||
(availableGeometry.height() - dialog.height()) / 2);
|
||||
}
|
||||
dialog.show();
|
||||
|
||||
return app.exec();
|
||||
|
Loading…
Reference in New Issue
Block a user