From 2cd5b448e13c733046e6904df78ff97ac1b28104 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 29 May 2015 17:37:20 +0200 Subject: [PATCH] NewDialog: Simplify code a bit Convert some connects to Qt5-style while at it. Change-Id: Ib5d8af8ccded1005302ad2da3c185c73a8992bd6 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/dialogs/newdialog.cpp | 29 ++++++++------------ src/plugins/coreplugin/dialogs/newdialog.h | 2 +- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index fd4eab448cf..aae3940ed88 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -224,20 +224,15 @@ NewDialog::NewDialog(QWidget *parent) : m_ui->templatesView->setModel(m_filterProxyModel); m_ui->templatesView->setIconSize(QSize(ICON_SIZE, ICON_SIZE)); - connect(m_ui->templateCategoryView->selectionModel(), - SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(currentCategoryChanged(QModelIndex))); + connect(m_ui->templateCategoryView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &NewDialog::currentCategoryChanged); - connect(m_ui->templatesView->selectionModel(), - SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(currentItemChanged(QModelIndex))); + connect(m_ui->templatesView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &NewDialog::currentItemChanged); - connect(m_ui->templatesView, - SIGNAL(doubleClicked(QModelIndex)), - this, SLOT(okButtonClicked())); - - connect(m_okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked())); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_ui->templatesView, &QListView::doubleClicked, this, &NewDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &NewDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &NewDialog::reject); connect(m_ui->comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setSelectedPlatform(QString))); } @@ -453,18 +448,16 @@ void NewDialog::saveState() m_lastCategory = currentItem->data(Qt::UserRole).toString(); } -void NewDialog::okButtonClicked() +void NewDialog::accept() { - if (m_ui->templatesView->currentIndex().isValid()) { - hide(); - saveState(); + saveState(); + QDialog::accept(); + if (m_ui->templatesView->currentIndex().isValid()) { IWizardFactory *wizard = currentWizardFactory(); QTC_ASSERT(wizard, accept(); return); QString path = wizard->runPath(m_defaultLocation); wizard->runWizard(path, ICore::dialogParent(), selectedPlatform(), m_extraVariables); - - close(); } } diff --git a/src/plugins/coreplugin/dialogs/newdialog.h b/src/plugins/coreplugin/dialogs/newdialog.h index aa9ccc12f0b..c18efef58db 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.h +++ b/src/plugins/coreplugin/dialogs/newdialog.h @@ -75,7 +75,7 @@ protected: private slots: void currentCategoryChanged(const QModelIndex &); void currentItemChanged(const QModelIndex &); - void okButtonClicked(); + void accept(); void reject(); void updateOkButton(); void setSelectedPlatform(const QString &platform);