2017-12-13 17:36:00 +00:00
|
|
|
|
|
|
|
#ifndef JUPYTERWIDGET_H
|
|
|
|
#define JUPYTERWIDGET_H
|
|
|
|
|
2018-03-02 13:15:53 +00:00
|
|
|
#ifdef CUTTER_ENABLE_JUPYTER
|
|
|
|
|
2017-12-13 17:36:00 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-03-03 17:12:03 +00:00
|
|
|
#include <QAbstractButton>
|
2017-12-13 17:36:00 +00:00
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2017-12-13 17:36:00 +00:00
|
|
|
#include "utils/JupyterConnection.h"
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class JupyterWidget;
|
2017-12-13 17:36:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class JupyterWebView;
|
2018-03-02 18:03:12 +00:00
|
|
|
class QTabWidget;
|
2018-03-16 21:46:57 +00:00
|
|
|
class MainWindow;
|
2018-03-02 18:03:12 +00:00
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class JupyterWidget : public CutterDockWidget
|
2017-12-13 17:36:00 +00:00
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
Q_OBJECT
|
2017-12-13 17:36:00 +00:00
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
JupyterWidget(MainWindow *main, QAction *action = nullptr);
|
2017-12-13 17:36:00 +00:00
|
|
|
~JupyterWidget();
|
|
|
|
|
2018-03-02 13:15:53 +00:00
|
|
|
#ifdef CUTTER_ENABLE_QTWEBENGINE
|
2017-12-13 17:36:00 +00:00
|
|
|
JupyterWebView *createNewTab();
|
2018-03-02 13:15:53 +00:00
|
|
|
#endif
|
2017-12-13 17:36:00 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void urlReceived(const QString &url);
|
2018-02-22 18:39:20 +00:00
|
|
|
void creationFailed();
|
2017-12-13 17:36:00 +00:00
|
|
|
|
2018-03-03 17:12:03 +00:00
|
|
|
void openHomeTab();
|
|
|
|
void tabCloseRequested(int index);
|
|
|
|
|
2017-12-13 17:36:00 +00:00
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::JupyterWidget> ui;
|
2018-03-03 17:12:03 +00:00
|
|
|
|
|
|
|
QAbstractButton *homeButton;
|
|
|
|
|
|
|
|
void removeTab(int index);
|
|
|
|
void clearTabs();
|
2017-12-13 17:36:00 +00:00
|
|
|
};
|
|
|
|
|
2018-03-02 13:15:53 +00:00
|
|
|
#ifdef CUTTER_ENABLE_QTWEBENGINE
|
|
|
|
|
|
|
|
#include <QWebEngineView>
|
2017-12-13 17:36:00 +00:00
|
|
|
|
|
|
|
class JupyterWebView : public QWebEngineView
|
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
Q_OBJECT
|
2017-12-13 17:36:00 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
JupyterWebView(JupyterWidget *mainWidget, QWidget *parent = nullptr);
|
|
|
|
|
2018-03-02 16:56:59 +00:00
|
|
|
void setTabWidget(QTabWidget *tabWidget);
|
|
|
|
|
2017-12-13 17:36:00 +00:00
|
|
|
protected:
|
|
|
|
QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) override;
|
|
|
|
|
2018-03-02 16:56:59 +00:00
|
|
|
private slots:
|
|
|
|
void onTitleChanged(const QString &title);
|
|
|
|
|
2017-12-13 17:36:00 +00:00
|
|
|
private:
|
|
|
|
JupyterWidget *mainWidget;
|
2018-03-02 16:56:59 +00:00
|
|
|
QTabWidget *tabWidget;
|
|
|
|
|
|
|
|
void updateTitle();
|
2017-12-13 17:36:00 +00:00
|
|
|
};
|
|
|
|
|
2018-03-02 13:15:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-12-13 17:36:00 +00:00
|
|
|
#endif //JUPYTERWIDGET_H
|