From e1791ac7190b8fc570c7097f48d2ad2b5cd29ee1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Sep 2009 18:33:32 +0200 Subject: Open new tab near previous --- src/mainview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mainview.cpp b/src/mainview.cpp index 7c91b992..3836ddd0 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -274,7 +274,8 @@ WebView *MainView::newWebView(bool focused) connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); - addTab(webView, i18n("(Untitled)")); + // opening tab NEAR the previous + insertTab(currentIndex() + 1, webView, i18n("(Untitled)")); if (focused) { -- cgit v1.2.1 From 7c6db1a17dbede4911d2c13cd36a485272f3e5a4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 13 Sep 2009 18:20:57 +0200 Subject: We have thumbnails! Hugh! --- src/CMakeLists.txt | 1 + src/homepage.cpp | 216 ++++++++++++++++++++++++++++++++--------------------- src/homepage.h | 9 +-- src/websnap.cpp | 88 ++++++++++++++++++++++ src/websnap.h | 65 ++++++++++++++++ 5 files changed, 286 insertions(+), 93 deletions(-) create mode 100644 src/websnap.cpp create mode 100644 src/websnap.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f7d54c39..db3722fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ ### ------- SETTING REKONQ FILES.. SET( rekonq_SRCS + websnap.cpp homepage.cpp networkaccessmanager.cpp autosaver.cpp diff --git a/src/homepage.cpp b/src/homepage.cpp index 6acd4afd..59078c51 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -32,6 +32,7 @@ #include "historymodels.h" #include "bookmarks.h" #include "application.h" +#include "websnap.h" // KDE Includes #include @@ -46,7 +47,6 @@ HomePage::HomePage(QObject *parent) : QObject(parent) { m_homePagePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); - m_imagesPath = "file://" + KStandardDirs::locate("appdata", "pics/"); } @@ -65,114 +65,156 @@ QString HomePage::rekonqHomePage() return QString(""); } - QString history = fillHistory(); - - QString bookmarks = fillBookmarks(); + QString speed = speedDial(); + QString search = searchEngines(); + QString closedtabs = recentlyClosedTabs(); + QString html = QString(QLatin1String(file.readAll())) - .arg(m_imagesPath) - .arg(history) - .arg(bookmarks); + .arg(search) + .arg(closedtabs) + .arg(speed) + ; return html; } -QString HomePage::fillHistory() +QString HomePage::speedDial() { - QString history = QString(); - HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); + KUrl::List ul ; + ul << KUrl("http://www.google.it") << KUrl("http://www.kde.org") << KUrl("http://rekonq.sourceforge.net") + << KUrl("http://www.slacky.eu") << KUrl("http://kde-apps.org") << KUrl("http://www.kernel.org") + << KUrl("http://it.wikipedia.org") << KUrl("http://www.adjam.org") << KUrl("http://adjamblog.wordpress.com"); - int i = 0; - do + QString speed = QString(); + for(int i = 0; i< ul.count(); ++i) { - 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 ); -// FIXME add an icon to each history item history += "\"icon\""; - history += QString("") + - son.data().toString() + QString("
"); - } - history += "

"; - } - else + KUrl url = ul.at(i); + QString fileName = QString("thumb") + QString::number(i) + QString(".png"); + QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + fileName, true); + if( !QFile::exists(path) ) { - history += QString("

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

