Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
朱子楚\zhuzi committed Apr 13, 2024
1 parent 9296b18 commit e8c47e0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/qml/page/T_Theme.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FluScrollablePage{

FluFrame{
Layout.fillWidth: true
Layout.preferredHeight: 400
Layout.preferredHeight: 420
padding: 10

ColumnLayout{
Expand Down
19 changes: 12 additions & 7 deletions src/FluTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QGuiApplication>
#include <QPalette>
#include <QImage>
#include <QThreadPool>
#include "Def.h"
#include "FluentIconDef.h"
#include "FluColors.h"
Expand Down Expand Up @@ -91,14 +92,18 @@ bool FluTheme::dark() const {
}

void FluTheme::updateDesktopImage(){
auto path = FluTools::getInstance()->getWallpaperFilePath();
if(_desktopImagePath != path){
if(!_desktopImagePath.isEmpty()){
_watcher.removePath(_desktopImagePath);
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)
Expand Down
2 changes: 2 additions & 0 deletions src/FluTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QColor>
#include <QTimer>
#include <QFileSystemWatcher>
#include <QMutex>
#include "FluAccentColor.h"
#include "stdafx.h"
#include "singleton.h"
Expand Down Expand Up @@ -70,6 +71,7 @@ SINGLETON(FluTheme)
private:
bool _systemDark;
QFileSystemWatcher _watcher;
QMutex _mutex;
};

#endif // FLUTHEME_H
12 changes: 12 additions & 0 deletions src/FluTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8c47e0

Please sign in to comment.