forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Jarek Kobus
parent
1f3896e8af
commit
2b8296e93e
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user