"); + kDebug() << "websnap"; + WebSnap *ws = new WebSnap(url, fileName); } - i++; + + speed += "\"""; } - while( model->hasIndex( i , 0 , QModelIndex() ) ); - - return history; - + return speed; } -QString HomePage::fillBookmarks() +QString HomePage::searchEngines() { - 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); - } + QString engines = "engines"; - return str; + return engines; } -QString HomePage::createSubMenu(const QString &item, const QString &s) +QString HomePage::recentlyClosedTabs() { - QString menu = "
"; + QString closedtabs = "closed"; - menu += "

" + item + "

"; - return menu; + return closedtabs; } - -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("
"); - } - - QString str = ""; // FIXME Add icon "\"icon\""; - str += "" + bookmark.text() + "
"; - return str; -} +// 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 ); +// // FIXME add an icon to each history item history += "\"icon\""; +// 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()->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 = "
"; +// +// 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("
"); +// } +// +// QString str = ""; // FIXME Add icon "\"icon\""; +// str += "" + bookmark.text() + "
"; +// return str; +// } diff --git a/src/homepage.h b/src/homepage.h index e8b5b4f5..c4ef7fc5 100644 --- a/src/homepage.h +++ b/src/homepage.h @@ -46,14 +46,11 @@ public: QString rekonqHomePage(); private: - QString fillHistory(); - QString fillBookmarks(); - - QString createSubMenu(const QString &, const QString &); - QString createBookItem(const KBookmark &); + QString speedDial(); + QString searchEngines(); + QString recentlyClosedTabs(); QString m_homePagePath; - QString m_imagesPath; }; #endif // REKONQ_HOME_PAGE diff --git a/src/websnap.cpp b/src/websnap.cpp new file mode 100644 index 00000000..8bacd3b2 --- /dev/null +++ b/src/websnap.cpp @@ -0,0 +1,88 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 Nokia Corporation +* 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 . +* +* ============================================================ */ + + +#include "websnap.h" +#include "websnap.moc" + +#include +#include + +#include +#include +#include +#include + + +WebSnap::WebSnap(const KUrl &url, const QString &fileName) + : QObject() + , m_url(url) + , m_image(QImage()) + , m_fileName(fileName) +{ + m_targetSize = QSize(200, 150); + connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool))); + QTimer::singleShot(0, this, SLOT(load())); + +} + + +void WebSnap::load() +{ + m_page.mainFrame()->load(m_url); +} + + +void WebSnap::saveResult(bool ok) +{ + // crude error-checking + if (!ok) + { + kDebug() << "Error loading site.."; + emit finished(); + return; + } + + // find proper size, we stick to sensible aspect ratio + QSize size = m_page.mainFrame()->contentsSize(); + size.setHeight(size.width() * m_targetSize.height() / m_targetSize.width()); + + // create the target surface + m_image = QImage( size , QImage::Format_ARGB32_Premultiplied); + m_image.fill(Qt::transparent); + + // render and rescale + QPainter p(&m_image); + m_page.setViewportSize(m_page.mainFrame()->contentsSize()); + m_page.mainFrame()->render(&p); + p.end(); + m_image = m_image.scaled(m_targetSize, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + + QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + m_fileName, true); + m_image.save( path ); + + emit finished(); +} diff --git a/src/websnap.h b/src/websnap.h new file mode 100644 index 00000000..cbb786c7 --- /dev/null +++ b/src/websnap.h @@ -0,0 +1,65 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 Nokia Corporation +* 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 WEB_SNAP_H +#define WEB_SNAP_H + + +#include + +#include +#include +#include + + +/** + * This class renders a site producing an image based + * on that. + * Heavily based on Graphics-Dojo WebSnap example (thanks!) + */ +class WebSnap : public QObject +{ + Q_OBJECT + +public: + WebSnap(const KUrl &url, const QString &fileName); + +signals: + void finished(); + +private slots: + void load(); + void saveResult(bool ok); + +private: + QWebPage m_page; + KUrl m_url; + QImage m_image; + QString m_fileName; + QSize m_targetSize; +}; + +#endif // WEB_SNAP_H -- cgit v1.2.1 From abea114ea32993cd6e41fc3b821deafa345c783b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 13 Sep 2009 18:28:02 +0200 Subject: Adding url to previews --- src/homepage.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/homepage.cpp b/src/homepage.cpp index 59078c51..957118f8 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -99,7 +99,9 @@ QString HomePage::speedDial() WebSnap *ws = new WebSnap(url, fileName); } - speed += "\"""; + speed += "
\"""; + speed += "
"; + speed += "" + url.prettyUrl() + "
"; } return speed; } @@ -107,7 +109,7 @@ QString HomePage::speedDial() QString HomePage::searchEngines() { - QString engines = "engines"; + QString engines = "engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines "; return engines; } @@ -115,7 +117,7 @@ QString HomePage::searchEngines() QString HomePage::recentlyClosedTabs() { - QString closedtabs = "closed"; + QString closedtabs = "engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines closed"; return closedtabs; } -- cgit v1.2.1 From 0506db8875284f5dc324e8b22674a7d3f1c575fe Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 13 Sep 2009 18:40:41 +0200 Subject: Search Engine, first draft Time to cook, now :) Hope you glad this "technologic" preview --- src/homepage.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/homepage.cpp b/src/homepage.cpp index 957118f8..430fa9a6 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include // Qt Includes #include @@ -109,7 +111,29 @@ QString HomePage::speedDial() QString HomePage::searchEngines() { - QString engines = "engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines "; + QString engines = "

Search Engines

"; + + KConfig config("kuriikwsfilterrc"); //Share with konqueror + KConfigGroup cg = config.group("General"); + QStringList favoriteEngines; + favoriteEngines << "google" << "wikipedia"; //defaults + favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines); + + foreach (const QString &engine, favoriteEngines) + { + if(!engine.isEmpty()) + { + engines += engine + ":
"; +// service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine)); +// const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter; +// data.setData(searchProviderPrefix + "some keyword"); +// a = new KAction(service->name(), this); +// a->setIcon(Application::icon(KUrl(data.uri()))); +// a->setData(searchProviderPrefix); +// connect(a, SIGNAL(triggered(bool)), this, SLOT(slotSearch())); +// searchMenu->addAction(a); + } + } return engines; } -- cgit v1.2.1 From b476c9caf91f94b8448dfce6565662d7d8a95156 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Sep 2009 00:05:14 +0200 Subject: Fixing a bit examples, positions, links and so on.. --- src/homepage.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/homepage.cpp b/src/homepage.cpp index 430fa9a6..20276f57 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -85,9 +85,9 @@ QString HomePage::rekonqHomePage() QString HomePage::speedDial() { KUrl::List ul ; - ul << KUrl("http://www.google.it") << KUrl("http://www.kde.org") << KUrl("http://rekonq.sourceforge.net") + ul << KUrl("http://www.google.com") << KUrl("http://www.kde.org") << KUrl("http://sourceforge.net") << KUrl("http://www.slacky.eu") << KUrl("http://kde-apps.org") << KUrl("http://www.kernel.org") - << KUrl("http://it.wikipedia.org") << KUrl("http://www.adjam.org") << KUrl("http://adjamblog.wordpress.com"); + << KUrl("http://it.wikipedia.org") << KUrl("http://www.adjam.org") << KUrl("http://wordpress.com"); QString speed = QString(); for(int i = 0; i< ul.count(); ++i) @@ -101,9 +101,11 @@ QString HomePage::speedDial() WebSnap *ws = new WebSnap(url, fileName); } - speed += "
\"""; + speed += ""; + speed += url.prettyUrl() + "
"; } return speed; } @@ -141,7 +143,7 @@ QString HomePage::searchEngines() QString HomePage::recentlyClosedTabs() { - QString closedtabs = "engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines engines closed"; + QString closedtabs = "

Recently closed tabs

"; return closedtabs; } -- cgit v1.2.1 From f59b52ea590fcef4f76b8691edec542e133c1b78 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Sep 2009 00:24:08 +0200 Subject: Recently closed tabs: first implementation --- src/homepage.cpp | 12 ++++++++++-- src/mainview.cpp | 12 +++++++++++- src/mainview.h | 4 ++++ 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/homepage.cpp b/src/homepage.cpp index 20276f57..6a327b3a 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -32,6 +32,8 @@ #include "historymodels.h" #include "bookmarks.h" #include "application.h" +#include "mainwindow.h" +#include "mainview.h" #include "websnap.h" // KDE Includes @@ -143,9 +145,15 @@ QString HomePage::searchEngines() QString HomePage::recentlyClosedTabs() { - QString closedtabs = "

Recently closed tabs

"; + QString closed = "

Recently closed tabs

"; - return closedtabs; + KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); + + foreach(const KUrl &url, links) + { + closed += "" + url.prettyUrl() + "
"; + } + return closed; } // QString HomePage::fillHistory() diff --git a/src/mainview.cpp b/src/mainview.cpp index 3836ddd0..a40729a3 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -176,6 +176,8 @@ void MainView::clear() /// TODO What exactly do we need to clear here? m_urlBar->clearHistory(); m_urlBar->clear(); + + m_recentlyClosedTabs.clear(); } @@ -403,11 +405,13 @@ void MainView::slotCloseTab(int index) int risp = KMessageBox::questionYesNo(this, i18n("You have modified this page and when closing it you would lose the modifications.\n" "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?")); + i18n("Closing tab confirmation")); if (risp == KMessageBox::No) return; } hasFocus = tab->hasFocus(); + + m_recentlyClosedTabs.prepend(tab->url()); } QWidget *webView = widget(index); @@ -583,3 +587,9 @@ void MainView::resizeEvent(QResizeEvent *event) { KTabWidget::resizeEvent(event); } + + +KUrl::List MainView::recentlyClosedTabs() +{ + return m_recentlyClosedTabs; +} diff --git a/src/mainview.h b/src/mainview.h index c59cca1a..ba79d9f8 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -71,6 +71,8 @@ public: WebView *currentWebView() const; int webViewIndex(WebView *webView) const; + KUrl::List recentlyClosedTabs(); + /** * show and hide TabBar if user doesn't choose * "Always Show TabBar" option @@ -158,6 +160,8 @@ private: QString m_loadingGitPath; int m_currentTabIndex; + + KUrl::List m_recentlyClosedTabs; }; #endif // MAINVIEW_H -- cgit v1.2.1 From 0af4d7e7ead3004092380d9f6baa74edf063cf27 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Sep 2009 01:12:32 +0200 Subject: Google search engine --- src/homepage.cpp | 137 ++++++++----------------------------------------------- 1 file changed, 18 insertions(+), 119 deletions(-) (limited to 'src') diff --git a/src/homepage.cpp b/src/homepage.cpp index 6a327b3a..a04b6e6d 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -117,27 +117,25 @@ QString HomePage::searchEngines() { QString engines = "

Search Engines

"; - KConfig config("kuriikwsfilterrc"); //Share with konqueror - KConfigGroup cg = config.group("General"); - QStringList favoriteEngines; - favoriteEngines << "google" << "wikipedia"; //defaults - favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines); +// KConfig config("kuriikwsfilterrc"); //Share with konqueror +// KConfigGroup cg = config.group("General"); +// QStringList favoriteEngines; +// favoriteEngines << "google" << "wikipedia"; //defaults +// favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines); +// +// foreach (const QString &engine, favoriteEngines) +// { +// if(!engine.isEmpty()) +// { +// engines += engine + ":
"; +// } +// } - foreach (const QString &engine, favoriteEngines) - { - if(!engine.isEmpty()) - { - engines += engine + ":
"; -// service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine)); -// const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter; -// data.setData(searchProviderPrefix + "some keyword"); -// a = new KAction(service->name(), this); -// a->setIcon(Application::icon(KUrl(data.uri()))); -// a->setData(searchProviderPrefix); -// connect(a, SIGNAL(triggered(bool)), this, SLOT(slotSearch())); -// searchMenu->addAction(a); - } - } + // Google search engine + engines += "
"; + engines += ""; + engines += ""; + engines += "
"; return engines; } @@ -155,102 +153,3 @@ QString HomePage::recentlyClosedTabs() } return closed; } - -// 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 ); -// // FIXME add an icon to each history item history += "\"icon\""; -// 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()->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 = "
"; -// -// 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("
"); -// } -// -// QString str = ""; // FIXME Add icon "\"icon\""; -// str += "" + bookmark.text() + "
"; -// return str; -// } -- cgit v1.2.1 From 78d922d6433be8375b18a92418c635c04fe9bb4a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 15 Sep 2009 02:39:22 +0200 Subject: Initial newtab page settings implementation it doesn't really fit our needs. Just a starting point.. --- src/CMakeLists.txt | 1 + src/homepage.cpp | 85 ++++++++++++++--------- src/homepage.h | 3 +- src/rekonq.kcfg | 14 ++++ src/settings.cpp | 67 +++++++++++++++++- src/settings.h | 5 ++ src/settings_newtabpage.ui | 164 +++++++++++++++++++++++++++++++++++++++++++++ src/websnap.cpp | 5 +- src/websnap.h | 2 +- 9 files changed, 310 insertions(+), 36 deletions(-) create mode 100644 src/settings_newtabpage.ui (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db3722fb..9b24e2ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,7 @@ KDE4_ADD_UI_FILES( rekonq_SRCS password.ui proxy.ui settings_general.ui + settings_newtabpage.ui settings_fonts.ui settings_proxy.ui settings_webkit.ui diff --git a/src/homepage.cpp b/src/homepage.cpp index a04b6e6d..1f759108 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -28,6 +28,9 @@ #include "homepage.h" #include "homepage.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "historymodels.h" #include "bookmarks.h" @@ -71,12 +74,12 @@ QString HomePage::rekonqHomePage() QString speed = speedDial(); QString search = searchEngines(); - QString closedtabs = recentlyClosedTabs(); + QString lastBlock = ReKonfig::useRecentlyClosedTabs() ? recentlyClosedTabs() : fillRecentHistory(); QString html = QString(QLatin1String(file.readAll())) .arg(search) - .arg(closedtabs) + .arg(lastBlock) .arg(speed) ; @@ -86,28 +89,20 @@ QString HomePage::rekonqHomePage() QString HomePage::speedDial() { - KUrl::List ul ; - ul << KUrl("http://www.google.com") << KUrl("http://www.kde.org") << KUrl("http://sourceforge.net") - << KUrl("http://www.slacky.eu") << KUrl("http://kde-apps.org") << KUrl("http://www.kernel.org") - << KUrl("http://it.wikipedia.org") << KUrl("http://www.adjam.org") << KUrl("http://wordpress.com"); + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); QString speed = QString(); - for(int i = 0; i< ul.count(); ++i) + for(int i = 0; i< urls.count(); ++i) { - KUrl url = ul.at(i); QString fileName = QString("thumb") + QString::number(i) + QString(".png"); QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + fileName, true); - if( !QFile::exists(path) ) - { - kDebug() << "websnap"; - WebSnap *ws = new WebSnap(url, fileName); - } speed += ""; + speed += names.at(i) + ""; } return speed; } @@ -117,20 +112,6 @@ QString HomePage::searchEngines() { QString engines = "

Search Engines

"; -// KConfig config("kuriikwsfilterrc"); //Share with konqueror -// KConfigGroup cg = config.group("General"); -// QStringList favoriteEngines; -// favoriteEngines << "google" << "wikipedia"; //defaults -// favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines); -// -// foreach (const QString &engine, favoriteEngines) -// { -// if(!engine.isEmpty()) -// { -// engines += engine + ":
"; -// } -// } - // Google search engine engines += "
"; engines += ""; @@ -144,12 +125,52 @@ QString HomePage::searchEngines() QString HomePage::recentlyClosedTabs() { QString closed = "

Recently closed tabs

"; - + closed += ""; return closed; } + + +QString HomePage::fillRecentHistory() +{ + QString history = "

Last 20 visited sites

"; + history += "