summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegabigbug <megabigbug@arrakis.(none)>2009-09-22 15:45:18 +0200
committermegabigbug <megabigbug@arrakis.(none)>2009-09-22 15:45:18 +0200
commitc64f84da6627ecd09d74f1e0ff2aa62f47a30c60 (patch)
tree25620771556c019b808332f074aa9816fe08d828
parentsmall fix of tab preview behavior (diff)
parentFixing foreach macros.. (diff)
downloadrekonq-c64f84da6627ecd09d74f1e0ff2aa62f47a30c60.tar.xz
Merge branch 'master' of git://gitorious.org/rekonq/mainline
-rw-r--r--src/cookiejar.cpp2
-rw-r--r--src/homepage.cpp2
-rw-r--r--src/mainview.cpp15
-rw-r--r--src/mainview.h1
-rw-r--r--src/networkaccessmanager.cpp2
-rw-r--r--src/sessionmanager.cpp2
-rw-r--r--src/tabbar.cpp12
-rw-r--r--src/webpage.cpp2
-rw-r--r--src/websnap.cpp44
-rw-r--r--src/websnap.h3
-rw-r--r--src/webview.cpp2
11 files changed, 49 insertions, 38 deletions
diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp
index cd7b97fa..a8ba18bc 100644
--- a/src/cookiejar.cpp
+++ b/src/cookiejar.cpp
@@ -84,7 +84,7 @@ QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl & url) const
bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> & cookieList, const QUrl & url)
{
QByteArray cookieHeader;
- foreach(const QNetworkCookie& cookie, cookieList)
+ Q_FOREACH(const QNetworkCookie& cookie, cookieList)
{
cookieHeader = "Set-Cookie: ";
cookieHeader += cookie.toRawForm();
diff --git a/src/homepage.cpp b/src/homepage.cpp
index aa679999..8dccc3fd 100644
--- a/src/homepage.cpp
+++ b/src/homepage.cpp
@@ -127,7 +127,7 @@ QString HomePage::recentlyClosedTabs()
KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs();
- foreach(const KUrl &url, links)
+ Q_FOREACH(const KUrl &url, links)
{
closed += "<li><a href=\"" + url.prettyUrl() + "\">" + url.prettyUrl() + "</a></li>";
}
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 6ef99b9b..47e39524 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -42,6 +42,7 @@
#include "webview.h"
#include "sessionmanager.h"
#include "homepage.h"
+#include "websnap.h"
// KDE Includes
#include <KUrl>
@@ -645,18 +646,6 @@ void MainView::leaveEvent(QEvent *event)
KTabWidget::leaveEvent(event);
}
-QPixmap MainView::renderTabPreview(int tab, int w, int h)
-{
- QPixmap image = QPixmap(webView(tab)->width(), webView(tab)->height());
- image.fill(Qt::transparent);
- QPainter p(&image);
- webView(tab)->page()->mainFrame()->render(&p);
- p.end();
- image = image.scaled(w, h, Qt::KeepAspectRatioByExpanding);
-
- return image;
-}
-
void MainView::showTabPreview(int tab)
{
int w=200;
@@ -672,7 +661,7 @@ void MainView::showTabPreview(int tab)
m_previewPopup->setFrameShape(QFrame::NoFrame);
m_previewPopup->setFixedSize(w, h);
QLabel *l = new QLabel();
- l->setPixmap(renderTabPreview(tab, w, h));
+ l->setPixmap(WebSnap::renderPreview(webView(tab)->page(), w, h));
m_previewPopup->setView(l);
m_previewPopup->layout()->setAlignment(Qt::AlignTop);
m_previewPopup->layout()->setMargin(0);
diff --git a/src/mainview.h b/src/mainview.h
index cd212dbd..5410b70e 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -96,7 +96,6 @@ public:
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void leaveEvent(QEvent *event);
void showTabPreview(int tab);
- QPixmap renderTabPreview(int tab, int w, int h);
signals:
// tab widget signals
diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp
index b2958d9e..6a89d104 100644
--- a/src/networkaccessmanager.cpp
+++ b/src/networkaccessmanager.cpp
@@ -117,7 +117,7 @@ void NetworkAccessManager::resetDiskCache()
QDir cacheDir(location + QString("/http") );
QStringList fileList = cacheDir.entryList();
- foreach(QString str, fileList)
+ Q_FOREACH(QString str, fileList)
{
QFile file(str);
file.remove();
diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp
index c93a229d..0c2c5c32 100644
--- a/src/sessionmanager.cpp
+++ b/src/sessionmanager.cpp
@@ -66,7 +66,7 @@ void SessionManager::saveSession()
}
QDataStream out(&sessionFile);
MainWindowList wl = Application::instance()->mainWindowList();
- foreach(QPointer<MainWindow> w, wl)
+ Q_FOREACH(QPointer<MainWindow> w, wl)
{
out << QByteArray("window");
MainView *mv = w->mainView();
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index d676af55..dfc1482c 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -73,7 +73,17 @@ TabBar::~TabBar()
void TabBar::postLaunch()
{
- m_addTabButton->setDefaultAction(Application::instance()->mainWindow()->actionByName("new_tab"));
+ // Find the correct MainWindow of this tab button
+ MainWindowList list = Application::instance()->mainWindowList();
+ Q_FOREACH(QPointer<MainWindow> w, list)
+ {
+ if (w->isAncestorOf(this))
+ {
+ m_addTabButton->setDefaultAction(w->actionByName("new_tab"));
+ break;
+ }
+ }
+
m_addTabButton->setAutoRaise(true);
m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
m_addTabButton->show();
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 697cf448..d5d1cd7c 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -200,7 +200,7 @@ void WebPage::manageNetworkErrors(QNetworkReply* reply)
return;
}
QList<QWebFrame *> children = firstFrame->childFrames();
- foreach(QWebFrame *frame, children)
+ Q_FOREACH(QWebFrame *frame, children)
{
frames.append(frame);
}
diff --git a/src/websnap.cpp b/src/websnap.cpp
index c669dee0..59275522 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -61,6 +61,32 @@ void WebSnap::load()
m_page.mainFrame()->load( QUrl(m_url) );
}
+QPixmap WebSnap::renderPreview(QWebPage *page,int w, int h)
+{
+ // prepare page
+ page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); //Why it doesn't work with one setScrollBarPolicy ? bug in qtwebkit ?
+ page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
+ page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+ page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+
+ // create the target surface
+ QPixmap image = QPixmap(page->viewportSize());
+ image.fill(Qt::transparent);
+
+ // render
+ QPainter p(&image);
+ page->mainFrame()->render(&p);
+ p.end();
+ image = image.scaled(w, h, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
+
+ // restore page settings
+ page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
+ page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
+ page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
+ page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
+
+ return image;
+}
void WebSnap::saveResult(bool ok)
{
@@ -70,24 +96,10 @@ void WebSnap::saveResult(bool ok)
kDebug() << "Error loading site..";
return;
}
-
- // find proper image size and later resize it..
- QSize size = m_page.mainFrame()->contentsSize();
-
- // create the target surface
- m_image = QPixmap( size );
- m_image.fill(Qt::transparent);
-
- // render and rescale
- QPainter p(&m_image);
- m_page.setViewportSize( size );
- m_page.mainFrame()->render(&p);
- p.end();
- m_image = m_image.scaled(WIDTH, HEIGHT, Qt::KeepAspectRatioByExpanding);
-
QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rek") + m_pos + ".png", true);
- if( m_image.save(path) )
+ m_image = renderPreview(&m_page, WIDTH, HEIGHT);
+ if(m_image.save(path))
{
kDebug() << "finished";
emit finished();
diff --git a/src/websnap.h b/src/websnap.h
index 2bcdfef8..63f8dccf 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -48,7 +48,8 @@ public:
WebSnap(const QString &url, const QString &pos);
QPixmap previewImage();
-
+ static QPixmap renderPreview(QWebPage *page, int w, int h);
+
signals:
void finished();
diff --git a/src/webview.cpp b/src/webview.cpp
index 8a74e76b..21a24c4f 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -175,7 +175,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
KService::Ptr service;
KUriFilterData data;
- foreach (const QString &engine, favoriteEngines)
+ Q_FOREACH(const QString &engine, favoriteEngines)
{
if(!engine.isEmpty())
{