diff options
Diffstat (limited to 'src/application.cpp')
-rw-r--r-- | src/application.cpp | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/src/application.cpp b/src/application.cpp index 5cc3b460..db71c602 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -36,12 +36,13 @@ // Local Includes #include "mainwindow.h" #include "historymanager.h" -#include "bookmarksmanager.h" +#include "bookmarkprovider.h" #include "mainview.h" #include "webtab.h" #include "urlbar.h" #include "sessionmanager.h" #include "adblockmanager.h" +#include "opensearchmanager.h" #include "webview.h" #include "filterurljob.h" #include "tabbar.h" @@ -64,6 +65,7 @@ QWeakPointer<HistoryManager> Application::s_historyManager; QWeakPointer<BookmarkProvider> Application::s_bookmarkProvider; QWeakPointer<SessionManager> Application::s_sessionManager; QWeakPointer<AdBlockManager> Application::s_adblockManager; +QWeakPointer<OpenSearchManager> Application::s_opensearchManager; Application::Application() @@ -98,6 +100,9 @@ Application::~Application() delete s_adblockManager.data(); s_adblockManager.clear(); + + delete s_opensearchManager.data(); + s_opensearchManager.clear(); } @@ -107,7 +112,7 @@ int Application::newInstance() KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); // not that easy, indeed - // We have to consider 3 variables here: + // We have to consider 3 variables here: // 1) Is first load? // 2) Are there arguments? // 3) Is rekonq recovering from crash? @@ -115,13 +120,13 @@ int Application::newInstance() bool isFirstLoad = m_mainWindows.isEmpty(); bool areThereArguments = (args->count() > 0); bool isRekonqCrashed = (ReKonfig::recoverOnCrash() == 1); - + kDebug() << "is first load? " << isFirstLoad; kDebug() << "are there arguments? " << areThereArguments; kDebug() << "is rekonq crashed? " << isRekonqCrashed; - + int exitValue = 1 * isFirstLoad + 2 * areThereArguments + 4 * isRekonqCrashed; - + if(isRekonqCrashed) { if( isFirstLoad && sessionManager()->restoreSession() ) @@ -139,7 +144,7 @@ int Application::newInstance() loadUrl( KUrl("about:blank"), Rekonq::NewFocusedTab); } } - + if(areThereArguments) { KUrl::List urlList; @@ -151,7 +156,7 @@ int Application::newInstance() else urlList += KUrl( args->arg(i) ); // "rekonq kde.org" || "rekonq kde:kdialog" case } - + if (isFirstLoad) { // No windows in the current desktop? No windows at all? @@ -178,7 +183,7 @@ int Application::newInstance() Q_FOREACH(const KUrl &u, urlList) loadUrl(u, Rekonq::NewFocusedTab); } - } + } } else { @@ -218,16 +223,16 @@ int Application::newInstance() break; } - } + } } - - + + if(isFirstLoad) { // give me some time to do the other things.. QTimer::singleShot(100, this, SLOT(postLaunch())); } - + return exitValue; } @@ -315,6 +320,17 @@ SessionManager *Application::sessionManager() } +OpenSearchManager *Application::opensearchManager() +{ + if (s_opensearchManager.isNull()) + { + s_opensearchManager = new OpenSearchManager(instance()); + s_opensearchManager.data()->setSearchProvider("google"); //TODO: use other suggestion engines + } + return s_opensearchManager.data(); +} + + KIcon Application::icon(const KUrl &url) { // avoid infinite loop at startup @@ -392,7 +408,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) Q_ASSERT( tabIndex != -1 ); UrlBar *barForTab = qobject_cast<UrlBar *>(w->mainView()->widgetBar()->widget(tabIndex)); barForTab->setQUrl(url); - + WebView *view = tab->view(); if (view) @@ -470,16 +486,16 @@ void Application::updateConfiguration() { MainView *mv = w.data()->mainView(); mv->updateTabBar(); - + if (b) mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); else mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab); } - QWebSettings *defaultSettings = QWebSettings::globalSettings(); - - // =========== Fonts ============== + QWebSettings *defaultSettings = QWebSettings::globalSettings(); + + // =========== Fonts ============== defaultSettings->setFontFamily(QWebSettings::StandardFont, ReKonfig::standardFontFamily() ); defaultSettings->setFontFamily(QWebSettings::FixedFont, ReKonfig::fixedFontFamily() ); defaultSettings->setFontFamily(QWebSettings::SerifFont, ReKonfig::serifFontFamily() ); @@ -487,15 +503,15 @@ void Application::updateConfiguration() defaultSettings->setFontFamily(QWebSettings::CursiveFont, ReKonfig::cursiveFontFamily()); defaultSettings->setFontFamily(QWebSettings::FantasyFont, ReKonfig::fantasyFontFamily()); - // compute font size + // compute font size // (I have to admit I know nothing about these DPI questions..: copied from kwebkitpart, as someone suggested) // font size in pixels = font size in inches × screen dpi - int defaultFontSize = ReKonfig::defaultFontSize(); + int defaultFontSize = ReKonfig::defaultFontSize(); int minimumFontSize = ReKonfig::minFontSize(); - + int logDpiY = mainWindow()->currentTab()->view()->logicalDpiY(); kDebug() << "Logical Dot per Inch Y: " << logDpiY; - + float toPix = (logDpiY < 96.0) ? 96.0/72.0 : logDpiY/72.0 ; @@ -503,7 +519,7 @@ void Application::updateConfiguration() defaultSettings->setFontSize(QWebSettings::DefaultFontSize, qRound(defaultFontSize * toPix) ); defaultSettings->setFontSize(QWebSettings::MinimumFontSize, qRound(minimumFontSize * toPix) ); - + // ================ WebKit ============================ defaultSettings->setAttribute(QWebSettings::AutoLoadImages, ReKonfig::autoLoadImages()); defaultSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, ReKonfig::dnsPrefetch()); |