OSDN Git Service

kvkbd: background blur fix
authorIvailo Monev <xakepa10@gmail.com>
Sun, 18 Jul 2021 18:22:38 +0000 (21:22 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 18 Jul 2021 18:24:50 +0000 (21:24 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
12 files changed:
kvkbd/colors/dark.css
kvkbd/colors/legacy.css
kvkbd/colors/light.css
kvkbd/colors/simple.css
kvkbd/src/dragwidget.cpp
kvkbd/src/dragwidget.h
kvkbd/src/kvkbdapp.cpp
kvkbd/src/kvkbdapp.h
kvkbd/src/resizabledragwidget.h
kvkbd/src/standart.css
kvkbd/src/themeloader.cpp
kvkbd/src/themeloader.h

index 68fa674..257bc77 100644 (file)
@@ -4,7 +4,6 @@ QWidget[name="main"] {
 }
 
 VButton {
-
     margin:1px;
     padding:0px;
     border-style: outset;
@@ -21,7 +20,6 @@ VButton {
 }
 
 VButton:pressed {
-    
     border-style: inset;
 }
 VButton:checked {
@@ -36,10 +34,10 @@ VButton:hover {
 }
 
 VButton[action="toggleExtension"] {
-  background-color:gray;
-  border-color: gray;
+    background-color:gray;
+    border-color: gray;
 }
 VButton[action="toggleVisibility"] {
-  background-color:red;
-  border-color:red;
+    background-color:red;
+    border-color:red;
 }
\ No newline at end of file
index ec6e5c5..b9f1e59 100644 (file)
@@ -1,13 +1,13 @@
 QWidget[name="main"] {
-    background-color:black;
+    background-color:rgba(0,0,0,30%);
     border-radius: 5px 5px 5px 5px;
 }
 
 VButton[action="toggleExtension"] {
-  background-color:gray;
-  border-color: gray;
+    background-color:gray;
+    border-color: gray;
 }
 VButton[action="toggleVisibility"] {
-  background-color:red;
-  border-color:red;
+    background-color:red;
+    border-color:red;
 }
\ No newline at end of file
index 348024e..3f81be2 100644 (file)
@@ -4,7 +4,6 @@ QWidget[name="main"] {
 }
 
 VButton {
-
     margin:1px;
     padding:0px;
     border-style: outset;
@@ -21,11 +20,9 @@ VButton {
 }
 
 VButton:pressed {
-    
     border-style: inset;
 }
 VButton:checked {
-    
     border-style: inset;
     border-width:2px;
 }
@@ -34,10 +31,10 @@ VButton:hover {
     border-color: #555555;
 }
 VButton[action="toggleExtension"] {
-  background-color:gray;
-  border-color: gray;
+    background-color:gray;
+    border-color: gray;
 }
 VButton[action="toggleVisibility"] {
-  background-color:red;
-  border-color:red;
+    background-color:red;
+    border-color:red;
 }
index a3b0efb..8a05c2a 100644 (file)
@@ -1,10 +1,8 @@
 QWidget[name="main"] {
-    background-color:rgba(255,255,255,12%);
-    
+    background-color:rgba(255,255,255,30%);
 }
 
 VButton {
-
     margin:2px;
     padding:0px;
     border-style: outset;
@@ -21,12 +19,10 @@ VButton {
 }
 
 VButton:pressed {
-    
     border-style: inset;
-  border-color: #333333;
+    border-color: #333333;
 }
 VButton:checked {
-    
 /*     border-style: inset; */
     border-width:2px;
     border-color: #333333;
@@ -37,10 +33,10 @@ VButton:hover {
   
 }
 VButton[action="toggleExtension"] {
-  background-color:gray;
-  border-color: gray;
+    background-color:gray;
+    border-color: gray;
 }
 VButton[action="toggleVisibility"] {
-  background-color:red;
-  border-color:red;
+    background-color:red;
+    border-color:red;
 }
index c1f067c..9458dab 100644 (file)
@@ -16,46 +16,32 @@ using namespace std;
 
 
 DragWidget::DragWidget(QWidget *parent) :
-    QWidget(parent),  dragged(false), moved(false), locked(false)
+    QWidget(parent), dragged(false), moved(false), locked(false)
 {
     setAttribute(Qt::WA_TranslucentBackground);
 }
 
 DragWidget::~DragWidget()
 {
-
 }
 
 void DragWidget::blurBackground(bool blurEnabled)
 {
-  this->setProperty("blurBackground", QVariant(blurEnabled));
-  
-  Display *dpy = QX11Info::display();
-  Atom net_wm_blur_region = XInternAtom(dpy, "_KDE_NET_WM_BLUR_BEHIND_REGION", False);
-  
-  if (blurEnabled) {
-
-      XChangeProperty(dpy, this->winId(), net_wm_blur_region, XA_CARDINAL, 32, PropModeReplace, 0, 0);
-
-  }
-  else {
-      XDeleteProperty(dpy, this->winId(), net_wm_blur_region);
-
-  }
-  repaint();
+    setProperty("blurBackground", QVariant(blurEnabled));
+    repaint();
 }
+
 void DragWidget::setLocked(bool locked)
 {
-  this->locked = locked;
+    this->locked = locked;
 }
 bool DragWidget::isLocked()
 {
-  return locked;
+    return locked;
 }
 
 void DragWidget::mousePressEvent(QMouseEvent *e)
 {
-
     if (locked) {
         return;
     }
@@ -63,18 +49,15 @@ void DragWidget::mousePressEvent(QMouseEvent *e)
     gpress = e->globalPos();
     dragged = true;
     dragPoint = e->pos();
-
-
-
 }
 
 void DragWidget::mouseMoveEvent(QMouseEvent *ev)
 {
+    if (!dragged) {
+        return;
+    }
     
-
-    if (!dragged) return;
-    
-    moved=true;
+    moved = true;
     
     QPoint curr(ev->globalPos().x() - dragPoint.x(), ev->globalPos().y() - dragPoint.y());
     move(curr);
@@ -83,7 +66,6 @@ void DragWidget::mouseMoveEvent(QMouseEvent *ev)
 
 void DragWidget::mouseReleaseEvent(QMouseEvent *)
 {
-   
     dragged = false;
     moved = false;
 }
@@ -101,12 +83,11 @@ void DragWidget::toggleVisibility()
     if (isMinimized()) {
         showNormal();
         show();
-       raise();
-    }
-    else {
+        raise();
+    } else {
         showMinimized();
         hide();
-       lower();
+        lower();
     }
 
 }
index 3fe24a5..479c522 100644 (file)
@@ -26,7 +26,6 @@ protected:
 
     virtual void paintEvent(QPaintEvent *e);
 
-
     QPoint dragPoint;
     QPoint gpress;
     
index 4e856dc..854d98e 100644 (file)
@@ -114,7 +114,7 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
     autoResizeAction->setChecked(autoResizeEnabled);
     widget->setProperty("autoresfont", autoResizeEnabled);
     cmenu->addAction(autoResizeAction);
-    connect(autoResizeAction,SIGNAL(triggered(bool)), this, SLOT(autoResizeFont(bool)));
+    connect(autoResizeAction, SIGNAL(triggered(bool)), this, SLOT(autoResizeFont(bool)));
 
 
     bool blur = cfg.readEntry("blurBackground", QVariant(true)).toBool();
@@ -123,9 +123,9 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
     blurBackgroundAction->setChecked(blur);
     cmenu->addAction(blurBackgroundAction);
     widget->blurBackground(blur);
-    connect(blurBackgroundAction,SIGNAL(triggered(bool)), widget, SLOT(blurBackground(bool)));
+    connect(blurBackgroundAction, SIGNAL(triggered(bool)), widget, SLOT(blurBackground(bool)));
     dock->blurBackground(blur);
-    connect(blurBackgroundAction,SIGNAL(triggered(bool)), dock, SLOT(blurBackground(bool)));
+    connect(blurBackgroundAction, SIGNAL(triggered(bool)), dock, SLOT(blurBackground(bool)));
     widget->blurBackground(blur);
     dock->blurBackground(blur);
 
@@ -133,19 +133,19 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
     KToggleAction *showDockAction = new KToggleAction(i18nc("@action:inmenu", "Show Dock"), this);
     showDockAction->setChecked(dockVisible);
     cmenu->addAction(showDockAction);
-    connect(showDockAction,SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
+    connect(showDockAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
 
     bool isLocked = cfg.readEntry("locked", QVariant(false)).toBool();
     KToggleAction *lockOnScreenAction = new KToggleAction(i18nc("@action:inmenu", "Lock on Screen"), this);
     lockOnScreenAction->setChecked(isLocked);
     cmenu->addAction(lockOnScreenAction);
-    connect(lockOnScreenAction,SIGNAL(triggered(bool)), widget, SLOT(setLocked(bool)));
+    connect(lockOnScreenAction, SIGNAL(triggered(bool)), widget, SLOT(setLocked(bool)));
 
     bool stickyModKeys = cfg.readEntry("stickyModKeys", QVariant(false)).toBool();
     KToggleAction *stickyModKeysAction = new KToggleAction(i18nc("@action:inmenu", "Sticky Modifier Keys"), this);
     stickyModKeysAction->setChecked(stickyModKeys);
     cmenu->addAction(stickyModKeysAction);
-    connect(stickyModKeysAction,SIGNAL(triggered(bool)), this, SLOT(setStickyModKeys(bool)));
+    connect(stickyModKeysAction, SIGNAL(triggered(bool)), this, SLOT(setStickyModKeys(bool)));
     widget->setProperty("stickyModKeys", stickyModKeys);
 
     QFont font = cfg.readEntry("font", widget->font());
@@ -157,6 +157,7 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
     cmenu->addMenu(colors);
     connect(themeLoader, SIGNAL(colorStyleChanged()), widget, SLOT(repaint()));
     connect(themeLoader, SIGNAL(colorStyleChanged()), dock, SLOT(repaint()));
+    connect(blurBackgroundAction, SIGNAL(triggered(bool)), themeLoader, SLOT(reloadColorStyle()));
 
     KHelpMenu *helpMenu = new KHelpMenu(widget, KCmdLineArgs::aboutData());
     cmenu->addMenu((QMenu*)helpMenu->menu());
@@ -165,7 +166,6 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
     themeLoader->loadTheme(themeName);
     widget->setProperty("layout", themeName);
 
-
     QSize defaultSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
     QDesktopWidget *pDesktop = QApplication::desktop();
 
@@ -306,8 +306,7 @@ void KvkbdApp::buttonLoaded(VButton *btn)
 {
     if (btn->property("modifier").toBool() == true) {
         modKeys.append(btn);
-    }
-    else {
+    } else {
         QObject::connect(btn, SIGNAL(keyClick(unsigned int)), xkbd, SLOT(processKeyPress(unsigned int)) );
     }
     QString bAction = btn->property("action").toString();
index 8fba54a..a792fa7 100644 (file)
@@ -43,8 +43,6 @@ public:
     KvkbdApp(bool loginhelper=false);
     ~KvkbdApp();
 
-    
-
 public slots:
     void keyProcessComplete(unsigned int);
     
@@ -55,12 +53,9 @@ public slots:
     void chooseFont();
     void autoResizeFont(bool mode);
     void setStickyModKeys(bool mode);
-   
     
     void partLoaded(MainWidget *vPart, int total_rows, int total_cols);
     void buttonLoaded(VButton *btn);
-
-    
     
 protected:
 
index 3dc818e..492f92d 100644 (file)
@@ -11,9 +11,6 @@ public:
     explicit ResizableDragWidget(QWidget *parent = 0);
     ~ResizableDragWidget();
 
-
-
-
 protected:
     virtual void mouseMoveEvent(QMouseEvent * e);
     virtual void mousePressEvent(QMouseEvent * e);
index 752e4d0..5df6d61 100644 (file)
@@ -1,10 +1,8 @@
 QWidget[name="main"] {
-    background-color:rgba(0,0,0,20%);
-
+    background-color:rgba(0,0,0,30%);
 }
 
 VButton {
-
     margin:1px;
     padding:0px;
     border-style: outset;
@@ -13,15 +11,12 @@ VButton {
     
     font-size:13px;
     font-weight:bold;
-    
 }
 
 VButton:pressed {
-    
     border-style: inset;
 }
 VButton:checked {
-    
     border-style: inset;
     border-width:2px;
 }
@@ -32,7 +27,6 @@ VButton:hover {
 VButton[colorGroup="normal"] {
     border-color: #97c5d5;
     background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1, stop: 0 #97c5d5, stop: 1 #c7f5f5);
-
 }
 VButton[colorGroup="system"] {
     border-color: #e8a8a5;
@@ -63,14 +57,14 @@ VButton[colorGroup="numeric"] {
     background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1, stop: 0 #9faaca, stop: 1 #9faaca);
 }
 VButton[action="toggleExtension"] {
-  background-color:gray;
-  border-color: gray;
+    background-color:gray;
+    border-color: gray;
 }
 VButton[action="toggleVisibility"] {
-  background-color:red;
-  border-color:red;
+    background-color:red;
+    border-color:red;
 }
 VButton[colorGroup="nextLayout"] {
-  background-color:none;
-  border:none;
+    background-color:none;
+    border:none;
 }
index 98e37c0..171b019 100644 (file)
@@ -65,8 +65,7 @@ void ThemeLoader::loadTheme(QString& themeName)
             if (QString::compare(themeName, "standart")==0) {
                 loading = false;
                 kapp->quit();
-            }
-            else {
+            } else {
                 themeName="standart";
             }
         }
@@ -74,36 +73,45 @@ void ThemeLoader::loadTheme(QString& themeName)
 }
 void ThemeLoader::loadColorFile(const QString& fileName)
 {
+    lastcolorstyle = fileName;
+
     QFile themeFile;
 
     themeFile.setFileName(fileName);
 
     if (!themeFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
-
         QMessageBox::information(0, "Error", QString("Unable to open css file: %1").arg(themeFile.fileName()));
         return;
     }
 
-    ((QWidget*)parent())->setStyleSheet(themeFile.readAll());
+    QString themeData = themeFile.readAll();
+    if (!(QWidget*)parent()->property("blurBackground").toBool()) {
+        themeData = themeData.replace(",30%);", ");");
+    }
+
+    ((QWidget*)parent())->setStyleSheet(themeData);
     ((QWidget*)parent())->setProperty("colors", fileName);
     themeFile.close();
     
     ((QWidget*)parent())->repaint();
     
     emit colorStyleChanged();
-    
-    
 }
+
 void ThemeLoader::loadColorStyle()
 {
-
     QAction *action = (QAction*)QObject::sender();
    
     QFileInfo info(action->data().toString());
     
-    this->loadColorFile(info.absoluteFilePath());
+    loadColorFile(info.absoluteFilePath());
+}
 
+void ThemeLoader::reloadColorStyle()
+{
+    loadColorFile(lastcolorstyle);
 }
+
 void ThemeLoader::findColorStyles(QMenu *colors, const QString& configSelectedStyle)
 {
     KStandardDirs kdirs;
@@ -119,10 +127,6 @@ void ThemeLoader::findColorStyles(QMenu *colors, const QString& configSelectedSt
     item->setData(":/theme/standart.css");
     colors->addAction(item);
     color_group->addAction(item);
-    
-    
-
-
 
     colors->setTitle("Color Style");
     colors->setIcon(KIcon("preferences-desktop-color"));
@@ -158,21 +162,20 @@ void ThemeLoader::findColorStyles(QMenu *colors, const QString& configSelectedSt
     }
 
     QString selectedStyle = configSelectedStyle;
-    if (selectedStyle.length()<1) {
-       selectedStyle = DEFAULT_CSS;
+    if (selectedStyle.length() < 1) {
+        selectedStyle = DEFAULT_CSS;
     }
     QAction *selectedAction = 0;
     
     QListIterator<QAction*> itrActions(color_group->actions());
     while (itrActions.hasNext()) {
         QAction *item = itrActions.next();
-       
-       if (item->data().toString() == selectedStyle) {
-           item->setChecked(true);
-           selectedAction = item;
-       }
-      
-       
+
+        if (item->data().toString() == selectedStyle) {
+            item->setChecked(true);
+            selectedAction = item;
+        }
+
         connect(item, SIGNAL(triggered(bool)), this, SLOT(loadColorStyle()));
     }
     
@@ -191,8 +194,6 @@ int ThemeLoader::loadLayout(const QString& themeName, const QString& path)
 
     QFile themeFile;
 
-
-
     QDomDocument doc;
 
     themeFile.setFileName(QString(path + "%1.xml").arg(themeName));
@@ -236,7 +237,6 @@ int ThemeLoader::loadLayout(const QString& themeName, const QString& path)
         //cout  << "heights[" << qPrintable(hintName) << "]=>"<< height << endl;
     }
 
-
     wList = docElem.elementsByTagName("spacingHints");
     wNode = wList.at(0);
     nList = (wNode.toElement()).elementsByTagName("item");
@@ -248,7 +248,6 @@ int ThemeLoader::loadLayout(const QString& themeName, const QString& path)
         //cout  << "spacing[" << qPrintable(hintName) << "]=>"<< width << endl;
     }
 
-
     wList = docElem.elementsByTagName("part");
     wNode = wList.at(0);
 
@@ -274,8 +273,6 @@ int ThemeLoader::loadLayout(const QString& themeName, const QString& path)
         }
     }
 
-
-
     return 0;
 }
 bool ThemeLoader::applyProperty(VButton *btn, const QString& attributeName, QDomNamedNodeMap *attributes, QVariant defaultValue)
@@ -286,8 +283,7 @@ bool ThemeLoader::applyProperty(VButton *btn, const QString& attributeName, QDom
     if (attributeValue.length()>0) {
         btn->setProperty(qPrintable(attributeName), attributeValue);
         ret = true;
-    }
-    else {
+    } else {
         if (defaultValue.toString().length()>0) {
             btn->setProperty(qPrintable(attributeName), defaultValue);
             ret = true;
@@ -332,7 +328,6 @@ void ThemeLoader::loadKeys(MainWidget *vPart, const QDomNode& wNode)
             rowHeight = heightMap.value(rowHeightHint);
         }
 
-
         for (int b=0; b<key_list.count(); b++) {
             QDomNode node = key_list.at(b);
             QDomNamedNodeMap attributes = node.attributes();
@@ -367,7 +362,6 @@ void ThemeLoader::loadKeys(MainWidget *vPart, const QDomNode& wNode)
                     btn->setText(btn->property("label").toString());
                 }
 
-
                 applyProperty(btn, "group_label", &attributes);
 
                 applyProperty(btn, "group_toggle", &attributes);
@@ -376,7 +370,7 @@ void ThemeLoader::loadKeys(MainWidget *vPart, const QDomNode& wNode)
 
                 applyProperty(btn, "colorGroup", &attributes, "normal");
 
-               applyProperty(btn, "tooltip", &attributes);
+                applyProperty(btn, "tooltip", &attributes);
 
                 QString modifier = attributes.namedItem("modifier").toAttr().value();
                 if (modifier.toInt()>0) {
@@ -411,8 +405,7 @@ void ThemeLoader::loadKeys(MainWidget *vPart, const QDomNode& wNode)
                 sx+=buttonWidth+rowSpacingX;
 
                 emit buttonLoaded(btn);
-            }
-            else if (node.toElement().tagName()=="spacing") {
+            } else if (node.toElement().tagName()=="spacing") {
 
                 QString widthHint = attributes.namedItem("width").toAttr().value();
                 QString heightHint = attributes.namedItem("height").toAttr().value();
@@ -451,9 +444,6 @@ void ThemeLoader::loadKeys(MainWidget *vPart, const QDomNode& wNode)
     vPart->setBaseSize(max_sx, max_sy);
 
     emit partLoaded(vPart, total_rows, total_cols);
-    
-
-
 }
 
 #include "moc_themeloader.cpp"
index 982269d..aedd3d0 100644 (file)
@@ -41,7 +41,6 @@ public:
 
     void loadTheme(QString& themeName);
     
-    
     void loadColorFile(const QString& fileName);
     
     int loadLayout(const QString& themeName, const QString& path);
@@ -58,12 +57,15 @@ protected:
     
 public slots:
     void loadColorStyle();
+    void reloadColorStyle();
     
 signals:
-
     void partLoaded(MainWidget *vPart, int total_rows, int total_cols);
     void buttonLoaded(VButton *btn);
     void colorStyleChanged();
+
+private:
+    QString lastcolorstyle;
 };
 
 #endif // THEMELOADER_H