ProjectExplorer: Let the user delete sessions via the "Delete" key

Task-number: QTCREATORBUG-17668
Change-Id: Id827be147627a54953e6495be503c97b31232cf3
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-05-09 15:17:31 +02:00
parent e3def98c00
commit e919a9f545
2 changed files with 14 additions and 3 deletions

View File

@@ -141,5 +141,16 @@ void SessionView::showEvent(QShowEvent *event)
setFocus();
}
void SessionView::keyPressEvent(QKeyEvent *event)
{
if (event->key() != Qt::Key_Delete) {
TreeView::keyPressEvent(event);
return;
}
const QString session = currentSession();
if (!session.isEmpty() && session != "default" && session != SessionManager::activeSession())
deleteCurrentSession();
}
} // namespace Internal
} // namespace ProjectExplorer

View File

@@ -51,15 +51,15 @@ public:
void selectActiveSession();
void selectSession(const QString &sessionName);
protected:
void showEvent(QShowEvent* event) override;
signals:
void activated(const QString &session);
void selected(const QString &session);
void sessionSwitched();
private:
void showEvent(QShowEvent* event) override;
void keyPressEvent(QKeyEvent *event) override;
SessionModel m_sessionModel;
};