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.
This commit is contained in:
Martchus 2023-06-07 22:53:41 +02:00
parent 925ce383f0
commit dd936b4a81
8 changed files with 59 additions and 42 deletions

View File

@ -14,6 +14,7 @@ set(HEADER_FILES
syncthingdir.h
syncthingdev.h
syncthingconnection.h
syncthingconnectionenums.h
syncthingconnectionstatus.h
syncthingconnectionsettings.h
syncthingnotifier.h

View File

@ -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;

View File

@ -0,0 +1,25 @@
#ifndef SYNCTHINGCONNECTION_ENUMS_H
#define SYNCTHINGCONNECTION_ENUMS_H
#include <c++utilities/misc/flagenumclass.h>
#include <QtGlobal>
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

View File

@ -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);
}

View File

@ -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

View File

@ -1054,7 +1054,7 @@ bool FinalWizardPage::validatePage()
return true;
}
void QtGui::FinalWizardPage::showResults()
void FinalWizardPage::showResults()
{
auto *const wizard = qobject_cast<Wizard *>(this->wizard());
if (!wizard) {

View File

@ -2,8 +2,7 @@
#define SETTINGS_WIZARD_H
#include "../global.h"
#include <c++utilities/misc/flagenumclass.h>
#include "./wizardenums.h"
#include <QWizard>
#include <QWizardPage>
@ -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

View File

@ -0,0 +1,28 @@
#ifndef SETTINGS_WIZARD_ENUMS_H
#define SETTINGS_WIZARD_ENUMS_H
#include <c++utilities/misc/flagenumclass.h>
#include <QtGlobal>
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