diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index 7b926a11109..46c65527dc0 100644 --- a/src/plugins/projectexplorer/sessiondialog.cpp +++ b/src/plugins/projectexplorer/sessiondialog.cpp @@ -78,21 +78,23 @@ void SessionValidator::fixup(QString &input) const input = copy; } -SessionNameInputDialog::SessionNameInputDialog(const QStringList &sessions, QWidget *parent) - : QDialog(parent), m_usedSwitchTo(false) +SessionNameInputDialog::SessionNameInputDialog(QWidget *parent) + : QDialog(parent) { auto hlayout = new QVBoxLayout(this); auto label = new QLabel(tr("Enter the name of the session:"), this); hlayout->addWidget(label); m_newSessionLineEdit = new QLineEdit(this); - m_newSessionLineEdit->setValidator(new SessionValidator(this, sessions)); + m_newSessionLineEdit->setValidator(new SessionValidator(this, SessionManager::sessions())); hlayout->addWidget(m_newSessionLineEdit); auto buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); buttons->button(QDialogButtonBox::Ok)->setText(tr("&Create")); m_switchToButton = buttons->addButton(tr("Create and &Open"), QDialogButtonBox::AcceptRole); + connect(m_switchToButton, &QPushButton::clicked, [this]() { + m_usedSwitchTo = true; + }); connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(buttons, &QDialogButtonBox::clicked, this, &SessionNameInputDialog::clicked); hlayout->addWidget(buttons); setLayout(hlayout); } @@ -107,12 +109,6 @@ QString SessionNameInputDialog::value() const return m_newSessionLineEdit->text(); } -void SessionNameInputDialog::clicked(QAbstractButton *button) -{ - if (button == m_switchToButton) - m_usedSwitchTo = true; -} - bool SessionNameInputDialog::isSwitchToRequested() const { return m_usedSwitchTo; diff --git a/src/plugins/projectexplorer/sessiondialog.h b/src/plugins/projectexplorer/sessiondialog.h index c9ee6e15f6f..576c9b4a7e1 100644 --- a/src/plugins/projectexplorer/sessiondialog.h +++ b/src/plugins/projectexplorer/sessiondialog.h @@ -59,18 +59,16 @@ class SessionNameInputDialog : public QDialog Q_OBJECT public: - explicit SessionNameInputDialog(const QStringList &sessions, QWidget *parent = nullptr); + explicit SessionNameInputDialog(QWidget *parent = nullptr); void setValue(const QString &value); QString value() const; bool isSwitchToRequested() const; private: - void clicked(QAbstractButton *button); - - QLineEdit *m_newSessionLineEdit; - QPushButton *m_switchToButton; - bool m_usedSwitchTo; + QLineEdit *m_newSessionLineEdit = nullptr; + QPushButton *m_switchToButton = nullptr; + bool m_usedSwitchTo = false; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/sessionmodel.cpp b/src/plugins/projectexplorer/sessionmodel.cpp index 1f42b8cc00d..38f9b8ed7d4 100644 --- a/src/plugins/projectexplorer/sessionmodel.cpp +++ b/src/plugins/projectexplorer/sessionmodel.cpp @@ -224,7 +224,7 @@ void SessionModel::switchToSession(const QString &session) void SessionModel::runNewSessionDialog(const QString &suggestedName, std::function createSession) { - SessionNameInputDialog newSessionInputDialog(SessionManager::sessions(), nullptr); + SessionNameInputDialog newSessionInputDialog; newSessionInputDialog.setWindowTitle(tr("New Session Name")); newSessionInputDialog.setValue(suggestedName);