diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index c136c13a7b15f20097594ed41f342ff4757e8026..3046c919b5fc52e21ba1ce272dafdc26c7f08278 100644 --- a/src/plugins/projectexplorer/sessiondialog.cpp +++ b/src/plugins/projectexplorer/sessiondialog.cpp @@ -94,13 +94,19 @@ public: void setValue(const QString &value); QString value() const; + bool isSwitchToRequested() const; + +private slots: + void clicked(QAbstractButton *button); private: QLineEdit *m_newSessionLineEdit; + QPushButton *m_switchToButton; + bool m_usedSwitchTo; }; SessionNameInputDialog::SessionNameInputDialog(const QStringList &sessions, QWidget *parent) - : QDialog(parent) + : QDialog(parent), m_usedSwitchTo(false) { QVBoxLayout *hlayout = new QVBoxLayout(this); QLabel *label = new QLabel(tr("Enter the name of the session:"), this); @@ -109,8 +115,10 @@ SessionNameInputDialog::SessionNameInputDialog(const QStringList &sessions, QWid m_newSessionLineEdit->setValidator(new SessionValidator(this, sessions)); hlayout->addWidget(m_newSessionLineEdit); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); + m_switchToButton = buttons->addButton(tr("Switch to"), QDialogButtonBox::AcceptRole); connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(clicked(QAbstractButton*))); hlayout->addWidget(buttons); setLayout(hlayout); } @@ -125,6 +133,17 @@ 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; +} + SessionDialog::SessionDialog(SessionManager *sessionManager) : m_sessionManager(sessionManager) @@ -223,6 +242,9 @@ void SessionDialog::createNew() m_ui.sessionList->addItems(sessions); m_ui.sessionList->setCurrentRow(sessions.indexOf(newSession)); markItems(); + if (newSessionInputDialog.isSwitchToRequested()) { + switchToSession(); + } } } @@ -272,6 +294,7 @@ void SessionDialog::switchToSession() m_sessionManager->loadSession(session); markItems(); updateActions(); + reject(); } } // namespace Internal