Commit bc83609f authored by Alexander Semke's avatar Alexander Semke
Browse files

When switching between the different worksheets, update the status bar

to properly show the status of the current worksheet.
parent c71ffbcb
Pipeline #50948 passed with stage
in 25 minutes and 31 seconds
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com> Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/ */
#include "cantor.h" #include "cantor.h"
#include "lib/session.h"
#include <cassert> #include <cassert>
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QPushButton> #include <QPushButton>
#include <QRegularExpression> #include <QRegularExpression>
#include <QStatusBar>
#include <QGraphicsView> #include <QGraphicsView>
#include "lib/backend.h" #include "lib/backend.h"
...@@ -69,8 +71,8 @@ CantorShell::CantorShell() : KParts::MainWindow(), m_part(nullptr), m_panelHandl ...@@ -69,8 +71,8 @@ CantorShell::CantorShell() : KParts::MainWindow(), m_part(nullptr), m_panelHandl
m_tabWidget->setDocumentMode(true); m_tabWidget->setDocumentMode(true);
setCentralWidget(m_tabWidget); setCentralWidget(m_tabWidget);
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(activateWorksheet(int))); connect(m_tabWidget, &QTabWidget::currentChanged, this, &CantorShell::activateWorksheet);
connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(m_tabWidget, &QTabWidget::tabCloseRequested, this, &CantorShell::closeTab);
// apply the saved mainwindow settings, if any, and ask the mainwindow // apply the saved mainwindow settings, if any, and ask the mainwindow
// to automatically save settings if changed: window size, toolbar // to automatically save settings if changed: window size, toolbar
...@@ -431,18 +433,39 @@ void CantorShell::activateWorksheet(int index) ...@@ -431,18 +433,39 @@ void CantorShell::activateWorksheet(int index)
m_pluginsStates[m_part] = states; m_pluginsStates[m_part] = states;
} }
m_part = findPart(m_tabWidget->widget(index)); if (index != -1)
if(m_part)
{ {
createGUI(m_part); m_part = findPart(m_tabWidget->widget(index));
if(m_part)
{
createGUI(m_part);
updateWindowTitle(m_part->url().fileName()); //update the status bar
updatePanel(); auto* wa = m_part->findChild<Cantor::WorksheetAccessInterface*>(Cantor::WorksheetAccessInterface::Name);
} if (wa->session())
else {
qDebug()<<"selected part doesn't exist"; auto status = wa->session()->status();
switch (status) {
case Cantor::Session::Running:
statusBar()->showMessage(i18n("Calculating..."));
break;
case Cantor::Session::Done:
statusBar()->showMessage(i18n("Ready"));
break;
case Cantor::Session::Disable:
statusBar()->showMessage(QString());
break;
}
}
updateWindowTitle(m_part->url().fileName());
updatePanel();
}
else
qDebug()<<"selected part doesn't exist";
m_tabWidget->setCurrentIndex(index); m_tabWidget->setCurrentIndex(index);
}
} }
void CantorShell::setTabCaption(const QString& caption, const QIcon& icon) void CantorShell::setTabCaption(const QString& caption, const QIcon& icon)
......
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