Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
朱子楚\zhuzi committed Apr 24, 2024
1 parent 83507a6 commit 5fd7c7d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion example/src/component/CircularReveal.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Q_PROPERTY_AUTO(int, radius)

void paint(QPainter *painter) override;

Q_INVOKABLE [[maybe_unused]] void start(int w, int h, const QPoint &center, int radius);
[[maybe_unused]] Q_INVOKABLE void start(int w, int h, const QPoint &center, int radius);

Q_SIGNAL void imageChanged();

Expand Down
2 changes: 1 addition & 1 deletion example/src/helper/InitializrHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SINGLETON(InitializrHelper)

~InitializrHelper() override;

Q_INVOKABLE [[maybe_unused]] void generate(const QString &name, const QString &path);
[[maybe_unused]] Q_INVOKABLE void generate(const QString &name, const QString &path);

Q_SIGNAL void error(const QString &message);

Expand Down
1 change: 0 additions & 1 deletion src/FluAccentColor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "FluAccentColor.h"

FluAccentColor::FluAccentColor(QObject *parent) : QObject{parent} {

}
2 changes: 1 addition & 1 deletion src/FluColors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
_Green = green;
}

[[maybe_unused]] FluAccentColor *FluColors::createAccentColor(const QColor& primaryColor) {
[[maybe_unused]] FluAccentColor *FluColors::createAccentColor(const QColor &primaryColor) {
auto accentColor = new FluAccentColor(this);
accentColor->normal(primaryColor);
accentColor->dark(FluTools::getInstance()->withOpacity(primaryColor, 0.9));
Expand Down
2 changes: 1 addition & 1 deletion src/FluColors.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Q_PROPERTY_AUTO_P(FluAccentColor*, Green);
public:
SINGLETON(FluColors)

[[maybe_unused]] Q_INVOKABLE FluAccentColor *createAccentColor(const QColor& primaryColor);
[[maybe_unused]] Q_INVOKABLE FluAccentColor *createAccentColor(const QColor &primaryColor);

static FluColors *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
};
31 changes: 19 additions & 12 deletions src/FluFrameless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void FluFrameless::componentComplete() {
::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
});
#endif
h = h + _appbar->height();
h = qRound(h + _appbar->height());
if (_fixSize) {
window()->setMaximumSize(QSize(w, h));
window()->setMinimumSize(QSize(w, h));
Expand Down Expand Up @@ -146,7 +146,7 @@ void FluFrameless::componentComplete() {
auto *wp = reinterpret_cast<WINDOWPOS *>(lParam);
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0) {
wp->flags |= SWP_NOCOPYBITS;
*result = ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(::DefWindowProcW(hwnd, uMsg, wParam, lParam));
return true;
}
return false;
Expand All @@ -158,7 +158,7 @@ void FluFrameless::componentComplete() {
const LONG originalBottom = clientRect->bottom;
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = hitTestResult;
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
return true;
}
int offsetSize;
Expand All @@ -175,12 +175,19 @@ void FluFrameless::componentComplete() {
if (!isCompositionEnabled()) {
offsetSize = 0;
}
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom - offsetSize;
clientRect->left = originalLeft + offsetSize;
clientRect->right = originalRight - offsetSize;
#else
if (!isMaximum) {
clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom - offsetSize;
clientRect->left = originalLeft + offsetSize;
clientRect->right = originalRight - offsetSize;
}
#endif
_setMaximizeHovered(false);
*result = WVR_REDRAW;
return true;
Expand Down Expand Up @@ -255,7 +262,7 @@ void FluFrameless::componentComplete() {
*result = FALSE;
return true;
} else if (uMsg == WM_NCACTIVATE) {
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1));
return true;
} else if (uMsg == WM_GETMINMAXINFO) {
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
Expand All @@ -270,9 +277,9 @@ void FluFrameless::componentComplete() {
auto geometry = window()->screen()->availableGeometry();
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
if(!_fixSize){
minmaxInfo->ptMinTrackSize.x = window()->minimumWidth() * pixelRatio + offsetXY.x();
minmaxInfo->ptMinTrackSize.y = window()->minimumHeight() * pixelRatio + offsetXY.y() + _appbar->height() * pixelRatio;
if (!_fixSize) {
minmaxInfo->ptMinTrackSize.x = qRound(window()->minimumWidth() * pixelRatio + offsetXY.x());
minmaxInfo->ptMinTrackSize.y = qRound(window()->minimumHeight() * pixelRatio + offsetXY.y() + _appbar->height() * pixelRatio);
}
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
Expand All @@ -294,11 +301,11 @@ void FluFrameless::componentComplete() {
} else if (uMsg == WM_SYSCOMMAND) {
if (wParam == SC_MINIMIZE) {
if (window()->transientParent()) {
HWND hwnd = reinterpret_cast<HWND>(window()->transientParent()->winId());
::ShowWindow(hwnd, 2);
auto _hwnd = reinterpret_cast<HWND>(window()->transientParent()->winId());
::ShowWindow(_hwnd, 2);
} else {
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
::ShowWindow(hwnd, 2);
auto _hwnd = reinterpret_cast<HWND>(window()->winId());
::ShowWindow(_hwnd, 2);
}
return true;
}
Expand Down
15 changes: 7 additions & 8 deletions src/FluTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ FluTheme::FluTheme(QObject *parent) : QObject{parent} {
});
connect(this, &FluTheme::darkChanged, this, [=] { refreshColors(); });
connect(this, &FluTheme::accentColorChanged, this, [=] { refreshColors(); });
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path){
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path) {
Q_EMIT desktopImagePathChanged();
});
connect(this, &FluTheme::blurBehindWindowEnabledChanged, this, [=] {checkUpdateDesktopImage();});
connect(this, &FluTheme::blurBehindWindowEnabledChanged, this, [=] { checkUpdateDesktopImage(); });
startTimer(1000);
}

