Skip to content

Commit 71d76e2

Browse files
authored
Add files via upload
1 parent 48b60b1 commit 71d76e2

41 files changed

Lines changed: 771 additions & 679 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ default, you must create it manually.
337337
"showOnHover": true
338338
},
339339
"clock": {
340-
"background": false,
341-
"showDate": false,
342340
"showIcon": true
343341
},
344342
"dragThreshold": 20,
@@ -577,7 +575,57 @@ default, you must create it manually.
577575
},
578576
"showOnHover": false,
579577
"favouriteApps": [],
580-
"hiddenApps": []
578+
"hiddenApps": [],
579+
"categories": [
580+
{
581+
"name": "Development",
582+
"icon": "code",
583+
"apps": ["code-oss"]
584+
},
585+
{
586+
"name": "Graphics",
587+
"icon": "palette",
588+
"apps": []
589+
},
590+
{
591+
"name": "Communication",
592+
"icon": "chat",
593+
"apps": ["vesktop", "discord"]
594+
},
595+
{
596+
"name": "Media",
597+
"icon": "play_circle",
598+
"apps": ["spotify", "obs"]
599+
},
600+
{
601+
"name": "Games",
602+
"icon": "sports_esports",
603+
"apps": ["steam"]
604+
},
605+
{
606+
"name": "Utilities",
607+
"icon": "build",
608+
"apps": ["obs"]
609+
}
610+
],
611+
"contextMenuMain": [
612+
{"launch": {"text": "Launch", "icon": "play_arrow", "bold": true}},
613+
{"terminal": {"parent": "launch"}},
614+
"separator",
615+
"favorites",
616+
"categories",
617+
"hide",
618+
"workspaces"
619+
],
620+
"contextMenuAdvanced": [
621+
"open-path",
622+
"desktop-file",
623+
"separator",
624+
{"custom-submenu": {"text": "Advanced Options", "icon": "settings"}},
625+
{"kill": {"parent": "custom-submenu"}},
626+
{"separator": {"parent": "custom-submenu"}},
627+
{"copy-exec": {"parent": "custom-submenu"}}
628+
]
581629
},
582630
"lock": {
583631
"recolourLogo": false,
@@ -600,8 +648,7 @@ default, you must create it manually.
600648
"paths": {
601649
"mediaGif": "root:/assets/bongocat.gif",
602650
"sessionGif": "root:/assets/kurukuru.gif",
603-
"wallpaperDir": "~/Pictures/Wallpapers",
604-
"lyricsDir": "~/Music/lyrics"
651+
"wallpaperDir": "~/Pictures/Wallpapers"
605652
},
606653
"services": {
607654
"audioIncrement": 0.1,

plugin/src/Caelestia/Internal/cachingimagemanager.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,34 @@ void CachingImageManager::updateSource(const QString& path) {
105105

106106
m_shaPath = path;
107107

108-
QtConcurrent::run(&CachingImageManager::sha256sum, path).then(this, [path, this](const QString& sha) {
108+
const auto future = QtConcurrent::run(&CachingImageManager::sha256sum, path);
109+
110+
const auto watcher = new QFutureWatcher<QString>(this);
111+
112+
connect(watcher, &QFutureWatcher<QString>::finished, this, [watcher, path, this]() {
109113
if (m_path != path) {
114+
// Object is destroyed or path has changed, ignore
115+
watcher->deleteLater();
110116
return;
111117
}
112118

113119
const QSize size = effectiveSize();
114120

115121
if (!m_item || !size.width() || !size.height()) {
122+
watcher->deleteLater();
116123
return;
117124
}
118125

119126
const QString fillMode = m_item->property("fillMode").toString();
120127
// clang-format off
121128
const QString filename = QString("%1@%2x%3-%4.png")
122-
.arg(sha).arg(size.width()).arg(size.height())
129+
.arg(watcher->result()).arg(size.width()).arg(size.height())
123130
.arg(fillMode == "PreserveAspectCrop" ? "crop" : fillMode == "PreserveAspectFit" ? "fit" : "stretch");
124131
// clang-format on
125132

126133
const QUrl cache = m_cacheDir.resolved(QUrl(filename));
127134
if (m_cachePath == cache) {
135+
watcher->deleteLater();
128136
return;
129137
}
130138

@@ -133,6 +141,7 @@ void CachingImageManager::updateSource(const QString& path) {
133141

134142
if (!cache.isLocalFile()) {
135143
qWarning() << "CachingImageManager::updateSource: cachePath" << cache << "is not a local file";
144+
watcher->deleteLater();
136145
return;
137146
}
138147

@@ -148,7 +157,11 @@ void CachingImageManager::updateSource(const QString& path) {
148157
if (m_shaPath == path) {
149158
m_shaPath = QString();
150159
}
160+
161+
watcher->deleteLater();
151162
});
163+
164+
watcher->setFuture(future);
152165
}
153166

154167
QUrl CachingImageManager::cachePath() const {

plugin/src/Caelestia/Internal/cachingimagemanager.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <QtQuick/qquickitem.h>
44
#include <qobject.h>
5-
#include <qpointer.h>
65
#include <qqmlintegration.h>
76

87
namespace caelestia::internal {
@@ -19,7 +18,8 @@ class CachingImageManager : public QObject {
1918

2019
public:
2120
explicit CachingImageManager(QObject* parent = nullptr)
22-
: QObject(parent) {}
21+
: QObject(parent)
22+
, m_item(nullptr) {}
2323

2424
[[nodiscard]] QQuickItem* item() const;
2525
void setItem(QQuickItem* item);
@@ -46,7 +46,7 @@ class CachingImageManager : public QObject {
4646
private:
4747
QString m_shaPath;
4848

49-
QPointer<QQuickItem> m_item;
49+
QQuickItem* m_item;
5050
QUrl m_cacheDir;
5151

5252
QString m_path;

plugin/src/Caelestia/Internal/sparklineitem.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ void SparklineItem::paint(QPainter* painter) {
2727
}
2828

2929
void SparklineItem::drawLine(QPainter* painter, CircularBuffer* buffer, const QColor& color, qreal fillAlpha) {
30-
if (m_historyLength < 2)
31-
return;
32-
3330
const qreal w = width();
3431
const qreal h = height();
3532
const int len = buffer->count();

plugin/src/Caelestia/Models/filesystemmodel.cpp

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void FileSystemModel::watchDirIfRecursive(const QString& path) {
219219
if (m_recursive && m_watchChanges) {
220220
const auto currentDir = m_dir;
221221
const bool showHidden = m_showHidden;
222-
auto future = QtConcurrent::run([showHidden, path]() {
222+
const auto future = QtConcurrent::run([showHidden, path]() {
223223
QDir::Filters filters = QDir::Dirs | QDir::NoDotAndDotDot;
224224
if (showHidden) {
225225
filters |= QDir::Hidden;
@@ -232,12 +232,16 @@ void FileSystemModel::watchDirIfRecursive(const QString& path) {
232232
}
233233
return dirs;
234234
});
235-
future.then(this, [currentDir, showHidden, this](const QStringList& paths) {
235+
const auto watcher = new QFutureWatcher<QStringList>(this);
236+
connect(watcher, &QFutureWatcher<QStringList>::finished, this, [currentDir, showHidden, watcher, this]() {
237+
const auto paths = watcher->result();
236238
if (currentDir == m_dir && showHidden == m_showHidden && !paths.isEmpty()) {
237239
// Ignore if dir or showHidden has changed
238240
m_watcher.addPaths(paths);
239241
}
242+
watcher->deleteLater();
240243
});
244+
watcher->setFuture(future);
241245
}
242246
}
243247

@@ -291,7 +295,7 @@ void FileSystemModel::updateEntriesForDir(const QString& dir) {
291295
oldPaths << entry->path();
292296
}
293297

294-
auto future = QtConcurrent::run([=](QPromise<QPair<QSet<QString>, QSet<QString>>>& promise) {
298+
const auto future = QtConcurrent::run([=](QPromise<QPair<QSet<QString>, QSet<QString>>>& promise) {
295299
const auto flags = recursive ? QDirIterator::Subdirectories : QDirIterator::NoIteratorFlags;
296300

297301
std::optional<QDirIterator> iter;
@@ -349,7 +353,7 @@ void FileSystemModel::updateEntriesForDir(const QString& dir) {
349353
newPaths.insert(path);
350354
}
351355

352-
if (promise.isCanceled()) {
356+
if (promise.isCanceled() || newPaths == oldPaths) {
353357
return;
354358
}
355359

@@ -361,17 +365,23 @@ void FileSystemModel::updateEntriesForDir(const QString& dir) {
361365
}
362366
m_futures.insert(dir, future);
363367

364-
future
365-
.then(this,
366-
[dir, this](QPair<QSet<QString>, QSet<QString>> result) {
367-
m_futures.remove(dir);
368-
if (!result.first.isEmpty() || !result.second.isEmpty()) {
369-
applyChanges(result.first, result.second);
370-
}
371-
})
372-
.onCanceled(this, [dir, this]() {
373-
m_futures.remove(dir);
374-
});
368+
const auto watcher = new QFutureWatcher<QPair<QSet<QString>, QSet<QString>>>(this);
369+
370+
connect(watcher, &QFutureWatcher<QPair<QSet<QString>, QSet<QString>>>::finished, this, [dir, watcher, this]() {
371+
m_futures.remove(dir);
372+
373+
if (!watcher->future().isResultReadyAt(0)) {
374+
watcher->deleteLater();
375+
return;
376+
}
377+
378+
const auto result = watcher->result();
379+
applyChanges(result.first, result.second);
380+
381+
watcher->deleteLater();
382+
});
383+
384+
watcher->setFuture(future);
375385
}
376386

377387
void FileSystemModel::applyChanges(const QSet<QString>& removedPaths, const QSet<QString>& addedPaths) {

plugin/src/Caelestia/Models/filesystemmodel.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class FileSystemModel : public QAbstractListModel {
132132
bool m_recursive;
133133
bool m_watchChanges;
134134
bool m_showHidden;
135-
bool m_sortReverse = false;
135+
bool m_sortReverse;
136136
Filter m_filter;
137137
QStringList m_nameFilters;
138138

plugin/src/Caelestia/Services/audiocollector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ AudioCollector::AudioCollector(QObject* parent)
221221
, m_writeBuffer(&m_buffer2) {}
222222

223223
AudioCollector::~AudioCollector() {
224-
AudioCollector::stop();
224+
stop();
225225
}
226226

227227
void AudioCollector::start() {

plugin/src/Caelestia/Services/audioprovider.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public slots:
2323
virtual void process() = 0;
2424

2525
private:
26-
QTimer* m_timer = nullptr;
26+
QTimer* m_timer;
2727
};
2828

2929
class AudioProvider : public Service {

plugin/src/Caelestia/Services/beattracker.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ BeatProcessor::~BeatProcessor() {
1919
if (m_in) {
2020
del_fvec(m_in);
2121
}
22-
if (m_out) {
23-
del_fvec(m_out);
24-
}
22+
del_fvec(m_out);
2523
}
2624

2725
void BeatProcessor::process() {

plugin/src/Caelestia/appdb.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ AppEntry::AppEntry(QObject* entry, unsigned int frequency, QObject* parent)
1111
, m_entry(entry)
1212
, m_frequency(frequency) {
1313
const auto mo = m_entry->metaObject();
14-
const auto tmo = &AppEntry::staticMetaObject;
14+
const auto tmo = metaObject();
1515

1616
for (const auto& prop :
1717
{ "name", "comment", "execString", "startupClass", "genericName", "categories", "keywords" }) {
@@ -303,13 +303,11 @@ void AppDb::updateApps() {
303303
newIds.insert(entry->property("id").toString());
304304
}
305305

306-
for (auto it = m_apps.begin(); it != m_apps.end();) {
307-
if (!newIds.contains(it.key())) {
306+
for (auto it = m_apps.keyBegin(); it != m_apps.keyEnd(); ++it) {
307+
const auto& id = *it;
308+
if (!newIds.contains(id)) {
308309
dirty = true;
309-
it.value()->deleteLater();
310-
it = m_apps.erase(it);
311-
} else {
312-
++it;
310+
m_apps.take(id)->deleteLater();
313311
}
314312
}
315313

0 commit comments

Comments
 (0)