fix: refine help output
This commit is contained in:
+54
-51
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: Uyanide pywang0608@foxmail.com
|
* @Author: Uyanide pywang0608@foxmail.com
|
||||||
* @Date: 2025-08-05 01:22:53
|
* @Date: 2025-08-05 01:22:53
|
||||||
* @LastEditTime: 2026-01-15 07:06:46
|
* @LastEditTime: 2026-01-15 07:43:44
|
||||||
* @Description: Animated carousel widget for displaying and selecting images.
|
* @Description: Animated carousel widget for displaying and selecting images.
|
||||||
*/
|
*/
|
||||||
#ifndef IMAGES_CAROUSEL_H
|
#ifndef IMAGES_CAROUSEL_H
|
||||||
@@ -20,56 +20,59 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "image_item.h"
|
#include "image_item.h"
|
||||||
|
|
||||||
// Two different image loading strategies:
|
/* Design Notes:
|
||||||
// - With loading screen: load all images directly
|
|
||||||
// 1. appendImages called -> increace m_addedImagesCount & spawn all ImageLoader
|
Two different image loading strategies:
|
||||||
// threads
|
- With loading screen: load all images directly
|
||||||
// 2. Each ImageLoader calls _insertImageQueue with queued connection
|
1. appendImages called -> increace m_addedImagesCount & spawn all ImageLoader
|
||||||
// 3. _insertImageQueue calls _insertImage directly
|
threads
|
||||||
// - Without loading screen: queue loaded images and insert them in batches
|
2. Each ImageLoader calls _insertImageQueue with queued connection
|
||||||
// 1. appendImages called -> increace m_addedImagesCount & spawn all ImageLoader
|
3. _insertImageQueue calls _insertImage directly
|
||||||
// threads and a timer m_imageInsertQueueTimer, disable UI updates
|
- Without loading screen: queue loaded images and insert them in batches
|
||||||
// 2. Each ImageLoader calls _insertImageQueue with queued connection
|
1. appendImages called -> increace m_addedImagesCount & spawn all ImageLoader
|
||||||
// 3. _insertImageQueue enqueues the ImageData
|
threads and a timer m_imageInsertQueueTimer, disable UI updates
|
||||||
// 4. m_imageInsertQueueTimer calls _processImageInsertQueue every
|
2. Each ImageLoader calls _insertImageQueue with queued connection
|
||||||
// s_processBatchTimeout ms
|
3. _insertImageQueue enqueues the ImageData
|
||||||
// 5. _processImageInsertQueue processes up to s_processBatchSize items from the
|
4. m_imageInsertQueueTimer calls _processImageInsertQueue every
|
||||||
// queue and calls _insertImage for each
|
s_processBatchTimeout ms
|
||||||
//
|
5. _processImageInsertQueue processes up to s_processBatchSize items from the
|
||||||
// The stop logic is identical:
|
queue and calls _insertImage for each
|
||||||
// - Force stop
|
|
||||||
// 1. Set m_stopSign to true
|
The stop logic is identical:
|
||||||
// 2. ImageLoader::run checks m_stopSign and returns early if true
|
- Force stop
|
||||||
// and calls _insertImageQueue using queued connection, but passing a
|
1. Set m_stopSign to true
|
||||||
// nullptr as parameter
|
2. ImageLoader::run checks m_stopSign and returns early if true
|
||||||
// 3. The callstack from _insertImageQueue to _insertImage is same as above
|
and calls _insertImageQueue using queued connection, but passing a
|
||||||
// 4. _insertImage ignores nullptr and just increases m_processedImagesCount
|
nullptr as parameter
|
||||||
// 5. when m_processedImagesCount >= m_addedImagesCount, emit stopped()
|
3. The callstack from _insertImageQueue to _insertImage is same as above
|
||||||
// 6. Call ImagesCarousel::_onImagesLoaded
|
4. _insertImage ignores nullptr and just increases m_processedImagesCount
|
||||||
// - Normal completion
|
5. when m_processedImagesCount >= m_addedImagesCount, emit stopped()
|
||||||
// 1. Same as above until _insertImage, but m_stopSign is false and ImageLoader::run
|
6. Call ImagesCarousel::_onImagesLoaded
|
||||||
// passes valid ImageData pointer to _insertImageQueue
|
- Normal completion
|
||||||
// 2. When m_processedImagesCount >= m_addedImagesCount, emit loadingCompleted()
|
1. Same as above until _insertImage, but m_stopSign is false and ImageLoader::run
|
||||||
// 3. Call ImagesCarousel::_onImagesLoaded
|
passes valid ImageData pointer to _insertImageQueue
|
||||||
//
|
2. When m_processedImagesCount >= m_addedImagesCount, emit loadingCompleted()
|
||||||
// 3 different ways to change focusing image:
|
3. Call ImagesCarousel::_onImagesLoaded
|
||||||
// - focusNextImage / focusPrevImage: directly change m_currentIndex and call
|
|
||||||
// focusCurrImage
|
3 different ways to change focusing image:
|
||||||
// These can be triggered by different events, e.g. key press, button click, etc.
|
- focusNextImage / focusPrevImage: directly change m_currentIndex and call
|
||||||
// - Auto focus on scroll: debounce scroll events and calculate the nearest image
|
focusCurrImage
|
||||||
// index to focus, then change m_currentIndex and call focusCurrImage
|
These can be triggered by different events, e.g. key press, button click, etc.
|
||||||
// - Initial focus: set m_currentIndex to 0 and call focusCurrImage
|
- Auto focus on scroll: debounce scroll events and calculate the nearest image
|
||||||
//
|
index to focus, then change m_currentIndex and call focusCurrImage
|
||||||
// Note:
|
- Initial focus: set m_currentIndex to 0 and call focusCurrImage
|
||||||
// - All methods and slots of ImageCarousel should be called from the main thread.
|
|
||||||
// - ImageCarousel::m_addedImagesCount and ImageCarousel::m_processedImagesCount
|
Note:
|
||||||
// should be identical after loading is finished, regardless of whether loading is
|
- All methods and slots of ImageCarousel should be called from the main thread.
|
||||||
// forcedly stopped or completed normally.
|
- ImageCarousel::m_addedImagesCount and ImageCarousel::m_processedImagesCount
|
||||||
// - ImageCarousel::getLoadedImagesCount() returns the number of images currently
|
should be identical after loading is finished, regardless of whether loading is
|
||||||
// displayed in the carousel, which may be less than m_addedImagesCount if loading
|
forcedly stopped or completed normally.
|
||||||
// is not yet completed or some images failed to load.
|
- ImageCarousel::getLoadedImagesCount() returns the number of images currently
|
||||||
// - The current implementation actually supports dynamic addition of images during runtime,
|
displayed in the carousel, which may be less than m_addedImagesCount if loading
|
||||||
// but the UI does not provide such functionality yet and thus it is not tested :)
|
is not yet completed or some images failed to load.
|
||||||
|
- The current implementation actually supports dynamic addition of images during runtime,
|
||||||
|
but the UI does not provide such functionality yet and thus it is not tested :)
|
||||||
|
*/
|
||||||
|
|
||||||
class ImageLoader;
|
class ImageLoader;
|
||||||
class ImagesCarousel;
|
class ImagesCarousel;
|
||||||
|
|||||||
+10
-2
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: Uyanide pywang0608@foxmail.com
|
* @Author: Uyanide pywang0608@foxmail.com
|
||||||
* @Date: 2025-08-05 00:37:58
|
* @Date: 2025-08-05 00:37:58
|
||||||
* @LastEditTime: 2026-01-15 05:58:06
|
* @LastEditTime: 2026-01-15 07:51:54
|
||||||
* @Description: Argument parser and entry point.
|
* @Description: Argument parser and entry point.
|
||||||
*/
|
*/
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -37,7 +37,15 @@ static class AppOptions {
|
|||||||
// -h --help
|
// -h --help
|
||||||
void printHelp() {
|
void printHelp() {
|
||||||
QTextStream out(stdout);
|
QTextStream out(stdout);
|
||||||
out << parser.helpText() << Qt::endl;
|
QString helpText = parser.helpText();
|
||||||
|
auto lines = helpText.split('\n');
|
||||||
|
for (auto& line : lines) {
|
||||||
|
if (line.contains("--help-all")) {
|
||||||
|
// Remove the --help-all option line added by Qt by default
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out << line << Qt::endl;
|
||||||
|
}
|
||||||
doReturn = true;
|
doReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user