File indexing completed on 2025-02-23 04:26:50
0001 /* 0002 * Copyright (C) 2021 CutefishOS Team. 0003 * 0004 * Author: cutefish <cutefishos@foxmail.com> 0005 * 0006 * This program is free software: you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation, either version 3 of the License, or 0009 * any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #pragma once 0021 0022 #include <QApplication> 0023 #include <QObject> 0024 #include <QQmlEngine> 0025 #include <QQmlParserStatus> 0026 #include <QRect> 0027 #include <QWindow> 0028 #include <QVector> 0029 0030 class WindowBlur : public QObject, public QQmlParserStatus 0031 { 0032 Q_OBJECT 0033 QML_ELEMENT 0034 Q_INTERFACES(QQmlParserStatus) 0035 0036 Q_PROPERTY(QWindow *view READ view WRITE setView NOTIFY viewChanged) 0037 Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) 0038 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) 0039 Q_PROPERTY(qreal windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged) 0040 0041 public: 0042 WindowBlur(QObject *parent = nullptr) noexcept; 0043 ~WindowBlur() override; 0044 0045 void classBegin() override; 0046 void componentComplete() override; 0047 0048 void setView(QWindow *view); 0049 QWindow *view() const; 0050 0051 void setGeometry(const QRect &rect); 0052 QRect geometry() const; 0053 0054 void setEnabled(bool enabled); 0055 bool enabled() const; 0056 0057 void setWindowRadius(qreal radius); 0058 qreal windowRadius() const; 0059 0060 private Q_SLOTS: 0061 void onViewVisibleChanged(bool); 0062 0063 private: 0064 void updateBlur(); 0065 0066 Q_SIGNALS: 0067 void viewChanged(); 0068 void enabledChanged(); 0069 void windowRadiusChanged(); 0070 void geometryChanged(); 0071 0072 private: 0073 QWindow *m_view; 0074 QRect m_rect; 0075 bool m_enabled; 0076 qreal m_windowRadius; 0077 };