diff options
-rw-r--r-- | data/CMakeLists.txt | 9 | ||||
-rw-r--r-- | data/closed.png | bin | 0 -> 118 bytes | |||
-rw-r--r-- | data/home.html | 116 | ||||
-rw-r--r-- | data/open.png | bin | 0 -> 120 bytes | |||
-rw-r--r-- | icons/CMakeLists.txt | 2 | ||||
-rw-r--r-- | icons/pics/CMakeLists.txt | 4 | ||||
-rw-r--r-- | icons/pics/hi64-actions-download.png | bin | 4518 -> 0 bytes | |||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/application.cpp | 6 | ||||
-rw-r--r-- | src/bookmarks.cpp | 6 | ||||
-rw-r--r-- | src/bookmarks.h | 6 | ||||
-rw-r--r-- | src/historymodels.h | 1 | ||||
-rw-r--r-- | src/homepage.cpp | 173 | ||||
-rw-r--r-- | src/homepage.h | 59 | ||||
-rw-r--r-- | src/mainview.cpp | 13 | ||||
-rw-r--r-- | src/mainwindow.cpp | 19 | ||||
-rw-r--r-- | src/mainwindow.h | 1 | ||||
-rw-r--r-- | src/rekonq.kcfg | 8 | ||||
-rw-r--r-- | src/settings.cpp | 19 | ||||
-rw-r--r-- | src/settings.h | 1 | ||||
-rw-r--r-- | src/settings_general.ui | 78 | ||||
-rw-r--r-- | src/webpage.cpp | 7 |
22 files changed, 466 insertions, 63 deletions
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 Binary files differnew file mode 100644 index 00000000..2b1bf01e --- /dev/null +++ b/data/closed.png 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 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + +<head> +<title>rekonq home page</title> +<style type="text/css"> + +html{ +margin:0; +padding:0; +} + +body{ +margin:0; +padding:0; +font-family: sans-serif; +font-size: 100%; +} + +/* ------------------------------------------------------- */ + +div#container{ +margin: 0; +} + +div#header{ +margin: 0; +padding: 2px; +background-color:#00f; +color: #ff0; +text-align: center; +} + +div#footer{ +background-color:#00f; +color: #ff0; +text-align: center; +} + +/* ------------------------------------------------------- */ + +h2{ +color: #00f; +} + +td{ +padding: 2em; +vertical-align: top; +} + +td.bookmarks{ + border-left: 2px solid #0000FF; + border-top-width: 0px; + border-bottom-width: 0px; +} + +.indent { +margin-left: 2em; +} +</style> + +<!-- =================================================================================== --> + +<script type="text/javascript"> +function ToggleVisibility(image, element) +{ + // Find the image. + var image = document.getElementById(image) + + // Find the element to hide/unhide. + var element = document.getElementById(element) + + // Check the element's current state. + if (element.style.display == "none") + { + // If hidden, unhide it. + element.style.display = "block"; + image.src = "%1open.png"; + } + else + { + // If not hidden, hide it. + element.style.display = "none"; + image.src = "%1closed.png"; + } +} +</script> + +<!-- =================================================================================== --> + +</head> + +<body> + +<div id="header"> +<h1>rekonq home page</h1> +</div> + +<table width="100%"> +<tr> +<td width="40%"><h2>History</h2></td> +<td width="60%"><h2>Bookmarks</h2></td> +</tr> + +<tr> +<td>%2</td> +<td class="bookmarks">%3</td> +</tr> +</table> + +<div id="footer"> +rekonq, lightweight Web Browser for KDE based on Webkit. +</div> + +</body> +</html> diff --git a/data/open.png b/data/open.png Binary files differnew file mode 100644 index 00000000..fee6f3fb --- /dev/null +++ b/data/open.png 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 Binary files differdeleted file mode 100644 index aa1101c1..00000000 --- a/icons/pics/hi64-actions-download.png +++ /dev/null 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 <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 "homepage.h" +#include "homepage.moc" + +// Local Includes +#include "historymodels.h" +#include "bookmarks.h" +#include "application.h" + +// KDE Includes +#include <KStandardDirs> +#include <KDebug> + +// Qt Includes +#include <QFile> + + +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 += "<p id=\"y" + s + "\" class=\"indent\" style=\"display:none\">"; + for(int j=0; j< model->rowCount(index); ++j) + { + QModelIndex son = model->index(j, 0, index ); + history += QString("<a href=\"") + son.data(HistoryModel::UrlStringRole).toString() + QString("\">") + + son.data().toString() + QString("</a><br />"); + } + history += "</p>"; + } + else + { + history += QString("<p> NO CHILDREN: ") + index.data().toString() + QString("</p>"); + } + 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 = "<div onClick=\"ToggleVisibility('x" + s + "','y" + s + "')\">"; + + menu += "<p><img id=\"x" + s + "\" src=\"" + m_imagesPath + "closed.png\" /> <b><u>" + item + "</u></b></p></div>"; + 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 += "<p id=\"y" + ss + "\" class=\"indent\" style=\"display:none\">"; + + while (!bm.isNull()) + { + result += createBookItem(bm); //menuAction->addAction(fillBookmarkBar(bm)); + bm = group.next(bm); + } + result += "</p>"; + return result; + } + + if(bookmark.isSeparator()) + { + return QString("<hr />"); + } + return "<a href=\"" + bookmark.url().prettyUrl() + "\">" + bookmark.text() + "</a><br />"; +} 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 <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 REKONQ_HOME_PAGE +#define REKONQ_HOME_PAGE + +// Qt Includes +#include <QtCore/QObject> +#include <QtCore/QString> + +// 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<KPassivePopup> 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 @@ <include>QtWebKit</include> <include>KUrl</include> -<kcfgfile name="rekonqrc"/> +<kcfgfile name="rekonqrc" /> <!-- General Settings --> <group name="General"> + <entry name="newTabsBehaviour" type="Int"> + <default>0</default> + </entry> <entry name="homePage" type="String"> <default>http://www.kde.org/</default> </entry> @@ -29,9 +32,6 @@ <entry name="openTabsBack" type="Bool"> <default>false</default> </entry> - <entry name="newTabsOpenHomePage" type="Bool"> - <default>false</default> - </entry> <entry name="showUrlsPopup" type="Bool"> <default>true</default> </entry> 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 @@ <rect> <x>0</x> <y>0</y> - <width>515</width> - <height>415</height> + <width>662</width> + <height>539</height> </rect> </property> <property name="windowTitle"> @@ -17,60 +17,62 @@ <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> - <string>Home Page</string> + <string>New Tabs Behaviour</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> <property name="text"> - <string>Home page:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <string>New tabs open </string> </property> </widget> </item> - <item row="1" column="1"> - <widget class="KLineEdit" name="kcfg_homePage"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="0" column="1"> + <widget class="KComboBox" name="kcfg_newTabsBehaviour"> + <property name="enabled"> + <bool>true</bool> </property> + <item> + <property name="text"> + <string>rekonq home page</string> + </property> + </item> + <item> + <property name="text"> + <string>blank page</string> + </property> + </item> + <item> + <property name="text"> + <string>url</string> + </property> + </item> </widget> </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <widget class="QPushButton" name="setHomeToCurrentPageButton"> - <property name="text"> - <string>Set to Current Page</string> + <widget class="KLineEdit" name="kcfg_homePage"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> </widget> </item> <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> + <widget class="QPushButton" name="setHomeToCurrentPageButton"> + <property name="text"> + <string>Set to Current Page</string> </property> - </spacer> + </widget> </item> </layout> </item> - <item row="0" column="1"> - <widget class="QCheckBox" name="kcfg_newTabsOpenHomePage"> - <property name="text"> - <string>New tabs open home page</string> - </property> - </widget> - </item> </layout> </widget> </item> 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) { |