🔧 fix: trigger preview action when color or palette changes
This commit is contained in:
@@ -190,7 +190,7 @@ Initial sorting behavior for loaded images.
|
||||
"previewDebounceTime": 500,
|
||||
"quitOnSelected": true,
|
||||
"onPreview": "swww img {{ path }}",
|
||||
"onSelected": "cp {{ path }} ~/.config/current_wallpaper.jpg",
|
||||
"onSelected": "cp {{ path }} ~/.config/wallpaper/current/ && swww img {{ path }}",
|
||||
"saveState": [
|
||||
{
|
||||
"key": "current_wp",
|
||||
|
||||
@@ -45,6 +45,11 @@ class Bootstrap {
|
||||
*paletteMgr);
|
||||
}
|
||||
|
||||
void start() {
|
||||
configMgr->captureState();
|
||||
imageMgr->loadAndProcess(configMgr->getWallpapers());
|
||||
}
|
||||
|
||||
~Bootstrap() {
|
||||
delete ServiceMgr;
|
||||
delete paletteMgr;
|
||||
|
||||
@@ -208,24 +208,45 @@ class Carousel : public QObject {
|
||||
connect(m_serviceMgr, &Service::Manager::restoreCompleted, this, &Carousel::restoreCompleted);
|
||||
connect(m_serviceMgr, &Service::Manager::cancelCompleted, this, &Carousel::cancelCompleted);
|
||||
|
||||
// "Preview" is costly, but is (usually) protected by a debounce timer, so it seems fine
|
||||
// to call it multiple times in a short period, and it simplifies the code a lot :)
|
||||
|
||||
// Preview on imageid change
|
||||
connect(this, &Carousel::currentImageIdChanged, this, [this]() {
|
||||
if (!m_currentImageId.isEmpty()) {
|
||||
m_serviceMgr->previewWallpaper(m_currentImageId);
|
||||
}
|
||||
});
|
||||
// Update color when imageid changes
|
||||
// Update displayed color when imageid changes
|
||||
connect(this, &Carousel::currentImageIdChanged, this, [this]() {
|
||||
if (!m_currentImageId.isEmpty()) {
|
||||
m_paletteMgr->updateColor(m_currentImageId);
|
||||
}
|
||||
});
|
||||
// Update color when selected color changes
|
||||
// Update displayed color when selected color changes
|
||||
connect(this, &Carousel::selectedColorChanged, this, [this]() {
|
||||
if (!m_currentImageId.isEmpty()) {
|
||||
m_paletteMgr->updateColor(m_currentImageId);
|
||||
}
|
||||
});
|
||||
// Preview on selected palette change
|
||||
connect(this, &Carousel::selectedPaletteChanged, this, [this]() {
|
||||
if (!m_currentImageId.isEmpty()) {
|
||||
m_serviceMgr->previewWallpaper(m_currentImageId);
|
||||
}
|
||||
});
|
||||
// Preview on displayed color name change
|
||||
connect(this, &Carousel::colorNameChanged, this, [this]() {
|
||||
if (!m_currentImageId.isEmpty()) {
|
||||
m_serviceMgr->previewWallpaper(m_currentImageId);
|
||||
}
|
||||
});
|
||||
// Preview on displayed color hex change
|
||||
connect(this, &Carousel::colorChanged, this, [this]() {
|
||||
if (!m_currentImageId.isEmpty()) {
|
||||
m_serviceMgr->previewWallpaper(m_currentImageId);
|
||||
}
|
||||
});
|
||||
|
||||
// Quit on selected
|
||||
if (m_configMgr->getActionConfig().quitOnSelected) {
|
||||
@@ -257,11 +278,6 @@ class Carousel : public QObject {
|
||||
setSortDescending(m_configMgr->getSortConfig().descending);
|
||||
}
|
||||
|
||||
void start() {
|
||||
m_configMgr->captureState();
|
||||
m_imageMgr->loadAndProcess(m_configMgr->getWallpapers());
|
||||
}
|
||||
|
||||
private:
|
||||
Config::Manager* m_configMgr;
|
||||
Image::Manager* m_imageMgr;
|
||||
|
||||
+8
-1
@@ -20,6 +20,11 @@ using namespace WallReel::Core;
|
||||
WALLREEL_DECLARE_SENDER("Main")
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Destruction order after QApplication quits its event loop:
|
||||
// 1. QQmlApplicationEngine (with all QML objects)
|
||||
// 2. provider (manages states and connections)
|
||||
// 3. bootstrap (manages lifecycle of all managers)
|
||||
// 4. QApplication
|
||||
|
||||
QApplication a(argc, argv);
|
||||
a.setApplicationName(APP_NAME);
|
||||
@@ -42,6 +47,7 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
{
|
||||
Provider::Carousel provider(&a, bootstrap);
|
||||
qmlRegisterSingletonInstance(
|
||||
COREMODULE_URI,
|
||||
@@ -60,9 +66,10 @@ int main(int argc, char* argv[]) {
|
||||
Qt::QueuedConnection);
|
||||
engine.loadFromModule(UIMODULE_URI, "Main");
|
||||
|
||||
provider.start();
|
||||
bootstrap.start();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user