mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Refactor some codes related to sessions. (#2280)
This commit is contained in:
parent
d544a5dc5f
commit
ade7b9c690
@ -403,17 +403,17 @@ MainApplication::AfterLaunch MainApplication::afterLaunch() const
|
||||
return static_cast<AfterLaunch>(Settings().value(QSL("Web-URL-Settings/afterLaunch"), RestoreSession).toInt());
|
||||
}
|
||||
|
||||
bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreData)
|
||||
void MainApplication::openSession(BrowserWindow* window, RestoreData &restoreData)
|
||||
{
|
||||
if (m_isPrivate || restoreData.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isRestoring = true;
|
||||
setOverrideCursor(Qt::BusyCursor);
|
||||
|
||||
if (!window)
|
||||
window = createWindow(Qz::BW_OtherRestoredWindow);
|
||||
|
||||
window->setUpdatesEnabled(false);
|
||||
window->tabWidget()->closeRecoveryTab();
|
||||
|
||||
if (m_isRestoring)
|
||||
window->tabWidget()->closeRecoveryTab();
|
||||
|
||||
if (window->tabWidget()->normalTabsCount() > 1) {
|
||||
// This can only happen when recovering crashed session!
|
||||
@ -452,8 +452,20 @@ bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreD
|
||||
processEvents();
|
||||
}
|
||||
|
||||
destroyRestoreManager();
|
||||
restoreOverrideCursor();
|
||||
}
|
||||
|
||||
bool MainApplication::restoreSession(BrowserWindow* window, RestoreData restoreData)
|
||||
{
|
||||
if (m_isPrivate || restoreData.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isRestoring = true;
|
||||
|
||||
openSession(window, restoreData);
|
||||
|
||||
destroyRestoreManager();
|
||||
m_isRestoring = false;
|
||||
|
||||
return true;
|
||||
@ -696,12 +708,8 @@ void MainApplication::postLaunch()
|
||||
QTimer::singleShot(5000, this, &MainApplication::runDeferredPostLaunchActions);
|
||||
}
|
||||
|
||||
void MainApplication::saveSession()
|
||||
void MainApplication::writeCurrentSession(const QString &filePath)
|
||||
{
|
||||
if (m_isPrivate || m_isRestoring || m_windows.count() == 0 || m_restoreManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
|
||||
@ -718,12 +726,21 @@ void MainApplication::saveSession()
|
||||
}
|
||||
}
|
||||
|
||||
QFile file(DataPaths::currentProfilePath() + QLatin1String("/session.dat"));
|
||||
QFile file(filePath);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(data);
|
||||
file.close();
|
||||
}
|
||||
|
||||
void MainApplication::saveSession()
|
||||
{
|
||||
if (m_isPrivate || m_isRestoring || m_windows.count() == 0 || m_restoreManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeCurrentSession(DataPaths::currentProfilePath() + QLatin1String("/session.dat"));
|
||||
}
|
||||
|
||||
void MainApplication::saveSettings()
|
||||
{
|
||||
if (isPrivate()) {
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
|
||||
AfterLaunch afterLaunch() const;
|
||||
|
||||
void openSession(BrowserWindow* window, RestoreData &restoreData);
|
||||
bool restoreSession(BrowserWindow* window, RestoreData restoreData);
|
||||
void destroyRestoreManager();
|
||||
void reloadSettings();
|
||||
@ -119,6 +120,8 @@ public slots:
|
||||
void changeOccurred();
|
||||
void quitApplication();
|
||||
|
||||
void writeCurrentSession(const QString &filePath);
|
||||
|
||||
signals:
|
||||
void settingsReloaded();
|
||||
void activeWindowChanged(BrowserWindow* window);
|
||||
|
@ -49,7 +49,7 @@ QObject *RestoreManager::recoveryObject(WebPage *page)
|
||||
return m_recoveryObject;
|
||||
}
|
||||
|
||||
void RestoreManager::createFromFile(const QString &file)
|
||||
void RestoreManager::createFromFile(const QString &file, QVector<WindowData> &data)
|
||||
{
|
||||
if (!QFile::exists(file)) {
|
||||
return;
|
||||
@ -97,6 +97,11 @@ void RestoreManager::createFromFile(const QString &file)
|
||||
tabStream >> currentTab;
|
||||
wd.currentTab = currentTab;
|
||||
|
||||
m_data.append(wd);
|
||||
data.append(wd);
|
||||
}
|
||||
}
|
||||
|
||||
void RestoreManager::createFromFile(const QString &file)
|
||||
{
|
||||
createFromFile(file, m_data);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
|
||||
QObject *recoveryObject(WebPage *page);
|
||||
|
||||
static void createFromFile(const QString &file, QVector<RestoreManager::WindowData> &data);
|
||||
private:
|
||||
void createFromFile(const QString &file);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user