From 2100a7a5c85931d46b72d391faa3d136d4401010 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Sat, 19 Jan 2019 08:11:26 -0700 Subject: Ask for confirmation when Closing Dolphin windows with a terminal panel running a program Summary: Ask for confirmation when Closing Dolphin windows with a terminal panel running a program. FEATURE: 304816 FIXED-IN: 19.04.0 Test Plan: # Open terminal panel # Run `watch ls` # Close Dolphin # Observe confirmation # Disable confirmation # Repeat, observe no confirmation # Enable confirmation in the settings # Repeat, observe a confirmation Reviewers: #dolphin, markg, elvisangelaccio, rominf Reviewed By: #dolphin, elvisangelaccio Subscribers: kfm-devel, elvisangelaccio, markg, ngraham, rkflx, broulik, #dolphin Tags: #dolphin Differential Revision: https://phabricator.kde.org/D10960 --- src/panels/terminal/terminalpanel.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/panels/terminal/terminalpanel.cpp') diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index b6c30c29c..3377bab24 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -79,12 +79,12 @@ void TerminalPanel::terminalExited() emit hideTerminalPanel(); } -bool TerminalPanel::isHiddenInVisibleWindow() +bool TerminalPanel::isHiddenInVisibleWindow() const { return parentWidget() && parentWidget()->isHidden() && m_terminal - && (m_terminal->foregroundProcessId() == -1); + && !hasProgramRunning(); } void TerminalPanel::dockVisibilityChanged() @@ -107,13 +107,23 @@ void TerminalPanel::dockVisibilityChanged() } } +QString TerminalPanel::runningProgramName() const +{ + return m_terminal ? m_terminal->foregroundProcessName() : QString(); +} + +bool TerminalPanel::hasProgramRunning() const +{ + return m_terminal && (m_terminal->foregroundProcessId() != -1); +} + bool TerminalPanel::urlChanged() { if (!url().isValid()) { return false; } - const bool sendInput = m_terminal && (m_terminal->foregroundProcessId() == -1) && isVisible(); + const bool sendInput = m_terminal && !hasProgramRunning() && isVisible(); if (sendInput) { changeDir(url()); } -- cgit v1.3