From 99b35a19b5fd9cecb3fc2403d9c913c476ba8677 Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 18 Jun 2013 11:03:52 +0200 Subject: [PATCH] Use palette colors for indicating not yet loaded tabs. Also fixed compile issue from previous commit. --- src/lib/webview/tabbar.cpp | 14 ++++++++++++++ src/lib/webview/tabbar.h | 4 ++++ src/lib/webview/tabwidget.h | 2 +- src/lib/webview/webtab.cpp | 12 ++++++++---- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 4e630fe6f..b8ab97269 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -480,6 +480,20 @@ QTabBar::ButtonPosition TabBar::closeButtonPosition() return (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this); } +void TabBar::overrideTabTextColor(int index, QColor color) +{ + if (!m_originalTabTextColor.isValid()) { + m_originalTabTextColor = tabTextColor(index); + } + + setTabTextColor(index, color); +} + +void TabBar::restoreTabTextColor(int index) +{ + setTabTextColor(index, m_originalTabTextColor); +} + void TabBar::showTabPreview() { WebTab* webTab = qobject_cast(m_tabWidget->widget(m_tabPreview->previewIndex())); diff --git a/src/lib/webview/tabbar.h b/src/lib/webview/tabbar.h index 14cfdd827..9272a04e9 100644 --- a/src/lib/webview/tabbar.h +++ b/src/lib/webview/tabbar.h @@ -45,6 +45,9 @@ public: QTabBar::ButtonPosition iconButtonPosition(); QTabBar::ButtonPosition closeButtonPosition(); + void overrideTabTextColor(int index, QColor color); + void restoreTabTextColor(int index); + void updatePinnedTabCloseButton(int index); void disconnectObjects(); @@ -119,6 +122,7 @@ private: mutable int m_normalTabWidth; mutable int m_activeTabWidth; + QColor m_originalTabTextColor; QRect m_originalGeometry; QPoint m_dragStartPosition; }; diff --git a/src/lib/webview/tabwidget.h b/src/lib/webview/tabwidget.h index 282d4553d..e5a615a9c 100644 --- a/src/lib/webview/tabwidget.h +++ b/src/lib/webview/tabwidget.h @@ -55,7 +55,7 @@ class QT_QUPZILLA_EXPORT MenuTabs : public QMenu { Q_OBJECT public: - explicit MenuTabs(QWidget *parent = 0) : QMenu(parent) {} + explicit MenuTabs(QWidget* parent = 0) : QMenu(parent) {} signals: void closeTab(int); diff --git a/src/lib/webview/webtab.cpp b/src/lib/webview/webtab.cpp index 951891447..61d2cc5d9 100644 --- a/src/lib/webview/webtab.cpp +++ b/src/lib/webview/webtab.cpp @@ -261,6 +261,7 @@ bool WebTab::isRestored() const return m_savedTab.isEmpty(); } +#include void WebTab::restoreTab(const WebTab::SavedTab &tab) { if (qzSettings->loadTabsOnActivation) { @@ -269,11 +270,13 @@ void WebTab::restoreTab(const WebTab::SavedTab &tab) m_view->tabWidget()->setTabIcon(index, tab.icon); m_view->tabWidget()->setTabText(index, tab.title); - if (! tab.url.isEmpty()) { - m_view->tabWidget()->tabBar()->setTabTextColor(index, QColor(100, 100, 100)); - } m_view->tabWidget()->setTabToolTip(index, tab.title); m_locationBar.data()->showUrl(tab.url); + + if (!tab.url.isEmpty()) { + QColor col = m_view->tabWidget()->getTabBar()->palette().text().color(); + m_view->tabWidget()->getTabBar()->overrideTabTextColor(index, col.lighter(250)); + } } else { p_restoreTab(tab); @@ -346,8 +349,9 @@ void WebTab::showNotification(QWidget* notif) void WebTab::slotRestore() { p_restoreTab(m_savedTab); - m_view->tabWidget()->tabBar()->setTabTextColor(tabIndex(), QColor(0, 0, 0)); m_savedTab.clear(); + + m_view->tabWidget()->getTabBar()->restoreTabTextColor(tabIndex()); } int WebTab::tabIndex() const