From 8f869c301cbfca97ed198efa27a5dc207389f22a Mon Sep 17 00:00:00 2001
From: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Date: Fri, 31 Jul 2009 15:18:46 +0200
Subject: [PATCH] Changed the 'session manager' dialog

There is not much sense to have Ok and Cancel button that just close
the dialog, so instead there should be a Close button and a button to
switch to the currently selected session.

Reviewed-by: dt
---
 src/plugins/projectexplorer/sessiondialog.cpp | 26 ++++++++++---------
 src/plugins/projectexplorer/sessiondialog.h   |  4 +--
 src/plugins/projectexplorer/sessiondialog.ui  |  2 +-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp
index 89b0a489bb3..911131d9e29 100644
--- a/src/plugins/projectexplorer/sessiondialog.cpp
+++ b/src/plugins/projectexplorer/sessiondialog.cpp
@@ -110,6 +110,11 @@ SessionDialog::SessionDialog(SessionManager *sessionManager, const QString &last
 {
     m_ui.setupUi(this);
 
+    QPushButton *switchButton = m_ui.buttonBox->addButton(tr("Switch to session"),
+                                                          QDialogButtonBox::AcceptRole);
+    connect(switchButton, SIGNAL(clicked()),
+            this, SLOT(switchToSession()));
+
     connect(m_ui.btCreateNew, SIGNAL(clicked()),
             this, SLOT(createNew()));
 
@@ -143,18 +148,6 @@ void SessionDialog::updateActions()
     m_ui.btDelete->setEnabled(enableDelete);
 }
 
-void SessionDialog::accept()
-{
-    // do nothing
-    QDialog::accept();
-}
-
-void SessionDialog::reject()
-{
-    // clear list
-    QDialog::reject();
-}
-
 void SessionDialog::createNew()
 {
     NewSessionInputDialog newSessionInputDialog(m_sessionManager->sessions());
@@ -192,6 +185,15 @@ void SessionDialog::remove()
     m_ui.sessionList->addItems(m_sessionManager->sessions());
 }
 
+void SessionDialog::switchToSession()
+{
+    if (m_ui.sessionList->currentItem()) {
+        QString session = m_ui.sessionList->currentItem()->text();
+        m_sessionManager->loadSession(session);
+    }
+    accept();
+}
+
 } // namespace Internal
 } // namespace ProjectExplorer
 
diff --git a/src/plugins/projectexplorer/sessiondialog.h b/src/plugins/projectexplorer/sessiondialog.h
index aed6c1a696b..9116ff731b6 100644
--- a/src/plugins/projectexplorer/sessiondialog.h
+++ b/src/plugins/projectexplorer/sessiondialog.h
@@ -47,13 +47,11 @@ class SessionDialog : public QDialog
 public:
     SessionDialog(SessionManager *sessionManager, const QString &lastSession, bool startup);
 
-    void accept();
-    void reject();
-
 private slots:
     void createNew();
     void clone();
     void remove();
+    void switchToSession();
 
     void updateActions();
 
diff --git a/src/plugins/projectexplorer/sessiondialog.ui b/src/plugins/projectexplorer/sessiondialog.ui
index ad11881aaef..ecc9bbd988b 100644
--- a/src/plugins/projectexplorer/sessiondialog.ui
+++ b/src/plugins/projectexplorer/sessiondialog.ui
@@ -65,7 +65,7 @@
    <item row="1" column="1" colspan="2">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+      <set>QDialogButtonBox::Close</set>
      </property>
     </widget>
    </item>
-- 
GitLab