Skip to content

Commit

Permalink
Merge pull request #165 from taj-ny/kcm-static-blur-image-picker
Browse files Browse the repository at this point in the history
kcm: add button for choosing static blur image
  • Loading branch information
taj-ny authored Jan 12, 2025
2 parents 913cfdd + 7f0e131 commit 4bfabf8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/kcm/blur_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <KPluginFactory>
#include "kwineffects_interface.h"

#include <QFileDialog>
#include <QPushButton>

namespace KWin
{

Expand All @@ -25,6 +28,8 @@ BlurEffectConfig::BlurEffectConfig(QObject *parent, const KPluginMetaData &data)
BlurConfig::instance("kwinrc");
addConfig(BlurConfig::self(), widget());

connect(ui.staticBlurImagePicker, &QPushButton::clicked, this, &BlurEffectConfig::slotStaticBlurImagePickerClicked);

QFile about(":/effects/forceblur/kcm/about.html");
if (about.open(QIODevice::ReadOnly)) {
const auto html = about.readAll()
Expand All @@ -38,6 +43,16 @@ BlurEffectConfig::~BlurEffectConfig()
{
}

void BlurEffectConfig::slotStaticBlurImagePickerClicked()
{
const auto imagePath = QFileDialog::getOpenFileName(widget(), "Select image", {}, "Images (*.png *.jpg *.jpeg *.bmp)");
if (imagePath.isNull()) {
return;
}

ui.kcfg_FakeBlurImage->setText(imagePath);
}

void BlurEffectConfig::save()
{
KCModule::save();
Expand Down
3 changes: 3 additions & 0 deletions src/kcm/blur_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class BlurEffectConfig : public KCModule

void save() override;

private slots:
void slotStaticBlurImagePickerClicked();

private:
::Ui::BlurEffectConfig ui;
};
Expand Down
7 changes: 7 additions & 0 deletions src/kcm/blur_config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,13 @@ the background, resulting in much lower GPU usage.</string>
<widget class="QLineEdit" name="kcfg_FakeBlurImage">
</widget>
</item>
<item>
<widget class="QPushButton" name="staticBlurImagePicker">
<property name="icon">
<iconset theme="document-open"/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down

0 comments on commit 4bfabf8

Please sign in to comment.