From 667bd0a8450835f9b95b8ce83fb4f04a7df6d4ca Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 8 Sep 2009 02:38:18 +0200 Subject: HUGE HUGE HUGE COMMIT! First implementation of "rekonq home page" - Added icons && htmls for it - fixed pics places && CMakeLists.txt - Added a HomePage class to create the "rekonq home Page" - Modified setting to load on new tab start 1) rekonq home page (default) 2) blank page 3) an url (to set) - removed home page button - fixed WebPage && loadUrl slot to load "home:" scheme - Added a toolbar method in BookmarksProvider to load bookmarks in the homepage The page needs a lot of love, but I think this is a really good starting point for. Hope you like it :) --- data/CMakeLists.txt | 9 +- data/closed.png | Bin 0 -> 118 bytes data/home.html | 116 +++++++++++++++++++++++ data/open.png | Bin 0 -> 120 bytes icons/CMakeLists.txt | 2 - icons/pics/CMakeLists.txt | 4 - icons/pics/hi64-actions-download.png | Bin 4518 -> 0 bytes src/CMakeLists.txt | 1 + src/application.cpp | 6 ++ src/bookmarks.cpp | 6 ++ src/bookmarks.h | 6 ++ src/historymodels.h | 1 + src/homepage.cpp | 173 +++++++++++++++++++++++++++++++++++ src/homepage.h | 59 ++++++++++++ src/mainview.cpp | 13 ++- src/mainwindow.cpp | 19 +++- src/mainwindow.h | 1 - src/rekonq.kcfg | 8 +- src/settings.cpp | 19 ++++ src/settings.h | 1 + src/settings_general.ui | 78 ++++++++-------- src/webpage.cpp | 7 ++ 22 files changed, 466 insertions(+), 63 deletions(-) create mode 100644 data/closed.png create mode 100644 data/home.html create mode 100644 data/open.png delete mode 100644 icons/pics/CMakeLists.txt delete mode 100644 icons/pics/hi64-actions-download.png create mode 100644 src/homepage.cpp create mode 100644 src/homepage.h diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 93b9f83c..062bc138 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,5 +1,5 @@ INSTALL( - FILES loading.mng + FILES closed.png loading.mng open.png webkit-icon.png DESTINATION ${DATA_INSTALL_DIR}/rekonq/pics ) @@ -14,11 +14,6 @@ INSTALL( ) INSTALL( - FILES notfound.html + FILES notfound.html home.html DESTINATION ${DATA_INSTALL_DIR}/rekonq/htmls ) - -INSTALL( - FILES webkit-icon.png - DESTINATION ${DATA_INSTALL_DIR}/rekonq/pics -) diff --git a/data/closed.png b/data/closed.png new file mode 100644 index 00000000..2b1bf01e Binary files /dev/null and b/data/closed.png differ diff --git a/data/home.html b/data/home.html new file mode 100644 index 00000000..d1a200cf --- /dev/null +++ b/data/home.html @@ -0,0 +1,116 @@ + + + + +rekonq home page + + + + + + + + + + + + + + + + + + + + + + + + +

History

Bookmarks

