1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Remove support for transparent background

This commit is contained in:
David Rosca 2015-08-31 21:40:08 +02:00
parent dad94c64a1
commit 86a4f3d724
5 changed files with 46 additions and 276 deletions

View File

@ -114,7 +114,6 @@ BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, const QUrl &startUrl)
, m_startTab(0) , m_startTab(0)
, m_sideBarManager(new SideBarManager(this)) , m_sideBarManager(new SideBarManager(this))
, m_statusBarMessage(new StatusBarMessage(this)) , m_statusBarMessage(new StatusBarMessage(this))
, m_useTransparentBackground(false)
, m_hideNavigationTimer(0) , m_hideNavigationTimer(0)
{ {
setObjectName("mainwindow"); setObjectName("mainwindow");
@ -452,7 +451,6 @@ void BrowserWindow::loadSettings()
bool showBookmarksToolbar = settings.value("showBookmarksToolbar", true).toBool(); bool showBookmarksToolbar = settings.value("showBookmarksToolbar", true).toBool();
bool showNavigationToolbar = settings.value("showNavigationToolbar", true).toBool(); bool showNavigationToolbar = settings.value("showNavigationToolbar", true).toBool();
bool showMenuBar = settings.value("showMenubar", true).toBool(); bool showMenuBar = settings.value("showMenubar", true).toBool();
bool makeTransparent = settings.value("useTransparentBackground", false).toBool();
m_sideBarWidth = settings.value("SideBarWidth", 250).toInt(); m_sideBarWidth = settings.value("SideBarWidth", 250).toInt();
m_webViewWidth = settings.value("WebViewWidth", 2000).toInt(); m_webViewWidth = settings.value("WebViewWidth", 2000).toInt();
const QString activeSideBar = settings.value("SideBar", "None").toString(); const QString activeSideBar = settings.value("SideBar", "None").toString();
@ -500,53 +498,6 @@ void BrowserWindow::loadSettings()
m_navigationToolbar->buttonAddTab()->setVisible(showAddTabButton); m_navigationToolbar->buttonAddTab()->setVisible(showAddTabButton);
m_sideBarManager->showSideBar(activeSideBar, false); m_sideBarManager->showSideBar(activeSideBar, false);
#ifdef Q_OS_WIN
if (m_useTransparentBackground && !makeTransparent) {
QtWin::extendFrameIntoClientArea(this, 0, 0, 0, 0);
QtWin::enableBlurBehindWindow(this, false);
m_tabWidget->tabBar()->enableBluredBackground(false);
m_useTransparentBackground = false;
}
#endif
if (!makeTransparent) {
return;
}
// Transparency on X11 (no blur like on Windows)
#ifdef QZ_WS_X11
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_NoSystemBackground, false);
QPalette pal = palette();
QColor bg = pal.window().color();
bg.setAlpha(180);
pal.setColor(QPalette::Window, bg);
setPalette(pal);
ensurePolished(); // workaround Oxygen filling the background
setAttribute(Qt::WA_StyledBackground, false);
#endif
#ifdef Q_OS_WIN
if (QtWin::isCompositionEnabled()) {
setContentsMargins(0, 0, 0, 0);
m_useTransparentBackground = true;
if (!isFullScreen()) {
m_tabWidget->tabBar()->enableBluredBackground(true);
QtWin::extendFrameIntoClientArea(this);
}
// Install event filters
menuBar()->installEventFilter(this);
m_tabWidget->tabBar()->installEventFilter(this);
m_navigationToolbar->installEventFilter(this);
m_bookmarksToolbar->installEventFilter(this);
statusBar()->installEventFilter(this);
m_navigationContainer->installEventFilter(this);
}
#endif
} }
void BrowserWindow::goForward() void BrowserWindow::goForward()
@ -639,11 +590,6 @@ Qz::BrowserWindowType BrowserWindow::windowType() const
return m_windowType; return m_windowType;
} }
bool BrowserWindow::isTransparentBackgroundAllowed() const
{
return m_useTransparentBackground && !isFullScreen();
}
QAction* BrowserWindow::action(const QString &name) const QAction* BrowserWindow::action(const QString &name) const
{ {
return m_mainMenu->action(name); return m_mainMenu->action(name);
@ -758,13 +704,6 @@ SideBar* BrowserWindow::addSideBar()
m_mainSplitter->setSizes(QList<int>() << m_sideBarWidth << m_webViewWidth); m_mainSplitter->setSizes(QList<int>() << m_sideBarWidth << m_webViewWidth);
#ifdef Q_OS_WIN
if (QtWin::isCompositionEnabled()) {
applyBlurToMainWindow();
m_sideBar.data()->installEventFilter(this);
}
#endif
return m_sideBar.data(); return m_sideBar.data();
} }
@ -844,13 +783,6 @@ void BrowserWindow::toggleTabsOnTop(bool enable)
{ {
qzSettings->tabsOnTop = enable; qzSettings->tabsOnTop = enable;
m_navigationContainer->toggleTabsOnTop(enable); m_navigationContainer->toggleTabsOnTop(enable);
#ifdef Q_OS_WIN
// workaround for changing TabsOnTop state when sidebar is visible
// TODO: we need a solution that changing TabsOnTop state
// doesn't call applyBlurToMainWindow() from eventFilter()
QTimer::singleShot(0, this, SLOT(applyBlurToMainWindow()));
#endif
} }
void BrowserWindow::toggleCaretBrowsing() void BrowserWindow::toggleCaretBrowsing()
@ -1062,13 +994,6 @@ void BrowserWindow::searchOnPage()
} }
toolBar->focusSearchLine(); toolBar->focusSearchLine();
#ifdef Q_OS_WIN
if (QtWin::isCompositionEnabled()) {
applyBlurToMainWindow();
toolBar->installEventFilter(this);
}
#endif
} }
void BrowserWindow::openFile() void BrowserWindow::openFile()
@ -1146,13 +1071,6 @@ bool BrowserWindow::event(QEvent* event)
m_navigationContainer->hide(); m_navigationContainer->hide();
m_navigationToolbar->setSuperMenuVisible(false); m_navigationToolbar->setSuperMenuVisible(false);
m_navigationToolbar->buttonExitFullscreen()->setVisible(true); m_navigationToolbar->buttonExitFullscreen()->setVisible(true);
#ifdef Q_OS_WIN
if (m_useTransparentBackground) {
m_tabWidget->tabBar()->enableBluredBackground(false);
QtWin::extendFrameIntoClientArea(this, 0, 0, 0 , 0);
QtWin::enableBlurBehindWindow(this, false);
}
#endif
} }
else if (ev->oldState() & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) { else if (ev->oldState() & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) {
// Leave fullscreen // Leave fullscreen
@ -1166,12 +1084,6 @@ bool BrowserWindow::event(QEvent* event)
m_navigationContainer->show(); m_navigationContainer->show();
m_navigationToolbar->setSuperMenuVisible(!m_menuBarVisible); m_navigationToolbar->setSuperMenuVisible(!m_menuBarVisible);
m_navigationToolbar->buttonExitFullscreen()->setVisible(false); m_navigationToolbar->buttonExitFullscreen()->setVisible(false);
#ifdef Q_OS_WIN
if (m_useTransparentBackground) {
m_tabWidget->tabBar()->enableBluredBackground(true);
applyBlurToMainWindow(true);
}
#endif
} }
if (m_hideNavigationTimer) { if (m_hideNavigationTimer) {
@ -1621,123 +1533,3 @@ void BrowserWindow::moveToVirtualDesktop(int desktopId)
32, PropModeReplace, (unsigned char*) &desktopId, 1L); 32, PropModeReplace, (unsigned char*) &desktopId, 1L);
} }
#endif #endif
#ifdef Q_OS_WIN
void BrowserWindow::applyBlurToMainWindow(bool force)
{
if (mApp->isClosing() || (!force && !isTransparentBackgroundAllowed())) {
return;
}
int topMargin = 0;
int bottomMargin = 1;
int rightMargin = 1;
int leftMargin = 1;
if (m_sideBar) {
if (isRightToLeft()) {
rightMargin += m_sideBar.data()->width() + m_mainSplitter->handleWidth();
}
else {
leftMargin += m_sideBar.data()->width() + m_mainSplitter->handleWidth();
}
}
topMargin += menuBar()->isVisible() ? menuBar()->height() : 0;
topMargin += m_navigationToolbar->isVisible() ? m_navigationToolbar->height() : 0;
topMargin += m_bookmarksToolbar->isVisible() ? m_bookmarksToolbar->height() : 0;
topMargin += m_tabWidget->tabBar()->height();
SearchToolBar* search = searchToolBar();
if (search) {
bottomMargin += search->height();
}
bottomMargin += statusBar()->isVisible() ? statusBar()->height() : 0;
QtWin::extendFrameIntoClientArea(this, leftMargin, topMargin, rightMargin, bottomMargin);
}
bool BrowserWindow::nativeEvent(const QByteArray &eventType, void* _message, long* result)
{
Q_UNUSED(eventType)
MSG* message = static_cast<MSG*>(_message);
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
Settings settings;
settings.beginGroup("Browser-View-Settings");
m_useTransparentBackground = settings.value("useTransparentBackground", false).toBool();
settings.endGroup();
if (m_useTransparentBackground && QtWin::isCompositionEnabled()) {
setUpdatesEnabled(false);
QtWin::extendFrameIntoClientArea(this, 0, 0, 0, 0);
QTimer::singleShot(0, this, SLOT(applyBlurToMainWindow()));
//install event filter
menuBar()->installEventFilter(this);
m_navigationToolbar->installEventFilter(this);
m_bookmarksToolbar->installEventFilter(this);
statusBar()->installEventFilter(this);
if (m_sideBar) {
m_sideBar.data()->installEventFilter(this);
}
SearchToolBar* search = searchToolBar();
if (search) {
search->installEventFilter(this);
}
if (isVisible()) {
hide();
show();
}
setUpdatesEnabled(true);
}
else {
m_useTransparentBackground = false;
}
}
return QMainWindow::nativeEvent(eventType, _message, result);
}
void BrowserWindow::paintEvent(QPaintEvent* event)
{
if (isTransparentBackgroundAllowed()) {
QPainter p(this);
p.setCompositionMode(QPainter::CompositionMode_Clear);
p.fillRect(event->rect(), QColor(0, 0, 0, 0));
}
QMainWindow::paintEvent(event);
}
bool BrowserWindow::eventFilter(QObject* object, QEvent* event)
{
switch (event->type()) {
case QEvent::Hide:
if (object == m_navigationContainer) {
m_navigationToolbar->removeEventFilter(this);
m_bookmarksToolbar->removeEventFilter(this);
break;
}
case QEvent::Show:
if (object == m_navigationContainer) {
m_navigationToolbar->installEventFilter(this);
m_bookmarksToolbar->installEventFilter(this);
break;
}
case QEvent::Resize:
case QEvent::DeferredDelete:
if (object == m_navigationContainer) {
break;
}
applyBlurToMainWindow();
break;
default:
break;
}
return QMainWindow::eventFilter(object, event);
}
#endif

