From 1ef712920d762f9f88393caf1018bd8708c02424 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 29 Apr 2010 12:41:39 +0200 Subject: Fixing tab switch behavior. It seems webkit removed an update on setViewPortSize, letting our trick about setScrollBarPolicy dangerous (no scrollbar on rendered pages) --- src/tabbar.cpp | 24 +++++++++++++++--------- src/tabbar.h | 4 ++-- src/websnap.cpp | 12 ++++++++---- 3 files changed, 25 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index a2f269c4..7e10a196 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -197,25 +197,31 @@ void TabBar::mouseMoveEvent(QMouseEvent *event) { //Find the tab under the mouse int i = 0; - int tab = -1; - while (ipos())) { - tab = i; + tabIndex = i; } i++; } - //if found and not the current tab then show tab preview - if (tab != -1 && tab != currentIndex() && m_currentTabPreview != tab && event->buttons() == Qt::NoButton) + // if found and not the current tab then show tab preview + if ( tabIndex != -1 + && tabIndex != currentIndex() + && m_currentTabPreview != tabIndex + && event->buttons() == Qt::NoButton + ) { - showTabPreview(tab); - m_currentTabPreview = tab; + showTabPreview(tabIndex); + m_currentTabPreview = tabIndex; } - //if current tab or not found then hide previous tab preview - if (tab==currentIndex() || tab==-1) + // if current tab or not found then hide previous tab preview + if (tabIndex == currentIndex() || tabIndex == -1) { if ( !m_previewPopup.isNull() ) { diff --git a/src/tabbar.h b/src/tabbar.h index 97c320fc..fd325b66 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -61,8 +61,6 @@ public: TabBar(QWidget *parent); ~TabBar(); - void showTabPreview(int tab); - signals: void cloneTab(int index); void closeTab(int index); @@ -94,6 +92,8 @@ private slots: void emptyAreaContextMenu(const QPoint &); private: + void showTabPreview(int tab); + friend class MainView; /** diff --git a/src/websnap.cpp b/src/websnap.cpp index 6be7314e..af52b592 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -72,10 +72,14 @@ void WebSnap::load() // You are playing with fire.. QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) { + // NOTE + // it seems no way to enable/disable scrollbars in new QtWebKit's + // and this is affecting tabbed browsing + // prepare page - page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); QSize oldSize = page.viewportSize(); +// page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); +// page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); // find the best size QSize size; @@ -98,8 +102,8 @@ QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h) pageImage = pageImage.scaled(w, h, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); // restore page settings - page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); - page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); +// page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); +// page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); page.setViewportSize(oldSize); QPixmap pm = QPixmap::fromImage(pageImage); -- cgit v1.2.1