mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-22 02:02:10 +02:00
Save pinned tabs per window if restoring session on start
No more pinned tabs restoring on wrong window. Also it is now possible to have different pinned tabs on each window.
This commit is contained in:
parent
94bac52e1f
commit
6d37ab5ce4
|
@ -196,8 +196,7 @@ void BrowserWindow::postLaunch()
|
|||
addTab = !mApp->restoreSession(this, mApp->restoreManager()->restoreData());
|
||||
}
|
||||
else {
|
||||
// Pinned tabs are restored in MainApplication::restoreStateSlot
|
||||
// Make sure they will be restored also when not restoring session
|
||||
// Restore pinned tabs also when not restoring session
|
||||
m_tabWidget->restorePinnedTabs();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -714,9 +714,18 @@ void MainApplication::saveSession()
|
|||
}
|
||||
}
|
||||
|
||||
BrowserWindow* qupzilla_ = getWindow();
|
||||
if (qupzilla_ && m_windows.count() == 1) {
|
||||
qupzilla_->tabWidget()->savePinnedTabs();
|
||||
int afterLaunch = Settings().value("Web-URL-Settings/afterLaunch", 3).toInt();
|
||||
|
||||
if (afterLaunch == 3) {
|
||||
// Pinned tabs are saved into session.dat, so remove the old saved pinned tabs
|
||||
QFile::remove(DataPaths::currentProfilePath() + QL1S("/pinnedtabs.dat"));
|
||||
}
|
||||
else {
|
||||
// Pinned tabs are saved only for last window into pinnedtabs.dat
|
||||
BrowserWindow* qupzilla_ = getWindow();
|
||||
if (qupzilla_ && m_windows.count() == 1) {
|
||||
qupzilla_->tabWidget()->savePinnedTabs();
|
||||
}
|
||||
}
|
||||
|
||||
QFile file(DataPaths::currentProfilePath() + QLatin1String("/session.dat"));
|
||||
|
|
|
@ -814,9 +814,8 @@ QByteArray TabWidget::saveState()
|
|||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
WebTab* webTab = weTab(i);
|
||||
if (!webTab || webTab->isPinned()) {
|
||||
if (!webTab)
|
||||
continue;
|
||||
}
|
||||
|
||||
WebTab::SavedTab tab(webTab);
|
||||
tabList.append(tab);
|
||||
|
@ -838,17 +837,14 @@ QByteArray TabWidget::saveState()
|
|||
|
||||
bool TabWidget::restoreState(const QVector<WebTab::SavedTab> &tabs, int currentTab)
|
||||
{
|
||||
Qz::BrowserWindowType type = m_window->windowType();
|
||||
|
||||
if (type == Qz::BW_FirstAppWindow || type == Qz::BW_MacFirstWindow) {
|
||||
restorePinnedTabs();
|
||||
}
|
||||
|
||||
for (int i = 0; i < tabs.size(); ++i) {
|
||||
WebTab::SavedTab tab = tabs.at(i);
|
||||
|
||||
int index = addView(QUrl(), Qz::NT_CleanSelectedTab);
|
||||
int index = addView(QUrl(), Qz::NT_CleanSelectedTab, false, tab.isPinned);
|
||||
weTab(index)->restoreTab(tab);
|
||||
|
||||
if (tab.isPinned)
|
||||
m_tabBar->updatePinnedTabCloseButton(index);
|
||||
}
|
||||
|
||||
setCurrentIndex(currentTab);
|
||||
|
|
|
@ -34,7 +34,12 @@
|
|||
#include <QTimer>
|
||||
#include <QSplitter>
|
||||
|
||||
static const int savedTabVersion = 1;
|
||||
static const int savedTabVersion = 2;
|
||||
|
||||
WebTab::SavedTab::SavedTab()
|
||||
: isPinned(false)
|
||||
{
|
||||
}
|
||||
|
||||
WebTab::SavedTab::SavedTab(WebTab* webTab)
|
||||
{
|
||||
|
@ -42,11 +47,12 @@ WebTab::SavedTab::SavedTab(WebTab* webTab)
|
|||
url = webTab->url();
|
||||
icon = webTab->icon();
|
||||
history = webTab->historyData();
|
||||
isPinned = webTab->isPinned();
|
||||
}
|
||||
|
||||
bool WebTab::SavedTab::isEmpty() const
|
||||
bool WebTab::SavedTab::isValid() const
|
||||
{
|
||||
return url.isEmpty();
|
||||
return !url.isEmpty();
|
||||
}
|
||||
|
||||
void WebTab::SavedTab::clear()
|
||||
|
@ -55,6 +61,7 @@ void WebTab::SavedTab::clear()
|
|||
url.clear();
|
||||
icon = QIcon();
|
||||
history.clear();
|
||||
isPinned = false;
|
||||
}
|
||||
|
||||
QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
|
||||
|
@ -64,6 +71,7 @@ QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
|
|||
stream << tab.url;
|
||||
stream << tab.icon.pixmap(16);
|
||||
stream << tab.history;
|
||||
stream << tab.isPinned;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
@ -73,12 +81,18 @@ QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
|
|||
int version;
|
||||
stream >> version;
|
||||
|
||||
if (version < 1)
|
||||
return stream;
|
||||
|
||||
QPixmap pixmap;
|
||||
stream >> tab.title;
|
||||
stream >> tab.url;
|
||||
stream >> pixmap;
|
||||
stream >> tab.history;
|
||||
|
||||
if (version >= 2)
|
||||
stream >> tab.isPinned;
|
||||
|
||||
tab.icon = QIcon(pixmap);
|
||||
|
||||
return stream;
|
||||
|
@ -255,14 +269,14 @@ TabIcon* WebTab::tabIcon() const
|
|||
|
||||
bool WebTab::isRestored() const
|
||||
{
|
||||
return m_savedTab.isEmpty();
|
||||
return !m_savedTab.isValid();
|
||||
}
|
||||
|
||||
void WebTab::restoreTab(const WebTab::SavedTab &tab)
|
||||
{
|
||||
Q_ASSERT(m_tabBar);
|
||||
|
||||
if (qzSettings->loadTabsOnActivation) {
|
||||
if (!tab.isPinned && qzSettings->loadTabsOnActivation) {
|
||||
m_savedTab = tab;
|
||||
int index = tabIndex();
|
||||
|
||||
|
@ -297,6 +311,7 @@ void WebTab::p_restoreTab(const QUrl &url, const QByteArray &history)
|
|||
void WebTab::p_restoreTab(const WebTab::SavedTab &tab)
|
||||
{
|
||||
p_restoreTab(tab.url, tab.history);
|
||||
m_isPinned = tab.isPinned;
|
||||
}
|
||||
|
||||
QPixmap WebTab::renderTabPreview()
|
||||
|
|
|
@ -44,11 +44,12 @@ public:
|
|||
QUrl url;
|
||||
QIcon icon;
|
||||
QByteArray history;
|
||||
bool isPinned;
|
||||
|
||||
SavedTab() { }
|
||||
SavedTab();
|
||||
SavedTab(WebTab* webTab);
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isValid() const;
|
||||
void clear();
|
||||
|
||||
friend QUPZILLA_EXPORT QDataStream &operator<<(QDataStream &stream, const SavedTab &tab);
|
||||
|
|
Loading…
Reference in New Issue
Block a user