forked from qt-creator/qt-creator
Session: Make Switch to button work when cloning sessions
Make Switch to button work in dialog shown when cloning sessions in the session manager. Task-number: QTCREATORBUG-10701 Change-Id: I6901a6cb842eabbfa38b25f3cc4925bec43c61a4 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -186,6 +186,17 @@ void SessionDialog::markItems()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionDialog::addSessionToUi(const QString &name, bool switchTo)
|
||||||
|
{
|
||||||
|
m_ui.sessionList->clear();
|
||||||
|
QStringList sessions = SessionManager::sessions();
|
||||||
|
m_ui.sessionList->addItems(sessions);
|
||||||
|
m_ui.sessionList->setCurrentRow(sessions.indexOf(name));
|
||||||
|
markItems();
|
||||||
|
if (switchTo)
|
||||||
|
switchToSession();
|
||||||
|
}
|
||||||
|
|
||||||
void SessionDialog::updateActions()
|
void SessionDialog::updateActions()
|
||||||
{
|
{
|
||||||
if (m_ui.sessionList->currentItem()) {
|
if (m_ui.sessionList->currentItem()) {
|
||||||
@@ -209,18 +220,12 @@ void SessionDialog::createNew()
|
|||||||
newSessionInputDialog.setWindowTitle(tr("New session name"));
|
newSessionInputDialog.setWindowTitle(tr("New session name"));
|
||||||
|
|
||||||
if (newSessionInputDialog.exec() == QDialog::Accepted) {
|
if (newSessionInputDialog.exec() == QDialog::Accepted) {
|
||||||
QString newSession = newSessionInputDialog.value();
|
QString sessionName = newSessionInputDialog.value();
|
||||||
if (newSession.isEmpty() || SessionManager::sessions().contains(newSession))
|
if (sessionName.isEmpty() || SessionManager::sessions().contains(sessionName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SessionManager::createSession(newSession);
|
SessionManager::createSession(sessionName);
|
||||||
m_ui.sessionList->clear();
|
addSessionToUi(sessionName, newSessionInputDialog.isSwitchToRequested());
|
||||||
QStringList sessions = SessionManager::sessions();
|
|
||||||
m_ui.sessionList->addItems(sessions);
|
|
||||||
m_ui.sessionList->setCurrentRow(sessions.indexOf(newSession));
|
|
||||||
markItems();
|
|
||||||
if (newSessionInputDialog.isSwitchToRequested())
|
|
||||||
switchToSession();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,13 +237,8 @@ void SessionDialog::clone()
|
|||||||
|
|
||||||
if (newSessionInputDialog.exec() == QDialog::Accepted) {
|
if (newSessionInputDialog.exec() == QDialog::Accepted) {
|
||||||
QString newSession = newSessionInputDialog.value();
|
QString newSession = newSessionInputDialog.value();
|
||||||
if (SessionManager::cloneSession(m_ui.sessionList->currentItem()->text(), newSession)) {
|
if (SessionManager::cloneSession(m_ui.sessionList->currentItem()->text(), newSession))
|
||||||
m_ui.sessionList->clear();
|
addSessionToUi(newSession, newSessionInputDialog.isSwitchToRequested());
|
||||||
QStringList sessions = SessionManager::sessions();
|
|
||||||
m_ui.sessionList->addItems(sessions);
|
|
||||||
m_ui.sessionList->setCurrentRow(sessions.indexOf(newSession));
|
|
||||||
markItems();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void addItems(bool setDefaultSession);
|
void addItems(bool setDefaultSession);
|
||||||
void markItems();
|
void markItems();
|
||||||
|
void addSessionToUi(const QString &name, bool switchTo);
|
||||||
Ui::SessionDialog m_ui;
|
Ui::SessionDialog m_ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user