View File

@ -104,8 +104,6 @@ public:
QUrl homepageUrl() const; QUrl homepageUrl() const;
bool isTransparentBackgroundAllowed() const;
QAction* action(const QString &name) const; QAction* action(const QString &name) const;
signals: signals:
@ -206,8 +204,6 @@ private:
int m_sideBarWidth; int m_sideBarWidth;
int m_webViewWidth; int m_webViewWidth;
bool m_useTransparentBackground;
// Shortcuts // Shortcuts
bool m_useTabNumberShortcuts; bool m_useTabNumberShortcuts;
bool m_useSpeedDialNumberShortcuts; bool m_useSpeedDialNumberShortcuts;
@ -226,18 +222,6 @@ private:
int getCurrentVirtualDesktop() const; int getCurrentVirtualDesktop() const;
void moveToVirtualDesktop(int desktopId); void moveToVirtualDesktop(int desktopId);
#endif #endif
#ifdef Q_OS_WIN
private slots:
void applyBlurToMainWindow(bool force = false);
private:
bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
void paintEvent(QPaintEvent* event);
bool eventFilter(QObject* object, QEvent* event);
#endif
}; };
#endif // QUPZILLA_H #endif // QUPZILLA_H

View File

@ -224,12 +224,8 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
ui->showAddTabButton->setChecked(settings.value("showAddTabButton", false).toBool()); ui->showAddTabButton->setChecked(settings.value("showAddTabButton", false).toBool());
ui->showReloadStopButtons->setChecked(settings.value("showReloadButton", true).toBool()); ui->showReloadStopButtons->setChecked(settings.value("showReloadButton", true).toBool());
ui->showWebSearchBar->setChecked(settings.value("showWebSearchBar", true).toBool()); ui->showWebSearchBar->setChecked(settings.value("showWebSearchBar", true).toBool());
ui->useTransparentBg->setChecked(settings.value("useTransparentBackground", false).toBool());
int currentSettingsPage = settings.value("settingsDialogPage", 0).toInt(0); int currentSettingsPage = settings.value("settingsDialogPage", 0).toInt(0);
settings.endGroup(); settings.endGroup();
#ifdef Q_OS_WIN
ui->useTransparentBg->setEnabled(QtWin::isCompositionEnabled());
#endif
//TABS //TABS
settings.beginGroup("Browser-Tabs-Settings"); settings.beginGroup("Browser-Tabs-Settings");
@ -928,7 +924,6 @@ void Preferences::saveSettings()
settings.setValue("showHomeButton", ui->showHome->isChecked()); settings.setValue("showHomeButton", ui->showHome->isChecked());
settings.setValue("showBackForwardButtons", ui->showBackForward->isChecked()); settings.setValue("showBackForwardButtons", ui->showBackForward->isChecked());
settings.setValue("showWebSearchBar", ui->showWebSearchBar->isChecked()); settings.setValue("showWebSearchBar", ui->showWebSearchBar->isChecked());
settings.setValue("useTransparentBackground", ui->useTransparentBg->isChecked());
settings.setValue("showAddTabButton", ui->showAddTabButton->isChecked()); settings.setValue("showAddTabButton", ui->showAddTabButton->isChecked());
settings.setValue("showReloadButton", ui->showReloadStopButtons->isChecked()); settings.setValue("showReloadButton", ui->showReloadStopButtons->isChecked());
settings.endGroup(); settings.endGroup();

