From 0a50c2d9ef1efb6cbb5a3fd93720defeff86557e Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 9 Apr 2012 19:45:00 +0200 Subject: [PATCH] Showing tab previews on ToolTip event now. - added Alexander Samilov into contributors --- AUTHORS | 1 + TODO | 1 - src/lib/network/qupzillaschemehandler.cpp | 1 + src/lib/other/aboutdialog.cpp | 1 + src/lib/webview/tabbar.cpp | 31 ++++++++++++----------- src/lib/webview/tabbar.h | 5 +--- src/lib/webview/tabpreview.cpp | 12 +++++++++ src/lib/webview/tabpreview.h | 4 +++ 8 files changed, 36 insertions(+), 20 deletions(-) diff --git a/AUTHORS b/AUTHORS index 60d9ca381..b6fec280e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,6 +5,7 @@ David Rosca Contributors: Mladen Pejaković (webview context menu improvements, speed dial background) +Alexander Samilov (tab previews) Bryan M Dunsmore (opening background tabs, closing window when closing last tab) Mariusz Fik (fixed tab order in preferences dialog) Daniele Cocca (close tabs with middle click, initial work on speed dial) diff --git a/TODO b/TODO index 1de73c048..f7e4c0436 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,6 @@ The list is not sorted by priority. * Password Manager: save more than one account for site + input completer * New LocationBar completer * (KDE) Nepomuk integration -* Page previews as tooltip on tabs (like Opera) * Support for remote Web inspector * option to save RSS feeds in external reader * Session manager diff --git a/src/lib/network/qupzillaschemehandler.cpp b/src/lib/network/qupzillaschemehandler.cpp index 93ffa1b3e..3b7f0157f 100644 --- a/src/lib/network/qupzillaschemehandler.cpp +++ b/src/lib/network/qupzillaschemehandler.cpp @@ -203,6 +203,7 @@ QString QupZillaSchemeReply::aboutPage() aPage.replace("%CONTRIBUTORS%", tr("Contributors")); aPage.replace("%CONTRIBUTORS-TEXT%", authorString("Mladen Pejaković", "pejakm@gmail.com") + "
" + + authorString("Alexander Samilov", "alexsamilovskih@gmail.com") + "
" + authorString("Bryan M Dunsmore", "dunsmoreb@gmail.com") + "
" + authorString("Mariusz Fik", "fisiu@opensuse.org") + "
" + authorString("Jan Rajnoha", "honza.rajny@hotmail.com") + "
" + diff --git a/src/lib/other/aboutdialog.cpp b/src/lib/other/aboutdialog.cpp index 47b9864ec..4a2825945 100644 --- a/src/lib/other/aboutdialog.cpp +++ b/src/lib/other/aboutdialog.cpp @@ -79,6 +79,7 @@ void AboutDialog::showAuthors() m_authorsHtml += tr("

Main developer:
%1 <%2>

").arg(QupZilla::AUTHOR, "nowrep@gmail.com"); m_authorsHtml += tr("

Contributors:
%1

").arg( QString::fromUtf8("Mladen Pejaković
" + "Alexander Samilov
" "Bryan M Dunsmore
" "Mariusz Fik
" "Jan Rajnoha
" diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 4bf08e05b..deb00b41f 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -50,7 +50,6 @@ TabBar::TabBar(QupZilla* mainClass, TabWidget* tabWidget) , m_tabPreview(new TabPreview(mainClass, tabWidget)) , m_clickedTab(0) , m_pinnedTabsCount(0) - , m_currentTabPreview(-1) , m_normalTabWidth(0) , m_lastTabWidth(0) , m_adjustingLastTab(false) @@ -119,7 +118,7 @@ void TabBar::setVisible(bool visible) emit hideButtons(); } - m_tabPreview->setVisible(false); + hideTabPreview(false); QTabBar::setVisible(visible); } @@ -360,14 +359,14 @@ int TabBar::normalTabsCount() void TabBar::showTabPreview() { - WebTab* webTab = qobject_cast(m_tabWidget->widget(m_currentTabPreview)); + WebTab* webTab = qobject_cast(m_tabWidget->widget(m_tabPreview->previewIndex())); if (!webTab) { return; } m_tabPreviewTimer->stop(); - m_tabPreview->setWebTab(webTab, m_currentTabPreview == currentIndex()); - m_tabPreview->showOnRect(tabRect(m_currentTabPreview)); + m_tabPreview->setWebTab(webTab, m_tabPreview->previewIndex() == currentIndex()); + m_tabPreview->showOnRect(tabRect(m_tabPreview->previewIndex())); } void TabBar::hideTabPreview(bool delayed) @@ -378,8 +377,6 @@ void TabBar::hideTabPreview(bool delayed) else { m_tabPreview->hideAnimated(); } - - m_currentTabPreview = -1; } void TabBar::mouseDoubleClickEvent(QMouseEvent* event) @@ -398,6 +395,8 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent* event) void TabBar::mousePressEvent(QMouseEvent* event) { + hideTabPreview(false); + if (mApp->plugins()->processMousePress(Qz::ON_TabBar, this, event)) { return; } @@ -430,14 +429,11 @@ void TabBar::mouseMoveEvent(QMouseEvent* event) const int tab = tabAt(event->pos()); - if (tab != -1 && tab != m_currentTabPreview && event->buttons() == Qt::NoButton && m_dragStartPosition.isNull()) { - m_currentTabPreview = tab; + if (tab != -1 && tab != m_tabPreview->previewIndex() && event->buttons() == Qt::NoButton && m_dragStartPosition.isNull()) { + m_tabPreview->setPreviewIndex(tab); if (m_tabPreview->isVisible()) { showTabPreview(); } - else { - QTimer::singleShot(200, this, SLOT(showTabPreview())); - } } QTabBar::mouseMoveEvent(event); @@ -473,11 +469,16 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event) QTabBar::mouseReleaseEvent(event); } -void TabBar::leaveEvent(QEvent* event) +bool TabBar::event(QEvent *event) { - hideTabPreview(); + if (event->type() == QEvent::Leave) { + hideTabPreview(); + } + else if (event->type() == QEvent::ToolTip && !m_tabPreview->isVisible()) { + showTabPreview(); + } - QTabBar::leaveEvent(event); + return QTabBar::event(event); } void TabBar::wheelEvent(QWheelEvent* event) diff --git a/src/lib/webview/tabbar.h b/src/lib/webview/tabbar.h index fc4064439..a16deecaf 100644 --- a/src/lib/webview/tabbar.h +++ b/src/lib/webview/tabbar.h @@ -59,8 +59,6 @@ signals: void showButtons(); void hideButtons(); -public slots: - private slots: void currentTabChanged(int index); void pinnedTabAdded(); @@ -84,8 +82,8 @@ private: void mousePressEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); - void leaveEvent(QEvent* event); void wheelEvent(QWheelEvent* event); + bool event(QEvent *event); void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); @@ -105,7 +103,6 @@ private: int m_clickedTab; int m_pinnedTabsCount; - int m_currentTabPreview; int m_normalTabWidth; int m_lastTabWidth; diff --git a/src/lib/webview/tabpreview.cpp b/src/lib/webview/tabpreview.cpp index 02744f0eb..a3b303181 100644 --- a/src/lib/webview/tabpreview.cpp +++ b/src/lib/webview/tabpreview.cpp @@ -35,6 +35,7 @@ TabPreview::TabPreview(QupZilla* mainClass, QWidget* parent) , p_QupZilla(mainClass) , m_pixmap(new QLabel) , m_title(new QLabel) + , m_previewIndex(-1) , m_animationsEnabled(true) { m_pixmap->setAlignment(Qt::AlignHCenter); @@ -63,6 +64,16 @@ TabPreview::TabPreview(QupZilla* mainClass, QWidget* parent) m_opacityEffect->setOpacity(0.0); } +int TabPreview::previewIndex() +{ + return m_previewIndex; +} + +void TabPreview::setPreviewIndex(int index) +{ + m_previewIndex = index; +} + void TabPreview::setWebTab(WebTab* webTab, bool noPixmap) { if (webTab->isRestored() && !webTab->isLoading() && !noPixmap) { @@ -102,6 +113,7 @@ void TabPreview::hideAnimated() void TabPreview::hide() { + m_previewIndex = -1; disconnect(m_opacityAnimation, SIGNAL(finished()), this, SLOT(hide())); QFrame::hide(); diff --git a/src/lib/webview/tabpreview.h b/src/lib/webview/tabpreview.h index 1cb5cc009..7ae2d0f0b 100644 --- a/src/lib/webview/tabpreview.h +++ b/src/lib/webview/tabpreview.h @@ -37,6 +37,9 @@ public: void setWebTab(WebTab* webTab, bool noPixmap); void showOnRect(const QRect &rect); + int previewIndex(); + void setPreviewIndex(int index); + void setAnimationsEnabled(bool enabled); public slots: @@ -57,6 +60,7 @@ private: QLabel* m_pixmap; QLabel* m_title; + int m_previewIndex; bool m_animationsEnabled; QPropertyAnimation* m_animation; QPropertyAnimation* m_opacityAnimation;