diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index 7dc9d497773..3faa2c603c1 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -139,6 +139,8 @@ void SessionModel::cloneSession(const QString &session) void SessionModel::deleteSession(const QString &session) { + if (!m_manager->confirmSessionDelete(session)) + return; beginResetModel(); m_manager->deleteSession(session); endResetModel(); diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 0116f3578b1..445db5f031a 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -673,6 +673,18 @@ bool SessionManager::renameSession(const QString &original, const QString &newNa return deleteSession(original); } + +/*! + \brief Shows a dialog asking the user to confirm deleting the session \p session +*/ +bool SessionManager::confirmSessionDelete(const QString &session) +{ + return QMessageBox::question(Core::ICore::mainWindow(), + tr("Delete Session"), + tr("Delete session %1?").arg(session), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes; +} + /*! \brief Deletes session name from session list and file from disk. */ diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 2f0a72bea77..bfbc6cf4935 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -73,6 +73,7 @@ public: bool createSession(const QString &session); + bool confirmSessionDelete(const QString &session); bool deleteSession(const QString &session); bool cloneSession(const QString &original, const QString &clone); diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index 8e751e89ce7..75ac0a6af23 100644 --- a/src/plugins/projectexplorer/sessiondialog.cpp +++ b/src/plugins/projectexplorer/sessiondialog.cpp @@ -244,7 +244,11 @@ void SessionDialog::clone() void SessionDialog::remove() { - m_sessionManager->deleteSession(m_ui.sessionList->currentItem()->text()); + const QString name = m_ui.sessionList->currentItem()->text(); + + if (!m_sessionManager->confirmSessionDelete(name)) + return; + m_sessionManager->deleteSession(name); m_ui.sessionList->clear(); addItems(false); markItems();