View File

@ -140,12 +140,21 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>608</width> <width>602</width>
<height>485</height> <height>466</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -161,7 +170,16 @@
<item row="4" column="2"> <item row="4" column="2">
<widget class="QFrame" name="newTabFrame"> <widget class="QFrame" name="newTabFrame">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -492,7 +510,16 @@
<string>Themes</string> <string>Themes</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_22"> <layout class="QGridLayout" name="gridLayout_22">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
@ -587,14 +614,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="9" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&lt;b&gt;Background&lt;b/&gt;</string>
</property>
</widget>
</item>
<item row="11" column="1">
<spacer name="verticalSpacer_12"> <spacer name="verticalSpacer_12">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -607,10 +627,10 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="10" column="1"> <item row="6" column="1">
<widget class="QCheckBox" name="useTransparentBg"> <widget class="QCheckBox" name="showAddTabButton">
<property name="text"> <property name="text">
<string>Use transparent background</string> <string>Show Add Tab button</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -621,13 +641,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1">
<widget class="QCheckBox" name="showAddTabButton">
<property name="text">
<string>Show Add Tab button</string>
</property>
</widget>
</item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QCheckBox" name="showReloadStopButtons"> <widget class="QCheckBox" name="showReloadStopButtons">
<property name="text"> <property name="text">
@ -2572,7 +2585,16 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QHBoxLayout" name="pluginsFrame"> <layout class="QHBoxLayout" name="pluginsFrame">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
</layout> </layout>
@ -2862,7 +2884,6 @@
<tabstop>systemProxy</tabstop> <tabstop>systemProxy</tabstop>
<tabstop>noProxy</tabstop> <tabstop>noProxy</tabstop>
<tabstop>showStatusbar</tabstop> <tabstop>showStatusbar</tabstop>
<tabstop>useTransparentBg</tabstop>
<tabstop>showNavigationToolbar</tabstop> <tabstop>showNavigationToolbar</tabstop>
<tabstop>pagesInCache</tabstop> <tabstop>pagesInCache</tabstop>
<tabstop>showHome</tabstop> <tabstop>showHome</tabstop>

