mirror of https://github.com/cutefishos/fishui
feat: msvc build compat
parent
44c845f05a
commit
525ade39fa
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: cutefish <cutefishos@foxmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "windowblur.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainterPath>
|
||||
#include <QScreen>
|
||||
#include <QDebug>
|
||||
|
||||
WindowBlur::WindowBlur(QObject *parent) noexcept
|
||||
: QObject(parent)
|
||||
, m_view(nullptr)
|
||||
, m_enabled(false)
|
||||
, m_windowRadius(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
WindowBlur::~WindowBlur()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowBlur::classBegin()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowBlur::componentComplete()
|
||||
{
|
||||
updateBlur();
|
||||
}
|
||||
|
||||
void WindowBlur::setView(QWindow *view)
|
||||
{
|
||||
if (view != m_view) {
|
||||
m_view = view;
|
||||
updateBlur();
|
||||
emit viewChanged();
|
||||
|
||||
connect(m_view, &QWindow::visibleChanged, this, &WindowBlur::onViewVisibleChanged);
|
||||
}
|
||||
}
|
||||
|
||||
QWindow* WindowBlur::view() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
||||
void WindowBlur::setGeometry(const QRect &rect)
|
||||
{
|
||||
if (rect != m_rect) {
|
||||
m_rect = rect;
|
||||
updateBlur();
|
||||
emit geometryChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QRect WindowBlur::geometry() const
|
||||
{
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
void WindowBlur::setEnabled(bool enabled)
|
||||
{
|
||||
if (enabled != m_enabled) {
|
||||
m_enabled = enabled;
|
||||
updateBlur();
|
||||
emit enabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool WindowBlur::enabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
void WindowBlur::setWindowRadius(qreal radius)
|
||||
{
|
||||
if (radius != m_windowRadius) {
|
||||
m_windowRadius = radius;
|
||||
updateBlur();
|
||||
emit windowRadiusChanged();
|
||||
}
|
||||
}
|
||||
|
||||
qreal WindowBlur::windowRadius() const
|
||||
{
|
||||
return m_windowRadius;
|
||||
}
|
||||
|
||||
void WindowBlur::onViewVisibleChanged(bool visible)
|
||||
{
|
||||
if (visible)
|
||||
updateBlur();
|
||||
}
|
||||
|
||||
void WindowBlur::updateBlur()
|
||||
{
|
||||
if (!m_view)
|
||||
return;
|
||||
|
||||
qWarning() << "not implement";
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: cutefish <cutefishos@foxmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WINDOWBLUR_H
|
||||
#define WINDOWBLUR_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QObject>
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlParserStatus>
|
||||
#include <QRect>
|
||||
#include <QWindow>
|
||||
#include <QVector>
|
||||
|
||||
class WindowBlur : public QObject, public QQmlParserStatus
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QWindow *view READ view WRITE setView NOTIFY viewChanged)
|
||||
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
|
||||
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
|
||||
Q_PROPERTY(qreal windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged)
|
||||
Q_INTERFACES(QQmlParserStatus)
|
||||
|
||||
public:
|
||||
WindowBlur(QObject *parent = nullptr) noexcept;
|
||||
~WindowBlur() override;
|
||||
|
||||
void classBegin() override;
|
||||
void componentComplete() override;
|
||||
|
||||
void setView(QWindow *view);
|
||||
QWindow *view() const;
|
||||
|
||||
void setGeometry(const QRect &rect);
|
||||
QRect geometry() const;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
bool enabled() const;
|
||||
|
||||
void setWindowRadius(qreal radius);
|
||||
qreal windowRadius() const;
|
||||
|
||||
private slots:
|
||||
void onViewVisibleChanged(bool);
|
||||
|
||||
private:
|
||||
void updateBlur();
|
||||
|
||||
signals:
|
||||
void viewChanged();
|
||||
void enabledChanged();
|
||||
void windowRadiusChanged();
|
||||
void geometryChanged();
|
||||
|
||||
private:
|
||||
QWindow *m_view;
|
||||
QRect m_rect;
|
||||
bool m_enabled;
|
||||
qreal m_windowRadius;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: cutefish <cutefishos@foxmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "windowhelper.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QDebug>
|
||||
|
||||
#include <KWindowSystem>
|
||||
|
||||
WindowHelper::WindowHelper(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void WindowHelper::startSystemMove(QWindow *w)
|
||||
{
|
||||
doStartSystemMoveResize(w, 16);
|
||||
}
|
||||
|
||||
void WindowHelper::startSystemResize(QWindow *w, Qt::Edges edges)
|
||||
{
|
||||
doStartSystemMoveResize(w, edges);
|
||||
}
|
||||
|
||||
void WindowHelper::minimizeWindow(QWindow *w)
|
||||
{
|
||||
KWindowSystem::minimizeWindow(w->winId());
|
||||
}
|
||||
|
||||
void WindowHelper::doStartSystemMoveResize(QWindow *w, int edges)
|
||||
{
|
||||
qWarning() << "not implement";
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2021 CutefishOS Team.
|
||||
*
|
||||
* Author: cutefish <cutefishos@foxmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WINDOWHELPER_H
|
||||
#define WINDOWHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWindow>
|
||||
|
||||
class WindowHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WindowHelper(QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE void startSystemMove(QWindow *w);
|
||||
Q_INVOKABLE void startSystemResize(QWindow *w, Qt::Edges edges);
|
||||
|
||||
Q_INVOKABLE void minimizeWindow(QWindow *w);
|
||||
|
||||
private:
|
||||
void doStartSystemMoveResize(QWindow *w, int edges);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // WINDOWHELPER_H
|
||||
Loading…
Reference in New Issue