summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-07-28 11:11:56 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:04 +0100
commit9a111024c84f7f7cc10cbbd5fc43ee82e48ae79e (patch)
tree688b549594169bfca6b248415286adede8e4f4c5 /src
parentUpdate SearchEngine class to fix it with KDE 4.9 changes (diff)
downloadrekonq-9a111024c84f7f7cc10cbbd5fc43ee82e48ae79e.tar.xz
Class Application Import, first (important) part
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/application.cpp520
-rw-r--r--src/application.h104
-rw-r--r--src/main.cpp36
-rw-r--r--src/rekonq.kcfg286
-rw-r--r--src/rekonq.kcfgc5
-rw-r--r--src/tabwindow/tabwindow.cpp43
-rw-r--r--src/tabwindow/tabwindow.h31
8 files changed, 993 insertions, 38 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eeaf4ef3..6150691e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,6 +7,7 @@ ADD_SUBDIRECTORY( data )
set(rekonq_KDEINIT_SRCS
#----------------------------------------
+ application.cpp
searchengine.cpp
urlresolver.cpp
websnap.cpp
@@ -42,6 +43,11 @@ ADD_DEFINITIONS ( ${KDE4_DEFINITIONS} )
KDE4_ADD_APP_ICON( rekonq_KDEINIT_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../icons/hi*-app-rekonq.png )
+### -------------- ADDING APPLICATION KCFG FILES...
+
+KDE4_ADD_KCFG_FILES( rekonq_KDEINIT_SRCS rekonq.kcfgc )
+
+
### --------------- ADDING EXECUTABLE...
# NOTE: This is the simple main used to test the tabwindow :)
diff --git a/src/application.cpp b/src/application.cpp
new file mode 100644
index 00000000..98b74649
--- /dev/null
+++ b/src/application.cpp
@@ -0,0 +1,520 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* 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
+* 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
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+// Self Includes
+#include "application.h"
+#include "application.moc"
+
+// Auto Includes
+#include "rekonq.h"
+
+// Local Includes
+#include "tabwindow.h"
+#include "webwindow.h"
+#include "urlresolver.h"
+
+// // KDE Includes
+#include <KCmdLineArgs>
+
+#include <KWindowSystem>
+#include <KWindowInfo>
+#include <KStartupInfo>
+
+#include <KMessageBox>
+// #include <KIcon>
+// #include <KStandardDirs>
+// #include <KAction>
+
+// #include <KGlobal>
+// #include <KCharsets>
+// #include <KPushButton>
+// #include <KMimeType>
+//
+// // Qt Includes
+// #include <QVBoxLayout>
+// #include <QDir>
+// #include <QTimer>
+
+
+Application::Application()
+ : KUniqueApplication()
+{
+}
+
+
+Application::~Application()
+{
+ // ok, we are closing well.
+ // Don't recover on next load..
+ ReKonfig::setRecoverOnCrash(0);
+ saveConfiguration();
+
+ kDebug() << "Bye bye (k)baby...";
+}
+
+
+int Application::newInstance()
+{
+ KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+
+ // not that easy, indeed
+ // We have to consider 3 variables here:
+ // 1) Is first load?
+ // 2) Are there arguments?
+ // 3) Is rekonq recovering from crash?
+ // 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
+
+ kDebug() << "is first load? " << isFirstLoad;
+ kDebug() << "are there arguments? " << areThereArguments;
+ kDebug() << "is rekonq crashed? " << hasToBeRecovered;
+
+ if (!isSessionRestored())
+ {
+ if (areThereArguments)
+ {
+ // 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()->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())
+ {
+ loadUrl(urlList.at(0), Rekonq::NewFocusedTab);
+ }
+ else
+ {
+ 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
+ {
+ for (int i = 1; i < urlList.count(); ++i)
+ loadUrl(urlList.at(i), Rekonq::NewWindow);
+ }
+ }
+ else
+ {
+ if (isFirstLoad)
+ {
+ if (hasToBeRecovered)
+ {
+ loadUrl(KUrl("about:closedTabs"), Rekonq::NewWindow);
+ }
+ else
+ {
+ switch (ReKonfig::startupBehaviour())
+ {
+ case 0: // open home page
+ newTabWindow()->newCleanTab();
+ break;
+ case 1: // open new tab page
+ loadUrl(KUrl("about:home"), Rekonq::NewWindow);
+ break;
+ case 2: // restore session FIXME
+// if (sessionManager()->restoreSessionFromScratch())
+// {
+// break;
+// }
+ default:
+ newTabWindow()->newCleanTab();
+ break;
+ }
+ }
+ }
+ else
+ {
+ 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;
+ }
+ }
+ }
+ } // !isSessionRestored()
+
+// if (isFirstLoad)
+// {
+// FIXME
+// if (hasToBeRecovered)
+// {
+// QTimer::singleShot(1000, tabWindow()->currentTab(), SLOT(showMessageBar()));
+// }
+// else
+// {
+// sessionManager()->setSessionManagementEnabled(true);
+// }
+//
+// if (ReKonfig::checkDefaultSearchEngine() && !hasToBeRecovered && SearchEngine::defaultEngine().isNull())
+// QTimer::singleShot(2000, tabWindow()->currentTab(), SLOT(showSearchEngineBar()));
+
+ // updating rekonq configuration
+ updateConfiguration();
+
+ setWindowIcon(KIcon("rekonq"));
+
+// FIXME historyManager();
+
+ ReKonfig::setRecoverOnCrash(ReKonfig::recoverOnCrash() + 1);
+ saveConfiguration();
+// }
+
+ KStartupInfo::appStarted();
+ isFirstLoad = false;
+
+ return 0;
+}
+
+
+Application *Application::instance()
+{
+ return (qobject_cast<Application *>(QCoreApplication::instance()));
+}
+
+
+void Application::saveConfiguration() const
+{
+ ReKonfig::self()->writeConfig();
+}
+
+
+TabWindow *Application::tabWindow()
+{
+ TabWindow *active = qobject_cast<TabWindow*>(QApplication::activeWindow());
+
+ if (!active)
+ {
+ if (m_tabWindows.isEmpty())
+ return 0;
+
+ Q_FOREACH(const QWeakPointer<TabWindow> &pointer, m_tabWindows)
+ {
+ if (KWindowInfo(pointer.data()->effectiveWinId(), NET::WMDesktop, 0).isOnCurrentDesktop())
+ return pointer.data();
+ }
+ return m_tabWindows.at(0).data();
+ }
+ return active;
+}
+
+
+void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
+{
+ if (url.isEmpty())
+ return;
+
+ if (!url.isValid())
+ {
+ KMessageBox::error(0, i18n("Malformed URL:\n%1", url.url(KUrl::RemoveTrailingSlash)));
+ return;
+ }
+
+ Rekonq::OpenType newType = type;
+ // Don't open useless tabs or windows for actions in about: pages
+ if (url.url().contains("about:") && url.url().contains("/"))
+ newType = Rekonq::CurrentTab;
+
+ TabWindow *w = 0;
+ if (newType == Rekonq::NewWindow
+ || (newType == Rekonq::NewTab && ReKonfig::openLinksInNewWindow()))
+ {
+ w = newTabWindow();
+ newType = Rekonq::CurrentTab;
+ }
+ else
+ {
+ w = tabWindow();
+ }
+
+ w->loadUrl(url, newType);
+}
+
+
+TabWindow *Application::newTabWindow()
+{
+ TabWindow *w = new TabWindow;
+ // This is used to track which window was activated most recently
+ w->installEventFilter(this);
+
+ m_tabWindows.prepend(w);
+ w->show();
+
+ return w;
+}
+
+
+void Application::removeTabWindow(TabWindow *window)
+{
+ m_tabWindows.removeOne(window);
+ kDebug() << "Removing Window from app window list...";
+
+ // bye bye...
+ if (m_tabWindows.count() == 0)
+ quit();
+}
+
+
+TabWindowList Application::tabWindowList()
+{
+ return m_tabWindows;
+}
+
+
+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)
+ {
+ TabWindow *window = qobject_cast<TabWindow*>(watched);
+ if (window)
+ {
+ if (m_tabWindows.at(0).data() != window)
+ {
+ int index = m_tabWindows.indexOf(QWeakPointer<TabWindow>(window));
+ Q_ASSERT(index != -1);
+ m_tabWindows.prepend(m_tabWindows.takeAt(index));
+ }
+ }
+ }
+
+ return QObject::eventFilter(watched, event);
+}
+
+
+void Application::updateConfiguration()
+{
+ kDebug() << "Updating... NOTHING!!!";
+// // ============== Tabs ==================
+// bool b = ReKonfig::closeTabSelectPrevious();
+// Q_FOREACH(const QWeakPointer<TabWindow> &w, m_tabWindows)
+// {
+// MainView *mv = w.data()->mainView();
+// mv->updateTabBar();
+//
+// mv->tabBar()->setAnimatedTabHighlighting(ReKonfig::animatedTabHighlighting());
+//
+// if (b)
+// mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
+// else
+// mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab);
+// }
+//
+// QWebSettings *defaultSettings = QWebSettings::globalSettings();
+//
+// // =========== Fonts ==============
+// defaultSettings->setFontFamily(QWebSettings::StandardFont, ReKonfig::standardFontFamily());
+// defaultSettings->setFontFamily(QWebSettings::FixedFont, ReKonfig::fixedFontFamily());
+// defaultSettings->setFontFamily(QWebSettings::SerifFont, ReKonfig::serifFontFamily());
+// defaultSettings->setFontFamily(QWebSettings::SansSerifFont, ReKonfig::sansSerifFontFamily());
+// defaultSettings->setFontFamily(QWebSettings::CursiveFont, ReKonfig::cursiveFontFamily());
+// defaultSettings->setFontFamily(QWebSettings::FantasyFont, ReKonfig::fantasyFontFamily());
+//
+// // 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
+// if (tabWindow() && tabWindow()->currentTab())
+// {
+// int logDpiY = tabWindow()->currentTab()->view()->logicalDpiY();
+// float toPix = (logDpiY < 96.0)
+// ? 96.0 / 72.0
+// : logDpiY / 72.0 ;
+//
+// int defaultFontSize = ReKonfig::defaultFontSize();
+// int minimumFontSize = ReKonfig::minFontSize();
+//
+// defaultSettings->setFontSize(QWebSettings::DefaultFontSize, qRound(defaultFontSize * toPix));
+// defaultSettings->setFontSize(QWebSettings::MinimumFontSize, qRound(minimumFontSize * toPix));
+// }
+//
+// // encodings
+// QString enc = ReKonfig::defaultEncoding();
+// defaultSettings->setDefaultTextEncoding(enc);
+//
+// // ================ WebKit ============================
+// defaultSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, ReKonfig::dnsPrefetch());
+// defaultSettings->setAttribute(QWebSettings::PrintElementBackgrounds, ReKonfig::printElementBackgrounds());
+//
+// defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, ReKonfig::javascriptEnabled());
+// defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, ReKonfig::javascriptCanOpenWindows());
+// defaultSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, ReKonfig::javascriptCanAccessClipboard());
+//
+// defaultSettings->setAttribute(QWebSettings::JavaEnabled, ReKonfig::javaEnabled());
+//
+// if (ReKonfig::pluginsEnabled() == 2)
+// defaultSettings->setAttribute(QWebSettings::PluginsEnabled, false);
+// else
+// defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true);
+//
+// // Enabling WebKit "Page Cache" feature: http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
+// defaultSettings->setMaximumPagesInCache(3);
+//
+// // ===== HTML 5 features WebKit support ======
+// defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, ReKonfig::offlineStorageDatabaseEnabled());
+// defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, ReKonfig::offlineWebApplicationCacheEnabled());
+// defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled, ReKonfig::localStorageEnabled());
+// if (ReKonfig::localStorageEnabled())
+// {
+// QString path = KStandardDirs::locateLocal("cache", QString("WebkitLocalStorage/rekonq"), true);
+// path.remove("rekonq");
+// QWebSettings::setOfflineStoragePath(path);
+// QWebSettings::setOfflineStorageDefaultQuota(50000);
+// }
+//
+// // ================= WebGl ===================
+// defaultSettings->setAttribute(QWebSettings::WebGLEnabled, ReKonfig::webGL());
+// defaultSettings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, ReKonfig::webGL());
+//
+// // Applies user defined CSS to all open webpages.
+// defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS());
+//
+// // ====== load Settings on main classes
+// historyManager()->loadSettings();
+//
+// defaultSettings = 0;
+//
+// if (!tabWindow())
+// return;
+//
+// ReKonfig::useFavicon()
+// ? tabWindow()->changeWindowIcon(tabWindow()->mainView()->currentIndex())
+// : tabWindow()->setWindowIcon(KIcon("rekonq"))
+// ;
+//
+// // hovering unfocused tabs options
+// switch (ReKonfig::hoveringTabOption())
+// {
+// case 0: // tab previews
+// case 3: // nothing
+// for (int i = 0; i < tabWindow()->mainView()->tabBar()->count(); i++)
+// {
+// tabWindow()->mainView()->tabBar()->setTabToolTip(i, QL1S(""));
+// }
+// break;
+//
+// case 1: // title previews
+// for (int i = 0; i < tabWindow()->mainView()->tabBar()->count(); i++)
+// {
+// tabWindow()->mainView()->tabBar()->setTabToolTip(i, tabWindow()->mainView()->tabText(i).remove('&'));
+// }
+// break;
+//
+// case 2: // url previews
+// for (int i = 0; i < tabWindow()->mainView()->tabBar()->count(); i++)
+// {
+// tabWindow()->mainView()->tabBar()->setTabToolTip(i, tabWindow()->mainView()->webTab(i)->url().toMimeDataString());
+// }
+// break;
+//
+// default: // non extant case
+// ASSERT_NOT_REACHED(unknown hoveringTabOption);
+// break;
+// }
+
+}
+
+
+void Application::queryQuit()
+{
+ if (tabWindowList().count() > 1)
+ {
+ int answer = KMessageBox::questionYesNoCancel(
+ tabWindow(),
+ i18n("Do you want to close the window or the whole application?"),
+ i18n("Application/Window closing..."),
+ KGuiItem(i18n("C&lose Current Window"),
+ KIcon("window-close")),
+ KStandardGuiItem::quit(),
+ KStandardGuiItem::cancel(),
+ "confirmClosingMultipleWindows"
+ );
+
+ switch (answer)
+ {
+ case KMessageBox::Yes:
+ tabWindow()->close();
+ return;
+
+ case KMessageBox::No:
+ break;
+
+ default:
+ return;
+ }
+ }
+
+ // in case of just one window...
+ quit();
+}
diff --git a/src/application.h b/src/application.h
new file mode 100644
index 00000000..a9f6ff63
--- /dev/null
+++ b/src/application.h
@@ -0,0 +1,104 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* 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
+* 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
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+#ifndef APPLICATION_H
+#define APPLICATION_H
+
+
+// Local Includes
+#include "tabwindow.h"
+
+// KDE Includes
+#include <KUniqueApplication>
+#include <KUrl>
+
+// Qt Includes
+#include <QWeakPointer>
+
+// Forward Declarations
+class WebWindow;
+
+
+typedef QList< QWeakPointer<TabWindow> > TabWindowList;
+
+
+// ---------------------------------------------------------------------------------------------------------------
+
+
+#define rApp Application::instance()
+
+/**
+ * Rekonq Application class
+ */
+class Application : public KUniqueApplication
+{
+ Q_OBJECT
+
+public:
+ Application();
+ ~Application();
+
+ int newInstance();
+ static Application *instance();
+
+ TabWindow *tabWindow();
+ TabWindow *newTabWindow();
+ TabWindowList tabWindowList();
+
+public Q_SLOTS:
+ /**
+ * Save application's configuration
+ *
+ * @see ReKonfig::self()->writeConfig();
+ */
+ void saveConfiguration() const;
+
+ /**
+ * @short load url
+ *
+ * @param url The url to load
+ * @param type the type where loading the url. @see Rekonq::OpenType
+ */
+ void loadUrl(const KUrl& url,
+ const Rekonq::OpenType& type = Rekonq::CurrentTab
+ );
+
+ void removeTabWindow(TabWindow *window);
+
+protected:
+ // This is used to track which window was activated most recently
+ bool eventFilter(QObject *watched, QEvent *event);
+
+private Q_SLOTS:
+ void updateConfiguration();
+
+ void queryQuit();
+
+private:
+ TabWindowList m_tabWindows;
+};
+
+#endif // APPLICATION_H
diff --git a/src/main.cpp b/src/main.cpp
index 5c55aa81..c5759d84 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -21,12 +21,14 @@
// version include
#include "config-version.h"
+#include "application.h"
#include "tabwindow.h"
#include "urlresolver.h"
#include <KDE/KAboutData>
-#include <KDE/KApplication>
+#include <KDE/KUniqueApplication>
#include <KDE/KCmdLineArgs>
+#include <KDebug>
#include <QDir>
#include <QUrl>
@@ -62,18 +64,18 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
// Register the supported options
KCmdLineArgs::addCmdLineOptions(options);
-// if (!Application::start())
-// {
-// kWarning() << "rekonq is already running!";
-// return 0;
-// }
+ if (!Application::start())
+ {
+ kWarning() << "rekonq is already running!";
+ return 0;
+ }
#if defined(Q_WS_X11)
// On X11, the raster engine gives better performance than native.
QApplication::setGraphicsSystem(QLatin1String("raster"));
#endif
- KApplication app;
+ Application app;
QWebSettings::setIconDatabasePath("/tmp/iconcache");
@@ -83,26 +85,6 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
KCmdLineArgs::setCwd(QDir::currentPath().toUtf8());
- TabWindow *w = new TabWindow;
-
- // no session.. just start up normally
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- if (args->count() == 0)
- {
- w->newCleanTab();
- w->show();
- }
- else
- {
- int i = 0;
- for (; i < args->count(); i++)
- {
- w->loadUrlInNewTab( UrlResolver::urlFromTextTyped(args->arg(i)) );
- }
- w->show();
- }
- args->clear();
-
// if (app.isSessionRestored())
// for (int i = 1; MainWindow::canBeRestored(i); i++)
// app.newMainWindow(false)->restore(i);
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
new file mode 100644
index 00000000..7def60c2
--- /dev/null
+++ b/src/rekonq.kcfg
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+
+<!-- Includes -->
+<include>QtWebKit</include>
+<include>QDateTime</include>
+<include>KUrl</include>
+<include>KGlobalSettings</include>
+
+<kcfgfile name="rekonqrc" />
+
+<!-- Miscellaneuos (not config UI) settings -->
+<group name="misc">
+ <entry name="FirstExecution" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="showHistoryPanel" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="showBookmarksPanel" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="walletBlackList" type="StringList">
+ <default></default>
+ </entry>
+ <entry name="recoverOnCrash" type="Int">
+ <default>0</default>
+ </entry>
+ <entry name="createDesktopAppShortcut" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="createMenuAppShortcut" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="checkDefaultSearchEngine" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="clearHistory" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="clearDownloads" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="clearCookies" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="clearCachedPages" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="clearWebIcons" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="clearHomePageThumbs" type="Bool">
+ <default>true</default>
+ </entry>
+</group>
+
+
+<!-- New Tab Page Settings -->
+<group name="NewTabPage">
+ <entry name="previewNames" type="StringList">
+ <default>KDE Homepage,rekonq site</default>
+ </entry>
+ <entry name="previewUrls" type="StringList">
+ <default>http://www.kde.org/,http://rekonq.kde.org/</default>
+ </entry>
+</group>
+
+
+<!-- General Settings -->
+<group name="General">
+ <entry name="startupBehaviour" type="Int">
+ <default>1</default>
+ </entry>
+ <entry name="useNewTabPage" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="homePage" type="String">
+ <default>http://www.kde.org/</default>
+ </entry>
+ <entry name="downloadPath" type="Url">
+ <default code="true">KGlobalSettings::downloadPath()</default>
+ </entry>
+ <entry name="askDownloadPath" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="kgetDownload" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="kgetList" type="Bool">
+ <default>false</default>
+ </entry>
+</group>
+
+
+<!-- Tabs Settings -->
+<group name="Tabs">
+ <!-- xxx -->
+ <entry name="newTabsBehaviour" type="Int">
+ <default>0</default>
+ </entry>
+ <entry name="newTabStartPage" type="Int">
+ <default>0</default>
+ </entry>
+ <!-- xxx -->
+ <entry name="hoveringTabOption" type="Int">
+ <default>0</default>
+ </entry>
+ <!-- xxx -->
+ <entry name="openLinksInNewWindow" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="openExternalLinksInNewWindow" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="lastTabClosesWindow" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="openNewTabsInBackground" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="openNewTabsNearCurrent" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="closeTabSelectPrevious" type="Bool">
+ <default>false</default>
+ </entry>
+</group>
+
+
+<!-- Fonts Settings -->
+<group name="Appearance">
+ <entry name="standardFontFamily" type="String">
+ <default code="true">KGlobalSettings::generalFont().family()</default>
+ </entry>
+ <entry name="fixedFontFamily" type="String">
+ <default code="true">KGlobalSettings::fixedFont().family()</default>
+ </entry>
+ <entry name="serifFontFamily" type="String">
+ <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::SerifFont)</default>
+ </entry>
+ <entry name="sansSerifFontFamily" type="String">
+ <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::SansSerifFont)</default>
+ </entry>
+ <entry name="cursiveFontFamily" type="String">
+ <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::CursiveFont)</default>
+ </entry>
+ <entry name="fantasyFontFamily" type="String">
+ <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::FantasyFont)</default>
+ </entry>
+ <entry name="defaultFontSize" type="Int">
+ <default>12</default>
+ </entry>
+ <entry name="minFontSize" type="Int">
+ <default>7</default>
+ </entry>
+ <entry name="defaultEncoding" type="String">
+ <default>ISO 8859-1</default>
+ </entry>
+ <entry name="userCSS" type="Url">
+ <default></default>
+ </entry>
+</group>
+
+
+<!-- Privacy Settings -->
+<group name="Privacy">
+ <entry name="javascriptCanOpenWindows" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="javascriptCanAccessClipboard" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="expireHistory" type="Int">
+ <default>0</default>
+ </entry>
+ <entry name="passwordSavingEnabled" type="Bool">
+ <default>true</default>
+ </entry>
+</group>
+
+
+<!-- WebKit Settings -->
+<group name="Webkit">
+ <!-- xxx -->
+ <entry name="javascriptEnabled" type="Bool">
+ <default>true</default>
+ </entry>
+ <!-- xxx -->
+ <entry name="pluginsEnabled" type="Int">
+ <default>0</default>
+ </entry>
+ <!-- xxx -->
+ <entry name="offlineStorageDatabaseEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="offlineWebApplicationCacheEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="localStorageEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <!-- xxx -->
+ <entry name="javaEnabled" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="webGL" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="spatialNavigation" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="frameFlattening" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="dnsPrefetch" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="printElementBackgrounds" type="Bool">
+ <default>true</default>
+ </entry>
+</group>
+
+
+<!-- Advanced Settings -->
+<group name="Advanced">
+ <entry name="hScrollWheelHistory" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="enableViShortcuts" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="accessKeysEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="smoothScrolling" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="useFavicon" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="middleClickAction" type="Int">
+ <default>2</default>
+ </entry>
+</group>
+
+
+<!-- Sync Settings -->
+<group name="Sync">
+ <entry name="syncEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="syncBookmarks" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="syncHistory" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="syncPasswords" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="syncType" type="Int">
+ <default>0</default>
+ </entry>
+ <entry name="syncHost" type="String">
+ <default></default>
+ </entry>
+ <entry name="syncUser" type="String">
+ <default></default>
+ </entry>
+ <entry name="syncPass" type="String">
+ <default></default>
+ </entry>
+ <entry name="syncPath" type="String">
+ <default></default>
+ </entry>
+ <entry name="syncPort" type="Int">
+ <default>21</default>
+ </entry>
+</group>
+
+</kcfg>
diff --git a/src/rekonq.kcfgc b/src/rekonq.kcfgc
new file mode 100644
index 00000000..50a9817d
--- /dev/null
+++ b/src/rekonq.kcfgc
@@ -0,0 +1,5 @@
+File=rekonq.kcfg
+ClassName=ReKonfig
+Singleton=true
+Mutators=true
+UseEnumTypes=true
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 9e2a17ce..a849426e 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -85,6 +85,11 @@ TabWindow::TabWindow(QWidget *parent)
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
+ // NOTE: NEVER create a tabwindow without AT LEAST one tab...
+ WebWindow *tab = prepareNewTab();
+ addTab(tab, i18n("new tab"));
+ setCurrentWidget(tab);
+
// FIXME: Manage sizes...
kDebug() << "SIZE: " << size();
kDebug() << "SIZE HINT: " << sizeHint();
@@ -147,15 +152,35 @@ WebWindow *TabWindow::prepareNewTab(WebPage *page)
}
-void TabWindow::loadUrlInNewTab(const QUrl &url, TabHistory *history)
+void TabWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *history)
{
- WebWindow *tab = prepareNewTab();
+ WebWindow *tab = 0;
+ switch (type)
+ {
+ case Rekonq::NewTab:
+ case Rekonq::NewBackGroundTab:
+ tab = prepareNewTab();
+ addTab(tab, i18n("new tab"));
+ break;
+
+ case Rekonq::NewFocusedTab:
+ tab = prepareNewTab();
+ addTab(tab, i18n("new tab"));
+ setCurrentWidget(tab);
+ break;
+
+ case Rekonq::NewWindow:
+ // TODO
+// emit loadUrlInNewWindow(url);
+ return;
- // Now, the dirty jobs...
- addTab(tab, i18n("new tab"));
- tab->load(url);
+ case Rekonq::CurrentTab:
+ default:
+ tab = currentWebWindow();
+ break;
+ };
- setCurrentWidget(tab);
+ tab->load(url);
if (history)
{
@@ -169,7 +194,7 @@ void TabWindow::loadUrlInNewTab(const QUrl &url, TabHistory *history)
void TabWindow::newCleanTab()
{
QUrl u = QUrl::fromUserInput("/DATI/WEBPAGES/HomePage/index.htm");
- loadUrlInNewTab(u);
+ loadUrl(u, Rekonq::NewTab);
}
@@ -338,7 +363,7 @@ void TabWindow::cloneTab(int index)
QWebHistory* history = webWindow(index)->page()->history();
TabHistory tHistory(history);
- loadUrlInNewTab(u, &tHistory);
+ loadUrl(u, Rekonq::NewTab, &tHistory);
}
@@ -440,7 +465,7 @@ void TabWindow::restoreClosedTab(int i)
QUrl u = QUrl(history.url);
- loadUrlInNewTab(u, &history);
+ loadUrl(u, Rekonq::NewTab, &history);
// just to get sure...
m_recentlyClosedTabs.removeAll(history);
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index f8cb759f..24f1b42e 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -25,8 +25,9 @@
#include <KTabWidget>
+class KUrl;
+
class QLabel;
-class QUrl;
class QToolButton;
class QWebHistory;
@@ -37,6 +38,32 @@ class WebPage;
class WebWindow;
+// --------------------------------------------------------------------------------------
+
+
+namespace Rekonq
+{
+
+/**
+* @short Open link options
+* Different modes of opening new tab
+*/
+enum OpenType
+{
+ CurrentTab, ///< open url in current tab
+ NewTab, ///< open url according to users settings
+ NewFocusedTab, ///< open url in new tab and focus it
+ NewBackGroundTab, ///< open url in new background tab
+ NewWindow ///< open url in new window
+};
+
+
+}
+
+
+// --------------------------------------------------------------------------------------
+
+
class TabWindow : public KTabWidget
{
Q_OBJECT
@@ -52,7 +79,7 @@ public:
TabBar* tabBar() const;
public Q_SLOTS:
- void loadUrlInNewTab(const QUrl &, TabHistory *history = 0);
+ void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0);
void newCleanTab();
private: