Commit 2b8296e9 authored by Daniel Teske's avatar Daniel Teske Committed by Jarek Kobus
Browse files

Add "Switch To" button to new session

Task-number: QTCREATORBUG-5310
Change-Id: I16d61be00c8d49957c286cde0b8ca0c5bae69756
Reviewed-on: http://codereview.qt.nokia.com/1308

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarJarek Kobus <jaroslaw.kobus@nokia.com>
parent 1f3896e8
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment