File indexing completed on 2024-12-22 04:31:05
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 #include "windowblur.h" 0021 0022 #include <QGuiApplication> 0023 #include <QPainterPath> 0024 #include <QScreen> 0025 #include <QDebug> 0026 0027 WindowBlur::WindowBlur(QObject *parent) noexcept 0028 : QObject(parent) 0029 , m_view(nullptr) 0030 , m_enabled(false) 0031 , m_windowRadius(0.0) 0032 { 0033 } 0034 0035 WindowBlur::~WindowBlur() 0036 { 0037 } 0038 0039 void WindowBlur::classBegin() 0040 { 0041 } 0042 0043 void WindowBlur::componentComplete() 0044 { 0045 updateBlur(); 0046 } 0047 0048 void WindowBlur::setView(QWindow *view) 0049 { 0050 if (view != m_view) { 0051 m_view = view; 0052 updateBlur(); 0053 emit viewChanged(); 0054 0055 connect(m_view, &QWindow::visibleChanged, this, &WindowBlur::onViewVisibleChanged); 0056 } 0057 } 0058 0059 QWindow* WindowBlur::view() const 0060 { 0061 return m_view; 0062 } 0063 0064 void WindowBlur::setGeometry(const QRect &rect) 0065 { 0066 if (rect != m_rect) { 0067 m_rect = rect; 0068 updateBlur(); 0069 emit geometryChanged(); 0070 } 0071 } 0072 0073 QRect WindowBlur::geometry() const 0074 { 0075 return m_rect; 0076 } 0077 0078 void WindowBlur::setEnabled(bool enabled) 0079 { 0080 if (enabled != m_enabled) { 0081 m_enabled = enabled; 0082 updateBlur(); 0083 emit enabledChanged(); 0084 } 0085 } 0086 0087 bool WindowBlur::enabled() const 0088 { 0089 return m_enabled; 0090 } 0091 0092 void WindowBlur::setWindowRadius(qreal radius) 0093 { 0094 if (radius != m_windowRadius) { 0095 m_windowRadius = radius; 0096 updateBlur(); 0097 emit windowRadiusChanged(); 0098 } 0099 } 0100 0101 qreal WindowBlur::windowRadius() const 0102 { 0103 return m_windowRadius; 0104 } 0105 0106 void WindowBlur::onViewVisibleChanged(bool visible) 0107 { 0108 if (visible) 0109 updateBlur(); 0110 } 0111 0112 void WindowBlur::updateBlur() 0113 { 0114 if (!m_view) 0115 return; 0116 0117 qWarning() << "not implement"; 0118 }