Compare commits
5 Commits
15b999c3c2
...
451dbdd4c2
Author | SHA1 | Date |
---|---|---|
|
451dbdd4c2 | |
|
db0588edcd | |
|
99f6b16aa1 | |
|
65b7737454 | |
|
cb4ec62c1e |
|
@ -13,6 +13,6 @@ class AppInfo : public QObject {
|
||||||
explicit AppInfo(QObject *parent = nullptr);
|
explicit AppInfo(QObject *parent = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SINGLETON(AppInfo)
|
EXAMPLESINGLETON(AppInfo)
|
||||||
[[maybe_unused]] Q_INVOKABLE void testCrash();
|
[[maybe_unused]] Q_INVOKABLE void testCrash();
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ private:
|
||||||
void templateToFile(const QString &source, const QString &dest, Args &&...args);
|
void templateToFile(const QString &source, const QString &dest, Args &&...args);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SINGLETON(InitializrHelper)
|
EXAMPLESINGLETON(InitializrHelper)
|
||||||
~InitializrHelper() override;
|
~InitializrHelper() override;
|
||||||
[[maybe_unused]] Q_INVOKABLE void generate(const QString &name, const QString &path);
|
[[maybe_unused]] Q_INVOKABLE void generate(const QString &name, const QString &path);
|
||||||
Q_SIGNAL void error(const QString &message);
|
Q_SIGNAL void error(const QString &message);
|
||||||
|
|
|
@ -144,7 +144,7 @@ private:
|
||||||
explicit Network(QObject *parent = nullptr);
|
explicit Network(QObject *parent = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SINGLETON(Network)
|
EXAMPLESINGLETON(Network)
|
||||||
|
|
||||||
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) {
|
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) {
|
||||||
return getInstance();
|
return getInstance();
|
||||||
|
|
|
@ -15,7 +15,7 @@ private:
|
||||||
explicit SettingsHelper(QObject *parent = nullptr);
|
explicit SettingsHelper(QObject *parent = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SINGLETON(SettingsHelper)
|
EXAMPLESINGLETON(SettingsHelper)
|
||||||
~SettingsHelper() override;
|
~SettingsHelper() override;
|
||||||
void init(char *argv[]);
|
void init(char *argv[]);
|
||||||
Q_INVOKABLE void saveDarkMode(int darkModel) {
|
Q_INVOKABLE void saveDarkMode(int darkModel) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ private:
|
||||||
[[maybe_unused]] explicit TranslateHelper(QObject *parent = nullptr);
|
[[maybe_unused]] explicit TranslateHelper(QObject *parent = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SINGLETON(TranslateHelper)
|
EXAMPLESINGLETON(TranslateHelper)
|
||||||
~TranslateHelper() override;
|
~TranslateHelper() override;
|
||||||
void init(QQmlEngine *engine);
|
void init(QQmlEngine *engine);
|
||||||
|
|
||||||
|
|
|
@ -4,22 +4,22 @@
|
||||||
* @brief The Singleton class
|
* @brief The Singleton class
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Singleton {
|
class ExampleSingleton {
|
||||||
public:
|
public:
|
||||||
static T *getInstance();
|
static T *getInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T *Singleton<T>::getInstance() {
|
T *ExampleSingleton<T>::getInstance() {
|
||||||
static T *instance = new T();
|
static T *instance = new T();
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SINGLETON(Class) \
|
#define EXAMPLESINGLETON(Class) \
|
||||||
private: \
|
private: \
|
||||||
friend class Singleton<Class>; \
|
friend class ExampleSingleton<Class>; \
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
static Class *getInstance() { \
|
static Class *getInstance() { \
|
||||||
return Singleton<Class>::getInstance(); \
|
return ExampleSingleton<Class>::getInstance(); \
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ Item {
|
||||||
}
|
}
|
||||||
QtObject{
|
QtObject{
|
||||||
id:d
|
id:d
|
||||||
property bool flagXChanged: true
|
property bool flagXChanged: false
|
||||||
property bool isAnimEnable: control.autoPlay && list_view.count>3
|
property bool isAnimEnable: control.autoPlay && list_view.count>3
|
||||||
function setData(data){
|
function setData(data){
|
||||||
if(!data){
|
if(!data){
|
||||||
|
@ -88,15 +88,18 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMovementEnded:{
|
onMovementEnded:{
|
||||||
|
d.flagXChanged = false
|
||||||
|
list_view.highlightMoveDuration = 0
|
||||||
currentIndex = list_view.contentX/list_view.width
|
currentIndex = list_view.contentX/list_view.width
|
||||||
if(currentIndex === 0){
|
if(currentIndex === 0){
|
||||||
currentIndex = list_view.count-2
|
currentIndex = list_view.count-2
|
||||||
}else if(currentIndex === list_view.count-1){
|
}else if(currentIndex === list_view.count-1){
|
||||||
currentIndex = 1
|
currentIndex = 1
|
||||||
}
|
}
|
||||||
d.flagXChanged = false
|
if(d.isAnimEnable){
|
||||||
timer_run.restart()
|
timer_run.restart()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
onMovementStarted: {
|
onMovementStarted: {
|
||||||
d.flagXChanged = true
|
d.flagXChanged = true
|
||||||
timer_run.stop()
|
timer_run.stop()
|
||||||
|
@ -104,12 +107,12 @@ Item {
|
||||||
onContentXChanged: {
|
onContentXChanged: {
|
||||||
if(d.flagXChanged){
|
if(d.flagXChanged){
|
||||||
var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
|
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){
|
if(contentX>=maxX){
|
||||||
contentX = maxX
|
contentX = maxX
|
||||||
}
|
}
|
||||||
if(contentX<=minY){
|
if(contentX<=minX){
|
||||||
contentX = minY
|
contentX = minX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,6 @@ ProgressBar{
|
||||||
id:d
|
id:d
|
||||||
property real _radius: strokeWidth/2
|
property real _radius: strokeWidth/2
|
||||||
}
|
}
|
||||||
onIndeterminateChanged:{
|
|
||||||
if(!indeterminate){
|
|
||||||
animator_x.duration = 0
|
|
||||||
rect_progress.x = 0
|
|
||||||
animator_x.duration = control.duration
|
|
||||||
}
|
|
||||||
}
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: 150
|
implicitWidth: 150
|
||||||
implicitHeight: control.strokeWidth
|
implicitHeight: control.strokeWidth
|
||||||
|
@ -45,6 +38,11 @@ ProgressBar{
|
||||||
id: animator_x
|
id: animator_x
|
||||||
running: control.indeterminate && control.visible
|
running: control.indeterminate && control.visible
|
||||||
loops: Animation.Infinite
|
loops: Animation.Infinite
|
||||||
|
onRunningChanged: {
|
||||||
|
if(!running){
|
||||||
|
rect_progress.x = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
from: -rect_progress.width
|
from: -rect_progress.width
|
||||||
to: control.width + rect_progress.width
|
to: control.width + rect_progress.width
|
||||||
|
|
|
@ -24,7 +24,7 @@ Item {
|
||||||
}
|
}
|
||||||
QtObject{
|
QtObject{
|
||||||
id:d
|
id:d
|
||||||
property bool flagXChanged: true
|
property bool flagXChanged: false
|
||||||
property bool isAnimEnable: control.autoPlay && list_view.count>3
|
property bool isAnimEnable: control.autoPlay && list_view.count>3
|
||||||
function setData(data){
|
function setData(data){
|
||||||
if(!data){
|
if(!data){
|
||||||
|
@ -88,15 +88,18 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMovementEnded:{
|
onMovementEnded:{
|
||||||
|
d.flagXChanged = false
|
||||||
|
list_view.highlightMoveDuration = 0
|
||||||
currentIndex = list_view.contentX/list_view.width
|
currentIndex = list_view.contentX/list_view.width
|
||||||
if(currentIndex === 0){
|
if(currentIndex === 0){
|
||||||
currentIndex = list_view.count-2
|
currentIndex = list_view.count-2
|
||||||
}else if(currentIndex === list_view.count-1){
|
}else if(currentIndex === list_view.count-1){
|
||||||
currentIndex = 1
|
currentIndex = 1
|
||||||
}
|
}
|
||||||
d.flagXChanged = false
|
if(d.isAnimEnable){
|
||||||
timer_run.restart()
|
timer_run.restart()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
onMovementStarted: {
|
onMovementStarted: {
|
||||||
d.flagXChanged = true
|
d.flagXChanged = true
|
||||||
timer_run.stop()
|
timer_run.stop()
|
||||||
|
@ -104,12 +107,12 @@ Item {
|
||||||
onContentXChanged: {
|
onContentXChanged: {
|
||||||
if(d.flagXChanged){
|
if(d.flagXChanged){
|
||||||
var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
|
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){
|
if(contentX>=maxX){
|
||||||
contentX = maxX
|
contentX = maxX
|
||||||
}
|
}
|
||||||
if(contentX<=minY){
|
if(contentX<=minX){
|
||||||
contentX = minY
|
contentX = minX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,6 @@ ProgressBar{
|
||||||
id:d
|
id:d
|
||||||
property real _radius: strokeWidth/2
|
property real _radius: strokeWidth/2
|
||||||
}
|
}
|
||||||
onIndeterminateChanged:{
|
|
||||||
if(!indeterminate){
|
|
||||||
animator_x.duration = 0
|
|
||||||
rect_progress.x = 0
|
|
||||||
animator_x.duration = control.duration
|
|
||||||
}
|
|
||||||
}
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: 150
|
implicitWidth: 150
|
||||||
implicitHeight: control.strokeWidth
|
implicitHeight: control.strokeWidth
|
||||||
|
@ -46,6 +39,11 @@ ProgressBar{
|
||||||
id: animator_x
|
id: animator_x
|
||||||
running: control.indeterminate && control.visible
|
running: control.indeterminate && control.visible
|
||||||
loops: Animation.Infinite
|
loops: Animation.Infinite
|
||||||
|
onRunningChanged: {
|
||||||
|
if(!running){
|
||||||
|
rect_progress.x = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
PropertyAnimation {
|
PropertyAnimation {
|
||||||
from: -rect_progress.width
|
from: -rect_progress.width
|
||||||
to: control.width + rect_progress.width
|
to: control.width + rect_progress.width
|
||||||
|
|
Loading…
Reference in New Issue