From 2b8296e93e1e05979b81cc39b28f7bf876d20b73 Mon Sep 17 00:00:00 2001 From: Daniel Teske <daniel.teske@nokia.com> Date: Thu, 7 Jul 2011 14:14:10 +0200 Subject: [PATCH] Add "Switch To" button to new session Task-number: QTCREATORBUG-5310 Change-Id: I16d61be00c8d49957c286cde0b8ca0c5bae69756 Reviewed-on: http://codereview.qt.nokia.com/1308 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com> --- src/plugins/projectexplorer/sessiondialog.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index c136c13a7b1..3046c919b5f 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 -- GitLab