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{
Layout.fillWidth: true
Layout.preferredHeight: 400
Layout.preferredHeight: 408
padding: 10
ColumnLayout{

View File

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

View File

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

View File

@ -281,6 +281,18 @@ QString FluTools::getWallpaperFilePath() {
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
return {};
#endif

View File

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

View File

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