mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Always open new window when restoring session after crash
Also remove special handling for qupzilla:restore tabs.
This commit is contained in:
parent
679268dbd1
commit
5cc41d219e
@ -449,11 +449,10 @@ void MainApplication::openSession(BrowserWindow* window, RestoreData &restoreDat
|
||||
|
||||
bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreData)
|
||||
{
|
||||
if (!window || m_isPrivate || !restoreData.isValid()) {
|
||||
if (m_isPrivate || !restoreData.isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
window->tabWidget()->closeRecoveryTab();
|
||||
openSession(window, restoreData);
|
||||
|
||||
m_restoreManager->clearRestoreData();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "browserwindow.h"
|
||||
#include "qztools.h"
|
||||
#include "iconprovider.h"
|
||||
#include "tabwidget.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
@ -72,11 +73,7 @@ QJsonArray RecoveryJsObject::restoreData() const
|
||||
|
||||
void RecoveryJsObject::startNewSession()
|
||||
{
|
||||
BrowserWindow *window = getBrowserWindow();
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
m_page->load(window->homepageUrl());
|
||||
closeTab();
|
||||
|
||||
mApp->restoreManager()->clearRestoreData();
|
||||
mApp->destroyRestoreManager();
|
||||
@ -112,16 +109,23 @@ void RecoveryJsObject::restoreSession(const QStringList &excludeWin, const QStri
|
||||
wd.currentTab = wd.tabs.size() - 1;
|
||||
}
|
||||
|
||||
BrowserWindow *window = getBrowserWindow();
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
if (!mApp->restoreSession(window, data))
|
||||
if (mApp->restoreSession(nullptr, data)) {
|
||||
closeTab();
|
||||
} else {
|
||||
startNewSession();
|
||||
}
|
||||
}
|
||||
|
||||
BrowserWindow *RecoveryJsObject::getBrowserWindow() const
|
||||
void RecoveryJsObject::closeTab()
|
||||
{
|
||||
TabbedWebView *view = qobject_cast<TabbedWebView*>(m_page->view());
|
||||
return view ? view->browserWindow() : Q_NULLPTR;
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (view->browserWindow()->tabWidget()->count() > 1) {
|
||||
view->closeView();
|
||||
} else {
|
||||
view->browserWindow()->close();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2015 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2015-2018 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -43,7 +43,7 @@ public slots:
|
||||
void restoreSession(const QStringList &excludeWin, const QStringList &excludeTab);
|
||||
|
||||
private:
|
||||
BrowserWindow *getBrowserWindow() const;
|
||||
void closeTab();
|
||||
|
||||
RestoreManager *m_manager;
|
||||
WebPage *m_page;
|
||||
|
@ -346,7 +346,7 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N
|
||||
m_lastBackgroundTabIndex = index;
|
||||
}
|
||||
|
||||
connect(webTab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
|
||||
connect(webTab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int)));
|
||||
connect(webTab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed()));
|
||||
connect(webTab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));
|
||||
connect(webTab->webView(), &WebView::urlChanged, this, [this](const QUrl &url) {
|
||||
@ -393,7 +393,7 @@ int TabWidget::insertView(int index, WebTab *tab, const Qz::NewTabPositionFlags
|
||||
m_lastBackgroundTabIndex = index;
|
||||
}
|
||||
|
||||
connect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
|
||||
connect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int)));
|
||||
connect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed()));
|
||||
connect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));
|
||||
|
||||
@ -429,7 +429,7 @@ void TabWidget::closeTab(int index)
|
||||
|
||||
TabbedWebView *webView = webTab->webView();
|
||||
m_locationBars->removeWidget(webView->webTab()->locationBar());
|
||||
disconnect(webView, SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
|
||||
disconnect(webView, SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int)));
|
||||
disconnect(webView, SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed()));
|
||||
disconnect(webView, SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));
|
||||
|
||||
@ -454,10 +454,6 @@ void TabWidget::requestCloseTab(int index)
|
||||
|
||||
TabbedWebView *webView = webTab->webView();
|
||||
|
||||
// Don't close restore page!
|
||||
if (webView->url().toString() == QL1S("falkon:restore") && mApp->restoreManager())
|
||||
return;
|
||||
|
||||
// This would close last tab, so we close the window instead
|
||||
if (count() <= 1) {
|
||||
// If we are not closing window upon closing last tab, let's just load new-tab-url
|
||||
@ -638,7 +634,7 @@ void TabWidget::detachTab(WebTab* tab)
|
||||
Q_ASSERT(tab);
|
||||
|
||||
m_locationBars->removeWidget(tab->locationBar());
|
||||
disconnect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
|
||||
disconnect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(requestCloseTab(int)));
|
||||
disconnect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed()));
|
||||
disconnect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));
|
||||
|
||||
@ -781,15 +777,6 @@ bool TabWidget::restoreState(const QVector<WebTab::SavedTab> &tabs, int currentT
|
||||
return true;
|
||||
}
|
||||
|
||||
void TabWidget::closeRecoveryTab()
|
||||
{
|
||||
foreach (WebTab* tab, allTabs(false)) {
|
||||
if (tab->url().toString() == QLatin1String("falkon:restore")) {
|
||||
closeTab(tab->tabIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TabWidget::~TabWidget()
|
||||
{
|
||||
delete m_closedTabsManager;
|
||||
|
@ -70,7 +70,6 @@ public:
|
||||
~TabWidget();
|
||||
|
||||
bool restoreState(const QVector<WebTab::SavedTab> &tabs, int currentTab);
|
||||
void closeRecoveryTab();
|
||||
|
||||
void setCurrentIndex(int index);
|
||||
|
||||
|
@ -36,11 +36,6 @@ void ClosedTabsManager::saveTab(WebTab *tab)
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't save restore tab
|
||||
if (tab->url().toString() == QL1S("qupzilla:restore")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tab closedTab;
|
||||
closedTab.position = tab->tabIndex();
|
||||
closedTab.tabState = WebTab::SavedTab(tab);
|
||||
|
@ -473,9 +473,6 @@ void TabManagerWidget::processActions()
|
||||
}
|
||||
|
||||
if (command == "closeSelection") {
|
||||
if (webTab->url().toString() == "falkon:restore") {
|
||||
continue;
|
||||
}
|
||||
selectedTabs.insertMulti(mainWindow, webTab);
|
||||
}
|
||||
else if (command == "detachSelection" || command == "bookmarkSelection") {
|
||||
|
Loading…
Reference in New Issue
Block a user