mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Regression: Fixed restoring sessions with pinned tabs.
- it was opening & restoring tabs in new window
This commit is contained in:
parent
abe5e5d885
commit
2acc6021aa
@ -871,45 +871,34 @@ bool MainApplication::saveStateSlot()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainApplication::restoreStateSlot(QupZilla* win, const RestoreData &recoveryData)
|
bool MainApplication::restoreStateSlot(QupZilla* window, RestoreData recoveryData)
|
||||||
{
|
{
|
||||||
if (m_isPrivateSession) {
|
if (m_isPrivateSession || recoveryData.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_isRestoring = true;
|
m_isRestoring = true;
|
||||||
|
|
||||||
if (recoveryData.isEmpty()) {
|
window->tabWidget()->closeRecoveryTab();
|
||||||
m_isRestoring = false;
|
|
||||||
|
|
||||||
return false;
|
if (window->tabWidget()->normalTabsCount() > 1) {
|
||||||
|
// This can only happen when recovering crashed session!
|
||||||
|
//
|
||||||
|
// Don't restore tabs in current window as user already opened
|
||||||
|
// some new tabs.
|
||||||
|
// Instead create new one and restore pinned tabs there
|
||||||
|
|
||||||
|
QupZilla* newWin = makeNewWindow(Qz::BW_OtherRestoredWindow);
|
||||||
|
newWin->tabWidget()->restorePinnedTabs();
|
||||||
|
newWin->restoreWindowState(recoveryData.takeFirst());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window->restoreWindowState(recoveryData.takeFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
QupZilla* window = win;
|
foreach(const RestoreManager::WindowData & data, recoveryData) {
|
||||||
|
QupZilla* window = makeNewWindow(Qz::BW_OtherRestoredWindow);
|
||||||
if (window->tabWidget()->count() > 1) {
|
window->restoreWindowState(data);
|
||||||
window = new QupZilla(Qz::BW_OtherRestoredWindow);
|
|
||||||
m_mainWindows.append(window);
|
|
||||||
}
|
|
||||||
win->tabWidget()->closeTab(window->tabWidget()->currentIndex(), true);
|
|
||||||
|
|
||||||
int windowCount = recoveryData.size();
|
|
||||||
int currentWindow = 0;
|
|
||||||
|
|
||||||
while (window) {
|
|
||||||
const RestoreManager::WindowData &wd = recoveryData.at(currentWindow);
|
|
||||||
window->restoreWindowState(wd);
|
|
||||||
window->show();
|
|
||||||
|
|
||||||
++currentWindow;
|
|
||||||
|
|
||||||
if (currentWindow < windowCount) {
|
|
||||||
window = new QupZilla(Qz::BW_OtherRestoredWindow);
|
|
||||||
m_mainWindows.append(window);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
window = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyRestoreManager();
|
destroyRestoreManager();
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
void connectDatabase();
|
void connectDatabase();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void reloadSettings();
|
void reloadSettings();
|
||||||
bool restoreStateSlot(QupZilla* window, const RestoreData &recoveryData);
|
bool restoreStateSlot(QupZilla* window, RestoreData recoveryData);
|
||||||
QupZilla* makeNewWindow(Qz::BrowserWindow type, const QUrl &startUrl = QUrl());
|
QupZilla* makeNewWindow(Qz::BrowserWindow type, const QUrl &startUrl = QUrl());
|
||||||
void aboutToCloseWindow(QupZilla* window);
|
void aboutToCloseWindow(QupZilla* window);
|
||||||
bool isStateChanged();
|
bool isStateChanged();
|
||||||
|
@ -32,6 +32,8 @@ RecoveryWidget::RecoveryWidget(WebView* view, QupZilla* mainClass)
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
|
||||||
const RestoreData &data = m_restoreManager->restoreData();
|
const RestoreData &data = m_restoreManager->restoreData();
|
||||||
|
|
||||||
for (int i = 0; i < data.size(); ++i) {
|
for (int i = 0; i < data.size(); ++i) {
|
||||||
|
@ -49,7 +49,7 @@ TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab)
|
|||||||
, m_rssChecked(false)
|
, m_rssChecked(false)
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
|
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
||||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished()));
|
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished()));
|
||||||
|
|
||||||
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
|
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
|
||||||
@ -128,7 +128,7 @@ void TabbedWebView::urlChanged(const QUrl &url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedWebView::loadProgress(int prog)
|
void TabbedWebView::slotLoadProgress(int prog)
|
||||||
{
|
{
|
||||||
if (prog > 60) {
|
if (prog > 60) {
|
||||||
checkRss();
|
checkRss();
|
||||||
|
@ -63,7 +63,7 @@ public slots:
|
|||||||
void showIcon();
|
void showIcon();
|
||||||
|
|
||||||
void slotLoadStarted();
|
void slotLoadStarted();
|
||||||
void loadProgress(int prog);
|
void slotLoadProgress(int prog);
|
||||||
|
|
||||||
void userLoadAction(const QUrl &url);
|
void userLoadAction(const QUrl &url);
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ void TabWidget::closeTab(int index, bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebTab* webTab = weTab(index);
|
WebTab* webTab = weTab(index);
|
||||||
if (!webTab) {
|
if (!webTab || !validIndex(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ void TabWidget::closeTab(int index, bool force)
|
|||||||
|
|
||||||
void TabWidget::currentTabChanged(int index)
|
void TabWidget::currentTabChanged(int index)
|
||||||
{
|
{
|
||||||
if (index < 0 || m_isRestoringState) {
|
if (!validIndex(index) || m_isRestoringState) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ void TabWidget::tabRemoved(int index)
|
|||||||
|
|
||||||
void TabWidget::startTabAnimation(int index)
|
void TabWidget::startTabAnimation(int index)
|
||||||
{
|
{
|
||||||
if (index == -1) {
|
if (!validIndex(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ void TabWidget::startTabAnimation(int index)
|
|||||||
|
|
||||||
void TabWidget::stopTabAnimation(int index)
|
void TabWidget::stopTabAnimation(int index)
|
||||||
{
|
{
|
||||||
if (index == -1) {
|
if (!validIndex(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +480,7 @@ void TabWidget::stopTabAnimation(int index)
|
|||||||
|
|
||||||
void TabWidget::setTabIcon(int index, const QIcon &icon)
|
void TabWidget::setTabIcon(int index, const QIcon &icon)
|
||||||
{
|
{
|
||||||
if (index == -1) {
|
if (!validIndex(index)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,6 +496,10 @@ void TabWidget::setTabIcon(int index, const QIcon &icon)
|
|||||||
|
|
||||||
void TabWidget::setTabText(int index, const QString &text)
|
void TabWidget::setTabText(int index, const QString &text)
|
||||||
{
|
{
|
||||||
|
if (!validIndex(index)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString newtext = text;
|
QString newtext = text;
|
||||||
newtext.replace('&', "&&"); // Avoid Alt+letter shortcuts
|
newtext.replace('&', "&&"); // Avoid Alt+letter shortcuts
|
||||||
|
|
||||||
@ -521,8 +525,22 @@ void TabWidget::previousTab()
|
|||||||
keyPressEvent(&fakeEvent);
|
keyPressEvent(&fakeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TabWidget::normalTabsCount() const
|
||||||
|
{
|
||||||
|
return m_tabBar->normalTabsCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
int TabWidget::pinnedTabsCount() const
|
||||||
|
{
|
||||||
|
return m_tabBar->pinnedTabsCount();
|
||||||
|
}
|
||||||
|
|
||||||
void TabWidget::reloadTab(int index)
|
void TabWidget::reloadTab(int index)
|
||||||
{
|
{
|
||||||
|
if (!validIndex(index)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
weTab(index)->reload();
|
weTab(index)->reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,11 +563,19 @@ void TabWidget::reloadAllTabs()
|
|||||||
|
|
||||||
void TabWidget::stopTab(int index)
|
void TabWidget::stopTab(int index)
|
||||||
{
|
{
|
||||||
|
if (!validIndex(index)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
weTab(index)->stop();
|
weTab(index)->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::closeAllButCurrent(int index)
|
void TabWidget::closeAllButCurrent(int index)
|
||||||
{
|
{
|
||||||
|
if (!validIndex(index)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WebTab* akt = weTab(index);
|
WebTab* akt = weTab(index);
|
||||||
|
|
||||||
foreach(WebTab * tab, allTabs(false)) {
|
foreach(WebTab * tab, allTabs(false)) {
|
||||||
@ -563,6 +589,10 @@ void TabWidget::closeAllButCurrent(int index)
|
|||||||
|
|
||||||
int TabWidget::duplicateTab(int index)
|
int TabWidget::duplicateTab(int index)
|
||||||
{
|
{
|
||||||
|
if (!validIndex(index)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
WebTab* webTab = weTab(index);
|
WebTab* webTab = weTab(index);
|
||||||
|
|
||||||
const QUrl &url = webTab->url();
|
const QUrl &url = webTab->url();
|
||||||
@ -732,7 +762,7 @@ void TabWidget::restorePinnedTabs()
|
|||||||
if (!historyState.isEmpty()) {
|
if (!historyState.isEmpty()) {
|
||||||
addedIndex = addView(QUrl(), Qz::NT_CleanSelectedTab);
|
addedIndex = addView(QUrl(), Qz::NT_CleanSelectedTab);
|
||||||
|
|
||||||
weTab(i)->p_restoreTab(url, historyState);
|
weTab(addedIndex)->p_restoreTab(url, historyState);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addedIndex = addView(url);
|
addedIndex = addView(url);
|
||||||
@ -746,7 +776,7 @@ void TabWidget::restorePinnedTabs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_tabBar->updateCloseButton(addedIndex);
|
m_tabBar->updateCloseButton(addedIndex);
|
||||||
m_tabBar->moveTab(addedIndex, i);
|
// m_tabBar->moveTab(addedIndex, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_isRestoringState = false;
|
m_isRestoringState = false;
|
||||||
@ -799,6 +829,15 @@ bool TabWidget::restoreState(const QList<WebTab::SavedTab> &tabs, int currentTab
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabWidget::closeRecoveryTab()
|
||||||
|
{
|
||||||
|
foreach(WebTab * tab, allTabs(false)) {
|
||||||
|
if (tab->url() == QUrl("qupzilla:restore")) {
|
||||||
|
closeTab(tab->tabIndex(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TabWidget::disconnectObjects()
|
void TabWidget::disconnectObjects()
|
||||||
{
|
{
|
||||||
disconnect(this);
|
disconnect(this);
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
|
|
||||||
QByteArray saveState();
|
QByteArray saveState();
|
||||||
bool restoreState(const QList<WebTab::SavedTab> &tabs, int currentTab);
|
bool restoreState(const QList<WebTab::SavedTab> &tabs, int currentTab);
|
||||||
|
void closeRecoveryTab();
|
||||||
|
|
||||||
void savePinnedTabs();
|
void savePinnedTabs();
|
||||||
void restorePinnedTabs();
|
void restorePinnedTabs();
|
||||||
@ -74,6 +75,9 @@ public:
|
|||||||
void nextTab();
|
void nextTab();
|
||||||
void previousTab();
|
void previousTab();
|
||||||
|
|
||||||
|
int normalTabsCount() const;
|
||||||
|
int pinnedTabsCount() const;
|
||||||
|
|
||||||
void showTabBar();
|
void showTabBar();
|
||||||
|
|
||||||
TabBar* getTabBar() { return m_tabBar; }
|
TabBar* getTabBar() { return m_tabBar; }
|
||||||
@ -120,6 +124,8 @@ private slots:
|
|||||||
void tabMoved(int before, int after);
|
void tabMoved(int before, int after);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
|
||||||
|
|
||||||
void tabInserted(int index);
|
void tabInserted(int index);
|
||||||
void tabRemoved(int index);
|
void tabRemoved(int index);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user