mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 03:58:56 -04:00
Merge pull request #716 from kiwix/issue636
This commit is contained in:
commit
0e0c03e515
@ -26,7 +26,7 @@ TabBar::TabBar(QWidget *parent) :
|
|||||||
|
|
||||||
connect(app->getAction(KiwixApp::NewTabAction), &QAction::triggered,
|
connect(app->getAction(KiwixApp::NewTabAction), &QAction::triggered,
|
||||||
this, [=]() {
|
this, [=]() {
|
||||||
this->createNewTab(true);
|
this->createNewTab(true, false);
|
||||||
auto topWidget = KiwixApp::instance()->getMainWindow()->getTopWidget();
|
auto topWidget = KiwixApp::instance()->getMainWindow()->getTopWidget();
|
||||||
topWidget->getSearchBar().setFocus(Qt::MouseFocusReason);
|
topWidget->getSearchBar().setFocus(Qt::MouseFocusReason);
|
||||||
topWidget->getSearchBar().clear();
|
topWidget->getSearchBar().clear();
|
||||||
@ -127,10 +127,15 @@ void TabBar::setNewTabButton()
|
|||||||
setTabButton(idx, QTabBar::RightSide, Q_NULLPTR);
|
setTabButton(idx, QTabBar::RightSide, Q_NULLPTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZimView* TabBar::createNewTab(bool setCurrent)
|
ZimView* TabBar::createNewTab(bool setCurrent, bool adjacentToCurrentTab)
|
||||||
{
|
{
|
||||||
auto tab = new ZimView(this, this);
|
auto tab = new ZimView(this, this);
|
||||||
int index = count() - 1; // the last tab is + button, insert before
|
int index;
|
||||||
|
if(adjacentToCurrentTab) {
|
||||||
|
index = currentIndex() + 1;
|
||||||
|
} else {
|
||||||
|
index = count() - 1; // for New Tab Button
|
||||||
|
}
|
||||||
mp_stackedWidget->insertWidget(index, tab);
|
mp_stackedWidget->insertWidget(index, tab);
|
||||||
index = insertTab(index, "");
|
index = insertTab(index, "");
|
||||||
QToolButton *tb = new QToolButton(this);
|
QToolButton *tb = new QToolButton(this);
|
||||||
@ -146,7 +151,7 @@ void TabBar::openUrl(const QUrl& url, bool newTab)
|
|||||||
{
|
{
|
||||||
WebView* webView = currentWebView();
|
WebView* webView = currentWebView();
|
||||||
if (newTab || !webView) {
|
if (newTab || !webView) {
|
||||||
webView = createNewTab(true)->getWebView();
|
webView = createNewTab(true, true)->getWebView();
|
||||||
}
|
}
|
||||||
QUITIFNULL(webView);
|
QUITIFNULL(webView);
|
||||||
webView->setUrl(url);
|
webView->setUrl(url);
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
|
|
||||||
void setContentManagerView(ContentManagerView* view);
|
void setContentManagerView(ContentManagerView* view);
|
||||||
void setNewTabButton();
|
void setNewTabButton();
|
||||||
ZimView* createNewTab(bool setCurrent);
|
ZimView* createNewTab(bool setCurrent, bool adjacentToCurrentTab);
|
||||||
|
|
||||||
ZimView* currentZimView() {
|
ZimView* currentZimView() {
|
||||||
return qobject_cast<ZimView*>(mp_stackedWidget->currentWidget());
|
return qobject_cast<ZimView*>(mp_stackedWidget->currentWidget());
|
||||||
|
@ -34,7 +34,7 @@ QWebEngineView* WebView::createWindow(QWebEnginePage::WebWindowType type)
|
|||||||
|| type==QWebEnginePage::WebBrowserTab )
|
|| type==QWebEnginePage::WebBrowserTab )
|
||||||
{
|
{
|
||||||
auto tabWidget = KiwixApp::instance()->getTabWidget();
|
auto tabWidget = KiwixApp::instance()->getTabWidget();
|
||||||
return tabWidget->createNewTab(false)->getWebView();
|
return tabWidget->createNewTab(false, true)->getWebView();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user