From b936bccd9d0d7f50f37c078b7aad9e75ee9fc981 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 16 Jun 2018 09:46:48 +0200 Subject: Add Plasma option to cmake that turns on KF5 blur window effect --- CMakeLists.txt | 7 +++++++ linux/makepkg/PKGBUILD | 3 +++ src/CMakeLists.txt | 10 +++++++++- src/mainwindow/mainwindow.cpp | 10 ++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb86ce6..a4f64d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,12 +9,19 @@ option(CompilerWarnings "Compiler warnings" ON) option(QtDeprecatedWarnings "Qt deprecated warnings" ON) option(UseLibCpp "Use libc++ over stdlibc++ (requires clang)" OFF) option(Tests "Enable/disable some basic autotests" ON) +option(Plasma "Enable some fancy effects on Plasma" OFF) # Libraries find_package(Qt5 COMPONENTS Core Widgets Concurrent REQUIRED) find_package(Qt5 5.10.1 COMPONENTS WebEngineWidgets REQUIRED) find_package(Boost COMPONENTS program_options REQUIRED) +if(Plasma) + find_package(ECM 1.6.0 REQUIRED NO_MODULE) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) + find_package(KF5 "5.6.0" COMPONENTS WindowSystem REQUIRED) +endif(Plasma) + # Global C++ settings set(CMAKE_CXX_STANDARD 17) diff --git a/linux/makepkg/PKGBUILD b/linux/makepkg/PKGBUILD index b088409..d3010f2 100644 --- a/linux/makepkg/PKGBUILD +++ b/linux/makepkg/PKGBUILD @@ -68,6 +68,9 @@ build() { # Flavour, also requires clang #_cmake_options="$_cmake_options -DUseLibCpp=On" + # Flavour: add some KF5 effects + _cmake_options="$_cmake_options -DPlasma=On" + # Build System # Flavour: I use ninja, but you can comment this out, or set your own # flavour. Don't forget to change the Build and Install though! diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c6876d..cf66a53 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,7 +58,15 @@ target_link_libraries(poi about addressbar configuration - bookmarks downloads web) + bookmarks downloads web +) + +if(Plasma) + target_link_libraries(poi KF5::WindowSystem) + target_compile_definitions(poi + PRIVATE PLASMA_BLUR # give the main window a translucent background and blur + ) +endif(Plasma) target_compile_definitions(poi PRIVATE QTBUG_65223_WORKAROUND diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 6558c65..b2c79cc 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -30,6 +30,10 @@ #include #include "browser.h" +#ifdef PLASMA_BLUR +#include +#endif + MainWindow::MainWindow(std::shared_ptr &config, QWidget *parent) : QMainWindow(parent) , mdiArea(new QMdiArea(this)) @@ -37,6 +41,11 @@ MainWindow::MainWindow(std::shared_ptr &config, QWidget *parent) Q_ASSERT(config); m_config = config; +#ifdef PLASMA_BLUR + setAttribute(Qt::WA_TranslucentBackground, true); + KWindowEffects::enableBlurBehind(this->winId(), true); +#endif + // create UI setWindowTitle(QString::fromStdString(config->value("mainwindow.title").value())); resize(config->value("mainwindow.width").value(), config->value("mainwindow.height").value()); @@ -55,6 +64,7 @@ MainWindow::MainWindow(std::shared_ptr &config, QWidget *parent) addressBar = new AddressBar(config->section("addressbar"), this); navigationToolBar->addWidget(addressBar); + mdiArea->setBackground(Qt::NoBrush); setCentralWidget(mdiArea); mdiArea->setFocus(); -- cgit v1.2.1