gui: add right-click context menu with Kill action for sessions
- Add killSession(sessionId) Q_INVOKABLE to Ollie9pClient - Accept right button in session tree MouseArea - Context menu with Kill option on right-click - MenuItem resolves session ID via parent chain
This commit is contained in:
parent
998efc15c5
commit
612adb03f8
22
gui/main.qml
22
gui/main.qml
|
|
@ -533,9 +533,15 @@ ApplicationWindow {
|
|||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
hoverEnabled: false
|
||||
onClicked: {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
if (type === "session") {
|
||||
sessionCtxMenu.popup()
|
||||
}
|
||||
return
|
||||
}
|
||||
if (renamingIndex >= 0) return
|
||||
if (type === "session") {
|
||||
toggleExpand(parent.modelIndex)
|
||||
|
|
@ -548,6 +554,20 @@ ApplicationWindow {
|
|||
startRename(parent.modelIndex)
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: sessionCtxMenu
|
||||
MenuItem {
|
||||
text: "Kill"
|
||||
icon.color: "#f44336"
|
||||
onClicked: {
|
||||
var item = sessionTreeModel.get(parent.parent.parent.modelIndex)
|
||||
if (item && item.type === "session")
|
||||
ollie.killSession(item.id)
|
||||
ollie.refreshSessions()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
|
|
|
|||
|
|
@ -160,6 +160,21 @@ bool Ollie9pClient::kill()
|
|||
return proc.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool Ollie9pClient::killSession(const QString &sessionId)
|
||||
{
|
||||
if (sessionId.isEmpty()) return false;
|
||||
QStringList agents = getAgents(sessionId);
|
||||
if (agents.isEmpty()) return false;
|
||||
QString path = "session/" + sessionId + "/agent/" + agents.first() + "/ctl";
|
||||
QProcess proc;
|
||||
proc.start(ninepBin(), {"-a", serverAddr(), "write", path});
|
||||
proc.waitForStarted(3000);
|
||||
proc.write("kill");
|
||||
proc.closeWriteChannel();
|
||||
proc.waitForFinished(3000);
|
||||
return proc.exitCode() == 0;
|
||||
}
|
||||
|
||||
QString Ollie9pClient::getConfig()
|
||||
{
|
||||
if (m_activeSessionId.isEmpty()) return {};
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public:
|
|||
Q_INVOKABLE bool submit(const QString &prompt);
|
||||
Q_INVOKABLE bool interrupt();
|
||||
Q_INVOKABLE bool kill();
|
||||
Q_INVOKABLE bool killSession(const QString &sessionId);
|
||||
Q_INVOKABLE QString getConfig();
|
||||
Q_INVOKABLE QStringList getAgents(const QString &sessionId);
|
||||
Q_INVOKABLE void setActiveAgentId(const QString &agentId);
|
||||
|
|
|
|||
Reference in New Issue