mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36: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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
m_isRestoring = true;
|
||||
|
||||
if (recoveryData.isEmpty()) {
|
||||
m_isRestoring = false;
|
||||
window->tabWidget()->closeRecoveryTab();
|
||||
|
||||
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;
|
||||
|
||||
if (window->tabWidget()->count() > 1) {
|
||||
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;
|
||||
}
|
||||
foreach(const RestoreManager::WindowData & data, recoveryData) {
|
||||
QupZilla* window = makeNewWindow(Qz::BW_OtherRestoredWindow);
|
||||
window->restoreWindowState(data);
|
||||
}
|
||||
|
||||
destroyRestoreManager();
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
void connectDatabase();
|
||||
void loadSettings();
|
||||
void reloadSettings();
|
||||
bool restoreStateSlot(QupZilla* window, const RestoreData &recoveryData);
|
||||
bool restoreStateSlot(QupZilla* window, RestoreData recoveryData);
|
||||
QupZilla* makeNewWindow(Qz::BrowserWindow type, const QUrl &startUrl = QUrl());
|
||||
void aboutToCloseWindow(QupZilla* window);
|
||||
bool isStateChanged();
|
||||
|
@ -32,6 +32,8 @@ RecoveryWidget::RecoveryWidget(WebView* view, QupZilla* mainClass)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
||||
const RestoreData &data = m_restoreManager->restoreData();
|
||||
|
||||
for (int i = 0; i < data.size(); ++i) {
|
||||
|
@ -49,7 +49,7 @@ TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab)
|
||||
, m_rssChecked(false)
|
||||
{
|
||||
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(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) {
|
||||
checkRss();
|
||||
|
@ -63,7 +63,7 @@ public slots:
|
||||
void showIcon();
|
||||
|
||||
void slotLoadStarted();
|
||||
void loadProgress(int prog);
|
||||
void slotLoadProgress(int prog);
|
||||
|
||||
void userLoadAction(const QUrl &url);
|
||||
|
||||
|
@ -349,7 +349,7 @@ void TabWidget::closeTab(int index, bool force)
|
||||
}
|
||||
|
||||
WebTab* webTab = weTab(index);
|
||||
if (!webTab) {
|
||||
if (!webTab || !validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ void TabWidget::closeTab(int index, bool force)
|
||||
|
||||
void TabWidget::currentTabChanged(int index)
|
||||
{
|
||||
if (index < 0 || m_isRestoringState) {
|
||||
if (!validIndex(index) || m_isRestoringState) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ void TabWidget::tabRemoved(int index)
|
||||
|
||||
void TabWidget::startTabAnimation(int index)
|
||||
{
|
||||
if (index == -1) {
|
||||
if (!validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -467,7 +467,7 @@ void TabWidget::startTabAnimation(int index)
|
||||
|
||||
void TabWidget::stopTabAnimation(int index)
|
||||
{
|
||||
if (index == -1) {
|
||||
if (!validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ void TabWidget::stopTabAnimation(int index)
|
||||
|
||||
void TabWidget::setTabIcon(int index, const QIcon &icon)
|
||||
{
|
||||
if (index == -1) {
|
||||
if (!validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -496,6 +496,10 @@ void TabWidget::setTabIcon(int index, const QIcon &icon)
|
||||
|
||||
void TabWidget::setTabText(int index, const QString &text)
|
||||
{
|
||||
if (!validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString newtext = text;
|
||||
newtext.replace('&', "&&"); // Avoid Alt+letter shortcuts
|
||||
|
||||
@ -521,8 +525,22 @@ void TabWidget::previousTab()
|
||||
keyPressEvent(&fakeEvent);
|
||||
}
|
||||
|
||||
int TabWidget::normalTabsCount() const
|
||||
{
|
||||
return m_tabBar->normalTabsCount();
|
||||
}
|
||||
|
||||
int TabWidget::pinnedTabsCount() const
|
||||
{
|
||||
return m_tabBar->pinnedTabsCount();
|
||||
}
|
||||
|
||||
void TabWidget::reloadTab(int index)
|
||||
{
|
||||
if (!validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
weTab(index)->reload();
|
||||
}
|
||||
|
||||
@ -545,11 +563,19 @@ void TabWidget::reloadAllTabs()
|
||||
|
||||
void TabWidget::stopTab(int index)
|
||||
{
|
||||
if (!validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
weTab(index)->stop();
|
||||
}
|
||||
|
||||
void TabWidget::closeAllButCurrent(int index)
|
||||
{
|
||||
if (!validIndex(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebTab* akt = weTab(index);
|
||||
|
||||
foreach(WebTab * tab, allTabs(false)) {
|
||||
@ -563,6 +589,10 @@ void TabWidget::closeAllButCurrent(int index)
|
||||
|
||||
int TabWidget::duplicateTab(int index)
|
||||
{
|
||||
if (!validIndex(index)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebTab* webTab = weTab(index);
|
||||
|
||||
const QUrl &url = webTab->url();
|
||||
@ -732,7 +762,7 @@ void TabWidget::restorePinnedTabs()
|
||||
if (!historyState.isEmpty()) {
|
||||
addedIndex = addView(QUrl(), Qz::NT_CleanSelectedTab);
|
||||
|
||||
weTab(i)->p_restoreTab(url, historyState);
|
||||
weTab(addedIndex)->p_restoreTab(url, historyState);
|
||||
}
|
||||
else {
|
||||
addedIndex = addView(url);
|
||||
@ -746,7 +776,7 @@ void TabWidget::restorePinnedTabs()
|
||||
}
|
||||
|
||||
m_tabBar->updateCloseButton(addedIndex);
|
||||
m_tabBar->moveTab(addedIndex, i);
|
||||
// m_tabBar->moveTab(addedIndex, i);
|
||||
}
|
||||
|
||||
m_isRestoringState = false;
|
||||
@ -799,6 +829,15 @@ bool TabWidget::restoreState(const QList<WebTab::SavedTab> &tabs, int currentTab
|
||||
return true;
|
||||
}
|
||||
|
||||
void TabWidget::closeRecoveryTab()
|
||||
{
|
||||
foreach(WebTab * tab, allTabs(false)) {
|
||||
if (tab->url() == QUrl("qupzilla:restore")) {
|
||||
closeTab(tab->tabIndex(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TabWidget::disconnectObjects()
|
||||
{
|
||||
disconnect(this);
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
|
||||
QByteArray saveState();
|
||||
bool restoreState(const QList<WebTab::SavedTab> &tabs, int currentTab);
|
||||
void closeRecoveryTab();
|
||||
|
||||
void savePinnedTabs();
|
||||
void restorePinnedTabs();
|
||||
@ -74,6 +75,9 @@ public:
|
||||
void nextTab();
|
||||
void previousTab();
|
||||
|
||||
int normalTabsCount() const;
|
||||
int pinnedTabsCount() const;
|
||||
|
||||
void showTabBar();
|
||||
|
||||
TabBar* getTabBar() { return m_tabBar; }
|
||||
@ -120,6 +124,8 @@ private slots:
|
||||
void tabMoved(int before, int after);
|
||||
|
||||
private:
|
||||
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
|
||||
|
||||
void tabInserted(int index);
|
||||
void tabRemoved(int index);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user