1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-22 02:02:10 +02:00

Make afterLaunch settings enum

This commit is contained in:
David Rosca 2015-09-28 14:51:38 +02:00
parent f28da4407f
commit 7adc31337b
4 changed files with 24 additions and 17 deletions

View File

@ -162,22 +162,20 @@ void BrowserWindow::postLaunch()
{
loadSettings();
Settings settings;
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 3).toInt();
bool addTab = true;
QUrl startUrl;
switch (afterLaunch) {
case 0:
switch (mApp->afterLaunch()) {
case MainApplication::OpenBlankPage:
startUrl = QUrl();
break;
case 2:
case MainApplication::OpenSpeedDial:
startUrl = QUrl("qupzilla:speeddial");
break;
case 1:
case 3:
case MainApplication::OpenHomePage:
case MainApplication::RestoreSession:
startUrl = m_homepage;
break;
@ -192,7 +190,7 @@ void BrowserWindow::postLaunch()
startUrl.clear();
m_tabWidget->addView(QUrl("qupzilla:restore"), Qz::NT_CleanSelectedTabAtTheEnd);
}
else if (afterLaunch == 3 && mApp->restoreManager()) {
else if (mApp->afterLaunch() == MainApplication::RestoreSession && mApp->restoreManager()) {
addTab = !mApp->restoreSession(this, mApp->restoreManager()->restoreData());
}
else {
@ -1336,10 +1334,9 @@ void BrowserWindow::closeEvent(QCloseEvent* event)
}
Settings settings;
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 3).toInt();
bool askOnClose = settings.value("Browser-Tabs-Settings/AskOnClosing", true).toBool();
if (afterLaunch == 3 && mApp->windowCount() == 1) {
if (mApp->afterLaunch() == MainApplication::RestoreSession && mApp->windowCount() == 1) {
askOnClose = false;
}

View File

@ -287,7 +287,6 @@ MainApplication::MainApplication(int &argc, char** argv)
if (!isPrivate()) {
Settings settings;
m_isStartingAfterCrash = settings.value("SessionRestore/isRunning", false).toBool();
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 3).toInt();
settings.setValue("SessionRestore/isRunning", true);
#ifndef DISABLE_UPDATES_CHECK
@ -300,7 +299,7 @@ MainApplication::MainApplication(int &argc, char** argv)
backupSavedSessions();
if (m_isStartingAfterCrash || afterLaunch == 3) {
if (m_isStartingAfterCrash || afterLaunch() == RestoreSession) {
m_restoreManager = new RestoreManager();
if (!m_restoreManager->isValid()) {
destroyRestoreManager();
@ -390,6 +389,11 @@ BrowserWindow* MainApplication::createWindow(Qz::BrowserWindowType type, const Q
return window;
}
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)
{
if (m_isPrivate || restoreData.isEmpty()) {
@ -717,9 +721,7 @@ void MainApplication::saveSession()
}
}
int afterLaunch = Settings().value("Web-URL-Settings/afterLaunch", 3).toInt();
if (afterLaunch != 3) {
if (afterLaunch() != RestoreSession) {
// Pinned tabs are saved only for last window into pinnedtabs.dat
BrowserWindow* qupzilla_ = getWindow();
if (qupzilla_ && m_windows.count() == 1) {

View File

@ -53,6 +53,13 @@ class QUPZILLA_EXPORT MainApplication : public QtSingleApplication
Q_OBJECT
public:
enum AfterLaunch {
OpenBlankPage = 0,
OpenHomePage = 1,
OpenSpeedDial = 2,
RestoreSession = 3
};
explicit MainApplication(int &argc, char** argv);
~MainApplication();
@ -68,6 +75,8 @@ public:
BrowserWindow* getWindow() const;
BrowserWindow* createWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl());
AfterLaunch afterLaunch() const;
bool restoreSession(BrowserWindow* window, RestoreData restoreData);
void destroyRestoreManager();
void reloadSettings();

View File

@ -146,9 +146,8 @@ Preferences::Preferences(BrowserWindow* window)
m_newTabUrl = settings.value("newTabUrl", QUrl(QSL("qupzilla:speeddial"))).toUrl();
ui->homepage->setText(m_homepage.toEncoded());
ui->newTabUrl->setText(m_newTabUrl.toEncoded());
int afterLaunch = settings.value("afterLaunch", 3).toInt();
settings.endGroup();
ui->afterLaunch->setCurrentIndex(afterLaunch);
ui->afterLaunch->setCurrentIndex(mApp->afterLaunch());
ui->checkUpdates->setChecked(settings.value("Web-Browser-Settings/CheckUpdates", DEFAULT_CHECK_UPDATES).toBool());
ui->dontLoadTabsUntilSelected->setChecked(settings.value("Web-Browser-Settings/LoadTabsOnActivation", true).toBool());