Compare commits

...

4 Commits

Author SHA1 Message Date
Kakueeen b531f1a693
Merge cb4ec62c1e into 882cc8989f 2025-02-21 17:24:03 +08:00
zhuzichu 882cc8989f
Merge pull request #589 from soulwyb/repair-FluPivot-example-error
修复Pivot的示例代码错误
2025-02-21 12:01:57 +08:00
wuyubin 444cc1aeee 修复Pivot的示例代码错误 2025-02-21 11:34:54 +08:00
liuzhangjian cb4ec62c1e fix: [singleton] Fixed an issue with the Singleton class redefinition
fix #564
2025-01-20 17:00:41 +08:00
8 changed files with 38 additions and 18 deletions

20
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"MicroPython.executeButton": [
{
"text": "▶",
"tooltip": "运行",
"alignment": "left",
"command": "extension.executeFile",
"priority": 3.5
}
],
"MicroPython.syncButton": [
{
"text": "$(sync)",
"tooltip": "同步",
"alignment": "left",
"command": "extension.execute",
"priority": 4
}
]
}

View File

@ -49,26 +49,26 @@ FluScrollablePage{
Layout.topMargin: -6
code:'FluPivot{
anchors.fill: parent
FluPivotItem:{
text: qsTr("All")
FluPivotItem {
title: qsTr("All")
contentItem: FluText{
text: qsTr("All emails go here.")
}
}
FluPivotItem:{
text: qsTr("Unread")
FluPivotItem {
title: qsTr("Unread")
contentItem: FluText{
text: qsTr("Unread emails go here.")
}
}
FluPivotItem:{
text: qsTr("Flagged")
FluPivotItem {
title: qsTr("Flagged")
contentItem: FluText{
text: qsTr("Flagged emails go here.")
}
}
FluPivotItem:{
text: qsTr("Urgent")
FluPivotItem {
title: qsTr("Urgent")
contentItem: FluText{
text: qsTr("Urgent emails go here.")
}

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(); \
}