cutter/src/widgets/JupyterWidget.h

82 lines
1.3 KiB
C
Raw Normal View History

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>
#include <QAbstractButton>
2017-12-13 17:36:00 +00:00
#include "CutterDockWidget.h"
2017-12-13 17:36:00 +00:00
#include "utils/JupyterConnection.h"
namespace Ui
{
class JupyterWidget;
}
class JupyterWebView;
2018-03-02 18:03:12 +00:00
class QTabWidget;
class MainWindow;
2018-03-02 18:03:12 +00:00
class JupyterWidget : public CutterDockWidget
2017-12-13 17:36:00 +00:00
{
Q_OBJECT
public:
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
void openHomeTab();
void tabCloseRequested(int index);
2017-12-13 17:36:00 +00:00
private:
std::unique_ptr<Ui::JupyterWidget> ui;
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
{
Q_OBJECT
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