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