1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Move last tab tracking from TabWidget to TabBar

This commit is contained in:
David Rosca 2018-02-06 14:48:42 +01:00
parent 0f2728e49e
commit 71f5d72a65
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
4 changed files with 8 additions and 21 deletions

View File

@ -26,6 +26,7 @@
#include "iconprovider.h"
#include "tabcontextmenu.h"
#include "searchenginesmanager.h"
#include "tabmrumodel.h"
#include <QMimeData>
#include <QMouseEvent>
@ -425,11 +426,13 @@ void TabBar::currentTabChanged(int index)
// Don't hide close buttons when dragging tabs
if (m_dragStartPosition.isNull()) {
showCloseButton(index);
hideCloseButton(m_tabWidget->lastTabIndex());
if (m_lastTab) {
hideCloseButton(m_lastTab->tabIndex());
}
QTimer::singleShot(100, this, [this]() { ensureVisible(); });
}
m_lastTab = webTab(index);
m_tabWidget->currentTabChanged(index);
}

View File

@ -18,8 +18,9 @@
#ifndef TABBAR_H
#define TABBAR_H
#include "combotabbar.h"
#include <QPointer>
#include "combotabbar.h"
#include "qzcommon.h"
class BrowserWindow;
@ -88,6 +89,7 @@ private:
QPoint m_dragStartPosition;
bool m_forceHidden;
QPointer<WebTab> m_lastTab;
};
#endif // TABBAR_H

View File

@ -321,7 +321,6 @@ int TabWidget::addView(const LoadRequest &req, const Qz::NewTabPositionFlags &op
int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position, bool pinned)
{
QUrl url = req.url();
m_lastTab = weTab();
m_currentTabFresh = false;
if (url.isEmpty() && !(openFlags & Qz::NT_CleanTab)) {
@ -512,7 +511,6 @@ void TabWidget::currentTabChanged(int index)
WebTab* webTab = weTab(index);
webTab->tabActivated();
m_lastTab = webTab;
LocationBar* locBar = webTab->locationBar();
@ -535,8 +533,6 @@ void TabWidget::tabWasMoved(int before, int after)
void TabWidget::setCurrentIndex(int index)
{
m_lastTab = weTab();
TabStackedWidget::setCurrentIndex(index);
}
@ -576,16 +572,6 @@ WebTab *TabWidget::webTab(int index) const
return index < 0 ? weTab() : weTab(index);
}
WebTab *TabWidget::lastTab() const
{
return m_lastTab;
}
int TabWidget::lastTabIndex() const
{
return m_lastTab ? m_lastTab->tabIndex() : -1;
}
int TabWidget::extraReservedWidth() const
{
return m_buttonAddTab->width();

View File

@ -85,9 +85,6 @@ public:
WebTab *webTab(int index = -1) const;
WebTab *lastTab() const;
int lastTabIndex() const;
TabBar* tabBar() const;
ClosedTabsManager* closedTabsManager() const;
QList<WebTab*> allTabs(bool withPinned = true);
@ -172,7 +169,6 @@ private:
AddTabButton* m_buttonAddTab;
AddTabButton* m_buttonAddTab2;
QPointer<WebTab> m_lastTab;
QPointer<WebTab> m_lastBackgroundTab;
bool m_dontCloseWithOneTab;