mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Jupyter Tab Titles
This commit is contained in:
parent
7914deb887
commit
a30579a536
@ -33,6 +33,7 @@ JupyterWebView *JupyterWidget::createNewTab()
|
|||||||
{
|
{
|
||||||
auto webView = new JupyterWebView(this);
|
auto webView = new JupyterWebView(this);
|
||||||
ui->tabWidget->addTab(webView, "Tab");
|
ui->tabWidget->addTab(webView, "Tab");
|
||||||
|
webView->setTabWidget(ui->tabWidget);
|
||||||
return webView;
|
return webView;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -73,6 +74,15 @@ void JupyterWidget::creationFailed()
|
|||||||
JupyterWebView::JupyterWebView(JupyterWidget *mainWidget, QWidget *parent) : QWebEngineView(parent)
|
JupyterWebView::JupyterWebView(JupyterWidget *mainWidget, QWidget *parent) : QWebEngineView(parent)
|
||||||
{
|
{
|
||||||
this->mainWidget = mainWidget;
|
this->mainWidget = mainWidget;
|
||||||
|
this->tabWidget = nullptr;
|
||||||
|
|
||||||
|
connect(this, &QWebEngineView::titleChanged, this, &JupyterWebView::onTitleChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JupyterWebView::setTabWidget(QTabWidget *tabWidget)
|
||||||
|
{
|
||||||
|
this->tabWidget = tabWidget;
|
||||||
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWebEngineView *JupyterWebView::createWindow(QWebEnginePage::WebWindowType type)
|
QWebEngineView *JupyterWebView::createWindow(QWebEnginePage::WebWindowType type)
|
||||||
@ -85,6 +95,27 @@ QWebEngineView *JupyterWebView::createWindow(QWebEnginePage::WebWindowType type)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JupyterWebView::onTitleChanged(const QString &)
|
||||||
|
{
|
||||||
|
updateTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JupyterWebView::updateTitle()
|
||||||
|
{
|
||||||
|
if (!tabWidget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString title = this->title();
|
||||||
|
if (title.isEmpty())
|
||||||
|
{
|
||||||
|
title = tr("Jupyter");
|
||||||
|
}
|
||||||
|
tabWidget->setTabText(tabWidget->indexOf(this), title);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,11 +48,19 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
JupyterWebView(JupyterWidget *mainWidget, QWidget *parent = nullptr);
|
JupyterWebView(JupyterWidget *mainWidget, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void setTabWidget(QTabWidget *tabWidget);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) override;
|
QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onTitleChanged(const QString &title);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JupyterWidget *mainWidget;
|
JupyterWidget *mainWidget;
|
||||||
|
QTabWidget *tabWidget;
|
||||||
|
|
||||||
|
void updateTitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user