Expand Down Expand Up @@ -74,15 +74,15 @@ bool FluTheme::dark() const {
}
}

void FluTheme::checkUpdateDesktopImage(){
if(!_blurBehindWindowEnabled){
void FluTheme::checkUpdateDesktopImage() {
if (!_blurBehindWindowEnabled) {
return;
}
QThreadPool::globalInstance()->start([=]() {
_mutex.lock();
auto path = FluTools::getInstance()->getWallpaperFilePath();
if(_desktopImagePath != path){
if(!_desktopImagePath.isEmpty()){
if (_desktopImagePath != path) {
if (!_desktopImagePath.isEmpty()) {
_watcher.removePath(_desktopImagePath);
}
desktopImagePath(path);
Expand All @@ -92,7 +92,6 @@ void FluTheme::checkUpdateDesktopImage(){
});
}

void FluTheme::timerEvent(QTimerEvent *event)
{
void FluTheme::timerEvent(QTimerEvent *event) {
checkUpdateDesktopImage();
}
11 changes: 3 additions & 8 deletions src/FluTheme.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef FLUTHEME_H
#define FLUTHEME_H
#pragma once

#include <QObject>
#include <QtQml/qqml.h>
Expand All @@ -18,7 +17,7 @@
*/
class FluTheme : public QObject {
Q_OBJECT
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
Q_PROPERTY_AUTO_P(FluAccentColor*, accentColor);
Q_PROPERTY_AUTO(QColor, primaryColor);
Q_PROPERTY_AUTO(QColor, backgroundColor);
Expand Down Expand Up @@ -49,8 +48,6 @@ Q_PROPERTY_AUTO(bool, blurBehindWindowEnabled);

void refreshColors();

void updateBackgroundMainColor();

protected:

void timerEvent(QTimerEvent *event) override;
Expand All @@ -70,6 +67,4 @@ SINGLETON(FluTheme)
bool _systemDark;
QFileSystemWatcher _watcher;
QMutex _mutex;
};

#endif // FLUTHEME_H
};

0 comments on commit 5fd7c7d

Please sign in to comment.