From 94fb258f2fb8a57e8c56aed44e5bec0897b76ef8 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Thu, 7 Aug 2025 22:08:22 +0200 Subject: [PATCH] feat: some may not want the loading screen --- config.example.json | 5 +++-- src/config.cpp | 8 +++++++- src/config.h | 19 +++++++++++-------- src/images_carousel.cpp | 3 +-- src/main.cpp | 2 +- src/main_window.cpp | 5 ++++- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/config.example.json b/config.example.json index 90f6913..4caeb9c 100644 --- a/config.example.json +++ b/config.example.json @@ -14,14 +14,15 @@ ] }, "actions": { - "confirm": "~/.scripts/change-wallpaper.fish \"%1\"" + "confirm": "~/.scripts/change-wallpaper.sh \"%1\"" }, "style": { "aspect_ratio": 1.6, "image_width": 320, "image_focus_width": 480, "window_width": 750, - "window_height": 500 + "window_height": 500, + "no_loading_screen": true }, "sort": { "type": "name", diff --git a/src/config.cpp b/src/config.cpp index 58d5e5e..529592f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1,7 +1,7 @@ /* * @Author: Uyanide pywang0608@foxmail.com * @Date: 2025-08-05 01:34:52 - * @LastEditTime: 2025-08-07 21:27:26 + * @LastEditTime: 2025-08-07 22:02:55 * @Description: Configuration manager. */ #include "config.h" @@ -99,6 +99,12 @@ void Config::_loadConfig(const QString &configPath) { info(QString("Window height: %1").arg(m_configItems.styleWindowHeight), GeneralLogger::STEP); } }}, + {"style.no_loading_screen", "no_loading_screen", [this](const QJsonValue &val) { + if (val.isBool()) { + m_configItems.styleNoLoadingScreen = val.toBool(); + info(QString("No loading screen: %1").arg(m_configItems.styleNoLoadingScreen), GeneralLogger::STEP); + } + }}, {"sort.type", "type", [this](const QJsonValue &val) { if (val.isString()) { QString type = val.toString().toLower(); diff --git a/src/config.h b/src/config.h index 5666bc7..4604f66 100644 --- a/src/config.h +++ b/src/config.h @@ -1,7 +1,7 @@ /* * @Author: Uyanide pywang0608@foxmail.com * @Date: 2025-08-05 01:34:52 - * @LastEditTime: 2025-08-06 00:23:45 + * @LastEditTime: 2025-08-07 22:03:05 * @Description: Configuration manager. */ #ifndef CONFIG_H @@ -44,6 +44,8 @@ class Config : public QObject { [[nodiscard]] int getStyleWindowHeight() const { return m_configItems.styleWindowHeight; } + [[nodiscard]] bool isStyleNoLoadingScreen() const { return m_configItems.styleNoLoadingScreen; } + [[nodiscard]] SortType getSortType() const { return m_configItems.sortType; } [[nodiscard]] bool isSortReverse() const { return m_configItems.sortReverse; } @@ -61,13 +63,14 @@ class Config : public QObject { QStringList wallpaperDirs; QStringList wallpaperExcludes; QString actionsConfirm; - double styleAspectRatio = 1.6; - int styleImageWidth = 320; - int styleImageFocusWidth = 480; - int styleWindowWidth = 720; - int styleWindowHeight = 500; - SortType sortType = SortType::None; - bool sortReverse = false; + double styleAspectRatio = 1.6; + int styleImageWidth = 320; + int styleImageFocusWidth = 480; + int styleWindowWidth = 720; + int styleWindowHeight = 500; + bool styleNoLoadingScreen = false; + SortType sortType = SortType::None; + bool sortReverse = false; } m_configItems; QStringList m_wallpapers; diff --git a/src/images_carousel.cpp b/src/images_carousel.cpp index ab0ffaf..f9e6951 100644 --- a/src/images_carousel.cpp +++ b/src/images_carousel.cpp @@ -1,7 +1,7 @@ /* * @Author: Uyanide pywang0608@foxmail.com * @Date: 2025-08-05 01:22:53 - * @LastEditTime: 2025-08-07 02:01:23 + * @LastEditTime: 2025-08-07 22:06:44 * @Description: Animated carousel widget for displaying and selecting images. */ #include "images_carousel.h" @@ -77,7 +77,6 @@ void ImagesCarousel::_onInitImagesLoaded() { if (m_loadedImages.isEmpty()) { return; } - m_currentIndex = 0; _focusCurrImage(); } diff --git a/src/main.cpp b/src/main.cpp index d16895c..de68efd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ /* * @Author: Uyanide pywang0608@foxmail.com * @Date: 2025-08-05 00:37:58 - * @LastEditTime: 2025-08-07 21:25:43 + * @LastEditTime: 2025-08-07 21:38:26 * @Description: Entry point. */ #include diff --git a/src/main_window.cpp b/src/main_window.cpp index 5f63b21..d1da534 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -1,7 +1,7 @@ /* * @Author: Uyanide pywang0608@foxmail.com * @Date: 2025-08-05 00:37:58 - * @LastEditTime: 2025-08-07 01:08:55 + * @LastEditTime: 2025-08-07 22:03:58 * @Description: MainWindow implementation. */ #include "main_window.h" @@ -140,6 +140,9 @@ void MainWindow::_onImageFocused(const QString &path, const int index, const int } void MainWindow::_onLoadingStarted(const qsizetype amount) { + if (m_config.isStyleNoLoadingScreen()) { + return; + } m_loadingIndicator->setMaximum(amount); ui->stackedWidget->setCurrentIndex(m_loadingIndicatorIndex); }