From dd936b4a8131a68348d24a39428522cd09a95c40 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 7 Jun 2023 22:53:41 +0200 Subject: [PATCH] Workaround lupdate not understanding "enum class" in some cases Apparently this is still problematic leading to errors like `Qualifying with unknown namespace/class`. It seems that moving the enum to a different header file works. The trick to use a macro to define `enum class` ceased to work on the other hand. Specifying a function with the namespace like `void QtGui::FinalWizardPage::showResults()` leads to the same problem and also needs to be avoided. --- syncthingconnector/CMakeLists.txt | 1 + syncthingconnector/syncthingconnection.h | 23 +-------------- syncthingconnector/syncthingconnectionenums.h | 25 +++++++++++++++++ syncthingconnector/syncthingservice.cpp | 2 +- syncthingwidgets/CMakeLists.txt | 1 + syncthingwidgets/settings/wizard.cpp | 2 +- syncthingwidgets/settings/wizard.h | 19 +------------ syncthingwidgets/settings/wizardenums.h | 28 +++++++++++++++++++ 8 files changed, 59 insertions(+), 42 deletions(-) create mode 100644 syncthingconnector/syncthingconnectionenums.h create mode 100644 syncthingwidgets/settings/wizardenums.h diff --git a/syncthingconnector/CMakeLists.txt b/syncthingconnector/CMakeLists.txt index 21280ec..5c105df 100644 --- a/syncthingconnector/CMakeLists.txt +++ b/syncthingconnector/CMakeLists.txt @@ -14,6 +14,7 @@ set(HEADER_FILES syncthingdir.h syncthingdev.h syncthingconnection.h + syncthingconnectionenums.h syncthingconnectionstatus.h syncthingconnectionsettings.h syncthingnotifier.h diff --git a/syncthingconnector/syncthingconnection.h b/syncthingconnector/syncthingconnection.h index dccad2c..12a8f21 100644 --- a/syncthingconnector/syncthingconnection.h +++ b/syncthingconnector/syncthingconnection.h @@ -1,6 +1,7 @@ #ifndef SYNCTHINGCONNECTION_H #define SYNCTHINGCONNECTION_H +#include "./syncthingconnectionenums.h" #include "./syncthingconnectionstatus.h" #include "./syncthingdev.h" #include "./syncthingdir.h" @@ -30,12 +31,6 @@ QT_FORWARD_DECLARE_CLASS(QJsonParseError) class ConnectionTests; class MiscTests; -#define SYNCTHING_CONNECTOR_ENUM_CLASS enum class -namespace Data { -SYNCTHING_CONNECTOR_ENUM_CLASS SyncthingStatusComputionFlags : quint64; -} -#undef SYNCTHING_CONNECTOR_ENUM_CLASS - namespace Data { struct SyncthingConnectionSettings; @@ -52,22 +47,6 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingLogEntry { QString message; }; -enum class SyncthingConnectionLoggingFlags : quint64 { - None, /**< loggingn is disabled */ - FromEnvironment = (1 << 0), /**< environment variables are checked to pull in any of the other flags dynamically */ - ApiCalls = (1 << 1), /**< log calls to Syncthing's REST-API and responses */ - ApiReplies = (1 << 2), /**< log replies from Syncthing's REST-API */ - Events = (1 << 3), /**< log events received via Syncthing's event API */ - DirsOrDevsResetted = (1 << 4), /**< log list of directories/devices when list is reset */ - All = ApiCalls | ApiReplies | Events | DirsOrDevsResetted, /** log as much as possible */ -}; - -} // namespace Data - -CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(Data, Data::SyncthingConnectionLoggingFlags) - -namespace Data { - class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject { friend ConnectionTests; friend MiscTests; diff --git a/syncthingconnector/syncthingconnectionenums.h b/syncthingconnector/syncthingconnectionenums.h new file mode 100644 index 0000000..a922a14 --- /dev/null +++ b/syncthingconnector/syncthingconnectionenums.h @@ -0,0 +1,25 @@ +#ifndef SYNCTHINGCONNECTION_ENUMS_H +#define SYNCTHINGCONNECTION_ENUMS_H + +#include + +#include + +namespace Data { +enum class SyncthingStatusComputionFlags : quint64; + +enum class SyncthingConnectionLoggingFlags : quint64 { + None, /**< loggingn is disabled */ + FromEnvironment = (1 << 0), /**< environment variables are checked to pull in any of the other flags dynamically */ + ApiCalls = (1 << 1), /**< log calls to Syncthing's REST-API and responses */ + ApiReplies = (1 << 2), /**< log replies from Syncthing's REST-API */ + Events = (1 << 3), /**< log events received via Syncthing's event API */ + DirsOrDevsResetted = (1 << 4), /**< log list of directories/devices when list is reset */ + All = ApiCalls | ApiReplies | Events | DirsOrDevsResetted, /** log as much as possible */ +}; + +} // namespace Data + +CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(Data, Data::SyncthingConnectionLoggingFlags) + +#endif // SYNCTHINGCONNECTION_ENUMS_H diff --git a/syncthingconnector/syncthingservice.cpp b/syncthingconnector/syncthingservice.cpp index 3aae407..4a54b8c 100644 --- a/syncthingconnector/syncthingservice.cpp +++ b/syncthingconnector/syncthingservice.cpp @@ -402,7 +402,7 @@ void SyncthingService::setEnabled(bool enabled) /*! * \brief Reload all unit files. */ -void Data::SyncthingService::reloadAllUnitFiles() +void SyncthingService::reloadAllUnitFiles() { registerErrorHandler(m_currentSystemdInterface->Reload(), QT_TR_NOOP_UTF8("reload all unit files"), false, false); } diff --git a/syncthingwidgets/CMakeLists.txt b/syncthingwidgets/CMakeLists.txt index 214bbbe..edfe375 100644 --- a/syncthingwidgets/CMakeLists.txt +++ b/syncthingwidgets/CMakeLists.txt @@ -12,6 +12,7 @@ set(WIDGETS_HEADER_FILES settings/settings.h settings/settingsdialog.h settings/wizard.h + settings/wizardenums.h webview/webpage.h webview/webviewdialog.h misc/textviewdialog.h diff --git a/syncthingwidgets/settings/wizard.cpp b/syncthingwidgets/settings/wizard.cpp index 3e0a88a..a00c2ce 100644 --- a/syncthingwidgets/settings/wizard.cpp +++ b/syncthingwidgets/settings/wizard.cpp @@ -1054,7 +1054,7 @@ bool FinalWizardPage::validatePage() return true; } -void QtGui::FinalWizardPage::showResults() +void FinalWizardPage::showResults() { auto *const wizard = qobject_cast(this->wizard()); if (!wizard) { diff --git a/syncthingwidgets/settings/wizard.h b/syncthingwidgets/settings/wizard.h index 57523fe..36088fa 100644 --- a/syncthingwidgets/settings/wizard.h +++ b/syncthingwidgets/settings/wizard.h @@ -2,8 +2,7 @@ #define SETTINGS_WIZARD_H #include "../global.h" - -#include +#include "./wizardenums.h" #include #include @@ -30,20 +29,6 @@ class AutostartWizardPage; class ApplyWizardPage; } // namespace Ui -enum class MainConfiguration : quint64 { - None, - CurrentlyRunning, - LauncherExternal, - LauncherBuiltIn, - SystemdUserUnit, - SystemdSystemUnit, -}; - -enum class ExtraConfiguration : quint64 { - None, - SystemdIntegration = (1 << 0), -}; - class SYNCTHINGWIDGETS_EXPORT Wizard : public QWizard { Q_OBJECT friend class WizardTests; @@ -255,6 +240,4 @@ private: } // namespace QtGui -CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(QtGui, QtGui::ExtraConfiguration) - #endif // SETTINGS_WIZARD_H diff --git a/syncthingwidgets/settings/wizardenums.h b/syncthingwidgets/settings/wizardenums.h new file mode 100644 index 0000000..7294fea --- /dev/null +++ b/syncthingwidgets/settings/wizardenums.h @@ -0,0 +1,28 @@ +#ifndef SETTINGS_WIZARD_ENUMS_H +#define SETTINGS_WIZARD_ENUMS_H + +#include + +#include + +namespace QtGui { + +enum class MainConfiguration : quint64 { + None, + CurrentlyRunning, + LauncherExternal, + LauncherBuiltIn, + SystemdUserUnit, + SystemdSystemUnit, +}; + +enum class ExtraConfiguration : quint64 { + None, + SystemdIntegration = (1 << 0), +}; + +} // namespace QtGui + +CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(QtGui, QtGui::ExtraConfiguration) + +#endif // SETTINGS_WIZARD_H