diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-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 | 178 | ||||
-rw-r--r-- | src/homepage.h | 59 | ||||
-rw-r--r-- | src/mainview.cpp | 14 | ||||
-rw-r--r-- | src/mainwindow.cpp | 35 | ||||
-rw-r--r-- | src/mainwindow.h | 5 | ||||
-rw-r--r-- | src/rekonq.kcfg | 14 | ||||
-rw-r--r-- | src/settings_general.ui | 174 | ||||
-rw-r--r-- | src/webpage.cpp | 2 |
12 files changed, 357 insertions, 138 deletions
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/bookmarks.cpp b/src/bookmarks.cpp index 69f6c945..a92cb2bb 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::rootGroup() +{ + return m_manager->root(); +} diff --git a/src/bookmarks.h b/src/bookmarks.h index df6a8767..5fd0ebee 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -200,6 +200,12 @@ public: */ QAction *actionByName(const QString &name); + /** + * returns Bookmark Manager root group + * + * @return the root bookmark group + */ + KBookmarkGroup rootGroup(); 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..6acd4afd --- /dev/null +++ b/src/homepage.cpp @@ -0,0 +1,178 @@ +/* ============================================================ +* +* 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 <KIconLoader> +#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 ); +// FIXME add an icon to each history item history += "<img src=\"" + ciao + "\" alt=\"icon\" />"; + 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()->rootGroup(); + 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 />"); + } + + QString str = ""; // FIXME Add icon "<img src=\"" + KStandardDirs::findResource( "icon", bookmark.icon() + ".png" ) + "\" alt=\"icon\" />"; + str += "<a href=\"" + bookmark.url().prettyUrl() + "\">" + bookmark.text() + "</a><br />"; + return str; +} 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..7c91b992 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -41,6 +41,7 @@ #include "urlbar.h" #include "webview.h" #include "sessionmanager.h" +#include "homepage.h" // KDE Includes #include <KUrl> @@ -295,9 +296,18 @@ void MainView::newTab() urlBar()->setUrl(KUrl("")); urlBar()->setFocus(); - if (ReKonfig::newTabsOpenHomePage()) + HomePage p; + + switch(ReKonfig::newTabsBehaviour()) { - w->load(QUrl(ReKonfig::homePage())); + case 0: + w->setHtml( p.rekonqHomePage() ); + break; + case 2: + w->load( QUrl(ReKonfig::homePage()) ); + break; + default: + break; } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e7494c0e..1dc56f7a 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" @@ -183,6 +184,10 @@ void MainWindow::setupToolbars() void MainWindow::postLaunch() { + // notification system + connect(m_view, SIGNAL(showStatusBarMessage(const QString&, Rekonq::Notify)), this, SLOT(notifyMessage(const QString&, Rekonq::Notify))); + connect(m_view, SIGNAL(linkHovered(const QString&)), this, SLOT(notifyMessage(const QString&))); + // --------- connect signals and slots connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); @@ -423,26 +428,8 @@ void MainWindow::setupSidePanel() void MainWindow::slotUpdateConfiguration() { // ============== General ================== - m_homePage = ReKonfig::homePage(); mainView()->showTabBar(); - // "status bar" messages (new notifyMessage system) - if(ReKonfig::showUrlsPopup()) - { - connect(m_view, SIGNAL(showStatusBarMessage(const QString&, Rekonq::Notify)), - this, SLOT(notifyMessage(const QString&, Rekonq::Notify))); - connect(m_view, SIGNAL(linkHovered(const QString&)), - this, SLOT(notifyMessage(const QString&))); - } - else - { - disconnect(m_view, SIGNAL(showStatusBarMessage(const QString&, Rekonq::Notify)), - this, SLOT(notifyMessage(const QString&, Rekonq::Notify))); - disconnect(m_view, SIGNAL(linkHovered(const QString&)), - this, SLOT(notifyMessage(const QString&))); - } - - // =========== Fonts ============== QWebSettings *defaultSettings = QWebSettings::globalSettings(); @@ -752,7 +739,17 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - Application::instance()->loadUrl(KUrl(m_homePage)); + WebView *w = currentTab(); + + if(ReKonfig::useNewTabPage()) + { + HomePage p; + w->setHtml( p.rekonqHomePage(), QUrl()); + } + else + { + w->load( QUrl(ReKonfig::homePage()) ); + } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 5a705e27..b2c41b49 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -79,8 +79,8 @@ private: SidePanel *sidePanel(); public slots: - void slotHome(); void slotUpdateBrowser(); + void slotHome(); /** * Notifies a message in a popup @@ -104,7 +104,7 @@ private slots: void slotBrowserLoading(bool); void slotUpdateActions(); void slotUpdateWindowTitle(const QString &title = QString()); - + // history related void slotOpenPrevious(); void slotOpenNext(); @@ -152,7 +152,6 @@ private: KToolBar *m_bmBar; QString m_lastSearch; - QString m_homePage; QPointer<KPassivePopup> m_popup; diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 86b1a5df..401ce58c 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -6,11 +6,17 @@ <include>QtWebKit</include> <include>KUrl</include> -<kcfgfile name="rekonqrc"/> +<kcfgfile name="rekonqrc" /> <!-- General Settings --> <group name="General"> + <entry name="useNewTabPage" type="Bool"> + <default>true</default> + </entry> + <entry name="newTabsBehaviour" type="Int"> + <default>0</default> + </entry> <entry name="homePage" type="String"> <default>http://www.kde.org/</default> </entry> @@ -29,12 +35,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> </group> <!-- Fonts Settings --> diff --git a/src/settings_general.ui b/src/settings_general.ui index 6c18e8cc..fe1ec457 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -6,80 +6,111 @@ <rect> <x>0</x> <y>0</y> - <width>515</width> - <height>415</height> + <width>442</width> + <height>369</height> </rect> </property> <property name="windowTitle"> <string>General</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> + <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Home Page</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QRadioButton" name="kcfg_useNewTabPage"> <property name="text"> - <string>Home page:</string> + <string>Use new tab page</string> </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <property name="checked"> + <bool>true</bool> </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> - </property> - </widget> - </item> - <item row="2" column="1"> + <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QPushButton" name="setHomeToCurrentPageButton"> + <widget class="QRadioButton" name="radioButton"> <property name="text"> - <string>Set to Current Page</string> + <string>Use this page:</string> + </property> + <property name="checked"> + <bool>false</bool> </property> </widget> </item> <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <widget class="KLineEdit" name="kcfg_homePage"> + <property name="enabled"> + <bool>true</bool> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - </spacer> + </widget> + </item> + <item> + <widget class="QPushButton" name="setHomeToCurrentPageButton"> + <property name="text"> + <string>Set to Current Page</string> + </property> + </widget> </item> </layout> </item> - <item row="0" column="1"> - <widget class="QCheckBox" name="kcfg_newTabsOpenHomePage"> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string>New Tabs Behaviour</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label_4"> <property name="text"> - <string>New tabs open home page</string> + <string>New tabs open </string> </property> </widget> </item> + <item row="0" column="1"> + <widget class="KComboBox" name="kcfg_newTabsBehaviour"> + <property name="enabled"> + <bool>true</bool> + </property> + <item> + <property name="text"> + <string>new tab page</string> + </property> + </item> + <item> + <property name="text"> + <string>blank page</string> + </property> + </item> + <item> + <property name="text"> + <string>home page</string> + </property> + </item> + </widget> + </item> </layout> </widget> </item> <item> - <widget class="QGroupBox" name="groupBox_3"> + <widget class="QGroupBox" name="groupBox_4"> <property name="title"> <string>Tabbed Browsing</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QVBoxLayout" name="verticalLayout_4"> <item> <widget class="QCheckBox" name="kcfg_openTabNoWindow"> <property name="text"> @@ -112,75 +143,6 @@ </widget> </item> <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>General Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QCheckBox" name="kcfg_showUrlsPopup"> - <property name="text"> - <string>Show URLs of links in a popup</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_4"> - <property name="title"> - <string>History</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Remove history items:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="KComboBox" name="kcfg_expireHistory"> - <item> - <property name="text"> - <string>After one day</string> - </property> - </item> - <item> - <property name="text"> - <string>After one week</string> - </property> - </item> - <item> - <property name="text"> - <string>After two weeks</string> - </property> - </item> - <item> - <property name="text"> - <string>After one month</string> - </property> - </item> - <item> - <property name="text"> - <string>After one year</string> - </property> - </item> - <item> - <property name="text"> - <string>Manually</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -188,7 +150,7 @@ <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>40</height> + <height>43</height> </size> </property> </spacer> diff --git a/src/webpage.cpp b/src/webpage.cpp index ede503a5..274f8d60 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -97,7 +97,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r KToolInvocation::invokeMailer(m_requestedUrl); return false; } - + if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) { Application::instance()->loadUrl(request.url(), Rekonq::SettingOpenTab); |