terminalpanel: Improve Konsole missing message

It now forces the pane to fit its height, and will animate on every appearance.
This commit is contained in:
Oliver Beard 2023-08-23 01:44:21 +01:00 committed by Méven Car
parent 99541a77fa
commit 38342ae820

View file

@ -77,7 +77,10 @@ void TerminalPanel::dockVisibilityChanged()
{ {
// Only react when the DockWidget itself (not some parent) is hidden. This way we don't // Only react when the DockWidget itself (not some parent) is hidden. This way we don't
// respond when e.g. Dolphin is minimized. // respond when e.g. Dolphin is minimized.
if (isHiddenInVisibleWindow() && m_terminal && !hasProgramRunning()) { if (isHiddenInVisibleWindow()) {
if (m_konsolePartMissingMessage) {
m_konsolePartMissingMessage->hide();
} else if (m_terminal && !hasProgramRunning()) {
// Make sure that the following "cd /" command will not affect the view. // Make sure that the following "cd /" command will not affect the view.
disconnect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)), this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString))); disconnect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)), this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString)));
@ -90,6 +93,7 @@ void TerminalPanel::dockVisibilityChanged()
// directory correctly. // directory correctly.
m_konsolePartCurrentDirectory = '/'; m_konsolePartCurrentDirectory = '/';
} }
}
} }
QString TerminalPanel::runningProgramName() const QString TerminalPanel::runningProgramName() const
@ -168,7 +172,8 @@ void TerminalPanel::showEvent(QShowEvent *event)
}); });
} }
} else if (!m_konsolePartMissingMessage) { } else {
if (!m_konsolePartMissingMessage) {
const auto konsoleInstallUrl = QUrl("appstream://org.kde.konsole.desktop"); const auto konsoleInstallUrl = QUrl("appstream://org.kde.konsole.desktop");
const auto konsoleNotInstalledText = i18n( const auto konsoleNotInstalledText = i18n(
"Terminal cannot be shown because Konsole is not installed. " "Terminal cannot be shown because Konsole is not installed. "
@ -184,9 +189,9 @@ void TerminalPanel::showEvent(QShowEvent *event)
m_konsolePartMissingMessage->addAction(installKonsoleAction); m_konsolePartMissingMessage->addAction(installKonsoleAction);
} }
m_layout->addWidget(m_konsolePartMissingMessage); m_layout->addWidget(m_konsolePartMissingMessage);
m_layout->addStretch(); m_layout->setSizeConstraint(QLayout::SetMaximumSize);
QTimer::singleShot(0, m_konsolePartMissingMessage, &KMessageWidget::animatedShow); }
} else {
m_konsolePartMissingMessage->animatedShow(); m_konsolePartMissingMessage->animatedShow();
} }
} }