%2%3
+ + + + + diff --git a/data/open.png b/data/open.png new file mode 100644 index 00000000..fee6f3fb Binary files /dev/null and b/data/open.png differ diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index d575cf4d..9d7ead58 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -1,4 +1,2 @@ # install standard icons KDE4_INSTALL_ICONS( ${ICON_INSTALL_DIR} ) - -ADD_SUBDIRECTORY( pics ) diff --git a/icons/pics/CMakeLists.txt b/icons/pics/CMakeLists.txt deleted file mode 100644 index 53d04224..00000000 --- a/icons/pics/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -INSTALL( - FILES hi64-actions-download.png - DESTINATION ${DATA_INSTALL_DIR}/rekonq/pics -) diff --git a/icons/pics/hi64-actions-download.png b/icons/pics/hi64-actions-download.png deleted file mode 100644 index aa1101c1..00000000 Binary files a/icons/pics/hi64-actions-download.png and /dev/null differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b760a64..f7d54c39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ ### ------- SETTING REKONQ FILES.. SET( rekonq_SRCS + homepage.cpp networkaccessmanager.cpp autosaver.cpp application.cpp diff --git a/src/application.cpp b/src/application.cpp index 1e30cfd0..f2a6c554 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -309,6 +309,12 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) return; } + if(url.scheme() == QLatin1String("home")) + { + mainWindow()->slotHome(); + return; + } + KUrl loadingUrl(url); if (loadingUrl.isRelative()) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 69f6c945..b1e482cf 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -295,3 +295,9 @@ KAction *BookmarkProvider::fillBookmarkBar(const KBookmark &bookmark) return new KBookmarkAction(bookmark, m_owner, this); } } + + +KBookmarkGroup BookmarkProvider::toolbar() +{ + return m_manager->toolbar(); +} diff --git a/src/bookmarks.h b/src/bookmarks.h index df6a8767..09d05f6c 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -200,6 +200,12 @@ public: */ QAction *actionByName(const QString &name); + /** + * returns Bookmark Manager toolbar + * + * Used in rekonq home page + */ + KBookmarkGroup toolbar(); signals: /** * @short This signal is emitted when an url has to be loaded diff --git a/src/historymodels.h b/src/historymodels.h index d6a04826..22a7bccd 100644 --- a/src/historymodels.h +++ b/src/historymodels.h @@ -236,6 +236,7 @@ private: * A modified QSortFilterProxyModel that always accepts * the root nodes in the tree * so filtering is only done on the children. + * * Used in the HistoryDialog. * */ diff --git a/src/homepage.cpp b/src/homepage.cpp new file mode 100644 index 00000000..bba49999 --- /dev/null +++ b/src/homepage.cpp @@ -0,0 +1,173 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 by Andrea Diamantini +* +* +* 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 . +* +* ============================================================ */ + + +// Self Includes +#include "homepage.h" +#include "homepage.moc" + +// Local Includes +#include "historymodels.h" +#include "bookmarks.h" +#include "application.h" + +// KDE Includes +#include +#include + +// Qt Includes +#include + + +HomePage::HomePage(QObject *parent) + : QObject(parent) +{ + m_homePagePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); + m_imagesPath = "file://" + KStandardDirs::locate("appdata", "pics/"); +} + + +HomePage::~HomePage() +{ +} + + +QString HomePage::rekonqHomePage() +{ + QFile file(m_homePagePath); + bool isOpened = file.open(QIODevice::ReadOnly); + if (!isOpened) + { + kWarning() << "Couldn't open the home.html file"; + return QString(""); + } + + QString history = fillHistory(); + + QString bookmarks = fillBookmarks(); + + QString html = QString(QLatin1String(file.readAll())) + .arg(m_imagesPath) + .arg(history) + .arg(bookmarks); + + return html; +} + + +QString HomePage::fillHistory() +{ + QString history = QString(); + HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); + + int i = 0; + do + { + QModelIndex index = model->index(i, 0, QModelIndex() ); + if(model->hasChildren(index)) + { + QString s = QString::number(i); + history += createSubMenu(index.data().toString(), s); + history += "

"; + for(int j=0; j< model->rowCount(index); ++j) + { + QModelIndex son = model->index(j, 0, index ); + history += QString("") + + son.data().toString() + QString("
"); + } + history += "

"; + } + else + { + history += QString("

NO CHILDREN: ") + index.data().toString() + QString("

"); + } + i++; + } + while( model->hasIndex( i , 0 , QModelIndex() ) ); + + return history; + +} + + +QString HomePage::fillBookmarks() +{ + KBookmarkGroup toolBarGroup = Application::bookmarkProvider()->toolbar(); + if (toolBarGroup.isNull()) + { + return QString("Error retrieving bookmarks!"); + } + + QString str = QString(""); + KBookmark bookmark = toolBarGroup.first(); + while (!bookmark.isNull()) + { + str += createBookItem(bookmark); + bookmark = toolBarGroup.next(bookmark); + } + + return str; +} + + +QString HomePage::createSubMenu(const QString &item, const QString &s) +{ + QString menu = "
"; + + menu += "

" + item + "

"; + return menu; +} + + +QString HomePage::createBookItem(const KBookmark &bookmark) +{ + static int i = 0; + + if (bookmark.isGroup()) + { + QString result = QString(""); + QString ss = "b" + QString::number(i); + i++; + + KBookmarkGroup group = bookmark.toGroup(); + KBookmark bm = group.first(); + result += createSubMenu( bookmark.text() , ss ); + result += "

"; + + while (!bm.isNull()) + { + result += createBookItem(bm); //menuAction->addAction(fillBookmarkBar(bm)); + bm = group.next(bm); + } + result += "

