mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Add a close button to the tabs.
This commit is contained in:
parent
ee2a55bcbf
commit
24dd0a39d5
@ -3,7 +3,8 @@
|
|||||||
TabWidget::TabWidget(QWidget *parent) :
|
TabWidget::TabWidget(QWidget *parent) :
|
||||||
QTabWidget(parent)
|
QTabWidget(parent)
|
||||||
{
|
{
|
||||||
|
setTabsClosable(true);
|
||||||
|
connect(this, &QTabWidget::tabCloseRequested, this, &TabWidget::closeTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebView* TabWidget::createNewTab(bool setCurrent)
|
WebView* TabWidget::createNewTab(bool setCurrent)
|
||||||
@ -44,3 +45,11 @@ void TabWidget::setIconOf(WebView *webView, const QIcon &icon)
|
|||||||
{
|
{
|
||||||
setTabIcon(indexOf(webView), icon);
|
setTabIcon(indexOf(webView), icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabWidget::closeTab(int index)
|
||||||
|
{
|
||||||
|
auto webview = widget(index);
|
||||||
|
removeTab(index);
|
||||||
|
webview->close();
|
||||||
|
delete webview;
|
||||||
|
}
|
||||||
|
@ -14,6 +14,9 @@ public:
|
|||||||
void openUrl(const QUrl &url, bool newTab);
|
void openUrl(const QUrl &url, bool newTab);
|
||||||
void setTitleOf(WebView* webView, const QString& title);
|
void setTitleOf(WebView* webView, const QString& title);
|
||||||
void setIconOf(WebView* webView, const QIcon& icon);
|
void setIconOf(WebView* webView, const QIcon& icon);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void closeTab(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TABWIDGET_H
|
#endif // TABWIDGET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user