1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Disabled opacity effect in animated tab previews by default.

It can still be enabled with ENABLE_OPACITY_EFFECT build variable.
This is final fix for #663
This commit is contained in:
nowrep 2013-02-07 12:35:54 +01:00
parent 9c31ff875e
commit efe5ed8e7d
5 changed files with 42 additions and 5 deletions

View File

@ -100,6 +100,16 @@ Available Defines
example:
$ export NONBLOCK_JS_DIALOGS="true"
ENABLE_OPACITY_EFFECT Enable opacity effect on animated tab previews. Tab previews
will then fade-in on show.
However, this feature may result in wrong scrolling into
anchor (#) links. Rendering of opacity effect may also be
garbled due to Flash.
(disabled by default)
example:
$ export ENABLE_OPACITY_EFFECT="true"
Windows specific defines:

View File

@ -15,6 +15,7 @@ Version 1.4.0
* use .qupzilla/tmp instead of /tmp for temporary data
* saving passwords should now work for much more sites
* don't steal Ctrl+B/U/I shortcuts from page
* disabled by default opacity effect on tab previews - see BUILDING
* fixed scrolling to anchor in background tabs
* fixed parsing UTF-8 filenames in Content-Disposition header
* fixed crash with context menu in websearchbar and locationbar

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 Alexander Samilovskih <alexsamilovskih@gmail.com>
* Copyright (C) 2010-2013 Alexander Samilovskih <alexsamilovskih@gmail.com>
* David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
@ -59,9 +59,11 @@ TabPreview::TabPreview(QupZilla* mainClass, QWidget* parent)
setMaximumWidth(250);
setMaximumHeight(170);
#ifdef ENABLE_OPACITY_EFFECT
setGraphicsEffect(&m_opacityEffect);
m_opacityEffect.setOpacity(0.0);
connect(&m_opacityTimeLine, SIGNAL(frameChanged(int)), this, SLOT(setOpacity(int)));
#endif
m_animation.setDuration(400);
m_animation.setFrameRange(0, 100);
@ -99,6 +101,7 @@ void TabPreview::setAnimationsEnabled(bool enabled)
void TabPreview::hideAnimated()
{
#ifdef ENABLE_OPACITY_EFFECT
if (m_opacityTimeLine.state() == QTimeLine::Running) {
m_opacityTimeLine.stop();
}
@ -114,12 +117,16 @@ void TabPreview::hideAnimated()
else {
QFrame::hide();
}
#endif
QFrame::hide();
}
void TabPreview::hide()
{
m_previewIndex = -1;
#ifdef ENABLE_OPACITY_EFFECT
disconnect(&m_opacityTimeLine, SIGNAL(finished()), this, SLOT(hide()));
#endif
QFrame::hide();
}
@ -163,8 +170,12 @@ void TabPreview::showOnRect(const QRect &r)
finishingGeometry = QRect(calculatePosition(r, previewSize), previewSize);
}
#ifdef ENABLE_OPACITY_EFFECT
if (!m_animationsEnabled) {
m_opacityEffect.setOpacity(1.0);
#else
if (!m_animationsEnabled || !wasVisible) {
#endif
QFrame::setGeometry(finishingGeometry);
return;
}
@ -176,14 +187,18 @@ void TabPreview::showOnRect(const QRect &r)
m_startGeometry = finishingGeometry;
}
QFrame::setGeometry(m_startGeometry);
calculateSteps(m_startGeometry, finishingGeometry);
m_animation.start();
}
#ifdef ENABLE_OPACITY_EFFECT
void TabPreview::setOpacity(int opacity)
{
m_opacityEffect.setOpacity(opacity / 100.0);
}
#endif
void TabPreview::setAnimationFrame(int frame)
{
@ -198,6 +213,7 @@ void TabPreview::setAnimationFrame(int frame)
void TabPreview::showAnimated()
{
#ifdef ENABLE_OPACITY_EFFECT
disconnect(&m_opacityTimeLine, SIGNAL(finished()), this, SLOT(hide()));
if (m_opacityTimeLine.state() == QTimeLine::Running) {
@ -208,6 +224,7 @@ void TabPreview::showAnimated()
m_opacityTimeLine.setStartFrame(m_opacityEffect.opacity() * 100);
m_opacityTimeLine.setEndFrame(100);
m_opacityTimeLine.start();
#endif
}
void TabPreview::paintEvent(QPaintEvent* pe)

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 Alexander Samilovskih <alexsamilovskih@gmail.com>
* Copyright (C) 2010-2013 Alexander Samilovskih <alexsamilovskih@gmail.com>
* David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
@ -21,7 +21,10 @@
#include <QFrame>
#include <QTimeLine>
#ifdef ENABLE_OPACITY_EFFECT
#include <QGraphicsOpacityEffect>
#endif
class QupZilla;
class WebTab;
@ -48,8 +51,10 @@ public slots:
void show();
private slots:
void setOpacity(int opacity);
void setAnimationFrame(int frame);
#ifdef ENABLE_OPACITY_EFFECT
void setOpacity(int opacity);
#endif
protected:
void paintEvent(QPaintEvent* pe);
@ -66,8 +71,10 @@ private:
int m_previewIndex;
bool m_animationsEnabled;
#ifdef ENABLE_OPACITY_EFFECT
QTimeLine m_opacityTimeLine;
QGraphicsOpacityEffect m_opacityEffect;
#endif
QTimeLine m_animation;
QRect m_startGeometry;

View File

@ -257,12 +257,14 @@ QPixmap WebTab::renderTabPreview()
{
TabbedWebView* currentWebView = p_QupZilla->weView();
WebPage* page = m_view->page();
const QSize oldSize = currentWebView ? currentWebView->page()->viewportSize() : page->viewportSize();
const QSize oldSize = page->viewportSize();
const QPoint originalScrollPosition = page->mainFrame()->scrollPosition();
// Hack to ensure rendering the same preview before and after the page was shown for the first time
// This can occur eg. with opening background tabs
page->setViewportSize(oldSize);
if (currentWebView) {
page->setViewportSize(currentWebView->size());
}
const int previewWidth = 230;
const int previewHeight = 150;