parent
a9d0e79eeb
commit
de46aad181
9 changed files with 331 additions and 254 deletions
@ -1,114 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 Franz Fellner <alpine.art.de@googlemail.com> |
||||
* 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 |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */ |
||||
#include "recoverywidget.h" |
||||
#include "ui_recoverywidget.h" |
||||
#include "restoremanager.h" |
||||
#include "mainapplication.h" |
||||
#include "webview.h" |
||||
#include "browserwindow.h" |
||||
|
||||
RecoveryWidget::RecoveryWidget(WebView* view, BrowserWindow* window) |
||||
: QWidget() |
||||
, ui(new Ui::RecoveryWidget) |
||||
, m_view(view) |
||||
, m_window(window) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
setCursor(Qt::ArrowCursor); |
||||
|
||||
const RestoreData data = mApp->restoreManager()->restoreData(); |
||||
|
||||
for (int i = 0; i < data.size(); ++i) { |
||||
const RestoreManager::WindowData wd = data.at(i); |
||||
|
||||
QTreeWidgetItem* root = new QTreeWidgetItem(ui->treeWidget); |
||||
root->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate); |
||||
root->setText(0, tr("Window %1").arg((i + 1))); |
||||
root->setCheckState(0, Qt::Checked); |
||||
|
||||
for (int tab = 0; tab < wd.tabsState.size(); ++tab) { |
||||
const WebTab::SavedTab st = wd.tabsState.at(tab); |
||||
|
||||
QTreeWidgetItem* child = new QTreeWidgetItem(root); |
||||
child->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
||||
child->setCheckState(0, Qt::Checked); |
||||
child->setIcon(0, st.icon); |
||||
child->setText(0, st.title); |
||||
} |
||||
} |
||||
|
||||
ui->treeWidget->expandAll(); |
||||
|
||||
connect(ui->restoreSession, SIGNAL(clicked()), this, SLOT(restoreSession())); |
||||
connect(ui->newSession, SIGNAL(clicked()), this, SLOT(newSession())); |
||||
} |
||||
|
||||
void RecoveryWidget::restoreSession() |
||||
{ |
||||
RestoreManager* manager = mApp->restoreManager(); |
||||
if (!manager) { |
||||
return; |
||||
} |
||||
|
||||
RestoreData data = manager->restoreData(); |
||||
|
||||
for (int win = ui->treeWidget->topLevelItemCount() - 1; win >= 0; --win) { |
||||
QTreeWidgetItem* root = ui->treeWidget->topLevelItem(win); |
||||
if (root->checkState(0) == Qt::Unchecked) { |
||||
data.remove(win); |
||||
continue; |
||||
} |
||||
|
||||
RestoreManager::WindowData &wd = data[win]; |
||||
for (int tab = root->childCount() - 1; tab >= 0; --tab) { |
||||
if (root->child(tab)->checkState(0) == Qt::Unchecked) { |
||||
wd.tabsState.remove(tab); |
||||
if (wd.currentTab >= tab) { |
||||
wd.currentTab--; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (wd.tabsState.isEmpty()) { |
||||
data.remove(win); |
||||
continue; |
||||
} |
||||
|
||||
if (wd.currentTab < 0) { |
||||
wd.currentTab = wd.tabsState.size() - 1; |
||||
} |
||||
} |
||||
|
||||
if (!mApp->restoreSession(m_window, data)) { |
||||
newSession(); |
||||
} |
||||
} |
||||
|
||||
void RecoveryWidget::newSession() |
||||
{ |
||||
m_view->load(m_window->homepageUrl()); |
||||
|
||||
mApp->destroyRestoreManager(); |
||||
} |
||||
|
||||
RecoveryWidget::~RecoveryWidget() |
||||
{ |
||||
delete ui; |
||||
} |
||||
@ -1,53 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 Franz Fellner <alpine.art.de@googlemail.com> |
||||
* 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 |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */ |
||||
#ifndef RECOVERYWIDGET_H |
||||
#define RECOVERYWIDGET_H |
||||
|
||||
#include <QWidget> |
||||
|
||||
namespace Ui |
||||
{ |
||||
class RecoveryWidget; |
||||
} |
||||
|
||||
class QTreeWidgetItem; |
||||
|
||||
class WebView; |
||||
class BrowserWindow; |
||||
|
||||
class RecoveryWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit RecoveryWidget(WebView* view, BrowserWindow* window); |
||||
~RecoveryWidget(); |
||||
|
||||
private slots: |
||||
void restoreSession(); |
||||
void newSession(); |
||||
|
||||
private: |
||||
Ui::RecoveryWidget* ui; |
||||
|
||||
WebView* m_view; |
||||
BrowserWindow* m_window; |
||||
}; |
||||
|
||||
#endif // RECOVERYWIDGET_H
|
||||
@ -1,70 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>RecoveryWidget</class> |
||||
<widget class="QWidget" name="RecoveryWidget"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>500</width> |
||||
<height>300</height> |
||||
</rect> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QTreeWidget" name="treeWidget"> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Windows and Tabs</string> |
||||
</property> |
||||
</column> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<widget class="QPushButton" name="newSession"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>0</width> |
||||
<height>30</height> |
||||
</size> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Start New Session</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="restoreSession"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>0</width> |
||||
<height>30</height> |
||||
</size> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Restore</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
||||
Loading…
Reference in new issue