mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-08 00:27:39 +03:00
fixed duplicate settings
This commit is contained in:
parent
50f9a701e1
commit
c0b3c60589
@ -40,11 +40,11 @@ inline std::vector<SettingInfo> getSettingsList() {
|
|||||||
SettingInfo::Enum("refreshFrequency", "Refresh Frequency", &CrossPointSettings::refreshFrequency,
|
SettingInfo::Enum("refreshFrequency", "Refresh Frequency", &CrossPointSettings::refreshFrequency,
|
||||||
{"1 page", "5 pages", "10 pages", "15 pages", "30 pages"}),
|
{"1 page", "5 pages", "10 pages", "15 pages", "30 pages"}),
|
||||||
SettingInfo::String("opdsServerUrl", "Calibre Web URL", SETTINGS.opdsServerUrl,
|
SettingInfo::String("opdsServerUrl", "Calibre Web URL", SETTINGS.opdsServerUrl,
|
||||||
sizeof(SETTINGS.opdsServerUrl) - 1),
|
sizeof(SETTINGS.opdsServerUrl) - 1, true),
|
||||||
SettingInfo::String("calibreUsername", "Calibre Username", SETTINGS.calibreUsername,
|
SettingInfo::String("calibreUsername", "Calibre Username", SETTINGS.calibreUsername,
|
||||||
sizeof(SETTINGS.calibreUsername) - 1),
|
sizeof(SETTINGS.calibreUsername) - 1, true),
|
||||||
SettingInfo::String("calibrePassword", "Calibre Password", SETTINGS.calibrePassword,
|
SettingInfo::String("calibrePassword", "Calibre Password", SETTINGS.calibrePassword,
|
||||||
sizeof(SETTINGS.calibrePassword) - 1),
|
sizeof(SETTINGS.calibrePassword) - 1, true),
|
||||||
SettingInfo::Action("Calibre Settings"),
|
SettingInfo::Action("Calibre Settings"),
|
||||||
SettingInfo::Action("Check for updates"),
|
SettingInfo::Action("Check for updates"),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,8 +15,16 @@
|
|||||||
// Get settings list from shared source (lazily initialized to avoid static init issues)
|
// Get settings list from shared source (lazily initialized to avoid static init issues)
|
||||||
namespace {
|
namespace {
|
||||||
const std::vector<SettingInfo>& getSettings() {
|
const std::vector<SettingInfo>& getSettings() {
|
||||||
static const std::vector<SettingInfo> settingsList = getSettingsList();
|
static std::vector<SettingInfo> filteredSettings = []() {
|
||||||
return settingsList;
|
std::vector<SettingInfo> filtered;
|
||||||
|
for (const auto& setting : getSettingsList()) {
|
||||||
|
if (!setting.hideFromDeviceUI) {
|
||||||
|
filtered.push_back(setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}();
|
||||||
|
return filteredSettings;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@ struct SettingInfo {
|
|||||||
uint8_t CrossPointSettings::* valuePtr; // Pointer to member in CrossPointSettings (for TOGGLE/ENUM/VALUE)
|
uint8_t CrossPointSettings::* valuePtr; // Pointer to member in CrossPointSettings (for TOGGLE/ENUM/VALUE)
|
||||||
char* stringPtr; // Pointer to char array (for STRING type)
|
char* stringPtr; // Pointer to char array (for STRING type)
|
||||||
size_t stringMaxLen; // Max length for STRING type
|
size_t stringMaxLen; // Max length for STRING type
|
||||||
|
bool hideFromDeviceUI; // Hide from device settings menu (but show in web API)
|
||||||
std::vector<std::string> enumValues;
|
std::vector<std::string> enumValues;
|
||||||
|
|
||||||
struct ValueRange {
|
struct ValueRange {
|
||||||
@ -33,25 +34,25 @@ struct SettingInfo {
|
|||||||
|
|
||||||
// Static constructors
|
// Static constructors
|
||||||
static SettingInfo Toggle(const char* key, const char* name, uint8_t CrossPointSettings::* ptr) {
|
static SettingInfo Toggle(const char* key, const char* name, uint8_t CrossPointSettings::* ptr) {
|
||||||
return {key, name, SettingType::TOGGLE, ptr, nullptr, 0, {}, {}};
|
return {key, name, SettingType::TOGGLE, ptr, nullptr, 0, false, {}, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
static SettingInfo Enum(const char* key, const char* name, uint8_t CrossPointSettings::* ptr,
|
static SettingInfo Enum(const char* key, const char* name, uint8_t CrossPointSettings::* ptr,
|
||||||
std::vector<std::string> values) {
|
std::vector<std::string> values) {
|
||||||
return {key, name, SettingType::ENUM, ptr, nullptr, 0, std::move(values), {}};
|
return {key, name, SettingType::ENUM, ptr, nullptr, 0, false, std::move(values), {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
static SettingInfo Action(const char* name) {
|
static SettingInfo Action(const char* name) {
|
||||||
return {nullptr, name, SettingType::ACTION, nullptr, nullptr, 0, {}, {}};
|
return {nullptr, name, SettingType::ACTION, nullptr, nullptr, 0, false, {}, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
static SettingInfo Value(const char* key, const char* name, uint8_t CrossPointSettings::* ptr,
|
static SettingInfo Value(const char* key, const char* name, uint8_t CrossPointSettings::* ptr,
|
||||||
const ValueRange valueRange) {
|
const ValueRange valueRange) {
|
||||||
return {key, name, SettingType::VALUE, ptr, nullptr, 0, {}, valueRange};
|
return {key, name, SettingType::VALUE, ptr, nullptr, 0, false, {}, valueRange};
|
||||||
}
|
}
|
||||||
|
|
||||||
static SettingInfo String(const char* key, const char* name, char* ptr, size_t maxLen) {
|
static SettingInfo String(const char* key, const char* name, char* ptr, size_t maxLen, bool hideFromDeviceUI = false) {
|
||||||
return {key, name, SettingType::STRING, nullptr, ptr, maxLen, {}, {}};
|
return {key, name, SettingType::STRING, nullptr, ptr, maxLen, hideFromDeviceUI, {}, {}};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user