From 618081a2e0c3eb0320ff22fa6615bc73e19152db Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 5 Aug 2012 18:21:50 +0200 Subject: Use a default size for tab preview. It will fix disproportionate previews caused by very high ratio. --- src/tabpreviewpopup.cpp | 23 ++++++++++++++++++----- src/tabpreviewpopup.h | 4 ++++ 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tabpreviewpopup.cpp b/src/tabpreviewpopup.cpp index 0490e602..92809abc 100644 --- a/src/tabpreviewpopup.cpp +++ b/src/tabpreviewpopup.cpp @@ -29,9 +29,6 @@ #include "tabpreviewpopup.h" // Rekonq Includes -#include "application.h" -#include "mainwindow.h" -#include "tabbar.h" #include "webtab.h" //Qt Includes @@ -96,10 +93,26 @@ TabPreviewPopup::~TabPreviewPopup() } +QSize TabPreviewPopup::thumbnailSize() const +{ + return m_thumbnail->pixmap()->size(); +} + + void TabPreviewPopup::setWebTab(WebTab* tab) { - int w = (tab->parentWidget()->sizeHint().width() / TabBar::baseWidthDivisor); - int h = w * tab->size().height() / tab->size().width(); + // The ratio of the tab + double ratio = (double) tab->size().height() / tab->size().width(); + + int w = previewBaseSize; + int h = previewBaseSize; + + // Apply the ratio to the width or the weight to not exceed previewBaseSize + if (ratio < 1) + h *= ratio; + else if (ratio > 1) + w *= (1 / ratio); + const QPixmap preview = tab->tabPreview(w, h); if (!preview.isNull()) diff --git a/src/tabpreviewpopup.h b/src/tabpreviewpopup.h index 5c62102f..14f6f0ed 100644 --- a/src/tabpreviewpopup.h +++ b/src/tabpreviewpopup.h @@ -52,6 +52,10 @@ public: explicit TabPreviewPopup(WebTab *tab, QWidget *parent = 0); virtual ~TabPreviewPopup(); + QSize thumbnailSize() const; + + static const int previewBaseSize = 200; + private: void setWebTab(WebTab *tab = 0); void setUrl(const QString& text); -- cgit v1.2.1