Compare commits

...

2 Commits

Author SHA1 Message Date
朱子楚\zhuzi
2c4cf82f63 update 2024-04-13 22:00:15 +08:00
朱子楚\zhuzi
e8c47e0fd8 update 2024-04-13 21:30:23 +08:00
6 changed files with 38 additions and 13 deletions

View File

@ -13,7 +13,7 @@ FluScrollablePage{
FluFrame{ FluFrame{
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 400 Layout.preferredHeight: 408
padding: 10 padding: 10
ColumnLayout{ ColumnLayout{

View File

@ -3,6 +3,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QPalette> #include <QPalette>
#include <QImage> #include <QImage>
#include <QThreadPool>
#include "Def.h" #include "Def.h"
#include "FluentIconDef.h" #include "FluentIconDef.h"
#include "FluColors.h" #include "FluColors.h"
@ -24,7 +25,7 @@ FluTheme::FluTheme(QObject *parent) : QObject{parent} {
_blurBehindWindowEnabled = false; _blurBehindWindowEnabled = false;
QGuiApplication::instance()->installEventFilter(this); QGuiApplication::instance()->installEventFilter(this);
refreshColors(); refreshColors();
updateDesktopImage(); checkUpdateDesktopImage();
connect(this, &FluTheme::darkModeChanged, this, [=] { connect(this, &FluTheme::darkModeChanged, this, [=] {
Q_EMIT darkChanged(); Q_EMIT darkChanged();
}); });
@ -48,7 +49,7 @@ void FluTheme::refreshColors() {
fontTertiaryColor(isDark ? QColor(200, 200, 200, 255) : QColor(153, 153, 153, 255)); fontTertiaryColor(isDark ? QColor(200, 200, 200, 255) : QColor(153, 153, 153, 255));
itemNormalColor(isDark ? QColor(255, 255, 255, 0) : QColor(0, 0, 0, 0)); itemNormalColor(isDark ? QColor(255, 255, 255, 0) : QColor(0, 0, 0, 0));
frameColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.12)) : QColor(0, 0, 0, qRound(255 * 0.09))); frameColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.12)) : QColor(0, 0, 0, qRound(255 * 0.09)));
frameActiveColor(isDark ? QColor(32, 32, 32, qRound(255 * 0.8)) : QColor(255, 255, 255, qRound(255 * 0.6))); frameActiveColor(isDark ? QColor(48, 48, 48, qRound(255 * 0.8)) : QColor(255, 255, 255, qRound(255 * 0.6)));
itemHoverColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.06)) : QColor(0, 0, 0, qRound(255 * 0.03))); itemHoverColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.06)) : QColor(0, 0, 0, qRound(255 * 0.03)));
itemPressColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.09)) : QColor(0, 0, 0, qRound(255 * 0.06))); itemPressColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.09)) : QColor(0, 0, 0, qRound(255 * 0.06)));
itemCheckColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.12)) : QColor(0, 0, 0, qRound(255 * 0.09))); itemCheckColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.12)) : QColor(0, 0, 0, qRound(255 * 0.09)));
@ -90,18 +91,24 @@ bool FluTheme::dark() const {
} }
} }
void FluTheme::updateDesktopImage(){ void FluTheme::checkUpdateDesktopImage(){
auto path = FluTools::getInstance()->getWallpaperFilePath(); QThreadPool::globalInstance()->start([=]() {
if(_desktopImagePath != path){ _mutex.lock();
if(!_desktopImagePath.isEmpty()){ auto path = FluTools::getInstance()->getWallpaperFilePath();
_watcher.removePath(_desktopImagePath); if(_desktopImagePath != path){
if(!_desktopImagePath.isEmpty()){
_watcher.removePath(_desktopImagePath);
}
desktopImagePath(path);
_watcher.addPath(path);
} }
desktopImagePath(path); _mutex.unlock();
_watcher.addPath(path); });
}
} }
void FluTheme::timerEvent(QTimerEvent *event) void FluTheme::timerEvent(QTimerEvent *event)
{ {
updateDesktopImage(); if(_blurBehindWindowEnabled){
checkUpdateDesktopImage();
}
} }

View File

@ -8,6 +8,7 @@
#include <QColor> #include <QColor>
#include <QTimer> #include <QTimer>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QMutex>
#include "FluAccentColor.h" #include "FluAccentColor.h"
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h" #include "singleton.h"
@ -54,7 +55,7 @@ protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
void updateDesktopImage(); void checkUpdateDesktopImage();
public: public:
SINGLETON(FluTheme) SINGLETON(FluTheme)
@ -70,6 +71,7 @@ SINGLETON(FluTheme)
private: private:
bool _systemDark; bool _systemDark;
QFileSystemWatcher _watcher; QFileSystemWatcher _watcher;
QMutex _mutex;
}; };
#endif // FLUTHEME_H #endif // FLUTHEME_H

View File

@ -281,6 +281,18 @@ QString FluTools::getWallpaperFilePath() {
return path; return path;
} }
} }
#elif defined(Q_OS_MACOS)
QProcess process;
QStringList args;
args << "-e";
args << R"(tell application "Finder" to get POSIX path of (desktop picture as alias))";
process.start("osascript", args);
process.waitForFinished();
QByteArray result = process.readAllStandardOutput().trimmed();
if(result.isEmpty()){
return "/System/Library/CoreServices/DefaultDesktop.heic";
}
return result;
#else #else
return {}; return {};
#endif #endif

View File

@ -118,6 +118,8 @@ Window {
id:img_back id:img_back
visible: false visible: false
cache: false cache: false
fillMode: Image.PreserveAspectCrop
asynchronous: true
Component.onCompleted: { Component.onCompleted: {
var geometry = FluTools.desktopAvailableGeometry(window) var geometry = FluTools.desktopAvailableGeometry(window)
width = geometry.width width = geometry.width

View File

@ -117,6 +117,8 @@ Window {
id:img_back id:img_back
visible: false visible: false
cache: false cache: false
fillMode: Image.PreserveAspectCrop
asynchronous: true
Component.onCompleted: { Component.onCompleted: {
var geometry = FluTools.desktopAvailableGeometry(window) var geometry = FluTools.desktopAvailableGeometry(window)
width = geometry.width width = geometry.width