diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-04-30 11:23:37 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-04-30 11:23:37 +0200 |
commit | c896cc340d7e6e0878b3249c5792e6d88a12cf42 (patch) | |
tree | fd0a7a61ff1d07f301f2188de5cb6fa473134897 /src/application.cpp | |
parent | A tiny improvement in the error page, showing a fat icon.. :) (diff) | |
download | rekonq-c896cc340d7e6e0878b3249c5792e6d88a12cf42.tar.xz |
A coding style round
Diffstat (limited to 'src/application.cpp')
-rw-r--r-- | src/application.cpp | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/src/application.cpp b/src/application.cpp index fd030232..0302558f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -12,9 +12,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * 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 @@ -71,10 +71,10 @@ QWeakPointer<AdBlockManager> Application::s_adblockManager; Application::Application() - : KUniqueApplication() + : KUniqueApplication() { - connect(Weaver::instance(), SIGNAL( jobDone(ThreadWeaver::Job*) ), - this, SLOT( loadResolvedUrl(ThreadWeaver::Job*) ) ); + connect(Weaver::instance(), SIGNAL(jobDone(ThreadWeaver::Job*)), + this, SLOT(loadResolvedUrl(ThreadWeaver::Job*))); } @@ -84,8 +84,8 @@ Application::~Application() // Don't recover on next load.. ReKonfig::setRecoverOnCrash(0); saveConfiguration(); - - foreach( QWeakPointer<MainWindow> window, m_mainWindows) + + foreach(QWeakPointer<MainWindow> window, m_mainWindows) { delete window.data(); window.clear(); @@ -93,13 +93,13 @@ Application::~Application() delete s_bookmarkProvider.data(); s_bookmarkProvider.clear(); - + delete s_historyManager.data(); s_historyManager.clear(); - + delete s_sessionManager.data(); s_sessionManager.clear(); - + delete s_adblockManager.data(); s_adblockManager.clear(); } @@ -107,7 +107,7 @@ Application::~Application() int Application::newInstance() { - KCmdLineArgs::setCwd( QDir::currentPath().toUtf8() ); + KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); bool isFirstLoad = m_mainWindows.isEmpty(); @@ -121,52 +121,52 @@ int Application::newInstance() kDebug() << "session restored"; return 1; } - - if(args->count() == 0) + + if (args->count() == 0) { - if(isFirstLoad) // we are starting rekonq, for the first time with no args: use startup behaviour + if (isFirstLoad) // we are starting rekonq, for the first time with no args: use startup behaviour { - switch(ReKonfig::startupBehaviour()) + switch (ReKonfig::startupBehaviour()) { - case 0: // open home page - mainWindow()->homePage(); - break; - case 1: // open new tab page - loadUrl( KUrl("about:home") ); - break; - case 2: // restore session - if(sessionManager()->restoreSession()) - break; - default: - mainWindow()->homePage(); + case 0: // open home page + mainWindow()->homePage(); + break; + case 1: // open new tab page + loadUrl(KUrl("about:home")); + break; + case 2: // restore session + if (sessionManager()->restoreSession()) break; - } + default: + mainWindow()->homePage(); + break; + } } else // rekonq has just been started. Just open a new window { - loadUrl( KUrl("about:home") , Rekonq::NewWindow ); + loadUrl(KUrl("about:home") , Rekonq::NewWindow); } } else { - if(isFirstLoad) + if (isFirstLoad) { // No windows in the current desktop? No windows at all? // Create a new one and load there sites... loadUrl(args->arg(0), Rekonq::CurrentTab); for (int i = 1; i < args->count(); ++i) - loadUrl( KUrl( args->arg(i) ), Rekonq::SettingOpenTab); + loadUrl(KUrl(args->arg(i)), Rekonq::SettingOpenTab); } else { // are there any windows there? use it int index = m_mainWindows.size(); - if(index > 0) + if (index > 0) { MainWindow *m = m_mainWindows.at(index - 1).data(); m->activateWindow(); for (int i = 0; i < args->count(); ++i) - loadUrl( KUrl( args->arg(i) ), Rekonq::NewCurrentTab); + loadUrl(KUrl(args->arg(i)), Rekonq::NewCurrentTab); } } } @@ -183,19 +183,19 @@ Application *Application::instance() void Application::postLaunch() -{ +{ // updating rekonq configuration updateConfiguration(); setWindowIcon(KIcon("rekonq")); - + // set Icon Database Path to store "favicons" associated with web sites QString directory = KStandardDirs::locateLocal("cache" , "" , true); QWebSettings::setIconDatabasePath(directory); Application::historyManager(); Application::sessionManager(); - + // bookmarks loading connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType&))); @@ -215,12 +215,12 @@ void Application::saveConfiguration() const MainWindow *Application::mainWindow() { - if(m_mainWindows.isEmpty()) + if (m_mainWindows.isEmpty()) return newMainWindow(); - + MainWindow *active = qobject_cast<MainWindow*>(QApplication::activeWindow()); - - if(!active) + + if (!active) { return m_mainWindows.at(0).data(); } @@ -230,10 +230,10 @@ MainWindow *Application::mainWindow() HistoryManager *Application::historyManager() { - if ( s_historyManager.isNull() ) + if (s_historyManager.isNull()) { s_historyManager = new HistoryManager(); - QWebHistoryInterface::setDefaultInterface( s_historyManager.data() ); + QWebHistoryInterface::setDefaultInterface(s_historyManager.data()); } return s_historyManager.data(); } @@ -241,7 +241,7 @@ HistoryManager *Application::historyManager() BookmarkProvider *Application::bookmarkProvider() { - if ( s_bookmarkProvider.isNull() ) + if (s_bookmarkProvider.isNull()) { s_bookmarkProvider = new BookmarkProvider(instance()); } @@ -251,7 +251,7 @@ BookmarkProvider *Application::bookmarkProvider() SessionManager *Application::sessionManager() { - if( s_sessionManager.isNull() ) + if (s_sessionManager.isNull()) { s_sessionManager = new SessionManager(instance()); } @@ -262,21 +262,21 @@ SessionManager *Application::sessionManager() KIcon Application::icon(const KUrl &url) { // avoid infinite loop at startup - if( Application::instance()->mainWindowList().isEmpty() ) + if (Application::instance()->mainWindowList().isEmpty()) return KIcon("text-html"); // first things first.. - if(url.isEmpty()) + if (url.isEmpty()) return KIcon("text-html"); // rekonq icons.. - if(url == KUrl("about:closedTabs")) + if (url == KUrl("about:closedTabs")) return KIcon("tab-close"); - if(url == KUrl("about:history")) + if (url == KUrl("about:history")) return KIcon("view-history"); - if(url == KUrl("about:bookmarks")) + if (url == KUrl("about:bookmarks")) return KIcon("bookmarks"); - if(url == KUrl("about:favorites")) + if (url == KUrl("about:favorites")) return KIcon("emblem-favorite"); KIcon icon = KIcon(QWebSettings::iconForUrl(url)); @@ -293,7 +293,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) if (url.isEmpty()) return; - if ( !url.isValid() ) + if (!url.isValid()) { KMessageBox::error(0, i18n("Malformed URL:\n%1", url.url(KUrl::RemoveTrailingSlash))); return; @@ -302,11 +302,11 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) // first, create the webview(s) to not let hangs UI.. WebTab *tab = 0; MainWindow *w = 0; - w = (type == Rekonq::NewWindow) + w = (type == Rekonq::NewWindow) ? newMainWindow() : mainWindow(); - - switch(type) + + switch (type) { case Rekonq::SettingOpenTab: tab = w->mainView()->newWebTab(!ReKonfig::openTabsBack(), ReKonfig::openTabsNearCurrent()); @@ -322,9 +322,9 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) tab = w->mainView()->currentWebTab(); break; }; - + WebView *view = tab->view(); - + if (view) { FilterUrlJob *job = new FilterUrlJob(view, url.pathOrUrl(), this); @@ -336,13 +336,13 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) MainWindow *Application::newMainWindow(bool withTab) { MainWindow *w = new MainWindow(); - - if(withTab) + + if (withTab) w->mainView()->newWebTab(); // remember using newWebTab and NOT newTab here!! - + m_mainWindows.prepend(w); w->show(); - + return w; } @@ -361,7 +361,7 @@ MainWindowList Application::mainWindowList() AdBlockManager *Application::adblockManager() { - if( s_adblockManager.isNull() ) + if (s_adblockManager.isNull()) { s_adblockManager = new AdBlockManager(instance()); } @@ -374,37 +374,37 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) FilterUrlJob *threadedJob = static_cast<FilterUrlJob *>(job); KUrl url = threadedJob->url(); WebView *view = threadedJob->view(); - + // Bye and thanks :) delete threadedJob; - + if (view) { - view->load(url); - + view->load(url); + // we are sure of the url now, let's add it to history // anyway we store here just http sites because local and ftp ones are // added trough the protocol handler and the other are ignored - if( url.protocol() == QLatin1String("http") || url.protocol() == QLatin1String("https") ) - historyManager()->addHistoryEntry( url.prettyUrl() ); + if (url.protocol() == QLatin1String("http") || url.protocol() == QLatin1String("https")) + historyManager()->addHistoryEntry(url.prettyUrl()); } } void Application::newWindow() { - loadUrl( KUrl("about:home"), Rekonq::NewWindow ); + loadUrl(KUrl("about:home"), Rekonq::NewWindow); mainWindow()->mainView()->urlBarWidget()->setFocus(); } void Application::updateConfiguration() { - // FIXME: - // all things related to mainview can be + // FIXME: + // all things related to mainview can be // improved/moved/replicated in all the mainwindows MainView *view = mainWindow()->mainView(); - + // ============== General ================== view->updateTabBar(); @@ -413,12 +413,12 @@ void Application::updateConfiguration() view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); else view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab); - + // =========== Encodings & Fonts ============== QWebSettings *defaultSettings = QWebSettings::globalSettings(); - defaultSettings->setDefaultTextEncoding( ReKonfig::defaultEncoding() ); - + defaultSettings->setDefaultTextEncoding(ReKonfig::defaultEncoding()); + int fnSize = ReKonfig::fontSize(); int minFnSize = ReKonfig::minFontSize(); @@ -441,8 +441,8 @@ void Application::updateConfiguration() defaultSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, ReKonfig::linksIncludedInFocusChain()); defaultSettings->setAttribute(QWebSettings::ZoomTextOnly, ReKonfig::zoomTextOnly()); defaultSettings->setAttribute(QWebSettings::PrintElementBackgrounds, ReKonfig::printElementBackgrounds()); - - if(ReKonfig::pluginsEnabled() == 2) + + if (ReKonfig::pluginsEnabled() == 2) defaultSettings->setAttribute(QWebSettings::PluginsEnabled, false); else defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true); @@ -451,7 +451,7 @@ void Application::updateConfiguration() defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, ReKonfig::offlineStorageDatabaseEnabled()); defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, ReKonfig::offlineWebApplicationCacheEnabled()); defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled, ReKonfig::localStorageEnabled()); - if(ReKonfig::localStorageEnabled()) + if (ReKonfig::localStorageEnabled()) { QString path = KStandardDirs::locateLocal("cache", QString("WebkitLocalStorage/rekonq"), true); path.remove("rekonq"); @@ -461,14 +461,14 @@ void Application::updateConfiguration() // Applies user defined CSS to all open webpages. If there no longer is a // user defined CSS removes it from all open webpages. - if(ReKonfig::userCSS().isEmpty()) - defaultSettings->setUserStyleSheetUrl( KUrl(KStandardDirs::locate("appdata" , "default.css")) ); + if (ReKonfig::userCSS().isEmpty()) + defaultSettings->setUserStyleSheetUrl(KUrl(KStandardDirs::locate("appdata" , "default.css"))); else defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS()); // ====== load Settings on main classes Application::historyManager()->loadSettings(); Application::adblockManager()->loadSettings(); - + defaultSettings = 0; } |