mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
SessionRestore: Set tab title after at the end
This change saves a lot of recalculations which is done after each tab is added. Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
8b2721e85c
commit
8acab0295a
|
@ -326,7 +326,7 @@ WebTab* TabBar::webTab(int index) const
|
||||||
|
|
||||||
void TabBar::showCloseButton(int index)
|
void TabBar::showCloseButton(int index)
|
||||||
{
|
{
|
||||||
if (!validIndex(index) || m_isRestoring) {
|
if (!validIndex(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
|
||||||
|
|
||||||
void TabBar::hideCloseButton(int index)
|
void TabBar::hideCloseButton(int index)
|
||||||
{
|
{
|
||||||
if (!validIndex(index) || tabsClosable() || m_isRestoring) {
|
if (!validIndex(index) || tabsClosable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ void TabBar::currentTabChanged(int index)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't hide close buttons when dragging tabs
|
// Don't hide close buttons when dragging tabs
|
||||||
if (m_dragStartPosition.isNull()) {
|
if (m_dragStartPosition.isNull() && !m_isRestoring) {
|
||||||
showCloseButton(index);
|
showCloseButton(index);
|
||||||
if (m_lastTab) {
|
if (m_lastTab) {
|
||||||
hideCloseButton(m_lastTab->tabIndex());
|
hideCloseButton(m_lastTab->tabIndex());
|
||||||
|
@ -436,6 +436,10 @@ void TabBar::currentTabChanged(int index)
|
||||||
|
|
||||||
void TabBar::setTabText(int index, const QString &text)
|
void TabBar::setTabText(int index, const QString &text)
|
||||||
{
|
{
|
||||||
|
if (m_isRestoring) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString tabText = text;
|
QString tabText = text;
|
||||||
|
|
||||||
// Avoid Alt+letter shortcuts
|
// Avoid Alt+letter shortcuts
|
||||||
|
@ -735,4 +739,9 @@ void TabBar::setIsRestoring(bool restoring)
|
||||||
m_isRestoring = restoring;
|
m_isRestoring = restoring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TabBar::isRestoring()
|
||||||
|
{
|
||||||
|
return m_isRestoring;
|
||||||
|
}
|
||||||
|
|
||||||
#include "tabbar.moc"
|
#include "tabbar.moc"
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
void wheelEvent(QWheelEvent* event) override;
|
void wheelEvent(QWheelEvent* event) override;
|
||||||
|
|
||||||
void setIsRestoring(bool restoring);
|
void setIsRestoring(bool restoring);
|
||||||
|
bool isRestoring();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void moveAddTabButton(int posX);
|
void moveAddTabButton(int posX);
|
||||||
|
|
|
@ -507,6 +507,7 @@ void TabWidget::currentTabChanged(int index)
|
||||||
m_lastBackgroundTab = nullptr;
|
m_lastBackgroundTab = nullptr;
|
||||||
m_currentTabFresh = false;
|
m_currentTabFresh = false;
|
||||||
|
|
||||||
|
if (!m_tabBar->isRestoring()) {
|
||||||
WebTab* webTab = weTab(index);
|
WebTab* webTab = weTab(index);
|
||||||
webTab->tabActivated();
|
webTab->tabActivated();
|
||||||
|
|
||||||
|
@ -517,6 +518,7 @@ void TabWidget::currentTabChanged(int index)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_window->currentTabChanged();
|
m_window->currentTabChanged();
|
||||||
|
}
|
||||||
|
|
||||||
Q_EMIT changed();
|
Q_EMIT changed();
|
||||||
}
|
}
|
||||||
|
@ -874,6 +876,11 @@ bool TabWidget::restoreState(const QVector<WebTab::SavedTab> &tabs, int currentT
|
||||||
|
|
||||||
m_tabBar->setIsRestoring(false);
|
m_tabBar->setIsRestoring(false);
|
||||||
|
|
||||||
|
auto const l_allTabs = allTabs();
|
||||||
|
for (const WebTab* tab : l_allTabs) {
|
||||||
|
m_tabBar->setTabText(tab->tabIndex(), tab->title());
|
||||||
|
}
|
||||||
|
|
||||||
setCurrentIndex(currentTab);
|
setCurrentIndex(currentTab);
|
||||||
QTimer::singleShot(0, m_tabBar, SLOT(ensureVisible(int,int)));
|
QTimer::singleShot(0, m_tabBar, SLOT(ensureVisible(int,int)));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user