diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-07-31 18:37:39 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:04 +0100 |
commit | c55e59e897309f512cf8dabda1f5b2d36f2483a3 (patch) | |
tree | 1b007a19081b4ce0811269d1fe727989ed56c088 /src | |
parent | Fix places where IconManager was needed... (diff) | |
download | rekonq-c55e59e897309f512cf8dabda1f5b2d36f2483a3.tar.xz |
Apply rekonq fixes for bug 304312
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 146 |
1 files changed, 74 insertions, 72 deletions
diff --git a/src/application.cpp b/src/application.cpp index 7092ad34..8cd0a728 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -94,84 +94,86 @@ int Application::newInstance() // so, we have 8 possible cases... static bool isFirstLoad = true; bool areThereArguments = (args->count() > 0); - bool hasToBeRecovered = (ReKonfig::recoverOnCrash() > 0); - // note that hasToBeRecovered is always true if it is not the first load - // !isFirstLoad -> hasToBeRecovered + bool hasToBeRecoveredFromCrash = (ReKonfig::recoverOnCrash() > 0); + // note that hasToBeRecoveredFromCrash is always true if it is not the first load + // !isFirstLoad -> hasToBeRecoveredFromCrash kDebug() << "is first load? " << isFirstLoad; kDebug() << "are there arguments? " << areThereArguments; - kDebug() << "is rekonq crashed? " << hasToBeRecovered; + kDebug() << "is rekonq crashed? " << hasToBeRecoveredFromCrash; - if (!isSessionRestored()) + if (areThereArguments) { - if (areThereArguments) + // prepare URLS to load + KUrl::List urlList; + for (int i = 0; i < args->count(); ++i) { - // prepare URLS to load - KUrl::List urlList; - for (int i = 0; i < args->count(); ++i) - { - const KUrl u = args->url(i); - - if (u.isLocalFile() && QFile::exists(u.toLocalFile())) // "rekonq somefile.html" case - { - urlList += u; - } - else - { - // "rekonq kde.org" || "rekonq kde:kdialog" cases - urlList += UrlResolver::urlFromTextTyped(args->arg(i)); - } - } - - if (isFirstLoad && (ReKonfig::startupBehaviour() == 2) && SessionManager::self()->restoreSessionFromScratch()) - { - isFirstLoad = false; - } + const KUrl u = args->url(i); - // first argument: 99% of the time we have just that... - if (isFirstLoad) + if (u.isLocalFile() && QFile::exists(u.toLocalFile())) // "rekonq somefile.html" case { - // No windows in the current desktop? No windows at all? - // Create a new one and load there sites... - loadUrl(urlList.at(0), Rekonq::NewWindow); + urlList += u; } else { - if (!ReKonfig::openExternalLinksInNewWindow()) - { - loadUrl(urlList.at(0), Rekonq::NewFocusedTab); - } - else - { - loadUrl(urlList.at(0), Rekonq::NewWindow); - } - - if (!tabWindow()->isActiveWindow()) - KWindowSystem::demandAttention(tabWindow()->winId(), true); + // "rekonq kde.org" || "rekonq kde:kdialog" cases + urlList += UrlResolver::urlFromTextTyped(args->arg(i)); } + } - // following arguments: what's best behavior here? - // I'm pretty sure no one has real opinion about... + if (isFirstLoad && (ReKonfig::startupBehaviour() == 2) && SessionManager::self()->restoreSessionFromScratch()) + { + isFirstLoad = false; + } + + // first argument: 99% of the time we have just that... + if (isFirstLoad) + { + // No windows in the current desktop? No windows at all? + // Create a new one and load there sites... + loadUrl(urlList.at(0), Rekonq::NewWindow); + } + else + { if (!ReKonfig::openExternalLinksInNewWindow()) { - for (int i = 1; i < urlList.count(); ++i) - loadUrl(urlList.at(i), Rekonq::NewFocusedTab); + loadUrl(urlList.at(0), Rekonq::NewFocusedTab); } else { - for (int i = 1; i < urlList.count(); ++i) - loadUrl(urlList.at(i), Rekonq::NewWindow); + loadUrl(urlList.at(0), Rekonq::NewWindow); } + + if (!tabWindow()->isActiveWindow()) + KWindowSystem::demandAttention(tabWindow()->winId(), true); + } + + // following arguments: what's best behavior here? + // I'm pretty sure no one has real opinion about... + if (!ReKonfig::openExternalLinksInNewWindow()) + { + for (int i = 1; i < urlList.count(); ++i) + loadUrl(urlList.at(i), Rekonq::NewFocusedTab); } else { - if (isFirstLoad) + for (int i = 1; i < urlList.count(); ++i) + loadUrl(urlList.at(i), Rekonq::NewWindow); + } + } + else + { + if (isFirstLoad) + { + if (hasToBeRecoveredFromCrash) { - if (hasToBeRecovered) - { - loadUrl(KUrl("about:closedTabs"), Rekonq::NewWindow); - } - else + loadUrl(KUrl("about:closedTabs"), Rekonq::NewWindow); + } + else + { + // NOTE: just load new tabs/windows without arguments + // if NOT is Session restored... + if (!isSessionRestored()) { switch (ReKonfig::startupBehaviour()) { @@ -192,28 +194,28 @@ int Application::newInstance() } } } - else + } + else + { + switch (ReKonfig::newTabsBehaviour()) { - switch (ReKonfig::newTabsBehaviour()) - { - case 0: // new tab page - loadUrl(KUrl("about:home") , Rekonq::NewWindow); - break; - case 2: // homepage - loadUrl(KUrl(ReKonfig::homePage()) , Rekonq::NewWindow); - break; - case 1: // blank page - default: - loadUrl(KUrl("about:blank") , Rekonq::NewWindow); - break; - } + case 0: // new tab page + loadUrl(KUrl("about:home") , Rekonq::NewWindow); + break; + case 2: // homepage + loadUrl(KUrl(ReKonfig::homePage()) , Rekonq::NewWindow); + break; + case 1: // blank page + default: + loadUrl(KUrl("about:blank") , Rekonq::NewWindow); + break; } } - } // !isSessionRestored() + } if (isFirstLoad) { - if (hasToBeRecovered) + if (hasToBeRecoveredFromCrash) { QTimer::singleShot(1000, tabWindow()->currentWebWindow(), SLOT(showMessageBar())); } @@ -222,7 +224,7 @@ int Application::newInstance() SessionManager::self()->setSessionManagementEnabled(true); } - if (ReKonfig::checkDefaultSearchEngine() && !hasToBeRecovered && SearchEngine::defaultEngine().isNull()) + if (ReKonfig::checkDefaultSearchEngine() && !hasToBeRecoveredFromCrash && SearchEngine::defaultEngine().isNull()) QTimer::singleShot(2000, tabWindow()->currentWebWindow(), SLOT(showSearchEngineBar())); // updating rekonq configuration |