diff --git a/src/ColorScheme.h b/src/ColorScheme.h --- a/src/ColorScheme.h +++ b/src/ColorScheme.h @@ -153,6 +153,17 @@ */ qreal opacity() const; + /** + * Enables blur behind the transparent window + * + * Defaults to false. + */ + void setBlur(bool blur); + /** + * Returns whether blur is enabled for this color scheme, see setBlur() + */ + bool blur() const; + void setWallpaper(const QString &path); ColorSchemeWallpaper::Ptr wallpaper() const; @@ -222,6 +233,9 @@ qreal _opacity; + // enables blur behind the terimnal window + bool _blur; + ColorSchemeWallpaper::Ptr _wallpaper; static const quint16 MAX_HUE = 340; diff --git a/src/ColorScheme.cpp b/src/ColorScheme.cpp --- a/src/ColorScheme.cpp +++ b/src/ColorScheme.cpp @@ -164,6 +164,7 @@ _table(nullptr), _randomTable(nullptr), _opacity(1.0), + _blur(false), _wallpaper(nullptr) { setWallpaper(QString()); @@ -175,6 +176,7 @@ _table(nullptr), _randomTable(nullptr), _opacity(other._opacity), + _blur(other._blur), _wallpaper(other._wallpaper) { setName(other.name()); @@ -358,14 +360,25 @@ return _opacity; } +void ColorScheme::setBlur(bool blur) +{ + _blur = blur; +} + +bool ColorScheme::blur() const +{ + return _blur; +} + void ColorScheme::read(const KConfig &config) { KConfigGroup configGroup = config.group("General"); const QString schemeDescription = configGroup.readEntry("Description", i18nc("@item", "Un-named Color Scheme")); _description = i18n(schemeDescription.toUtf8().constData()); _opacity = configGroup.readEntry("Opacity", 1.0); + _blur = configGroup.readEntry("Blur", false); setWallpaper(configGroup.readEntry("Wallpaper", QString())); for (int i = 0; i < TABLE_COLORS; i++) { @@ -402,6 +415,7 @@ configGroup.writeEntry("Description", _description); configGroup.writeEntry("Opacity", _opacity); + configGroup.writeEntry("Blur", _blur); configGroup.writeEntry("Wallpaper", _wallpaper->path()); for (int i = 0; i < TABLE_COLORS; i++) { diff --git a/src/ColorSchemeEditor.h b/src/ColorSchemeEditor.h --- a/src/ColorSchemeEditor.h +++ b/src/ColorSchemeEditor.h @@ -77,6 +77,7 @@ private Q_SLOTS: void setTransparencyPercentLabel(int percent); + void setBlur(bool blur); void setRandomizedBackgroundColor(bool randomized); void editColorItem(QTableWidgetItem *item); void wallpaperPathChanged(const QString &path); diff --git a/src/ColorSchemeEditor.cpp b/src/ColorSchemeEditor.cpp --- a/src/ColorSchemeEditor.cpp +++ b/src/ColorSchemeEditor.cpp @@ -93,6 +93,10 @@ connect(_ui->transparencySlider, &QSlider::valueChanged, this, &Konsole::ColorSchemeEditor::setTransparencyPercentLabel); + // blur behind window + connect(_ui->blurCheckBox, &QCheckBox::toggled, this, + &Konsole::ColorSchemeEditor::setBlur); + // randomized background connect(_ui->randomizedBackgroundCheck, &QCheckBox::toggled, this, &Konsole::ColorSchemeEditor::setRandomizedBackgroundColor); @@ -248,6 +252,11 @@ _colors->setOpacity(opacity); } +void ColorSchemeEditor::setBlur(bool blur) +{ + _colors->setBlur(blur); +} + void ColorSchemeEditor::setRandomizedBackgroundColor(bool randomized) { _colors->setRandomizedBackgroundColor(randomized); @@ -279,6 +288,9 @@ _ui->transparencySlider->setValue(transparencyPercent); setTransparencyPercentLabel(transparencyPercent); + // blur behind window checkbox + _ui->blurCheckBox->setChecked(scheme->blur()); + // randomized background color checkbox _ui->randomizedBackgroundCheck->setChecked(scheme->randomizedBackgroundColor()); diff --git a/src/ColorSchemeEditor.ui b/src/ColorSchemeEditor.ui --- a/src/ColorSchemeEditor.ui +++ b/src/ColorSchemeEditor.ui @@ -41,6 +41,13 @@ + + + + Blur background + + + diff --git a/src/MainWindow.h b/src/MainWindow.h --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -158,6 +158,7 @@ void profileListChanged(const QList &sessionActions); void configureNotifications(); + void setBlur(bool blur); void updateWindowIcon(); void updateWindowCaption(); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -98,6 +99,8 @@ &Konsole::MainWindow::disconnectController); connect(_viewManager, &Konsole::ViewManager::viewPropertiesChanged, bookmarkHandler(), &Konsole::BookmarkHandler::setViews); + connect(_viewManager, &Konsole::ViewManager::blurSettingChanged, + this, &Konsole::MainWindow::setBlur); connect(_viewManager, &Konsole::ViewManager::updateWindowIcon, this, &Konsole::MainWindow::updateWindowIcon); @@ -240,6 +243,8 @@ Q_ASSERT(controller); _pluggedController = controller; + setBlur(ViewManager::profileHasBlurEnabled(SessionManager::instance()->sessionProfile(_pluggedController->session()))); + // listen for title changes from the current session connect(controller, &Konsole::SessionController::titleChanged, this, &Konsole::MainWindow::activeViewTitleChanged); @@ -876,6 +881,17 @@ KNotifyConfigWidget::configure(this); } +void MainWindow::setBlur(bool blur) +{ + if (_pluggedController == nullptr) { + return; + } + + if (!_pluggedController->isKonsolePart()) { + KWindowEffects::enableBlurBehind(winId(), blur); + } +} + void MainWindow::setMenuBarInitialVisibility(bool visible) { _menuBarInitialVisibility = visible; diff --git a/src/SessionController.h b/src/SessionController.h --- a/src/SessionController.h +++ b/src/SessionController.h @@ -173,6 +173,9 @@ return _allControllers; } + /* Returns true if called within a KPart; false if called within Konsole. */ + bool isKonsolePart() const; + Q_SIGNALS: /** * Emitted when the view associated with the controller is focused. @@ -309,9 +312,6 @@ void setFindNextPrevEnabled(bool enabled); void listenForScreenWindowUpdates(); - /* Returns true if called within a KPart; false if called within Konsole. */ - bool isKonsolePart() const; - private: void updateSessionIcon(); diff --git a/src/ViewManager.h b/src/ViewManager.h --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -179,6 +179,11 @@ return _sessionMap.values(); } + /** + * Returns whether the @p profile has the blur setting enabled + */ + static bool profileHasBlurEnabled(const Profile::Ptr profile); + Q_SIGNALS: /** Emitted when the last view is removed from the view manager */ void empty(); @@ -222,6 +227,8 @@ void setMenuBarVisibleRequest(bool); void updateWindowIcon(); + void blurSettingChanged(bool); + /** Requests creation of a new view with the default profile. */ void newViewRequest(); /** Requests creation of a new view, with the selected profile. */ diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -860,6 +860,11 @@ return colorScheme; } +bool ViewManager::profileHasBlurEnabled(const Profile::Ptr profile) +{ + return colorSchemeForProfile(profile)->blur(); +} + void ViewManager::applyProfileToView(TerminalDisplay *view, const Profile::Ptr profile) { Q_ASSERT(profile); @@ -874,6 +879,8 @@ view->setOpacity(colorScheme->opacity()); view->setWallpaper(colorScheme->wallpaper()); + emit blurSettingChanged(colorScheme->blur()); + // load font view->setAntialias(profile->antiAliasFonts()); view->setBoldIntense(profile->boldIntense());