mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 08:37:26 +00:00
Added an error tab when Jupyter fails
This commit is contained in:
parent
b9b903052c
commit
d23cc71b79
@ -45,6 +45,7 @@ void JupyterConnection::start()
|
||||
if (!moduleCodeObject)
|
||||
{
|
||||
qWarning() << "Could not compile cutter_jupyter.";
|
||||
emit creationFailed();
|
||||
return;
|
||||
}
|
||||
cutterJupyterModule = PyImport_ExecCodeModule("cutter_jupyter", moduleCodeObject);
|
||||
@ -52,6 +53,7 @@ void JupyterConnection::start()
|
||||
if (!cutterJupyterModule)
|
||||
{
|
||||
qWarning() << "Could not import cutter_jupyter.";
|
||||
emit creationFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
|
||||
signals:
|
||||
void urlReceived(const QString &url);
|
||||
void creationFailed();
|
||||
|
||||
private:
|
||||
PyObject *cutterJupyterModule = nullptr;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include <QFile>
|
||||
|
||||
/* Return the number of arguments of the application command line */
|
||||
PyObject *api_version(PyObject *self, PyObject *null)
|
||||
{
|
||||
Q_UNUSED(self)
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include "JupyterWidget.h"
|
||||
|
||||
#include <QWebEngineSettings>
|
||||
#include <QTabWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
JupyterWidget::JupyterWidget(QWidget *parent, Qt::WindowFlags flags) :
|
||||
QDockWidget(parent, flags),
|
||||
@ -13,6 +16,7 @@ JupyterWidget::JupyterWidget(QWidget *parent, Qt::WindowFlags flags) :
|
||||
|
||||
jupyter = new JupyterConnection(this);
|
||||
connect(jupyter, &JupyterConnection::urlReceived, this, &JupyterWidget::urlReceived);
|
||||
connect(jupyter, &JupyterConnection::creationFailed, this, &JupyterWidget::creationFailed);
|
||||
jupyter->start();
|
||||
}
|
||||
|
||||
@ -27,13 +31,22 @@ JupyterWebView *JupyterWidget::createNewTab()
|
||||
return webView;
|
||||
}
|
||||
|
||||
|
||||
void JupyterWidget::urlReceived(const QString &url)
|
||||
{
|
||||
createNewTab()->load(QUrl(url));
|
||||
}
|
||||
|
||||
|
||||
void JupyterWidget::creationFailed()
|
||||
{
|
||||
QWidget *failPage = new QWidget(this);
|
||||
QLabel *label = new QLabel(failPage);
|
||||
label->setText(tr("An error occurred while opening jupyter. Make sure Jupyter is installed system-wide."));
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
layout->addWidget(label);
|
||||
layout->setAlignment(label, Qt::AlignCenter);
|
||||
failPage->setLayout(layout);
|
||||
ui->tabWidget->addTab(failPage, tr("Error"));
|
||||
}
|
||||
|
||||
JupyterWebView::JupyterWebView(JupyterWidget *mainWidget, QWidget *parent) : QWebEngineView(parent)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void urlReceived(const QString &url);
|
||||
void creationFailed();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::JupyterWidget> ui;
|
||||
|
Loading…
Reference in New Issue
Block a user