1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-22 02:02:10 +02: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_sideBarManager(new SideBarManager(this))
, m_statusBarMessage(new StatusBarMessage(this))
, m_useTransparentBackground(false)
, m_hideNavigationTimer(0)
{
setObjectName("mainwindow");
@ -452,7 +451,6 @@ void BrowserWindow::loadSettings()
bool showBookmarksToolbar = settings.value("showBookmarksToolbar", true).toBool();
bool showNavigationToolbar = settings.value("showNavigationToolbar", true).toBool();
bool showMenuBar = settings.value("showMenubar", true).toBool();
bool makeTransparent = settings.value("useTransparentBackground", false).toBool();
m_sideBarWidth = settings.value("SideBarWidth", 250).toInt();
m_webViewWidth = settings.value("WebViewWidth", 2000).toInt();
const QString activeSideBar = settings.value("SideBar", "None").toString();
@ -500,53 +498,6 @@ void BrowserWindow::loadSettings()
m_navigationToolbar->buttonAddTab()->setVisible(showAddTabButton);
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()
@ -639,11 +590,6 @@ Qz::BrowserWindowType BrowserWindow::windowType() const
return m_windowType;
}
bool BrowserWindow::isTransparentBackgroundAllowed() const
{
return m_useTransparentBackground && !isFullScreen();
}
QAction* BrowserWindow::action(const QString &name) const
{
return m_mainMenu->action(name);
@ -758,13 +704,6 @@ SideBar* BrowserWindow::addSideBar()
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();
}
@ -844,13 +783,6 @@ void BrowserWindow::toggleTabsOnTop(bool enable)
{
qzSettings->tabsOnTop = 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()
@ -1062,13 +994,6 @@ void BrowserWindow::searchOnPage()
}
toolBar->focusSearchLine();
#ifdef Q_OS_WIN
if (QtWin::isCompositionEnabled()) {
applyBlurToMainWindow();
toolBar->installEventFilter(this);
}
#endif
}
void BrowserWindow::openFile()
@ -1146,13 +1071,6 @@ bool BrowserWindow::event(QEvent* event)
m_navigationContainer->hide();
m_navigationToolbar->setSuperMenuVisible(false);
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)) {
// Leave fullscreen
@ -1166,12 +1084,6 @@ bool BrowserWindow::event(QEvent* event)
m_navigationContainer->show();
m_navigationToolbar->setSuperMenuVisible(!m_menuBarVisible);
m_navigationToolbar->buttonExitFullscreen()->setVisible(false);
#ifdef Q_OS_WIN
if (m_useTransparentBackground) {
m_tabWidget->tabBar()->enableBluredBackground(true);
applyBlurToMainWindow(true);
}
#endif
}
if (m_hideNavigationTimer) {
@ -1621,123 +1533,3 @@ void BrowserWindow::moveToVirtualDesktop(int desktopId)
32, PropModeReplace, (unsigned char*) &desktopId, 1L);
}
#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;
bool isTransparentBackgroundAllowed() const;
QAction* action(const QString &name) const;
signals:
@ -206,8 +204,6 @@ private:
int m_sideBarWidth;
int m_webViewWidth;
bool m_useTransparentBackground;
// Shortcuts
bool m_useTabNumberShortcuts;
bool m_useSpeedDialNumberShortcuts;
@ -226,18 +222,6 @@ private:
int getCurrentVirtualDesktop() const;
void moveToVirtualDesktop(int desktopId);
#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

View File

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

View File

@ -140,12 +140,21 @@
<rect>
<x>0</x>
<y>0</y>
<width>608</width>
<height>485</height>
<width>602</width>
<height>466</height>
</rect>
</property>
<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>
</property>
<item>
@ -161,7 +170,16 @@
<item row="4" column="2">
<widget class="QFrame" name="newTabFrame">
<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>
</property>
<item>
@ -492,7 +510,16 @@
<string>Themes</string>
</attribute>
<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>
</property>
<item row="0" column="0">
@ -587,14 +614,7 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<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">
<item row="9" column="1">
<spacer name="verticalSpacer_12">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -607,10 +627,10 @@
</property>
</spacer>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="useTransparentBg">
<item row="6" column="1">
<widget class="QCheckBox" name="showAddTabButton">
<property name="text">
<string>Use transparent background</string>
<string>Show Add Tab button</string>
</property>
</widget>
</item>
@ -621,13 +641,6 @@
</property>
</widget>
</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">
<widget class="QCheckBox" name="showReloadStopButtons">
<property name="text">
@ -2572,7 +2585,16 @@
</sizepolicy>
</property>
<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>
</property>
</layout>
@ -2862,7 +2884,6 @@
<tabstop>systemProxy</tabstop>
<tabstop>noProxy</tabstop>
<tabstop>showStatusbar</tabstop>
<tabstop>useTransparentBg</tabstop>
<tabstop>showNavigationToolbar</tabstop>
<tabstop>pagesInCache</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)
{
#ifdef Q_OS_WIN
if (m_window->isTransparentBackgroundAllowed()) {
QtWin::extendFrameIntoClientArea(m_window);
}
#endif
QUrl url = req.url();
m_lastTabIndex = currentIndex();
@ -387,29 +382,12 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N
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
if (!(openFlags & Qz::NT_SelectedTab)) {
m_tabBar->ensureVisible(index);
}
emit changed();
#ifdef Q_OS_WIN
QTimer::singleShot(0, m_window, SLOT(applyBlurToMainWindow()));
#endif
return index;
}