Compare commits

...

5 Commits

Author SHA1 Message Date
Kakueeen 451dbdd4c2
Merge cb4ec62c1e into db0588edcd 2025-02-21 11:23:48 +08:00
zhuzichu db0588edcd
Merge pull request #588 from Polaris-Night/main
修复FluCarousel手动翻页的问题
2025-02-21 11:23:30 +08:00
Polaris-Night 99f6b16aa1 修复FluProgressBar属性错误 2025-02-20 20:15:21 +08:00
Polaris-Night 65b7737454 修复FluCarousel设置autoPlay为false时手动翻页仍触发自动轮播翻页问题. fixed #563
修复FluCarousel设置autoPlay为false时不能无限向左/右翻页的问题.
2025-02-20 20:11:01 +08:00
liuzhangjian cb4ec62c1e fix: [singleton] Fixed an issue with the Singleton class redefinition
fix #564
2025-01-20 17:00:41 +08:00
10 changed files with 38 additions and 36 deletions

View File

@ -13,6 +13,6 @@ class AppInfo : public QObject {
explicit AppInfo(QObject *parent = nullptr);
public:
SINGLETON(AppInfo)
EXAMPLESINGLETON(AppInfo)
[[maybe_unused]] Q_INVOKABLE void testCrash();
};

View File

@ -15,7 +15,7 @@ private:
void templateToFile(const QString &source, const QString &dest, Args &&...args);
public:
SINGLETON(InitializrHelper)
EXAMPLESINGLETON(InitializrHelper)
~InitializrHelper() override;
[[maybe_unused]] Q_INVOKABLE void generate(const QString &name, const QString &path);
Q_SIGNAL void error(const QString &message);

View File

@ -144,7 +144,7 @@ private:
explicit Network(QObject *parent = nullptr);
public:
SINGLETON(Network)
EXAMPLESINGLETON(Network)
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) {
return getInstance();

View File

@ -15,7 +15,7 @@ private:
explicit SettingsHelper(QObject *parent = nullptr);
public:
SINGLETON(SettingsHelper)
EXAMPLESINGLETON(SettingsHelper)
~SettingsHelper() override;
void init(char *argv[]);
Q_INVOKABLE void saveDarkMode(int darkModel) {

View File

@ -14,7 +14,7 @@ private:
[[maybe_unused]] explicit TranslateHelper(QObject *parent = nullptr);
public:
SINGLETON(TranslateHelper)
EXAMPLESINGLETON(TranslateHelper)
~TranslateHelper() override;
void init(QQmlEngine *engine);

View File

@ -4,22 +4,22 @@
* @brief The Singleton class
*/
template <typename T>
class Singleton {
class ExampleSingleton {
public:
static T *getInstance();
};
template <typename T>
T *Singleton<T>::getInstance() {
T *ExampleSingleton<T>::getInstance() {
static T *instance = new T();
return instance;
}
#define SINGLETON(Class) \
#define EXAMPLESINGLETON(Class) \
private: \
friend class Singleton<Class>; \
friend class ExampleSingleton<Class>; \
\
public: \
static Class *getInstance() { \
return Singleton<Class>::getInstance(); \
return ExampleSingleton<Class>::getInstance(); \
}

View File

@ -24,7 +24,7 @@ Item {
}
QtObject{
id:d
property bool flagXChanged: true
property bool flagXChanged: false
property bool isAnimEnable: control.autoPlay && list_view.count>3
function setData(data){
if(!data){
@ -88,14 +88,17 @@ Item {
}
}
onMovementEnded:{
d.flagXChanged = false
list_view.highlightMoveDuration = 0
currentIndex = list_view.contentX/list_view.width
if(currentIndex === 0){
currentIndex = list_view.count-2
}else if(currentIndex === list_view.count-1){
currentIndex = 1
}
d.flagXChanged = false
timer_run.restart()
if(d.isAnimEnable){
timer_run.restart()
}
}
onMovementStarted: {
d.flagXChanged = true
@ -104,12 +107,12 @@ Item {
onContentXChanged: {
if(d.flagXChanged){
var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
var minY = Math.max(0,(list_view.width*(currentIndex-1)))
var minX = Math.max(0,(list_view.width*(currentIndex-1)))
if(contentX>=maxX){
contentX = maxX
}
if(contentX<=minY){
contentX = minY
if(contentX<=minX){
contentX = minX
}
}
}

View File

@ -14,13 +14,6 @@ ProgressBar{
id:d
property real _radius: strokeWidth/2
}
onIndeterminateChanged:{
if(!indeterminate){
animator_x.duration = 0
rect_progress.x = 0
animator_x.duration = control.duration
}
}
background: Rectangle {
implicitWidth: 150
implicitHeight: control.strokeWidth
@ -45,6 +38,11 @@ ProgressBar{
id: animator_x
running: control.indeterminate && control.visible
loops: Animation.Infinite
onRunningChanged: {
if(!running){
rect_progress.x = 0
}
}
PropertyAnimation {
from: -rect_progress.width
to: control.width + rect_progress.width

View File

@ -24,7 +24,7 @@ Item {
}
QtObject{
id:d
property bool flagXChanged: true
property bool flagXChanged: false
property bool isAnimEnable: control.autoPlay && list_view.count>3
function setData(data){
if(!data){
@ -88,14 +88,17 @@ Item {
}
}
onMovementEnded:{
d.flagXChanged = false
list_view.highlightMoveDuration = 0
currentIndex = list_view.contentX/list_view.width
if(currentIndex === 0){
currentIndex = list_view.count-2
}else if(currentIndex === list_view.count-1){
currentIndex = 1
}
d.flagXChanged = false
timer_run.restart()
if(d.isAnimEnable){
timer_run.restart()
}
}
onMovementStarted: {
d.flagXChanged = true
@ -104,12 +107,12 @@ Item {
onContentXChanged: {
if(d.flagXChanged){
var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
var minY = Math.max(0,(list_view.width*(currentIndex-1)))
var minX = Math.max(0,(list_view.width*(currentIndex-1)))
if(contentX>=maxX){
contentX = maxX
}
if(contentX<=minY){
contentX = minY
if(contentX<=minX){
contentX = minX
}
}
}

View File

@ -15,13 +15,6 @@ ProgressBar{
id:d
property real _radius: strokeWidth/2
}
onIndeterminateChanged:{
if(!indeterminate){
animator_x.duration = 0
rect_progress.x = 0
animator_x.duration = control.duration
}
}
background: Rectangle {
implicitWidth: 150
implicitHeight: control.strokeWidth
@ -46,6 +39,11 @@ ProgressBar{
id: animator_x
running: control.indeterminate && control.visible
loops: Animation.Infinite
onRunningChanged: {
if(!running){
rect_progress.x = 0
}
}
PropertyAnimation {
from: -rect_progress.width
to: control.width + rect_progress.width