Commit 4f40d69c authored by Nikita Sirgienko's avatar Nikita Sirgienko

Fix problem with missing backend icon for created sessions

parent 83575703
...@@ -351,6 +351,9 @@ void CantorShell::addWorksheet(const QString& backendName) ...@@ -351,6 +351,9 @@ void CantorShell::addWorksheet(const QString& backendName)
// Setting focus on worksheet view, because Qt clear focus of added widget inside addTab // 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 // This fix https://bugs.kde.org/show_bug.cgi?id=395976
part->widget()->findChild<QGraphicsView*>()->setFocus(); part->widget()->findChild<QGraphicsView*>()->setFocus();
// Force run updateCaption for getting proper backend icon
QMetaObject::invokeMethod(part, "updateCaption");
} }
else else
{ {
...@@ -405,12 +408,11 @@ void CantorShell::activateWorksheet(int index) ...@@ -405,12 +408,11 @@ void CantorShell::activateWorksheet(int index)
void CantorShell::setTabCaption(const QString& caption, const QIcon& icon) void CantorShell::setTabCaption(const QString& caption, const QIcon& icon)
{ {
if (caption.isEmpty()) return;
KParts::ReadWritePart* part=dynamic_cast<KParts::ReadWritePart*>(sender()); KParts::ReadWritePart* part=dynamic_cast<KParts::ReadWritePart*>(sender());
if (part) 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); m_tabWidget->setTabIcon(m_tabWidget->indexOf(part->widget()), icon);
} }
} }
......
...@@ -724,11 +724,11 @@ void CantorPart::updateCaption() ...@@ -724,11 +724,11 @@ void CantorPart::updateCaption()
//strip away the extension //strip away the extension
filename=filename.left(filename.lastIndexOf(QLatin1Char('.'))); filename=filename.left(filename.lastIndexOf(QLatin1Char('.')));
if (filename.isEmpty())
filename = i18n("Unnamed");
if (!m_worksheet->isReadOnly()) 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 else
emit setCaption(filename+QLatin1Char(' ') + i18n("[read-only]"), QIcon()); emit setCaption(filename+QLatin1Char(' ') + i18n("[read-only]"), QIcon());
} }
......
...@@ -84,6 +84,9 @@ Q_SIGNALS: ...@@ -84,6 +84,9 @@ Q_SIGNALS:
void showHelp(const QString& help); void showHelp(const QString& help);
void worksheetSave(const QUrl& url); void worksheetSave(const QUrl& url);
public Q_SLOTS:
void updateCaption();
protected: protected:
/** /**
* This must be implemented by each part * This must be implemented by each part
...@@ -123,7 +126,6 @@ protected Q_SLOTS: ...@@ -123,7 +126,6 @@ protected Q_SLOTS:
void worksheetSessionLoginStarted(); void worksheetSessionLoginStarted();
void worksheetSessionLoginDone(); void worksheetSessionLoginDone();
void initialized(); void initialized();
void updateCaption();
void pluginsChanged(); void pluginsChanged();
void runCommand(const QString& value); void runCommand(const QString& value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment