diff options
-rw-r--r-- | src/application.cpp | 20 | ||||
-rw-r--r-- | src/application.h | 1 | ||||
-rw-r--r-- | src/homepage.cpp | 29 | ||||
-rw-r--r-- | src/homepage.h | 12 | ||||
-rw-r--r-- | src/mainview.cpp | 7 | ||||
-rw-r--r-- | src/mainwindow.cpp | 9 | ||||
-rw-r--r-- | src/webpage.cpp | 6 |
7 files changed, 66 insertions, 18 deletions
diff --git a/src/application.cpp b/src/application.cpp index 9bbf7792..9b7d175f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -42,6 +42,7 @@ #include "webview.h" #include "urlbar.h" #include "sessionmanager.h" +#include "homepage.h" // KDE Includes #include <KCmdLineArgs> @@ -303,6 +304,13 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) KMessageBox::error(0, i18n("Malformed URL:\n%1", url.url())); return; } + + // loading home pages + if (url.scheme() == QLatin1String("about")) + { + homePage(url); + return; + } if (url.scheme() == QLatin1String("mailto")) { @@ -416,3 +424,15 @@ MainWindowList Application::mainWindowList() { return m_mainWindows; } + + +void Application::homePage(const KUrl &url) +{ + kDebug() << "loading home: " << url; + MainView *view = mainWindow()->mainView(); + WebView *w = view->currentWebView(); + HomePage p(w); + w->setHtml( p.rekonqHomePage(url), url); + view->urlBar()->setFocus(); + return; +} diff --git a/src/application.h b/src/application.h index e5616d59..f886982c 100644 --- a/src/application.h +++ b/src/application.h @@ -101,6 +101,7 @@ public: MainWindow *mainWindow(); MainWindowList mainWindowList(); + void homePage(const KUrl &url = KUrl("about:home")); static KIcon icon(const KUrl &url); diff --git a/src/homepage.cpp b/src/homepage.cpp index 230692c0..dabcaad7 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -49,9 +49,8 @@ #include <QFile> -HomePage::HomePage(QObject *parent, const QString &authority) +HomePage::HomePage(QObject *parent) : QObject(parent) - , m_authority(authority) { m_homePagePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); } @@ -62,7 +61,7 @@ HomePage::~HomePage() } -QString HomePage::rekonqHomePage() +QString HomePage::rekonqHomePage(const KUrl &url) { QFile file(m_homePagePath); bool isOpened = file.open(QIODevice::ReadOnly); @@ -73,9 +72,18 @@ QString HomePage::rekonqHomePage() } QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); - QString speed = speedDial(); QString menu = homePageMenu(); + QString speed; + if(url == KUrl("about:lastSites")) + speed = fillRecentHistory(); + if(url == KUrl("about:history")) + speed = history(); + if(url == KUrl("about:bookmarks")) + speed = bookmarks(); + if(url == KUrl("about:home") || url == KUrl("about:preferred")) + speed = speedDial(); + QString html = QString(QLatin1String(file.readAll())) .arg(imagesPath) .arg(menu) @@ -176,3 +184,16 @@ QString HomePage::homePageMenu() menu += "</ul>"; return menu; } + + +QString HomePage::history() +{ + return QString(""); +} + + +QString HomePage::bookmarks() +{ + return QString(""); +} + diff --git a/src/homepage.h b/src/homepage.h index 3996c095..48fc4fa6 100644 --- a/src/homepage.h +++ b/src/homepage.h @@ -27,6 +27,10 @@ #ifndef REKONQ_HOME_PAGE #define REKONQ_HOME_PAGE + +// KDE Includes +#include <KUrl> + // Qt Includes #include <QtCore/QObject> #include <QtCore/QString> @@ -40,20 +44,20 @@ class HomePage : public QObject Q_OBJECT public: - HomePage(QObject *parent = 0, const QString &authority = QString("home")); + HomePage(QObject *parent = 0); ~HomePage(); - QString rekonqHomePage(); + QString rekonqHomePage(const KUrl &url = KUrl("about:home")); QString homePageMenu(); private: QString speedDial(); QString recentlyClosedTabs(); QString fillRecentHistory(); + QString history(); + QString bookmarks(); QString m_homePagePath; - - QString m_authority; }; #endif // REKONQ_HOME_PAGE diff --git a/src/mainview.cpp b/src/mainview.cpp index f9a5cc5b..231700a0 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -305,12 +305,10 @@ void MainView::newTab() { WebView *w = newWebView(); - HomePage p(w); - switch(ReKonfig::newTabsBehaviour()) { case 0: - w->setHtml( p.rekonqHomePage() ); + Application::instance()->homePage(); break; case 1: urlBar()->setUrl(KUrl("")); @@ -581,6 +579,7 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) return label; } + void MainView::resizeEvent(QResizeEvent *event) { KTabWidget::resizeEvent(event); @@ -592,6 +591,7 @@ KUrl::List MainView::recentlyClosedTabs() return m_recentlyClosedTabs; } + void MainView::mouseMoveEvent(QMouseEvent *event) { //Find the tab under the mouse @@ -634,6 +634,7 @@ void MainView::leaveEvent(QEvent *event) KTabWidget::leaveEvent(event); } + void MainView::showTabPreview(int tab) { int w=200; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 722189f5..e0aed6e7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -45,7 +45,6 @@ #include "findbar.h" #include "sidepanel.h" #include "urlbar.h" -#include "homepage.h" // Ui Includes #include "ui_cleardata.h" @@ -740,17 +739,13 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - WebView *w = currentTab(); - if(ReKonfig::newTabHomePage()) { - HomePage p(w); - w->setHtml( p.rekonqHomePage(), QUrl()); - m_view->urlBar()->setFocus(); + Application::instance()->homePage(); } else { - w->load( QUrl(ReKonfig::homePage()) ); + currentTab()->load( QUrl(ReKonfig::homePage()) ); } } diff --git a/src/webpage.cpp b/src/webpage.cpp index 942f20e3..49896892 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -107,6 +107,12 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r return false; } + if (request.url().scheme() == QLatin1String("about")) + { + Application::instance()->loadUrl( request.url() ); + return false; + } + m_requestedUrl = request.url(); return QWebPage::acceptNavigationRequest(frame, request, type); |