summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-09-15 02:39:22 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-09-15 02:39:22 +0200
commit78d922d6433be8375b18a92418c635c04fe9bb4a (patch)
tree284afcc28af598b6f241dc5919b79290d558e015 /src
parentSome CSS fixes (diff)
downloadrekonq-78d922d6433be8375b18a92418c635c04fe9bb4a.tar.xz
Initial newtab page settings implementation
it doesn't really fit our needs. Just a starting point..
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/homepage.cpp85
-rw-r--r--src/homepage.h3
-rw-r--r--src/rekonq.kcfg14
-rw-r--r--src/settings.cpp67
-rw-r--r--src/settings.h5
-rw-r--r--src/settings_newtabpage.ui164
-rw-r--r--src/websnap.cpp5
-rw-r--r--src/websnap.h2
9 files changed, 310 insertions, 36 deletions
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 += "<div class=\"thumbnail\">";
- speed += "<a href=\"" + url.prettyUrl() + "\">";
- speed += "<img src=\"" + path + "\" width=\"200\" alt=\"" + url.prettyUrl() + "\" />";
+ speed += "<a href=\"" + urls.at(i) + "\">";
+ speed += "<img src=\"" + path + "\" width=\"200\" alt=\"" + names.at(i) + "\" />";
speed += "<br />";
- speed += url.prettyUrl() + "</a></div>";
+ speed += names.at(i) + "</a></div>";
}
return speed;
}
@@ -117,20 +112,6 @@ QString HomePage::searchEngines()
{
QString engines = "<h2>Search Engines</h2>";
-// 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 + ": <input type=\"text\" name=\"" + engine + "\" /><br />";
-// }
-// }
-
// Google search engine
engines += "<form method=\"get\" action=\"http://www.google.com/search\">";
engines += "<label for=\"q\">Google:</label>";
@@ -144,12 +125,52 @@ QString HomePage::searchEngines()
QString HomePage::recentlyClosedTabs()
{
QString closed = "<h2>Recently closed tabs</h2>";
-
+ closed += "<ul>";
+
KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs();
foreach(const KUrl &url, links)
{
- closed += "<a href=\"" + url.prettyUrl() + "\">" + url.prettyUrl() + "</a><br />";
+ closed += "<li><a href=\"" + url.prettyUrl() + "\">" + url.prettyUrl() + "</a></li>";
}
+
+ closed += "</ul>";
return closed;
}
+
+
+QString HomePage::fillRecentHistory()
+{
+ QString history = "<h2>Last 20 visited sites</h2>";
+ history += "<ul>";
+
+ HistoryTreeModel *model = Application::historyManager()->historyTreeModel();
+
+ int i = 0;
+ do
+ {
+ QModelIndex index = model->index(i, 0, QModelIndex() );
+ if(model->hasChildren(index))
+ {
+ for(int j=0; j< model->rowCount(index) && i<20 ; ++j)
+ {
+ QModelIndex son = model->index(j, 0, index );
+
+ history += "<li>";
+ history += QString("<a href=\"") + son.data(HistoryModel::UrlStringRole).toString() + QString("\">");
+ history += son.data().toString();
+ history += QString("</a>");
+ history += "</li>";
+
+ i++;
+ }
+ }
+ i++;
+ }
+ while( i<20 || model->hasIndex( i , 0 , QModelIndex() ) );
+
+ history += "<ul>";
+
+ return history;
+
+} \ No newline at end of file
diff --git a/src/homepage.h b/src/homepage.h
index c4ef7fc5..82117664 100644
--- a/src/homepage.h
+++ b/src/homepage.h
@@ -49,7 +49,8 @@ private:
QString speedDial();
QString searchEngines();
QString recentlyClosedTabs();
-
+ QString fillRecentHistory();
+
QString m_homePagePath;
};
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index 401ce58c..6b57a9fa 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -9,6 +9,20 @@
<kcfgfile name="rekonqrc" />
+<!-- New Tab Page Settings -->
+ <group name="NewTabPage">
+ <entry name="previewNames" type="StringList">
+ <default>KDE site,Google,rekonq,SourceForge,kde-apps,kernel, wikipedia,wordpress,adjam site</default>
+ </entry>
+ <entry name="previewUrls" type="StringList">
+ <default>http://www.kde.org,http://www.google.com,http://rekonq.sourceforge.net,http://sourceforge.net,http://kde-apps.org,http://www.kernel.org,http://wikipedia.org,http://wordpress.com,http://www.adjam.org</default>
+ </entry>
+ <entry name="useRecentlyClosedTabs" type="Bool">
+ <default>false</default>
+ </entry>
+ </group>
+
+
<!-- General Settings -->
<group name="General">
<entry name="useNewTabPage" type="Bool">
diff --git a/src/settings.cpp b/src/settings.cpp
index 843b3375..dd61e357 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -38,9 +38,11 @@
#include "mainwindow.h"
#include "networkaccessmanager.h"
#include "webview.h"
+#include "websnap.h"
//Ui Includes
#include "ui_settings_general.h"
+#include "ui_settings_newtabpage.h"
#include "ui_settings_fonts.h"
#include "ui_settings_proxy.h"
#include "ui_settings_webkit.h"
@@ -62,6 +64,7 @@ class Private
{
private:
Ui::general generalUi;
+ Ui::newtabpage newtabpageUi;
Ui::fonts fontsUi;
Ui::proxy proxyUi;
Ui::webkit webkitUi;
@@ -86,6 +89,12 @@ Private::Private(SettingsDialog *parent)
pageItem->setIcon(KIcon("rekonq"));
widget = new QWidget;
+ newtabpageUi.setupUi(widget);
+ widget->layout()->setMargin(0);
+ pageItem = parent->addPage(widget , i18n("New Tab Page"));
+ pageItem->setIcon(KIcon("tab-new"));
+
+ widget = new QWidget;
fontsUi.setupUi(widget);
widget->layout()->setMargin(0);
pageItem = parent->addPage(widget , i18n("Fonts"));
@@ -130,6 +139,7 @@ Private::Private(SettingsDialog *parent)
SettingsDialog::SettingsDialog(QWidget *parent)
: KConfigDialog(parent, "rekonfig", ReKonfig::self())
, d(new Private(this))
+ , m_progress(0)
{
setFaceType(KPageDialog::List);
showButtonSeparator(true);
@@ -146,7 +156,8 @@ SettingsDialog::SettingsDialog(QWidget *parent)
connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings()));
connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings()));
-
+ connect(this, SIGNAL(okClicked()), this, SLOT(updateSnaps()));
+
setWebSettingsToolTips();
}
@@ -177,6 +188,23 @@ void SettingsDialog::setWebSettingsToolTips()
// we need this function to UPDATE the config widget data..
void SettingsDialog::readConfig()
{
+ // ====== New Tab Page
+ QTableWidget *t = d->newtabpageUi.tableWidget;
+ QStringList names, urls;
+ names = ReKonfig::previewNames();
+ urls = ReKonfig::previewUrls();
+ for(int i=0; i<9; ++i)
+ {
+ QTableWidgetItem *name = new QTableWidgetItem( names.at(i) );
+ t->setItem(i,0,name);
+ QTableWidgetItem *url = new QTableWidgetItem( urls.at(i) );
+ t->setItem(i,1,url);
+ }
+
+ ReKonfig::setPreviewNames(names);
+ ReKonfig::setPreviewUrls(urls);
+
+
// ======= Fonts
d->fontsUi.kcfg_fixedFont->setOnlyFixed(true);
@@ -190,6 +218,17 @@ void SettingsDialog::readConfig()
// we need this function to SAVE settings in rc file..
void SettingsDialog::saveSettings()
{
+ QTableWidget *t = d->newtabpageUi.tableWidget;
+ QStringList names, urls;
+ for(int i=0; i<9; ++i)
+ {
+ names << t->item(i,0)->text();
+ urls << t->item(i,1)->text();
+ }
+
+ ReKonfig::setPreviewNames(names);
+ ReKonfig::setPreviewUrls(urls);
+
ReKonfig::self()->writeConfig();
d->ebrowsingModule->save();
d->cookiesModule->save();
@@ -214,3 +253,29 @@ void SettingsDialog::setHomeToCurrentPage()
d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl());
}
}
+
+
+void SettingsDialog::updateSnaps()
+{
+ if(hasChanged())
+ {
+ QStringList urls = ReKonfig::previewUrls();
+ for(int i=0; i<9; ++i)
+ {
+ QString fileName = QString("thumb") + QString::number(i) + QString(".png");
+ WebSnap *ws = new WebSnap(urls.at(i), fileName);
+ connect(ws, SIGNAL(finished()), this, SLOT(polish()));
+ }
+ m_progress = new KProgressDialog(this, i18n("Loading..."), i18n("Retrieving site images..."));
+ m_progress->progressBar()->setRange(0,8);
+ m_progress->show();
+ }
+}
+
+
+void SettingsDialog::polish()
+{
+ WebSnap *ws = qobject_cast<WebSnap*>(sender());
+ delete ws;
+ m_progress->progressBar()->setValue( m_progress->progressBar()->value() + 1);
+} \ No newline at end of file
diff --git a/src/settings.h b/src/settings.h
index 0be89173..9278d758 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -31,6 +31,7 @@
// KDE Includes
#include <KConfigDialog>
+#include <KProgressDialog>
// Forward Declarations
class QWidget;
@@ -50,11 +51,15 @@ private:
Private* const d;
void setWebSettingsToolTips();
+ KProgressDialog *m_progress;
private slots:
void readConfig();
void saveSettings();
void setHomeToCurrentPage();
+
+ void updateSnaps();
+ void polish();
};
#endif // SETTINGS_H
diff --git a/src/settings_newtabpage.ui b/src/settings_newtabpage.ui
new file mode 100644
index 00000000..006185c0
--- /dev/null
+++ b/src/settings_newtabpage.ui
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>newtabpage</class>
+ <widget class="QWidget" name="newtabpage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>377</width>
+ <height>444</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Previews</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTableWidget" name="tableWidget">
+ <property name="rowCount">
+ <number>9</number>
+ </property>
+ <property name="columnCount">
+ <number>2</number>
+ </property>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <row/>
+ <column/>
+ <column/>
+ <item row="0" column="0">
+ <property name="text">
+ <string>KDE site</string>
+ </property>
+ </item>
+ <item row="0" column="1">
+ <property name="text">
+ <string>http://www.kde.org</string>
+ </property>
+ </item>
+ <item row="1" column="0">
+ <property name="text">
+ <string>KDE apps</string>
+ </property>
+ </item>
+ <item row="1" column="1">
+ <property name="text">
+ <string>http://kde-apps.org</string>
+ </property>
+ </item>
+ <item row="2" column="0">
+ <property name="text">
+ <string>rekonq site</string>
+ </property>
+ </item>
+ <item row="2" column="1">
+ <property name="text">
+ <string>http://rekonq.sourceforge.net</string>
+ </property>
+ </item>
+ <item row="3" column="0">
+ <property name="text">
+ <string>Google</string>
+ </property>
+ </item>
+ <item row="3" column="1">
+ <property name="text">
+ <string>http://www.google.com</string>
+ </property>
+ </item>
+ <item row="4" column="0">
+ <property name="text">
+ <string>Wikipedia</string>
+ </property>
+ </item>
+ <item row="4" column="1">
+ <property name="text">
+ <string>http://wikipedia.org</string>
+ </property>
+ </item>
+ <item row="5" column="0">
+ <property name="text">
+ <string>SourceForge</string>
+ </property>
+ </item>
+ <item row="5" column="1">
+ <property name="text">
+ <string>http://sourceforge.net</string>
+ </property>
+ </item>
+ <item row="6" column="0">
+ <property name="text">
+ <string>Kernel</string>
+ </property>
+ </item>
+ <item row="6" column="1">
+ <property name="text">
+ <string>http://www.kernel.org</string>
+ </property>
+ </item>
+ <item row="7" column="0">
+ <property name="text">
+ <string>Wordpress</string>
+ </property>
+ </item>
+ <item row="7" column="1">
+ <property name="text">
+ <string>http://wordpress.com</string>
+ </property>
+ </item>
+ <item row="8" column="0">
+ <property name="text">
+ <string>Planet KDE</string>
+ </property>
+ </item>
+ <item row="8" column="1">
+ <property name="text">
+ <string>http://planetkde.org</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>blocks</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="kcfg_useRecentlyClosedTabs">
+ <property name="text">
+ <string>show last 20 visited sites</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioButton_2">
+ <property name="text">
+ <string>show recently closed tabs</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 8bacd3b2..05ea17a9 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -33,6 +33,7 @@
#include <QSize>
#include <QWebFrame>
+#include <QWebSettings>
#include <QPainter>
#include <QTimer>
@@ -43,10 +44,12 @@ WebSnap::WebSnap(const KUrl &url, const QString &fileName)
, m_image(QImage())
, m_fileName(fileName)
{
+ // this to not register websnap history
+ m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
+
m_targetSize = QSize(200, 150);
connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool)));
QTimer::singleShot(0, this, SLOT(load()));
-
}
diff --git a/src/websnap.h b/src/websnap.h
index cbb786c7..8993fd08 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -46,7 +46,7 @@ class WebSnap : public QObject
public:
WebSnap(const KUrl &url, const QString &fileName);
-
+
signals:
void finished();