Detect SSH disconnect via KonsolePart's terminalExited signal
Connect to KonsolePart's terminalExited() signal which fires when the ssh process exits (clean exit, timeout, connection reset). On exit, update status to Disconnected and emit disconnected().
This commit is contained in:
parent
ac239c1943
commit
21adc454b4
|
|
@ -151,13 +151,8 @@ bool SshView::startConnection()
|
|||
return false;
|
||||
}
|
||||
|
||||
// Connect to the terminal's finished signal to detect disconnection
|
||||
connect(m_terminalPart, &KParts::ReadOnlyPart::destroyed, this, [this]() {
|
||||
if (!m_quitting) {
|
||||
setStatus(Disconnected);
|
||||
Q_EMIT disconnected();
|
||||
}
|
||||
});
|
||||
// KonsolePart emits terminalExited() when the process (ssh) exits.
|
||||
connect(m_terminalPart, SIGNAL(terminalExited()), this, SLOT(handleTerminalExited()));
|
||||
|
||||
// Start SSH directly via startProgram for clean process lifecycle.
|
||||
terminalInterface->startProgram(sshPath, sshCommand);
|
||||
|
|
@ -170,6 +165,14 @@ bool SshView::startConnection()
|
|||
return true;
|
||||
}
|
||||
|
||||
void SshView::handleTerminalExited()
|
||||
{
|
||||
if (!m_quitting) {
|
||||
setStatus(Disconnected);
|
||||
Q_EMIT disconnected();
|
||||
}
|
||||
}
|
||||
|
||||
void SshView::startQuittingConnection()
|
||||
{
|
||||
m_quitting = true;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ protected:
|
|||
void handleMouseEvent(QMouseEvent *event) override;
|
||||
void handleLocalClipboardChanged(const QMimeData *data) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleTerminalExited();
|
||||
|
||||
private:
|
||||
bool loadKonsolePart();
|
||||
QStringList buildSshCommand() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue