1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Fix "Hide tabbar with only one tab" option to work also with fullscreen.

Closes #927
This commit is contained in:
nowrep 2013-06-06 13:14:12 +02:00
parent c305811334
commit 9be2b6f5ca
7 changed files with 37 additions and 47 deletions

View File

@ -1883,8 +1883,8 @@ bool QupZilla::event(QEvent* event)
menuBar()->setVisible(m_menuBarVisible);
statusBar()->setVisible(m_statusBarVisible);
m_navigationContainer->show();
m_tabWidget->showTabBar();
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(true);
m_tabWidget->getTabBar()->setVisible(true);
#ifndef Q_OS_MAC
m_navigationBar->setSuperMenuVisible(!m_menuBarVisible);
#endif

View File

@ -76,20 +76,25 @@ void TabBar::loadSettings()
{
Settings settings;
settings.beginGroup("Browser-Tabs-Settings");
m_hideTabBarWithOneTab = settings.value("hideTabsWithOneTab", false).toBool();
m_tabPreview->setAnimationsEnabled(settings.value("tabPreviewAnimationsEnabled", true).toBool());
m_showTabPreviews = settings.value("showTabPreviews", true).toBool();
bool activateLastTab = settings.value("ActivateLastTabWhenClosingActual", false).toBool();
settings.endGroup();
setSelectionBehaviorOnRemove(activateLastTab ? QTabBar::SelectPreviousTab : QTabBar::SelectRightTab);
settings.endGroup();
}
void TabBar::updateVisibilityWithFullscreen(bool visible)
{
// It is needed to save original geometry, otherwise
// tabbar will get 3px height in fullscreen once it was hidden
// Make sure to honor user preference
if (visible) {
visible = !(count() == 1 && m_hideTabBarWithOneTab);
}
QTabBar::setVisible(visible);
if (visible) {
@ -104,11 +109,16 @@ void TabBar::updateVisibilityWithFullscreen(bool visible)
void TabBar::setVisible(bool visible)
{
if (visible) {
if (p_QupZilla->isFullScreen()) {
return;
}
if (visible && p_QupZilla->isFullScreen()) {
return;
}
// Make sure to honor user preference
if (visible) {
visible = !(count() == 1 && m_hideTabBarWithOneTab);
}
if (visible) {
emit showButtons();
}
else {
@ -117,7 +127,6 @@ void TabBar::setVisible(bool visible)
}
hideTabPreview(false);
QTabBar::setVisible(visible);
}
@ -493,12 +502,20 @@ void TabBar::hideTabPreview(bool delayed)
}
}
void TabBar::tabInserted(int index)
{
Q_UNUSED(index)
setVisible(!(count() == 1 && m_hideTabBarWithOneTab));
}
void TabBar::tabRemoved(int index)
{
Q_UNUSED(index)
m_tabWidget->showNavigationBar(p_QupZilla->navigationContainer());
showCloseButton(currentIndex());
setVisible(!(count() == 1 && m_hideTabBarWithOneTab));
}
void TabBar::mouseDoubleClickEvent(QMouseEvent* event)

View File

@ -88,6 +88,7 @@ private slots:
private:
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
void tabInserted(int index);
void tabRemoved(int index);
void hideCloseButton(int index);
@ -110,6 +111,7 @@ private:
QTimer* m_tabPreviewTimer;
bool m_showTabPreviews;
bool m_hideTabBarWithOneTab;
int m_clickedTab;
int m_pinnedTabsCount;

View File

@ -145,7 +145,6 @@ void TabWidget::loadSettings()
{
Settings settings;
settings.beginGroup("Browser-Tabs-Settings");
m_hideTabBarWithOneTab = settings.value("hideTabsWithOneTab", false).toBool();
m_dontQuitWithOneTab = settings.value("dontQuitWithOneTab", false).toBool();
m_closedInsteadOpened = settings.value("closedInsteadOpenedTabs", false).toBool();
m_newTabAfterActive = settings.value("newTabAfterActive", true).toBool();
@ -480,20 +479,6 @@ void TabWidget::tabMoved(int before, int after)
m_lastTabIndex = before;
}
void TabWidget::tabInserted(int index)
{
Q_UNUSED(index)
tabBar()->setVisible(!(count() == 1 && m_hideTabBarWithOneTab));
}
void TabWidget::tabRemoved(int index)
{
Q_UNUSED(index)
tabBar()->setVisible(!(count() == 1 && m_hideTabBarWithOneTab));
}
void TabWidget::startTabAnimation(int index)
{
if (!validIndex(index)) {
@ -605,16 +590,6 @@ void TabWidget::reloadTab(int index)
weTab(index)->reload();
}
void TabWidget::showTabBar()
{
if (count() == 1 && m_hideTabBarWithOneTab) {
tabBar()->hide();
}
else {
tabBar()->show();
}
}
int TabWidget::lastTabIndex() const
{
return m_lastTabIndex;

View File

@ -79,8 +79,6 @@ public:
int normalTabsCount() const;
int pinnedTabsCount() const;
void showTabBar();
int lastTabIndex() const;
void showNavigationBar(QWidget* bar);
@ -137,12 +135,8 @@ private:
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
void tabInserted(int index);
void tabRemoved(int index);
void resizeEvent(QResizeEvent* e);
bool m_hideTabBarWithOneTab;
bool m_dontQuitWithOneTab;
bool m_closedInsteadOpened;
bool m_newTabAfterActive;

View File

@ -359,7 +359,13 @@ void WebTab::showNavigationBar(QWidget* bar)
// Needed to prevent flickering when closing tabs
m_navigationContainer->setUpdatesEnabled(true);
m_navigationContainer->show();
if (p_QupZilla->isFullScreen()) {
m_navigationContainer->setVisible(p_QupZilla->tabWidget()->getTabBar()->isVisible());
}
else {
m_navigationContainer->show();
}
}
}

View File

@ -159,15 +159,11 @@ void WebView::setPage(QWebPage* page)
mApp->plugins()->emitWebPageCreated(m_page);
/* Set white background by default.
Fixes issue with dark themes.
See #602
*/
// Set white background by default.
// Fixes issue with dark themes. See #602
QPalette pal = palette();
pal.setBrush(QPalette::Base, Qt::white);
page->setPalette(pal);
}
void WebView::load(const QUrl &url)