File indexing completed on 2024-12-22 04:31:08
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 #ifndef WINDOWBLUR_H 0021 #define WINDOWBLUR_H 0022 0023 #include <QGuiApplication> 0024 #include <QObject> 0025 #include <QQmlEngine> 0026 #include <QQmlParserStatus> 0027 #include <QRect> 0028 #include <QWindow> 0029 #include <QVector> 0030 0031 class WindowBlur : public QObject, public QQmlParserStatus 0032 { 0033 Q_OBJECT 0034 Q_PROPERTY(QWindow *view READ view WRITE setView NOTIFY viewChanged) 0035 Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged) 0036 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) 0037 Q_PROPERTY(qreal windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged) 0038 Q_INTERFACES(QQmlParserStatus) 0039 0040 public: 0041 WindowBlur(QObject *parent = nullptr) noexcept; 0042 ~WindowBlur() override; 0043 0044 void classBegin() override; 0045 void componentComplete() override; 0046 0047 void setView(QWindow *view); 0048 QWindow *view() const; 0049 0050 void setGeometry(const QRect &rect); 0051 QRect geometry() const; 0052 0053 void setEnabled(bool enabled); 0054 bool enabled() const; 0055 0056 void setWindowRadius(qreal radius); 0057 qreal windowRadius() const; 0058 0059 private slots: 0060 void onViewVisibleChanged(bool); 0061 0062 private: 0063 void updateBlur(); 0064 0065 signals: 0066 void viewChanged(); 0067 void enabledChanged(); 0068 void windowRadiusChanged(); 0069 void geometryChanged(); 0070 0071 private: 0072 QWindow *m_view; 0073 QRect m_rect; 0074 bool m_enabled; 0075 qreal m_windowRadius; 0076 }; 0077 0078 #endif