Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Müller <fmueller@owncloud.com>2022-06-11 02:34:18 +0300
committerHannah von Reth <vonreth@kde.org>2022-07-01 18:46:52 +0300
commit08891659242891dabba4d5885a2c2aa33ecc5399 (patch)
tree6a5604d9c58a4406b9447837d0fe40e90628a518
parent1cbf68636c87b886a1c34f1946932818cadb6cf8 (diff)
Consolidate wizard enums in single file
Makes using the Qt metatype system (with Q_ENUM_NS and Q_NAMESPACE) easier. Both may not be used in multiple files within the same namespace. Even use in children namespaces (A::B) don't work when those macros are used in a parent namespace already.
-rw-r--r--src/gui/folderman.h2
-rw-r--r--src/gui/newwizard/CMakeLists.txt5
-rw-r--r--src/gui/newwizard/enums.cpp39
-rw-r--r--src/gui/newwizard/enums.h (renamed from src/gui/newwizard/syncmode.h)20
-rw-r--r--src/gui/newwizard/navigation.cpp2
-rw-r--r--src/gui/newwizard/navigation.h2
-rw-r--r--src/gui/newwizard/setupwizardcontroller.h2
-rw-r--r--src/gui/newwizard/states/abstractsetupwizardstate.h2
-rw-r--r--src/gui/newwizard/states/setupwizardstate.cpp16
-rw-r--r--src/gui/newwizard/states/setupwizardstate.h56
-rw-r--r--src/gui/newwizard/syncmode.cpp16
11 files changed, 66 insertions, 96 deletions
diff --git a/src/gui/folderman.h b/src/gui/folderman.h
index be9d7311c..9b9e50af5 100644
--- a/src/gui/folderman.h
+++ b/src/gui/folderman.h
@@ -25,7 +25,7 @@
#include "navigationpanehelper.h"
#include "syncfileitem.h"
-#include "newwizard/syncmode.h"
+#include "newwizard/enums.h"
class TestFolderMigration;
diff --git a/src/gui/newwizard/CMakeLists.txt b/src/gui/newwizard/CMakeLists.txt
index 475561c27..a64395395 100644
--- a/src/gui/newwizard/CMakeLists.txt
+++ b/src/gui/newwizard/CMakeLists.txt
@@ -1,4 +1,6 @@
add_library(newwizard STATIC
+ enums.cpp
+
pages/abstractsetupwizardpage.h
pages/abstractsetupwizardpage.cpp
@@ -39,9 +41,6 @@ add_library(newwizard STATIC
postfixlineedit.cpp
- syncmode.cpp
-
- states/setupwizardstate.cpp
states/abstractsetupwizardstate.cpp
states/serverurlsetupwizardstate.cpp
states/basiccredentialssetupwizardstate.cpp
diff --git a/src/gui/newwizard/enums.cpp b/src/gui/newwizard/enums.cpp
new file mode 100644
index 000000000..8795887de
--- /dev/null
+++ b/src/gui/newwizard/enums.cpp
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) Fabian Müller <fmueller@owncloud.com>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*/
+
+// just a stub so the MOC file can be included somewhere
+#include "moc_enums.cpp"
+
+#include <QApplication>
+
+using namespace OCC::Wizard;
+
+namespace {
+const char contextC[] = "SetupWizardState";
+}
+
+template <>
+QString OCC::Utility::enumToDisplayName(SetupWizardState state)
+{
+ switch (state) {
+ case SetupWizardState::ServerUrlState:
+ return QApplication::translate(contextC, "Server URL");
+ case SetupWizardState::CredentialsState:
+ return QApplication::translate(contextC, "Credentials");
+ case SetupWizardState::AccountConfiguredState:
+ return QApplication::translate(contextC, "Sync Options");
+ default:
+ Q_UNREACHABLE();
+ }
+}
diff --git a/src/gui/newwizard/syncmode.h b/src/gui/newwizard/enums.h
index a9fa49aa5..a6995b1b2 100644
--- a/src/gui/newwizard/syncmode.h
+++ b/src/gui/newwizard/enums.h
@@ -14,11 +14,25 @@
#pragma once
+#include "common/utility.h"
+#include "enums.h"
+
#include <QObject>
namespace OCC::Wizard {
Q_NAMESPACE
+enum class SetupWizardState {
+ ServerUrlState,
+ FirstState = ServerUrlState,
+
+ CredentialsState,
+
+ AccountConfiguredState,
+ FinalState = AccountConfiguredState,
+};
+Q_ENUM_NS(SetupWizardState)
+
enum class SyncMode {
Invalid = 0,
SyncEverything,
@@ -26,4 +40,10 @@ enum class SyncMode {
UseVfs,
};
Q_ENUM_NS(SyncMode)
+
+}
+
+namespace OCC {
+template <>
+QString Utility::enumToDisplayName(Wizard::SetupWizardState state);
}
diff --git a/src/gui/newwizard/navigation.cpp b/src/gui/newwizard/navigation.cpp
index 0c7cdb1c0..93c3f22b3 100644
--- a/src/gui/newwizard/navigation.cpp
+++ b/src/gui/newwizard/navigation.cpp
@@ -19,7 +19,7 @@ void Navigation::setEntries(const QList<SetupWizardState> &newEntries)
removeAllItems();
for (const auto state : newEntries) {
- const QString &text = setupWizardStateToText(state);
+ const QString text = Utility::enumToDisplayName(state);
auto newButton = new QRadioButton(text, this);
diff --git a/src/gui/newwizard/navigation.h b/src/gui/newwizard/navigation.h
index 13b7911b4..35d7d858e 100644
--- a/src/gui/newwizard/navigation.h
+++ b/src/gui/newwizard/navigation.h
@@ -14,7 +14,7 @@
#pragma once
-#include "states/setupwizardstate.h"
+#include "enums.h"
#include <QHBoxLayout>
#include <QMap>
diff --git a/src/gui/newwizard/setupwizardcontroller.h b/src/gui/newwizard/setupwizardcontroller.h
index a13ce49ab..de2f397e2 100644
--- a/src/gui/newwizard/setupwizardcontroller.h
+++ b/src/gui/newwizard/setupwizardcontroller.h
@@ -15,12 +15,12 @@
#pragma once
#include "account.h"
+#include "enums.h"
#include "pages/abstractsetupwizardpage.h"
#include "setupwizardaccountbuilder.h"
#include "setupwizardcontext.h"
#include "setupwizardwindow.h"
#include "states/abstractsetupwizardstate.h"
-#include "syncmode.h"
#include <QDialog>
#include <optional>
diff --git a/src/gui/newwizard/states/abstractsetupwizardstate.h b/src/gui/newwizard/states/abstractsetupwizardstate.h
index 2691de3b8..9fd67f354 100644
--- a/src/gui/newwizard/states/abstractsetupwizardstate.h
+++ b/src/gui/newwizard/states/abstractsetupwizardstate.h
@@ -14,10 +14,10 @@
#pragma once
+#include "enums.h"
#include "pages/abstractsetupwizardpage.h"
#include "setupwizardaccountbuilder.h"
#include "setupwizardcontext.h"
-#include "setupwizardstate.h"
#include "setupwizardwindow.h"
namespace OCC::Wizard {
diff --git a/src/gui/newwizard/states/setupwizardstate.cpp b/src/gui/newwizard/states/setupwizardstate.cpp
deleted file mode 100644
index 0e3bb6505..000000000
--- a/src/gui/newwizard/states/setupwizardstate.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) Fabian Müller <fmueller@owncloud.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-// just a stub so the MOC file can be included somewhere
-#include "moc_setupwizardstate.cpp"
diff --git a/src/gui/newwizard/states/setupwizardstate.h b/src/gui/newwizard/states/setupwizardstate.h
deleted file mode 100644
index 9d4ae00fd..000000000
--- a/src/gui/newwizard/states/setupwizardstate.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) Fabian Müller <fmueller@owncloud.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#pragma once
-
-#include <QObject>
-
-namespace OCC::Wizard {
-Q_NAMESPACE
-
-/**
- * Determines the state the wizard is in. The number of states is equal to the number of pages in the pagination.
- *
- * Every state may be represented by more than one class. These classes can be used like different "strategies".
- * For instance, we have two different credentials state implementations representing different authentication
- * methods.
- *
- * Since we need to decide which states to have at compile time, disabling or hiding optional states must be taken
- * care of by the pagination class. All states have to be added here nevertheless.
- */
-enum class SetupWizardState {
- ServerUrlState,
- FirstState = ServerUrlState,
-
- CredentialsState,
-
- AccountConfiguredState,
- FinalState = AccountConfiguredState,
-};
-Q_ENUM_NS(SetupWizardState)
-
-static QString setupWizardStateToText(SetupWizardState state)
-{
- switch (state) {
- case SetupWizardState::ServerUrlState:
- return QObject::tr("Server URL");
- case SetupWizardState::CredentialsState:
- return QObject::tr("Credentials");
- case SetupWizardState::AccountConfiguredState:
- return QObject::tr("Sync Options");
- default:
- Q_UNREACHABLE();
- }
-}
-}
diff --git a/src/gui/newwizard/syncmode.cpp b/src/gui/newwizard/syncmode.cpp
deleted file mode 100644
index 74b76c8f5..000000000
--- a/src/gui/newwizard/syncmode.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) Fabian Müller <fmueller@owncloud.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-// just a stub so the MOC file can be included somewhere
-#include "moc_syncmode.cpp"