From 4f40d69c9292bbb2184e7f292fcb3455cfdb17f2 Mon Sep 17 00:00:00 2001 From: Nikita Sirgienko Date: Fri, 21 Feb 2020 14:43:22 +0300 Subject: [PATCH] Fix problem with missing backend icon for created sessions --- src/cantor.cpp | 8 +++++--- src/cantor_part.cpp | 8 ++++---- src/cantor_part.h | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cantor.cpp b/src/cantor.cpp index d99e6482..aea5659a 100644 --- a/src/cantor.cpp +++ b/src/cantor.cpp @@ -351,6 +351,9 @@ void CantorShell::addWorksheet(const QString& backendName) // Setting focus on worksheet view, because Qt clear focus of added widget inside addTab // This fix https://bugs.kde.org/show_bug.cgi?id=395976 part->widget()->findChild()->setFocus(); + + // Force run updateCaption for getting proper backend icon + QMetaObject::invokeMethod(part, "updateCaption"); } else { @@ -405,12 +408,11 @@ void CantorShell::activateWorksheet(int index) void CantorShell::setTabCaption(const QString& caption, const QIcon& icon) { - if (caption.isEmpty()) return; - KParts::ReadWritePart* part=dynamic_cast(sender()); if (part) { - m_tabWidget->setTabText(m_tabWidget->indexOf(part->widget()), caption); + if (!caption.isEmpty()) + m_tabWidget->setTabText(m_tabWidget->indexOf(part->widget()), caption); m_tabWidget->setTabIcon(m_tabWidget->indexOf(part->widget()), icon); } } diff --git a/src/cantor_part.cpp b/src/cantor_part.cpp index e8b4e104..503ef6f6 100644 --- a/src/cantor_part.cpp +++ b/src/cantor_part.cpp @@ -724,11 +724,11 @@ void CantorPart::updateCaption() //strip away the extension filename=filename.left(filename.lastIndexOf(QLatin1Char('.'))); - if (filename.isEmpty()) - filename = i18n("Unnamed"); - if (!m_worksheet->isReadOnly()) - emit setCaption(filename, QIcon::fromTheme(m_worksheet->session()->backend()->icon())); + { + if (m_worksheet->session()) + emit setCaption(filename, QIcon::fromTheme(m_worksheet->session()->backend()->icon())); + } else emit setCaption(filename+QLatin1Char(' ') + i18n("[read-only]"), QIcon()); } diff --git a/src/cantor_part.h b/src/cantor_part.h index ef68e789..452198ac 100644 --- a/src/cantor_part.h +++ b/src/cantor_part.h @@ -84,6 +84,9 @@ Q_SIGNALS: void showHelp(const QString& help); void worksheetSave(const QUrl& url); +public Q_SLOTS: + void updateCaption(); + protected: /** * This must be implemented by each part @@ -123,7 +126,6 @@ protected Q_SLOTS: void worksheetSessionLoginStarted(); void worksheetSessionLoginDone(); void initialized(); - void updateCaption(); void pluginsChanged(); void runCommand(const QString& value); -- GitLab