forked from qt-creator/qt-creator
SessionNameInputDialog: allow to setup title and button
Change-Id: Ifd08f51b12748814b50192e54789d9b036aaaca3 Task-number: QTCREATORBUG-18272 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -188,14 +188,23 @@ void SessionModel::resetSessions()
|
||||
|
||||
void SessionModel::newSession()
|
||||
{
|
||||
runNewSessionDialog("", [](const QString &newName) {
|
||||
SessionNameInputDialog sessionInputDialog;
|
||||
sessionInputDialog.setWindowTitle(tr("New Session Name"));
|
||||
sessionInputDialog.setActionText(tr("&Create"), tr("Create and &Open"));
|
||||
|
||||
runSessionNameInputDialog(&sessionInputDialog, [](const QString &newName) {
|
||||
SessionManager::createSession(newName);
|
||||
});
|
||||
}
|
||||
|
||||
void SessionModel::cloneSession(const QString &session)
|
||||
{
|
||||
runNewSessionDialog(session + " (2)", [session](const QString &newName) {
|
||||
SessionNameInputDialog sessionInputDialog;
|
||||
sessionInputDialog.setWindowTitle(tr("New Session Name"));
|
||||
sessionInputDialog.setActionText(tr("&Clone"), tr("Clone and &Open"));
|
||||
sessionInputDialog.setValue(session + " (2)");
|
||||
|
||||
runSessionNameInputDialog(&sessionInputDialog, [session](const QString &newName) {
|
||||
SessionManager::cloneSession(session, newName);
|
||||
});
|
||||
}
|
||||
@@ -211,7 +220,12 @@ void SessionModel::deleteSession(const QString &session)
|
||||
|
||||
void SessionModel::renameSession(const QString &session)
|
||||
{
|
||||
runNewSessionDialog(session, [session](const QString &newName) {
|
||||
SessionNameInputDialog sessionInputDialog;
|
||||
sessionInputDialog.setWindowTitle(tr("Rename Session"));
|
||||
sessionInputDialog.setActionText(tr("&Rename"), tr("Rename and &Open"));
|
||||
sessionInputDialog.setValue(session);
|
||||
|
||||
runSessionNameInputDialog(&sessionInputDialog, [session](const QString &newName) {
|
||||
SessionManager::renameSession(session, newName);
|
||||
});
|
||||
}
|
||||
@@ -222,21 +236,17 @@ void SessionModel::switchToSession(const QString &session)
|
||||
emit sessionSwitched();
|
||||
}
|
||||
|
||||
void SessionModel::runNewSessionDialog(const QString &suggestedName, std::function<void(const QString &)> createSession)
|
||||
void SessionModel::runSessionNameInputDialog(SessionNameInputDialog *sessionInputDialog, std::function<void(const QString &)> createSession)
|
||||
{
|
||||
SessionNameInputDialog newSessionInputDialog;
|
||||
newSessionInputDialog.setWindowTitle(tr("New Session Name"));
|
||||
newSessionInputDialog.setValue(suggestedName);
|
||||
|
||||
if (newSessionInputDialog.exec() == QDialog::Accepted) {
|
||||
QString newSession = newSessionInputDialog.value();
|
||||
if (sessionInputDialog->exec() == QDialog::Accepted) {
|
||||
QString newSession = sessionInputDialog->value();
|
||||
if (newSession.isEmpty() || SessionManager::sessions().contains(newSession))
|
||||
return;
|
||||
beginResetModel();
|
||||
createSession(newSession);
|
||||
endResetModel();
|
||||
|
||||
if (newSessionInputDialog.isSwitchToRequested())
|
||||
if (sessionInputDialog->isSwitchToRequested())
|
||||
switchToSession(newSession);
|
||||
emit sessionCreated(newSession);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user