diff options
Diffstat (limited to 'examples/widgets/dialogs')
-rw-r--r-- | examples/widgets/dialogs/classwizard/classwizard.cpp | 58 | ||||
-rw-r--r-- | examples/widgets/dialogs/configdialog/configdialog.cpp | 6 | ||||
-rw-r--r-- | examples/widgets/dialogs/extension/finddialog.cpp | 2 | ||||
-rw-r--r-- | examples/widgets/dialogs/findfiles/window.cpp | 19 | ||||
-rw-r--r-- | examples/widgets/dialogs/findfiles/window.h | 1 | ||||
-rw-r--r-- | examples/widgets/dialogs/licensewizard/licensewizard.cpp | 10 | ||||
-rw-r--r-- | examples/widgets/dialogs/sipdialog/dialog.cpp | 7 | ||||
-rw-r--r-- | examples/widgets/dialogs/standarddialogs/dialog.cpp | 63 | ||||
-rw-r--r-- | examples/widgets/dialogs/standarddialogs/main.cpp | 9 | ||||
-rw-r--r-- | examples/widgets/dialogs/tabdialog/tabdialog.cpp | 4 |
10 files changed, 96 insertions, 83 deletions
diff --git a/examples/widgets/dialogs/classwizard/classwizard.cpp b/examples/widgets/dialogs/classwizard/classwizard.cpp index 0f1a2a0869..d3e366efe6 100644 --- a/examples/widgets/dialogs/classwizard/classwizard.cpp +++ b/examples/widgets/dialogs/classwizard/classwizard.cpp @@ -79,31 +79,31 @@ void ClassWizard::accept() if (field("comment").toBool()) { block += "/*\n"; - block += " " + header.toLatin1() + "\n"; + block += " " + header.toLatin1() + '\n'; block += "*/\n"; - block += "\n"; + block += '\n'; } if (field("protect").toBool()) { - block += "#ifndef " + macroName + "\n"; - block += "#define " + macroName + "\n"; - block += "\n"; + block += "#ifndef " + macroName + '\n'; + block += "#define " + macroName + '\n'; + block += '\n'; } if (field("includeBase").toBool()) { - block += "#include " + baseInclude + "\n"; - block += "\n"; + block += "#include " + baseInclude + '\n'; + block += '\n'; } block += "class " + className; if (!baseClass.isEmpty()) block += " : public " + baseClass; - block += "\n"; + block += '\n'; block += "{\n"; /* qmake ignore Q_OBJECT */ if (field("qobjectMacro").toBool()) { block += " Q_OBJECT\n"; - block += "\n"; + block += '\n'; } block += "public:\n"; @@ -115,7 +115,7 @@ void ClassWizard::accept() block += " " + className + "();\n"; if (field("copyCtor").toBool()) { block += " " + className + "(const " + className + " &other);\n"; - block += "\n"; + block += '\n'; block += " " + className + " &operator=" + "(const " + className + " &other);\n"; } @@ -123,11 +123,11 @@ void ClassWizard::accept() block += "};\n"; if (field("protect").toBool()) { - block += "\n"; + block += '\n'; block += "#endif\n"; } - QFile headerFile(outputDir + "/" + header); + QFile headerFile(outputDir + '/' + header); if (!headerFile.open(QFile::WriteOnly | QFile::Text)) { QMessageBox::warning(0, QObject::tr("Simple Wizard"), QObject::tr("Cannot write file %1:\n%2") @@ -141,12 +141,12 @@ void ClassWizard::accept() if (field("comment").toBool()) { block += "/*\n"; - block += " " + implementation.toLatin1() + "\n"; + block += " " + implementation.toLatin1() + '\n'; block += "*/\n"; - block += "\n"; + block += '\n'; } block += "#include \"" + header.toLatin1() + "\"\n"; - block += "\n"; + block += '\n'; if (field("qobjectCtor").toBool()) { block += className + "::" + className + "(QObject *parent)\n"; @@ -171,7 +171,7 @@ void ClassWizard::accept() block += "{\n"; block += " *this = other;\n"; block += "}\n"; - block += "\n"; + block += '\n'; block += className + " &" + className + "::operator=(const " + className + " &other)\n"; block += "{\n"; @@ -183,7 +183,7 @@ void ClassWizard::accept() } } - QFile implementationFile(outputDir + "/" + implementation); + QFile implementationFile(outputDir + '/' + implementation); if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) { QMessageBox::warning(0, QObject::tr("Simple Wizard"), QObject::tr("Cannot write file %1:\n%2") @@ -252,8 +252,8 @@ ClassInfoPage::ClassInfoPage(QWidget *parent) defaultCtorRadioButton->setChecked(true); - connect(defaultCtorRadioButton, SIGNAL(toggled(bool)), - copyCtorCheckBox, SLOT(setEnabled(bool))); + connect(defaultCtorRadioButton, &QAbstractButton::toggled, + copyCtorCheckBox, &QWidget::setEnabled); //! [11] //! [12] registerField("className*", classNameLineEdit); @@ -311,14 +311,14 @@ CodeStylePage::CodeStylePage(QWidget *parent) baseIncludeLineEdit = new QLineEdit; baseIncludeLabel->setBuddy(baseIncludeLineEdit); - connect(protectCheckBox, SIGNAL(toggled(bool)), - macroNameLabel, SLOT(setEnabled(bool))); - connect(protectCheckBox, SIGNAL(toggled(bool)), - macroNameLineEdit, SLOT(setEnabled(bool))); - connect(includeBaseCheckBox, SIGNAL(toggled(bool)), - baseIncludeLabel, SLOT(setEnabled(bool))); - connect(includeBaseCheckBox, SIGNAL(toggled(bool)), - baseIncludeLineEdit, SLOT(setEnabled(bool))); + connect(protectCheckBox, &QAbstractButton::toggled, + macroNameLabel, &QWidget::setEnabled); + connect(protectCheckBox, &QAbstractButton::toggled, + macroNameLineEdit, &QWidget::setEnabled); + connect(includeBaseCheckBox, &QAbstractButton::toggled, + baseIncludeLabel, &QWidget::setEnabled); + connect(includeBaseCheckBox, &QAbstractButton::toggled, + baseIncludeLineEdit, &QWidget::setEnabled); registerField("comment", commentCheckBox); registerField("protect", protectCheckBox); @@ -356,9 +356,9 @@ void CodeStylePage::initializePage() if (baseClass.isEmpty()) { baseIncludeLineEdit->clear(); } else if (QRegExp("Q[A-Z].*").exactMatch(baseClass)) { - baseIncludeLineEdit->setText("<" + baseClass + ">"); + baseIncludeLineEdit->setText('<' + baseClass + '>'); } else { - baseIncludeLineEdit->setText("\"" + baseClass.toLower() + ".h\""); + baseIncludeLineEdit->setText('"' + baseClass.toLower() + ".h\""); } } //! [16] diff --git a/examples/widgets/dialogs/configdialog/configdialog.cpp b/examples/widgets/dialogs/configdialog/configdialog.cpp index 8e68940227..c4565a6407 100644 --- a/examples/widgets/dialogs/configdialog/configdialog.cpp +++ b/examples/widgets/dialogs/configdialog/configdialog.cpp @@ -62,7 +62,7 @@ ConfigDialog::ConfigDialog() createIcons(); contentsWidget->setCurrentRow(0); - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + connect(closeButton, &QAbstractButton::clicked, this, &QWidget::close); QHBoxLayout *horizontalLayout = new QHBoxLayout; horizontalLayout->addWidget(contentsWidget); @@ -102,9 +102,7 @@ void ConfigDialog::createIcons() queryButton->setTextAlignment(Qt::AlignHCenter); queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - connect(contentsWidget, - SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*))); + connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage); } void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) diff --git a/examples/widgets/dialogs/extension/finddialog.cpp b/examples/widgets/dialogs/extension/finddialog.cpp index 19eab195cb..895b0cf2ce 100644 --- a/examples/widgets/dialogs/extension/finddialog.cpp +++ b/examples/widgets/dialogs/extension/finddialog.cpp @@ -78,7 +78,7 @@ FindDialog::FindDialog(QWidget *parent) buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole); - connect(moreButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool))); + connect(moreButton, &QAbstractButton::toggled, extension, &QWidget::setVisible); QVBoxLayout *extensionLayout = new QVBoxLayout; extensionLayout->setMargin(0); diff --git a/examples/widgets/dialogs/findfiles/window.cpp b/examples/widgets/dialogs/findfiles/window.cpp index 86c34a6352..780c398ad5 100644 --- a/examples/widgets/dialogs/findfiles/window.cpp +++ b/examples/widgets/dialogs/findfiles/window.cpp @@ -46,8 +46,10 @@ Window::Window(QWidget *parent) : QWidget(parent) { - browseButton = createButton(tr("&Browse..."), SLOT(browse())); - findButton = createButton(tr("&Find"), SLOT(find())); + browseButton = new QPushButton(tr("&Browse..."), this); + connect(browseButton, &QAbstractButton::clicked, this, &Window::browse); + findButton = new QPushButton(tr("&Find"), this); + connect(findButton, &QAbstractButton::clicked, this, &Window::find); fileComboBox = createComboBox(tr("*")); textComboBox = createComboBox(); @@ -195,15 +197,6 @@ void Window::showFiles(const QStringList &files) } //! [8] -//! [9] -QPushButton *Window::createButton(const QString &text, const char *member) -{ - QPushButton *button = new QPushButton(text); - connect(button, SIGNAL(clicked()), this, member); - return button; -} -//! [9] - //! [10] QComboBox *Window::createComboBox(const QString &text) { @@ -228,8 +221,8 @@ void Window::createFilesTable() filesTable->verticalHeader()->hide(); filesTable->setShowGrid(false); - connect(filesTable, SIGNAL(cellActivated(int,int)), - this, SLOT(openFileOfItem(int,int))); + connect(filesTable, &QTableWidget::cellActivated, + this, &Window::openFileOfItem); } //! [11] diff --git a/examples/widgets/dialogs/findfiles/window.h b/examples/widgets/dialogs/findfiles/window.h index 281c932e2f..89dd87b83b 100644 --- a/examples/widgets/dialogs/findfiles/window.h +++ b/examples/widgets/dialogs/findfiles/window.h @@ -68,7 +68,6 @@ private slots: private: QStringList findFiles(const QStringList &files, const QString &text); void showFiles(const QStringList &files); - QPushButton *createButton(const QString &text, const char *member); QComboBox *createComboBox(const QString &text = QString()); void createFilesTable(); diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.cpp b/examples/widgets/dialogs/licensewizard/licensewizard.cpp index ace2e1229a..0f11f3ab7b 100644 --- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp +++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp @@ -70,7 +70,7 @@ LicenseWizard::LicenseWizard(QWidget *parent) setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo.png")); //! [7] - connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp())); + connect(this, &QWizard::helpRequested, this, &LicenseWizard::showHelp); //! [7] setWindowTitle(tr("License Wizard")); @@ -339,13 +339,13 @@ void ConclusionPage::setVisible(bool visible) //! [29] wizard()->setButtonText(QWizard::CustomButton1, tr("&Print")); wizard()->setOption(QWizard::HaveCustomButton1, true); - connect(wizard(), SIGNAL(customButtonClicked(int)), - this, SLOT(printButtonClicked())); + connect(wizard(), &QWizard::customButtonClicked, + this, &ConclusionPage::printButtonClicked); //! [29] } else { wizard()->setOption(QWizard::HaveCustomButton1, false); - disconnect(wizard(), SIGNAL(customButtonClicked(int)), - this, SLOT(printButtonClicked())); + disconnect(wizard(), &QWizard::customButtonClicked, + this, &ConclusionPage::printButtonClicked); } } //! [28] diff --git a/examples/widgets/dialogs/sipdialog/dialog.cpp b/examples/widgets/dialogs/sipdialog/dialog.cpp index f57cd094ae..48859ec5ff 100644 --- a/examples/widgets/dialogs/sipdialog/dialog.cpp +++ b/examples/widgets/dialogs/sipdialog/dialog.cpp @@ -89,10 +89,9 @@ Dialog::Dialog() //! [Dialog constructor part4] //! [Dialog constructor part5] - connect(button, SIGNAL(clicked()), - qApp, SLOT(closeAllWindows())); - connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), - this, SLOT(desktopResized(int))); + connect(button, &QAbstractButton::clicked, qApp, &QApplication::closeAllWindows); + connect(QApplication::desktop(), &QDesktopWidget::workAreaResized, + this, &Dialog::desktopResized); } //! [Dialog constructor part5] diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp index 0a1532616c..b28cf0f934 100644 --- a/examples/widgets/dialogs/standarddialogs/dialog.cpp +++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp @@ -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); @@ -180,27 +190,27 @@ Dialog::Dialog(QWidget *parent) QPushButton *errorButton = new QPushButton(tr("QErrorMessage::showM&essage()")); - connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); - connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); - connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); - connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); - connect(multiLineTextButton, SIGNAL(clicked()), this, SLOT(setMultiLineText())); - connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); - connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); - connect(directoryButton, SIGNAL(clicked()), - this, SLOT(setExistingDirectory())); - connect(openFileNameButton, SIGNAL(clicked()), - this, SLOT(setOpenFileName())); - connect(openFileNamesButton, SIGNAL(clicked()), - this, SLOT(setOpenFileNames())); - connect(saveFileNameButton, SIGNAL(clicked()), - this, SLOT(setSaveFileName())); - connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); - connect(informationButton, SIGNAL(clicked()), - this, SLOT(informationMessage())); - connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); - connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); - connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); + connect(integerButton, &QAbstractButton::clicked, this, &Dialog::setInteger); + connect(doubleButton, &QAbstractButton::clicked, this, &Dialog::setDouble); + connect(itemButton, &QAbstractButton::clicked, this, &Dialog::setItem); + connect(textButton, &QAbstractButton::clicked, this, &Dialog::setText); + connect(multiLineTextButton, &QAbstractButton::clicked, this, &Dialog::setMultiLineText); + connect(colorButton, &QAbstractButton::clicked, this, &Dialog::setColor); + connect(fontButton, &QAbstractButton::clicked, this, &Dialog::setFont); + connect(directoryButton, &QAbstractButton::clicked, + this, &Dialog::setExistingDirectory); + connect(openFileNameButton, &QAbstractButton::clicked, + this, &Dialog::setOpenFileName); + connect(openFileNamesButton, &QAbstractButton::clicked, + this, &Dialog::setOpenFileNames); + connect(saveFileNameButton, &QAbstractButton::clicked, + this, &Dialog::setSaveFileName); + connect(criticalButton, &QAbstractButton::clicked, this, &Dialog::criticalMessage); + connect(informationButton, &QAbstractButton::clicked, + this, &Dialog::informationMessage); + connect(questionButton, &QAbstractButton::clicked, this, &Dialog::questionMessage); + connect(warningButton, &QAbstractButton::clicked, this, &Dialog::warningMessage); + connect(errorButton, &QAbstractButton::clicked, this, &Dialog::errorMessage); QWidget *page = new QWidget; QGridLayout *layout = new QGridLayout(page); @@ -242,6 +252,10 @@ Dialog::Dialog(QWidget *parent) layout->addWidget(fontLabel, 0, 1); fontDialogOptionsWidget = new DialogOptionsWidget; fontDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFontDialog::DontUseNativeDialog); + fontDialogOptionsWidget->addCheckBox(tr("Show scalable fonts"), QFontDialog::ScalableFonts); + fontDialogOptionsWidget->addCheckBox(tr("Show non scalable fonts"), QFontDialog::NonScalableFonts); + fontDialogOptionsWidget->addCheckBox(tr("Show monospaced fonts"), QFontDialog::MonospacedFonts); + fontDialogOptionsWidget->addCheckBox(tr("Show proportional fonts"), QFontDialog::ProportionalFonts); fontDialogOptionsWidget->addCheckBox(tr("No buttons") , QFontDialog::NoButtons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); layout->addWidget(fontDialogOptionsWidget, 2, 0, 1 ,2); @@ -266,6 +280,7 @@ Dialog::Dialog(QWidget *parent) fileDialogOptionsWidget->addCheckBox(tr("Do not use sheet"), QFileDialog::DontUseSheet); fileDialogOptionsWidget->addCheckBox(tr("Readonly"), QFileDialog::ReadOnly); fileDialogOptionsWidget->addCheckBox(tr("Hide name filter details"), QFileDialog::HideNameFilterDetails); + fileDialogOptionsWidget->addCheckBox(tr("Do not use custom directory icons (Windows)"), QFileDialog::DontUseCustomDirectoryIcons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 4, 0); layout->addWidget(fileDialogOptionsWidget, 5, 0, 1 ,2); toolbox->addItem(page, tr("File Dialogs")); @@ -286,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() diff --git a/examples/widgets/dialogs/standarddialogs/main.cpp b/examples/widgets/dialogs/standarddialogs/main.cpp index eafd2271df..8a8ee2ac0b 100644 --- a/examples/widgets/dialogs/standarddialogs/main.cpp +++ b/examples/widgets/dialogs/standarddialogs/main.cpp @@ -39,6 +39,8 @@ ****************************************************************************/ #include <QApplication> +#include <QStyleHints> +#include <QDesktopWidget> #include <QTranslator> #include <QLocale> #include <QLibraryInfo> @@ -48,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_"); @@ -58,6 +61,12 @@ int main(int argc, char *argv[]) #endif Dialog dialog; + 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(); diff --git a/examples/widgets/dialogs/tabdialog/tabdialog.cpp b/examples/widgets/dialogs/tabdialog/tabdialog.cpp index ec1a6efbc8..75a7b85e3b 100644 --- a/examples/widgets/dialogs/tabdialog/tabdialog.cpp +++ b/examples/widgets/dialogs/tabdialog/tabdialog.cpp @@ -59,8 +59,8 @@ TabDialog::TabDialog(const QString &fileName, QWidget *parent) //! [1] //! [3] | QDialogButtonBox::Cancel); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); //! [2] //! [3] //! [4] |