mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 16:47: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)
|
if (!moduleCodeObject)
|
||||||
{
|
{
|
||||||
qWarning() << "Could not compile cutter_jupyter.";
|
qWarning() << "Could not compile cutter_jupyter.";
|
||||||
|
emit creationFailed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cutterJupyterModule = PyImport_ExecCodeModule("cutter_jupyter", moduleCodeObject);
|
cutterJupyterModule = PyImport_ExecCodeModule("cutter_jupyter", moduleCodeObject);
|
||||||
@ -52,6 +53,7 @@ void JupyterConnection::start()
|
|||||||
if (!cutterJupyterModule)
|
if (!cutterJupyterModule)
|
||||||
{
|
{
|
||||||
qWarning() << "Could not import cutter_jupyter.";
|
qWarning() << "Could not import cutter_jupyter.";
|
||||||
|
emit creationFailed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void urlReceived(const QString &url);
|
void urlReceived(const QString &url);
|
||||||
|
void creationFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PyObject *cutterJupyterModule = nullptr;
|
PyObject *cutterJupyterModule = nullptr;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
/* Return the number of arguments of the application command line */
|
|
||||||
PyObject *api_version(PyObject *self, PyObject *null)
|
PyObject *api_version(PyObject *self, PyObject *null)
|
||||||
{
|
{
|
||||||
Q_UNUSED(self)
|
Q_UNUSED(self)
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#include "JupyterWidget.h"
|
#include "JupyterWidget.h"
|
||||||
|
|
||||||
#include <QWebEngineSettings>
|
#include <QWebEngineSettings>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
JupyterWidget::JupyterWidget(QWidget *parent, Qt::WindowFlags flags) :
|
JupyterWidget::JupyterWidget(QWidget *parent, Qt::WindowFlags flags) :
|
||||||
QDockWidget(parent, flags),
|
QDockWidget(parent, flags),
|
||||||
@ -13,6 +16,7 @@ JupyterWidget::JupyterWidget(QWidget *parent, Qt::WindowFlags flags) :
|
|||||||
|
|
||||||
jupyter = new JupyterConnection(this);
|
jupyter = new JupyterConnection(this);
|
||||||
connect(jupyter, &JupyterConnection::urlReceived, this, &JupyterWidget::urlReceived);
|
connect(jupyter, &JupyterConnection::urlReceived, this, &JupyterWidget::urlReceived);
|
||||||
|
connect(jupyter, &JupyterConnection::creationFailed, this, &JupyterWidget::creationFailed);
|
||||||
jupyter->start();
|
jupyter->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,13 +31,22 @@ JupyterWebView *JupyterWidget::createNewTab()
|
|||||||
return webView;
|
return webView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JupyterWidget::urlReceived(const QString &url)
|
void JupyterWidget::urlReceived(const QString &url)
|
||||||
{
|
{
|
||||||
createNewTab()->load(QUrl(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)
|
JupyterWebView::JupyterWebView(JupyterWidget *mainWidget, QWidget *parent) : QWebEngineView(parent)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void urlReceived(const QString &url);
|
void urlReceived(const QString &url);
|
||||||
|
void creationFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::JupyterWidget> ui;
|
std::unique_ptr<Ui::JupyterWidget> ui;
|
||||||
|
Loading…
Reference in New Issue
Block a user