diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2011-07-17 16:46:24 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2011-07-17 16:46:24 +0200 |
commit | 82167d2422a4b6e3071dca68cf65a66e1da41ab4 (patch) | |
tree | 03c1f95a2aa60c48822a463cc3812b5c3415991e /src/application.cpp | |
parent | Improving tab previews (diff) | |
download | rekonq-82167d2422a4b6e3071dca68cf65a66e1da41ab4.tar.xz |
A round of the "new" astyle 2.01...
Diffstat (limited to 'src/application.cpp')
-rw-r--r-- | src/application.cpp | 125 |
1 files changed, 66 insertions, 59 deletions
diff --git a/src/application.cpp b/src/application.cpp index 40cfcffe..69a3b0c9 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -70,8 +70,8 @@ using namespace ThreadWeaver; Application::Application() - : KUniqueApplication() - , _privateBrowsingAction(0) + : KUniqueApplication() + , _privateBrowsingAction(0) { connect(Weaver::instance(), SIGNAL(jobDone(ThreadWeaver::Job*)), this, SLOT(loadResolvedUrl(ThreadWeaver::Job*))); @@ -95,32 +95,38 @@ Application::~Application() window.clear(); } - if (!m_historyManager.isNull()) { + if(!m_historyManager.isNull()) + { delete m_historyManager.data(); m_historyManager.clear(); } - if (!m_bookmarkProvider.isNull()) { + if(!m_bookmarkProvider.isNull()) + { delete m_bookmarkProvider.data(); m_bookmarkProvider.clear(); } - if (!m_sessionManager.isNull()) { + if(!m_sessionManager.isNull()) + { delete m_sessionManager.data(); m_sessionManager.clear(); } - if (!m_opensearchManager.isNull()) { + if(!m_opensearchManager.isNull()) + { delete m_opensearchManager.data(); m_opensearchManager.clear(); } - if (!m_iconManager.isNull()) { + if(!m_iconManager.isNull()) + { delete m_iconManager.data(); m_iconManager.clear(); } - if (!m_adblockManager.isNull()) { + if(!m_adblockManager.isNull()) + { delete m_adblockManager.data(); m_adblockManager.clear(); } @@ -129,7 +135,8 @@ Application::~Application() // add a check to NOT close rekonq // until last download is finished - if (!m_downloadManager.isNull()) { + if(!m_downloadManager.isNull()) + { delete m_adblockManager.data(); m_adblockManager.clear(); } @@ -159,25 +166,25 @@ int Application::newInstance() int exitValue = 1 * isFirstLoad + 2 * areThereArguments + 4 * isRekonqCrashed; - if (isRekonqCrashed && isFirstLoad) + if(isRekonqCrashed && isFirstLoad) { loadUrl(KUrl("about:closedTabs"), Rekonq::NewWindow); mainWindow()->currentTab()->showMessageBar(); } - if (areThereArguments) + if(areThereArguments) { KUrl::List urlList; - for (int i = 0; i < args->count(); ++i) + 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 + if(u.isLocalFile() && QFile::exists(u.toLocalFile())) // "rekonq somefile.html" case urlList += u; else urlList += KUrl(args->arg(i)); // "rekonq kde.org" || "rekonq kde:kdialog" case } - if (isFirstLoad && !isRekonqCrashed) + if(isFirstLoad && !isRekonqCrashed) { // No windows in the current desktop? No windows at all? // Create a new one and load there sites... @@ -185,17 +192,17 @@ int Application::newInstance() } else { - if (ReKonfig::openTabNoWindow()) + if(ReKonfig::openTabNoWindow()) { loadUrl(urlList.at(0), Rekonq::NewTab); - if (!mainWindow()->isActiveWindow()) + if(!mainWindow()->isActiveWindow()) KWindowSystem::demandAttention(mainWindow()->winId(), true); } else loadUrl(urlList.at(0), Rekonq::NewWindow); } - for (int i = 1; i < urlList.count(); ++i) + for(int i = 1; i < urlList.count(); ++i) loadUrl(urlList.at(i), Rekonq::NewTab); KStartupInfo::appStarted(); @@ -204,9 +211,9 @@ int Application::newInstance() else { - if (isFirstLoad && !isRekonqCrashed) // we are starting rekonq, for the first time with no args: use startup behaviour + if(isFirstLoad && !isRekonqCrashed) // 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 newMainWindow()->homePage(); @@ -223,9 +230,9 @@ int Application::newInstance() break; } } - else if (!isFirstLoad) // rekonq has just been started. Just open a new window + else if(!isFirstLoad) // rekonq has just been started. Just open a new window { - switch (ReKonfig::newTabsBehaviour()) + switch(ReKonfig::newTabsBehaviour()) { case 0: // new tab page loadUrl(KUrl("about:home") , Rekonq::NewWindow); @@ -244,7 +251,7 @@ int Application::newInstance() } } - if (isFirstLoad) + if(isFirstLoad) { // give me some time to do the other things.. QTimer::singleShot(100, this, SLOT(postLaunch())); @@ -290,14 +297,14 @@ MainWindow *Application::mainWindow() { MainWindow *active = qobject_cast<MainWindow*>(QApplication::activeWindow()); - if (!active) + if(!active) { if(m_mainWindows.isEmpty()) return 0; - Q_FOREACH (const QWeakPointer<MainWindow> &pointer, m_mainWindows) + Q_FOREACH(const QWeakPointer<MainWindow> &pointer, m_mainWindows) { - if (KWindowInfo(pointer.data()->effectiveWinId(),NET::WMDesktop,0).isOnCurrentDesktop()) + if(KWindowInfo(pointer.data()->effectiveWinId(), NET::WMDesktop, 0).isOnCurrentDesktop()) return pointer.data(); } return m_mainWindows.at(0).data(); @@ -308,7 +315,7 @@ MainWindow *Application::mainWindow() HistoryManager *Application::historyManager() { - if (m_historyManager.isNull()) + if(m_historyManager.isNull()) { m_historyManager = new HistoryManager; } @@ -318,7 +325,7 @@ HistoryManager *Application::historyManager() BookmarkProvider *Application::bookmarkProvider() { - if (m_bookmarkProvider.isNull()) + if(m_bookmarkProvider.isNull()) { m_bookmarkProvider = new BookmarkProvider; } @@ -328,7 +335,7 @@ BookmarkProvider *Application::bookmarkProvider() SessionManager *Application::sessionManager() { - if (m_sessionManager.isNull()) + if(m_sessionManager.isNull()) { m_sessionManager = new SessionManager; } @@ -338,7 +345,7 @@ SessionManager *Application::sessionManager() OpenSearchManager *Application::opensearchManager() { - if (m_opensearchManager.isNull()) + if(m_opensearchManager.isNull()) { m_opensearchManager = new OpenSearchManager; } @@ -348,7 +355,7 @@ OpenSearchManager *Application::opensearchManager() IconManager *Application::iconManager() { - if (m_iconManager.isNull()) + if(m_iconManager.isNull()) { m_iconManager = new IconManager; } @@ -358,7 +365,7 @@ IconManager *Application::iconManager() DownloadManager *Application::downloadManager() { - if (m_downloadManager.isNull()) + if(m_downloadManager.isNull()) { m_downloadManager = new DownloadManager(instance()); } @@ -368,10 +375,10 @@ DownloadManager *Application::downloadManager() void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) { - if (url.isEmpty()) + if(url.isEmpty()) return; - if (!url.isValid()) + if(!url.isValid()) { KMessageBox::error(0, i18n("Malformed URL:\n%1", url.url(KUrl::RemoveTrailingSlash))); return; @@ -384,10 +391,10 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) ? newMainWindow() : mainWindow(); - switch (type) + switch(type) { case Rekonq::NewTab: - if (ReKonfig::openTabNoWindow()) + if(ReKonfig::openTabNoWindow()) tab = w->mainView()->newWebTab(!ReKonfig::openTabsBack()); else { @@ -417,7 +424,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) WebView *view = tab->view(); - if (view) + if(view) { FilterUrlJob *job = new FilterUrlJob(view, url.pathOrUrl(), this); Weaver::instance()->enqueue(job); @@ -431,7 +438,7 @@ MainWindow *Application::newMainWindow(bool withTab) // This is used to track which window was activated most recently w->installEventFilter(this); - if (withTab) + if(withTab) w->mainView()->newWebTab(); // remember using newWebTab and NOT newTab here!! m_mainWindows.prepend(w); @@ -455,7 +462,7 @@ MainWindowList Application::mainWindowList() AdBlockManager *Application::adblockManager() { - if (m_adblockManager.isNull()) + if(m_adblockManager.isNull()) { m_adblockManager = new AdBlockManager; } @@ -469,7 +476,7 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) KUrl url = threadedJob->url(); WebView *view = threadedJob->view(); - if (view) + if(view) { view->load(url); } @@ -486,16 +493,16 @@ void Application::newWindow() } -bool Application::eventFilter( QObject* watched, QEvent* event ) +bool Application::eventFilter(QObject* watched, QEvent* event) { // Track which window was activated most recently to prefer it on window choosing // (e.g. when another application opens a link) - if (event->type() == QEvent::WindowActivate) + if(event->type() == QEvent::WindowActivate) { MainWindow *window = qobject_cast<MainWindow*>(watched); - if (window) + if(window) { - if (m_mainWindows.at(0).data() != window) + if(m_mainWindows.at(0).data() != window) { int index = m_mainWindows.indexOf(QWeakPointer<MainWindow>(window)); Q_ASSERT(index != -1); @@ -504,7 +511,7 @@ bool Application::eventFilter( QObject* watched, QEvent* event ) } } - return QObject::eventFilter( watched, event ); + return QObject::eventFilter(watched, event); } @@ -517,9 +524,9 @@ void Application::updateConfiguration() MainView *mv = w.data()->mainView(); mv->updateTabBar(); - mv->tabBar()->setAnimatedTabHighlighting( ReKonfig::animatedTabHighlighting() ); + mv->tabBar()->setAnimatedTabHighlighting(ReKonfig::animatedTabHighlighting()); - if (b) + if(b) mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); else mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab); @@ -566,7 +573,7 @@ void Application::updateConfiguration() 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); @@ -578,7 +585,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"); @@ -588,38 +595,38 @@ void Application::updateConfiguration() // Applies user/system defined CSS to all open webpages. ReKonfig::userCSS().isEmpty() - ? defaultSettings->setUserStyleSheetUrl(KUrl(KStandardDirs::locate("appdata" , "default_rekonq.css"))) - : defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS()) + ? defaultSettings->setUserStyleSheetUrl(KUrl(KStandardDirs::locate("appdata" , "default_rekonq.css"))) + : defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS()) ; // ====== load Settings on main classes historyManager()->loadSettings(); adblockManager()->loadSettings(); - if (!ReKonfig::useFavicon()) + if(!ReKonfig::useFavicon()) mainWindow()->setWindowIcon(KIcon("rekonq")); else mainWindow()->changeWindowIcon(mainWindow()->mainView()->currentIndex()); // hovering unfocused tabs options - switch (ReKonfig::hoveringTabOption()) + switch(ReKonfig::hoveringTabOption()) { case 0: // tab previews case 3: // nothing - for (int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) + for(int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) { mainWindow()->mainView()->tabBar()->setTabToolTip(i, ""); } break; case 1: // title previews - for (int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) + for(int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) { mainWindow()->mainView()->tabBar()->setTabToolTip(i, mainWindow()->mainView()->tabText(i).remove('&')); } break; case 2: // url previews - for (int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) + for(int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) { mainWindow()->mainView()->tabBar()->setTabToolTip(i, mainWindow()->mainView()->webTab(i)->url().toMimeDataString()); } @@ -646,17 +653,17 @@ void Application::setPrivateBrowsingMode(bool b) QWebSettings *settings = QWebSettings::globalSettings(); bool isJustEnabled = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); - if (isJustEnabled == b) + if(isJustEnabled == b) return; // uhm... something goes wrong... - if (b) + if(b) { QString caption = i18n("Are you sure you want to turn on private browsing?"); QString text = i18n("<b>%1</b>" "<p>rekonq will save your current tabs for when you'll stop private browsing the net.</p>", caption); int button = KMessageBox::warningContinueCancel(mainWindow(), text, caption, KStandardGuiItem::cont(), KStandardGuiItem::cancel(), i18n("don't ask again")); - if (button != KMessageBox::Continue) + if(button != KMessageBox::Continue) return; settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); @@ -679,7 +686,7 @@ void Application::setPrivateBrowsingMode(bool b) _privateBrowsingAction->setChecked(false); loadUrl(KUrl("about:blank"), Rekonq::NewWindow); - if (!sessionManager()->restoreSession()) + if(!sessionManager()->restoreSession()) loadUrl(KUrl("about:home"), Rekonq::NewWindow); } } |