summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-09-30 10:21:58 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-09-30 10:21:58 +0200
commitb4516b0bacb68179eb6f7cbff9c6474ec03cc9ab (patch)
treeac6ffe5c874627302ddbce6a7dd350e1b6efb0c6
parenta lot fo changes in the history/bookmarks page (restored initial method rewam... (diff)
downloadrekonq-b4516b0bacb68179eb6f7cbff9c6474ec03cc9ab.tar.xz
BIG BIG commit
removed: - last closed tabs feature - new tab page settings (unuseful, we need something better) implemented - new home page layout (needs love) - new about: protocol to load home page sections - preview images cache todo: - cleaning cache mechanism - bug fixing - add/remove to preferred actions
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/history.cpp5
-rw-r--r--src/homepage.cpp69
-rw-r--r--src/homepage.h3
-rw-r--r--src/mainview.cpp10
-rw-r--r--src/mainview.h4
-rw-r--r--src/previewimage.cpp22
-rw-r--r--src/previewimage.h8
-rw-r--r--src/rekonq.kcfg9
-rw-r--r--src/settings.cpp64
-rw-r--r--src/settings.h2
-rw-r--r--src/settings_newtabpage.ui74
-rw-r--r--src/webpluginfactory.cpp9
-rw-r--r--src/websnap.cpp11
-rw-r--r--src/websnap.h3
15 files changed, 73 insertions, 221 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c443de2e..11fc5c6b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,7 +33,6 @@ 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/history.cpp b/src/history.cpp
index da39c4be..7e5cb741 100644
--- a/src/history.cpp
+++ b/src/history.cpp
@@ -114,6 +114,11 @@ bool HistoryManager::historyContains(const QString &url) const
void HistoryManager::addHistoryEntry(const QString &url)
{
QUrl cleanUrl(url);
+
+ // don't store about: urls (home page related)
+ if(cleanUrl.scheme() == QString("about"))
+ return;
+
cleanUrl.setPassword(QString());
cleanUrl.setHost(cleanUrl.host().toLower());
HistoryItem item(cleanUrl.toString(), QDateTime::currentDateTime());
diff --git a/src/homepage.cpp b/src/homepage.cpp
index c57661c4..5b8c9de2 100644
--- a/src/homepage.cpp
+++ b/src/homepage.cpp
@@ -82,7 +82,7 @@ QString HomePage::rekonqHomePage(const KUrl &url)
if(url == KUrl("about:bookmarks"))
speed = fillBookmarks();
if(url == KUrl("about:home") || url == KUrl("about:preferred"))
- speed = speedDial();
+ speed = fillPreferred();
QString html = QString(QLatin1String(file.readAll()))
.arg(imagesPath)
@@ -93,7 +93,7 @@ QString HomePage::rekonqHomePage(const KUrl &url)
}
-QString HomePage::speedDial()
+QString HomePage::fillPreferred()
{
QStringList names = ReKonfig::previewNames();
QStringList urls = ReKonfig::previewUrls();
@@ -104,7 +104,6 @@ QString HomePage::speedDial()
speed += "<td><div class=\"thumbnail\">";
speed += "<object type=\"application/image-preview\" width=\"200\">";
speed += "<param name=\"url\" value=\"" + urls.at(i) + "\">";
- speed += "<param name=\"position\" value=\"" + QString::number(i) + "\">";
speed += "</object>";
speed += "<br /><br />";
speed += "<a href=\"" + urls.at(i) + "\">" + names.at(i) + "</a></div></td>";
@@ -115,7 +114,6 @@ QString HomePage::speedDial()
speed += "<td><div class=\"thumbnail\">";
speed += "<object type=\"application/image-preview\" width=\"200\">";
speed += "<param name=\"url\" value=\"" + urls.at(i) + "\">";
- speed += "<param name=\"position\" value=\"" + QString::number(i) + "\">";
speed += "</object>";
speed += "<br /><br />";
speed += "<a href=\"" + urls.at(i) + "\">" + names.at(i) + "</a></div></td>";
@@ -126,51 +124,54 @@ QString HomePage::speedDial()
}
-QString HomePage::recentlyClosedTabs()
-{
- QString closed = "<h2>" + i18n("Recently closed tabs") + "</h2>";
- closed += "<ul>";
- KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs();
-
- Q_FOREACH(const KUrl &url, links)
- {
- closed += "<li><a href=\"" + url.prettyUrl() + "\">" + url.prettyUrl() + "</a></li>";
- }
- closed += "</ul>";
- return closed;
-}
-
-
QString HomePage::lastVisitedSites()
{
- QString history = "<h2>" + i18n("Last 20 visited sites") + "</h2>";
- history += "<ul>";
HistoryTreeModel *model = Application::historyManager()->historyTreeModel();
+
+ QString last = "<table><tr>";
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)
+ for(int j=0; j< model->rowCount(index) && j<4; ++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>";
+
+ last += "<td><div class=\"thumbnail\">";
+ last += "<object type=\"application/image-preview\" width=\"200\">";
+ last += "<param name=\"url\" value=\"" + son.data(HistoryModel::UrlStringRole).toString() + "\">";
+ last += "<param name=\"position\" value=\"" + QString::number(i) + "\">";
+ last += "</object>";
+ last += "<br /><br />";
+ last += "<a href=\"" + son.data(HistoryModel::UrlStringRole).toString() + "\">" + son.data().toString() + "</a></div></td>";
+
+ i++;
+ }
+ last += "</tr><tr>";
+ for(int j=4; j< model->rowCount(index) && j<8; ++j)
+ {
+ QModelIndex son = model->index(j, 0, index );
+
+ last += "<td><div class=\"thumbnail\">";
+ last += "<object type=\"application/image-preview\" width=\"200\">";
+ last += "<param name=\"url\" value=\"" + son.data(HistoryModel::UrlStringRole).toString() + "\">";
+ last += "<param name=\"position\" value=\"" + QString::number(i) + "\">";
+ last += "</object>";
+ last += "<br /><br />";
+ last += "<a href=\"" + son.data(HistoryModel::UrlStringRole).toString() + "\">" + son.data().toString() + "</a></div></td>";
i++;
}
}
i++;
}
- while( i<20 || model->hasIndex( i , 0 , QModelIndex() ) );
+ while( i<8 || model->hasIndex( i , 0 , QModelIndex() ) );
+
+ last += "</tr></table>";
+ return last;
- history += "<ul>";
- return history;
}
@@ -188,7 +189,7 @@ QString HomePage::homePageMenu()
QString HomePage::fillHistory()
{
- QString history = QString();
+ QString history = "<table>";
HistoryTreeModel *model = Application::historyManager()->historyTreeModel();
int i = 0;
@@ -203,13 +204,15 @@ QString HomePage::fillHistory()
QModelIndex son = model->index(j, 0, index );
history += QString("<tr><td>") + son.data().toString() + QString("</td>");
history += QString("<td><a href=\"") + son.data(HistoryModel::UrlStringRole).toString() + QString("\">") +
- son.data(HistoryModel::UrlStringRole).toString() + QString("</a></td></tr>");
+ son.data(HistoryModel::UrlStringRole).toString() + QString("</a></td>");
+ history += QString("<td>") + son.data(HistoryModel::DateTimeRole).toString() + QString("</td></tr>");
}
}
i++;
}
while( model->hasIndex( i , 0 , QModelIndex() ) );
+ history += "</table>";
return history;
}
diff --git a/src/homepage.h b/src/homepage.h
index 3c57f164..c4a7a0e2 100644
--- a/src/homepage.h
+++ b/src/homepage.h
@@ -51,8 +51,7 @@ public:
QString homePageMenu();
private:
- QString speedDial();
- QString recentlyClosedTabs();
+ QString fillPreferred();
QString lastVisitedSites();
QString fillHistory();
QString fillBookmarks();
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 231700a0..d02dd37d 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -183,8 +183,6 @@ void MainView::clear()
/// TODO What exactly do we need to clear here?
m_urlBar->clearHistory();
m_urlBar->clear();
-
- m_recentlyClosedTabs.clear();
}
@@ -418,8 +416,6 @@ void MainView::slotCloseTab(int index)
return;
}
hasFocus = tab->hasFocus();
-
- m_recentlyClosedTabs.prepend(tab->url());
}
QWidget *webView = widget(index);
@@ -586,12 +582,6 @@ void MainView::resizeEvent(QResizeEvent *event)
}
-KUrl::List MainView::recentlyClosedTabs()
-{
- return m_recentlyClosedTabs;
-}
-
-
void MainView::mouseMoveEvent(QMouseEvent *event)
{
//Find the tab under the mouse
diff --git a/src/mainview.h b/src/mainview.h
index 0d4145f3..548bc0f1 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -73,8 +73,6 @@ 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
@@ -166,8 +164,6 @@ private:
int m_currentTabIndex;
- KUrl::List m_recentlyClosedTabs;
-
QPointer<KPassivePopup> m_previewPopup;
int m_currentTabPreview;
};
diff --git a/src/previewimage.cpp b/src/previewimage.cpp
index c10f8924..9cd1fdaa 100644
--- a/src/previewimage.cpp
+++ b/src/previewimage.cpp
@@ -35,21 +35,22 @@
#include <KStandardDirs>
#include <KDebug>
-PreviewImage::PreviewImage(const QString &url, const QString &pos)
+
+PreviewImage::PreviewImage(const QString &url)
: QLabel()
, ws(0)
, m_url(url)
{
- QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rek") + pos + ".png", true);
+ m_savePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true);
- if(QFile::exists(path))
+ if(QFile::exists(m_savePath))
{
- m_pixmap.load(path);
+ m_pixmap.load(m_savePath);
setPixmap( m_pixmap );
}
else
{
- ws = new WebSnap( url, pos );
+ ws = new WebSnap( url );
connect(ws, SIGNAL(finished()), this, SLOT(setSiteImage()));
QString path = KStandardDirs::locate("appdata", "pics/busywidget.gif");
@@ -73,7 +74,10 @@ void PreviewImage::setSiteImage()
delete m;
setMovie(0);
- setPixmap( ws->previewImage() );
+ m_pixmap = ws->previewImage();
+ setPixmap(m_pixmap);
+
+ m_pixmap.save(m_savePath);
}
@@ -82,3 +86,9 @@ void PreviewImage::mousePressEvent(QMouseEvent *event)
Q_UNUSED(event)
Application::instance()->loadUrl(m_url);
}
+
+
+QString PreviewImage::guessNameFromUrl(QString url)
+{
+ return QUrl(url).toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash );
+}
diff --git a/src/previewimage.h b/src/previewimage.h
index 52698019..11dee271 100644
--- a/src/previewimage.h
+++ b/src/previewimage.h
@@ -39,21 +39,23 @@ class PreviewImage : public QLabel
Q_OBJECT
public:
- PreviewImage(const QString &url, const QString &pos);
-
+ PreviewImage(const QString &url);
~PreviewImage();
+ QString guessNameFromUrl(QString url);
+
public slots:
void setSiteImage();
protected:
void mousePressEvent(QMouseEvent *event);
-
+
private:
QPixmap m_pixmap;
WebSnap *ws;
QString m_url;
+ QString m_savePath;
};
#endif // PREVIEW_IMAGE_H
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index a3b0a1f6..ae499e26 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -8,21 +8,16 @@
<kcfgfile name="rekonqrc" />
-
<!-- New Tab Page Settings -->
<group name="NewTabPage">
<entry name="previewNames" type="StringList">
- <default>KDE site,KDE site,KDE site,KDE site,KDE site,KDE site,Google,rekonq</default>
+ <default>KDE site,KDE apps,KDE look,UserBase,KDE forum,TechBase,Planet KDE,rekonq</default>
</entry>
<entry name="previewUrls" type="StringList">
- <default>http://www.kde.org,http://www.kde.org,http://www.kde.org,http://www.kde.org,http://www.kde.org,http://www.kde.org,http://www.google.com,http://rekonq.sourceforge.net</default>
- </entry>
- <entry name="showLastVisitedSites" type="Bool">
- <default>true</default>
+ <default>http://www.kde.org,http://kde-apps.org,http://kde-look.org,http://userbase.kde.org,http://forum.kde.org,http://techbase.kde.org,http://planetkde.org,http://rekonq.sourceforge.net</default>
</entry>
</group>
-
<!-- General Settings -->
<group name="General">
<entry name="newTabHomePage" type="Bool">
diff --git a/src/settings.cpp b/src/settings.cpp
index 30b8ccab..ec5094c2 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -41,7 +41,6 @@
//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"
@@ -63,7 +62,6 @@ class Private
{
private:
Ui::general generalUi;
- Ui::newtabpage newtabpageUi;
Ui::fonts fontsUi;
Ui::proxy proxyUi;
Ui::webkit webkitUi;
@@ -86,12 +84,6 @@ Private::Private(SettingsDialog *parent)
widget->layout()->setMargin(0);
pageItem = parent->addPage(widget , i18n("General"));
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);
@@ -144,18 +136,10 @@ SettingsDialog::SettingsDialog(QWidget *parent)
setWindowTitle(i18n("rekonfig..."));
setModal(true);
- QStringList headerLabels;
- headerLabels << i18n("Name") << i18n("Url");
- d->newtabpageUi.tableWidget->setHorizontalHeaderLabels(headerLabels);
-
readConfig();
- // you have to do this after readConfig()...
- d->newtabpageUi.tableWidget->resizeColumnsToContents();
connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage()));
-
- connect(d->newtabpageUi.tableWidget, SIGNAL(cellChanged(int, int)), this, SLOT(deleteThumb(int,int)));
connect(d->ebrowsingModule, SIGNAL(changed(bool)), this, SLOT(updateButtons()));
connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons()));
@@ -198,28 +182,6 @@ void SettingsDialog::readConfig()
d->generalUi.rbUseNewTabPage->setChecked( true );
else
d->generalUi.rbUseHomePage->setChecked( true );
-
- // ====== New Tab Page
- QTableWidget *t = d->newtabpageUi.tableWidget;
- QStringList names, urls;
- names = ReKonfig::previewNames();
- urls = ReKonfig::previewUrls();
- for(int i=0; i< urls.count(); ++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);
-
- if( ReKonfig::showLastVisitedSites() )
- d->newtabpageUi.showLastVisitedSites->setChecked( true );
- else
- d->newtabpageUi.showRecentlyClosedTabs->setChecked( true );
-
// ======= Fonts
d->fontsUi.kcfg_fixedFont->setOnlyFixed(true);
@@ -235,21 +197,6 @@ void SettingsDialog::readConfig()
void SettingsDialog::saveSettings()
{
ReKonfig::setNewTabHomePage( d->generalUi.rbUseNewTabPage->isChecked() );
-
- QTableWidget *t = d->newtabpageUi.tableWidget;
- QStringList names, urls;
- for(int i=0; i<9; ++i)
- {
- if(t->item(i,0) && !t->item(i,0)->text().isEmpty())
- names << t->item(i,0)->text();
- if(t->item(i,1)&& !t->item(i,1)->text().isEmpty())
- urls << t->item(i,1)->text();
- }
-
- ReKonfig::setPreviewNames(names);
- ReKonfig::setPreviewUrls(urls);
-
- ReKonfig::setShowLastVisitedSites( d->newtabpageUi.showLastVisitedSites->isChecked() );
ReKonfig::self()->writeConfig();
d->ebrowsingModule->save();
@@ -275,14 +222,3 @@ void SettingsDialog::setHomeToCurrentPage()
d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl());
}
}
-
-
-void SettingsDialog::deleteThumb(int row ,int col)
-{
- if(col!=1)
- return;
-
- QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rek") + QString::number(row) + ".png", true);
- QFile::remove(path);
-}
-
diff --git a/src/settings.h b/src/settings.h
index 8f61ad25..0be89173 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -55,8 +55,6 @@ private slots:
void saveSettings();
void setHomeToCurrentPage();
-
- void deleteThumb(int,int);
};
#endif // SETTINGS_H
diff --git a/src/settings_newtabpage.ui b/src/settings_newtabpage.ui
deleted file mode 100644
index 2061d285..00000000
--- a/src/settings_newtabpage.ui
+++ /dev/null
@@ -1,74 +0,0 @@
-<?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/>
- </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="showLastVisitedSites">
- <property name="text">
- <string>show last 20 visited sites</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="showRecentlyClosedTabs">
- <property name="text">
- <string>show recently closed tabs</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp
index 5ec6ad55..27799ca6 100644
--- a/src/webpluginfactory.cpp
+++ b/src/webpluginfactory.cpp
@@ -56,19 +56,16 @@ QObject *WebPluginFactory::create(const QString &mimeType,
if(mimeType == QString("application/image-preview") )
{
- QString imageUrl, pos;
+ QString imageUrl;
for(int i = 0; i<argumentNames.count(); ++i)
{
if(argumentNames.at(i) == QString("url"))
{
imageUrl = argumentValues.at(i);
- }
- if(argumentNames.at(i) == QString("position"))
- {
- pos = argumentValues.at(i);
+ break;
}
}
- return new PreviewImage(imageUrl, pos);
+ return new PreviewImage(imageUrl);
}
// this let QtWebKit using builtin plugins
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 6293b2e9..9d747e66 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -43,11 +43,10 @@
#define HEIGHT 150
-WebSnap::WebSnap(const QString &url, const QString &pos)
+WebSnap::WebSnap(const QString &url)
: QObject()
{
m_url = url;
- m_pos = pos;
// this to not register websnap history
m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
@@ -61,6 +60,7 @@ void WebSnap::load()
m_page.mainFrame()->load( QUrl(m_url) );
}
+
QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h)
{
// prepare page
@@ -102,6 +102,7 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h)
return image;
}
+
void WebSnap::saveResult(bool ok)
{
// crude error-checking
@@ -111,12 +112,8 @@ void WebSnap::saveResult(bool ok)
return;
}
- QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rek") + m_pos + ".png", true);
m_image = renderPreview(m_page, WIDTH, HEIGHT);
- if(m_image.save(path))
- {
- emit finished();
- }
+ emit finished();
}
diff --git a/src/websnap.h b/src/websnap.h
index 5a550838..7feb37fb 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -45,7 +45,7 @@ class WebSnap : public QObject
Q_OBJECT
public:
- WebSnap(const QString &url, const QString &pos);
+ WebSnap(const QString &url);
QPixmap previewImage();
static QPixmap renderPreview(const QWebPage &page, int w, int h);
@@ -62,7 +62,6 @@ private:
QPixmap m_image;
QString m_url;
- QString m_pos;
};
#endif // WEB_SNAP_H