|
@@ -72,6 +72,7 @@ public:
|
|
|
|
|
|
BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab, Optional<u64> page_index)
|
|
|
: m_tabs_container(new TabWidget(this))
|
|
|
+ , m_new_tab_button_toolbar(new QToolBar("New Tab", m_tabs_container))
|
|
|
, m_cookie_jar(cookie_jar)
|
|
|
, m_web_content_options(web_content_options)
|
|
|
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
|
|
@@ -661,6 +662,11 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ m_new_tab_button_toolbar->addAction(m_new_tab_action);
|
|
|
+ m_new_tab_button_toolbar->setMovable(false);
|
|
|
+ m_new_tab_button_toolbar->setStyleSheet("QToolBar { background: transparent; }");
|
|
|
+ m_new_tab_button_toolbar->setIconSize(QSize(16, 16));
|
|
|
+
|
|
|
setCentralWidget(m_tabs_container);
|
|
|
setContextMenuPolicy(Qt::PreventContextMenu);
|
|
|
}
|
|
@@ -674,6 +680,20 @@ void BrowserWindow::set_current_tab(Tab* tab)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void BrowserWindow::update_new_tab_button()
|
|
|
+{
|
|
|
+ if (m_new_tab_button_toolbar == nullptr || m_tabs_container == nullptr || m_tabs_container->count() < 1)
|
|
|
+ return;
|
|
|
+ QSize tab_bar_size = m_tabs_container->tabBar()->sizeHint();
|
|
|
+ int window_width = this->rect().width();
|
|
|
+ QRect new_rect;
|
|
|
+ new_rect.setX(qMin(tab_bar_size.width(), window_width - 32));
|
|
|
+ new_rect.setWidth(32);
|
|
|
+ new_rect.setHeight(32);
|
|
|
+ m_tabs_container->tabBar()->setMaximumWidth(window_width - 32);
|
|
|
+ m_new_tab_button_toolbar->setGeometry(new_rect);
|
|
|
+}
|
|
|
+
|
|
|
void BrowserWindow::debug_request(ByteString const& request, ByteString const& argument)
|
|
|
{
|
|
|
if (!m_current_tab)
|
|
@@ -814,6 +834,8 @@ void BrowserWindow::initialize_tab(Tab* tab)
|
|
|
tab->set_navigator_compatibility_mode(navigator_compatibility_mode());
|
|
|
tab->set_enable_do_not_track(Settings::the()->enable_do_not_track());
|
|
|
tab->view().set_preferred_color_scheme(m_preferred_color_scheme);
|
|
|
+
|
|
|
+ update_new_tab_button();
|
|
|
}
|
|
|
|
|
|
void BrowserWindow::activate_tab(int index)
|
|
@@ -827,6 +849,8 @@ void BrowserWindow::close_tab(int index)
|
|
|
m_tabs_container->removeTab(index);
|
|
|
tab->deleteLater();
|
|
|
|
|
|
+ update_new_tab_button();
|
|
|
+
|
|
|
if (m_tabs_container->count() == 0)
|
|
|
close();
|
|
|
}
|
|
@@ -1153,6 +1177,7 @@ void BrowserWindow::resizeEvent(QResizeEvent* event)
|
|
|
for_each_tab([&](auto& tab) {
|
|
|
tab.view().set_window_size({ frameSize().width() * m_device_pixel_ratio, frameSize().height() * m_device_pixel_ratio });
|
|
|
});
|
|
|
+ update_new_tab_button();
|
|
|
}
|
|
|
|
|
|
void BrowserWindow::moveEvent(QMoveEvent* event)
|