View File

@ -323,11 +323,6 @@ int TabWidget::addView(const LoadRequest &req, const Qz::NewTabPositionFlags &op
int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position, bool pinned) int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position, bool pinned)
{ {
#ifdef Q_OS_WIN
if (m_window->isTransparentBackgroundAllowed()) {
QtWin::extendFrameIntoClientArea(m_window);
}
#endif
QUrl url = req.url(); QUrl url = req.url();
m_lastTabIndex = currentIndex(); m_lastTabIndex = currentIndex();
@ -387,29 +382,12 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N
m_window->locationBar()->setFocus(); m_window->locationBar()->setFocus();
} }
#if QTWEBENGINE_DISABLED
if (openFlags & Qz::NT_NotSelectedTab) {
WebTab* currentWebTab = weTab();
// Workarounding invalid QWebEnginePage::viewportSize() until QWebEngineView is shown
// Fixes invalid scrolling to anchor(#) links
if (currentWebTab && currentWebTab->webView()) {
TabbedWebView* currentView = currentWebTab->webView();
webTab->webView()->resize(currentView->size());
webTab->webView()->page()->setViewportSize(currentView->page()->viewportSize());
}
}
#endif
// Make sure user notice opening new background tabs // Make sure user notice opening new background tabs
if (!(openFlags & Qz::NT_SelectedTab)) { if (!(openFlags & Qz::NT_SelectedTab)) {
m_tabBar->ensureVisible(index); m_tabBar->ensureVisible(index);
} }
emit changed(); emit changed();
#ifdef Q_OS_WIN
QTimer::singleShot(0, m_window, SLOT(applyBlurToMainWindow()));
#endif
return index; return index;
} }