"; + return result; + } + + if(bookmark.isSeparator()) + { + return QString("
"); + } + return "" + bookmark.text() + "
"; +} diff --git a/src/homepage.h b/src/homepage.h new file mode 100644 index 00000000..e8b5b4f5 --- /dev/null +++ b/src/homepage.h @@ -0,0 +1,59 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 by Andrea Diamantini +* +* +* 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 . +* +* ============================================================ */ + + +#ifndef REKONQ_HOME_PAGE +#define REKONQ_HOME_PAGE + +// Qt Includes +#include +#include + +// Forward Includes +class KBookmark; + + +class HomePage : public QObject +{ +Q_OBJECT + +public: + HomePage(QObject *parent = 0); + ~HomePage(); + + QString rekonqHomePage(); + +private: + QString fillHistory(); + QString fillBookmarks(); + + QString createSubMenu(const QString &, const QString &); + QString createBookItem(const KBookmark &); + + QString m_homePagePath; + QString m_imagesPath; +}; + +#endif // REKONQ_HOME_PAGE diff --git a/src/mainview.cpp b/src/mainview.cpp index 76684c31..61122ad9 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -294,10 +294,17 @@ void MainView::newTab() urlBar()->setUrl(KUrl("")); urlBar()->setFocus(); - - if (ReKonfig::newTabsOpenHomePage()) + + switch(ReKonfig::newTabsBehaviour()) { - w->load(QUrl(ReKonfig::homePage())); + case 0: + w->load(QUrl("home:/")); + break; + case 2: + w->load( QUrl(ReKonfig::homePage()) ); + break; + default: + break; } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7f5c5996..513b7d73 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -45,6 +45,7 @@ #include "findbar.h" #include "sidepanel.h" #include "urlbar.h" +#include "homepage.h" // Ui Includes #include "ui_cleardata.h" @@ -169,7 +170,6 @@ void MainWindow::setupToolbar() m_mainBar->addAction( actionByName(KStandardAction::name(KStandardAction::Forward)) ); m_mainBar->addSeparator(); m_mainBar->addAction( actionByName("stop_reload") ); - m_mainBar->addAction( actionByName(KStandardAction::name(KStandardAction::Home)) ); m_mainBar->addAction( actionByName("url_bar") ); m_mainBar->addAction( actionByName("bookmarksActionMenu") ); m_mainBar->addAction( actionByName("rekonq_tools") ); @@ -256,7 +256,6 @@ void MainWindow::setupActions() a = KStandardAction::fullScreen(this, SLOT(slotViewFullScreen(bool)), this, actionCollection()); a->setShortcut(KShortcut(Qt::Key_F11, Qt::CTRL + Qt::SHIFT + Qt::Key_F)); - KStandardAction::home(this, SLOT(slotHome()), actionCollection()); KStandardAction::preferences(this, SLOT(slotPreferences()), actionCollection()); // WEB Actions (NO KStandardActions..) @@ -422,7 +421,6 @@ void MainWindow::setupSidePanel() void MainWindow::slotUpdateConfiguration() { // ============== General ================== - m_homePage = ReKonfig::homePage(); mainView()->showTabBar(); // "status bar" messages (new notifyMessage system) @@ -752,7 +750,20 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - Application::instance()->loadUrl(KUrl(m_homePage)); + WebView *w = Application::instance()->mainWindow()->mainView()->currentWebView(); + HomePage p; + + switch(ReKonfig::newTabsBehaviour()) + { + case 0: + w->setHtml( p.rekonqHomePage(), QUrl("home:/")); + break; + case 2: + w->load( QUrl(ReKonfig::homePage()) ); + break; + default: + break; + } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 21cf1a4f..24e9a58e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -152,7 +152,6 @@ private: KToolBar *m_mainBar; QString m_lastSearch; - QString m_homePage; QPointer m_popup; diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 86b1a5df..2ac9b331 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -6,11 +6,14 @@ QtWebKit KUrl - + + + 0 + http://www.kde.org/ @@ -29,9 +32,6 @@ false - - false - true diff --git a/src/settings.cpp b/src/settings.cpp index 843b3375..0838b252 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -141,6 +141,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); + int n = d->generalUi.kcfg_newTabsBehaviour->currentIndex(); + checkLineEnable(n); + connect(d->generalUi.kcfg_newTabsBehaviour, SIGNAL(currentIndexChanged(int)), this, SLOT(checkLineEnable(int))); + connect(d->ebrowsingModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); @@ -214,3 +218,18 @@ void SettingsDialog::setHomeToCurrentPage() d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl()); } } + + +void SettingsDialog::checkLineEnable(int n) +{ + if(n == 2) + { + d->generalUi.kcfg_homePage->setEnabled(true); + d->generalUi.setHomeToCurrentPageButton->setEnabled(true); + } + else + { + d->generalUi.kcfg_homePage->setEnabled(false); + d->generalUi.setHomeToCurrentPageButton->setEnabled(false); + } +} \ No newline at end of file diff --git a/src/settings.h b/src/settings.h index 0be89173..6cdbd5e3 100644 --- a/src/settings.h +++ b/src/settings.h @@ -55,6 +55,7 @@ private slots: void saveSettings(); void setHomeToCurrentPage(); + void checkLineEnable(int); }; #endif // SETTINGS_H diff --git a/src/settings_general.ui b/src/settings_general.ui index 6c18e8cc..70accdec 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -6,8 +6,8 @@ 0 0 - 515 - 415 + 662 + 539 @@ -17,60 +17,62 @@ - Home Page + New Tabs Behaviour - - + + - Home page: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + New tabs open - - - - - 0 - 0 - + + + + true + + + rekonq home page + + + + + blank page + + + + + url + + - - + + - - - Set to Current Page + + + true + + + + 0 + 0 + - - - Qt::Horizontal - - - - 40 - 20 - + + + Set to Current Page - + - - - - New tabs open home page - - - diff --git a/src/webpage.cpp b/src/webpage.cpp index ede503a5..cc7f7f10 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -97,6 +97,13 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r KToolInvocation::invokeMailer(m_requestedUrl); return false; } + + if(m_requestedUrl.scheme() == QLatin1String("home")) + { + Application::instance()->mainWindow()->slotHome(); + return false; + } + if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) { -- cgit v1.2.1