1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

[PrivateBrowsing] Show PrivateBrowsing indicator as left corner widget in tabbar

Removed PrivateBrowsing icon in Status Bar
This commit is contained in:
nowrep 2014-03-31 09:50:54 +02:00
parent da6ccdcee5
commit bfe08409b4
5 changed files with 32 additions and 16 deletions

View File

@ -321,10 +321,6 @@ void BrowserWindow::setupUi()
statusBar()->setObjectName("mainwindow-statusbar"); statusBar()->setObjectName("mainwindow-statusbar");
statusBar()->setCursor(Qt::ArrowCursor); statusBar()->setCursor(Qt::ArrowCursor);
m_progressBar = new ProgressBar(statusBar()); m_progressBar = new ProgressBar(statusBar());
m_privateBrowsing = new QLabel(this);
m_privateBrowsing->setPixmap(IconProvider::privateBrowsingIcon().pixmap(16));
m_privateBrowsing->setVisible(false);
m_privateBrowsing->setToolTip(tr("Private Browsing Enabled"));
m_adblockIcon = new AdBlockIcon(this); m_adblockIcon = new AdBlockIcon(this);
m_ipLabel = new QLabel(this); m_ipLabel = new QLabel(this);
m_ipLabel->setObjectName("statusbar-ip-label"); m_ipLabel->setObjectName("statusbar-ip-label");
@ -332,7 +328,6 @@ void BrowserWindow::setupUi()
statusBar()->addPermanentWidget(m_progressBar); statusBar()->addPermanentWidget(m_progressBar);
statusBar()->addPermanentWidget(m_ipLabel); statusBar()->addPermanentWidget(m_ipLabel);
statusBar()->addPermanentWidget(m_privateBrowsing);
statusBar()->addPermanentWidget(m_adblockIcon); statusBar()->addPermanentWidget(m_adblockIcon);
// Workaround for Oxygen tooltips not having transparent background // Workaround for Oxygen tooltips not having transparent background
@ -438,9 +433,6 @@ void BrowserWindow::loadSettings()
m_sideBarManager->showSideBar(activeSideBar, false); m_sideBarManager->showSideBar(activeSideBar, false);
// Private browsing
m_privateBrowsing->setVisible(mApp->isPrivate());
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (m_useTransparentBackground && !makeTransparent) { if (m_useTransparentBackground && !makeTransparent) {
QtWin::extendFrameIntoClientArea(this, 0, 0, 0, 0); QtWin::extendFrameIntoClientArea(this, 0, 0, 0, 0);

View File

@ -183,7 +183,6 @@ private:
QVBoxLayout* m_mainLayout; QVBoxLayout* m_mainLayout;
QSplitter* m_mainSplitter; QSplitter* m_mainSplitter;
QLabel* m_privateBrowsing;
AdBlockIcon* m_adblockIcon; AdBlockIcon* m_adblockIcon;
QPointer<WebInspectorDockWidget> m_webInspectorDock; QPointer<WebInspectorDockWidget> m_webInspectorDock;

View File

@ -729,6 +729,19 @@ bool ComboTabBar::isMainBarOverflowed() const
return m_mainBarOverFlowed; return m_mainBarOverFlowed;
} }
int ComboTabBar::cornerWidth(Qt::Corner corner) const
{
if (corner == Qt::TopLeftCorner) {
return m_leftContainer->width();
}
else if (corner == Qt::TopRightCorner) {
return m_rightContainer->width();
}
qFatal("ComboTabBar::cornerWidth Only TopLeft and TopRight corners are implemented!");
return -1;
}
void ComboTabBar::addCornerWidget(QWidget* widget, Qt::Corner corner) void ComboTabBar::addCornerWidget(QWidget* widget, Qt::Corner corner)
{ {
if (corner == Qt::TopLeftCorner) { if (corner == Qt::TopLeftCorner) {
@ -738,7 +751,7 @@ void ComboTabBar::addCornerWidget(QWidget* widget, Qt::Corner corner)
m_rightLayout->addWidget(widget); m_rightLayout->addWidget(widget);
} }
else { else {
qWarning() << "ComboTabBar::addCornerWidget Only TopLeft and TopRight corners are implemented!"; qFatal("ComboTabBar::addCornerWidget Only TopLeft and TopRight corners are implemented!");
} }
} }
@ -835,7 +848,8 @@ void ComboTabBar::setMinimumWidths()
comboTabBarPixelMetric(ExtraReservedWidth); comboTabBarPixelMetric(ExtraReservedWidth);
// This is the full width that would be needed for the tabbar (including pinned tabbar) // This is the full width that would be needed for the tabbar (including pinned tabbar)
int realTabBarWidth = mainTabBarWidth + m_pinnedTabBarWidget->width(); int realTabBarWidth = mainTabBarWidth + m_pinnedTabBarWidget->width() +
cornerWidth(Qt::TopLeftCorner);
// Does it fit in our widget? // Does it fit in our widget?
if (realTabBarWidth <= width()) { if (realTabBarWidth <= width()) {

View File

@ -37,12 +37,9 @@ class ToolButton;
class QUPZILLA_EXPORT ComboTabBar : public QWidget class QUPZILLA_EXPORT ComboTabBar : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
Q_PROPERTY(int count READ count) Q_PROPERTY(int count READ count)
friend class TabBarHelper;
public: public:
enum SizeType { enum SizeType {
PinnedTabWidth, PinnedTabWidth,
@ -132,6 +129,9 @@ public:
bool isDragInProgress() const; bool isDragInProgress() const;
bool isMainBarOverflowed() const; bool isMainBarOverflowed() const;
// Width of all widgets in the corner
int cornerWidth(Qt::Corner corner) const;
// Add widget to the left/right corner
void addCornerWidget(QWidget* widget, Qt::Corner corner); void addCornerWidget(QWidget* widget, Qt::Corner corner);
public slots: public slots:
@ -195,6 +195,8 @@ private:
bool m_lastAppliedOverflow; bool m_lastAppliedOverflow;
bool m_usesScrollButtons; bool m_usesScrollButtons;
bool m_bluredBackground; bool m_bluredBackground;
friend class TabBarHelper;
}; };
class QUPZILLA_EXPORT TabBarHelper : public QTabBar class QUPZILLA_EXPORT TabBarHelper : public QTabBar

View File

@ -36,6 +36,7 @@
#include <QApplication> #include <QApplication>
#include <QTimer> #include <QTimer>
#include <QRect> #include <QRect>
#include <QLabel>
#include <QScrollArea> #include <QScrollArea>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QToolTip> #include <QToolTip>
@ -81,6 +82,15 @@ TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget)
setCloseButtonsToolTip(BrowserWindow::tr("Close Tab")); setCloseButtonsToolTip(BrowserWindow::tr("Close Tab"));
connect(this, SIGNAL(scrollBarValueChanged(int)), this, SLOT(hideTabPreview())); connect(this, SIGNAL(scrollBarValueChanged(int)), this, SLOT(hideTabPreview()));
connect(this, SIGNAL(overFlowChanged(bool)), this, SLOT(overflowChanged(bool))); connect(this, SIGNAL(overFlowChanged(bool)), this, SLOT(overflowChanged(bool)));
if (mApp->isPrivate()) {
QLabel* privateBrowsing = new QLabel(this);
privateBrowsing->setObjectName(QSL("private-browsing-icon"));
privateBrowsing->setPixmap(IconProvider::privateBrowsingIcon().pixmap(16, 16));
privateBrowsing->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
privateBrowsing->setFixedWidth(30);
addCornerWidget(privateBrowsing, Qt::TopLeftCorner);
}
} }
void TabBar::loadSettings() void TabBar::loadSettings()
@ -290,13 +300,12 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
if (index == count() - 1) { if (index == count() - 1) {
WebTab* lastMainActiveTab = qobject_cast<WebTab*>(m_tabWidget->widget(mainTabBarCurrentIndex())); WebTab* lastMainActiveTab = qobject_cast<WebTab*>(m_tabWidget->widget(mainTabBarCurrentIndex()));
int xForAddTabButton = pinTabBarWidth() + normalTabsCount() * m_normalTabWidth; int xForAddTabButton = cornerWidth(Qt::TopLeftCorner) + pinTabBarWidth() + normalTabsCount() * m_normalTabWidth;
if (lastMainActiveTab && m_activeTabWidth > m_normalTabWidth) { if (lastMainActiveTab && m_activeTabWidth > m_normalTabWidth) {
xForAddTabButton += m_activeTabWidth - m_normalTabWidth; xForAddTabButton += m_activeTabWidth - m_normalTabWidth;
} }
// RTL Support
if (QApplication::layoutDirection() == Qt::RightToLeft) { if (QApplication::layoutDirection() == Qt::RightToLeft) {
xForAddTabButton = width() - xForAddTabButton; xForAddTabButton = width() - xForAddTabButton;
} }