mirror of
https://github.com/hyprwm/Hyprland
synced 2026-04-03 01:00:39 +02:00
* move string parsing for eCMType to its own namespace, similar to how `src/protocols/types/ContentType.cpp` is done * expose cm type and sdr settings in `hyprctl monitors`, format floats to .2f
23 lines
967 B
C++
23 lines
967 B
C++
#include "CMType.hpp"
|
|
#include <optional>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
static std::unordered_map<std::string, NCMType::eCMType> const table = {{"auto", NCMType::CM_AUTO}, {"srgb", NCMType::CM_SRGB}, {"wide", NCMType::CM_WIDE},
|
|
{"edid", NCMType::CM_EDID}, {"hdr", NCMType::CM_HDR}, {"hdredid", NCMType::CM_HDR_EDID},
|
|
{"dcip3", NCMType::CM_DCIP3}, {"dp3", NCMType::CM_DP3}, {"adobe", NCMType::CM_ADOBE}};
|
|
|
|
std::optional<NCMType::eCMType> NCMType::fromString(const std::string cmType) {
|
|
auto it = table.find(cmType);
|
|
if (it == table.end())
|
|
return std::nullopt;
|
|
return it->second;
|
|
}
|
|
|
|
std::string NCMType::toString(eCMType cmType) {
|
|
for (const auto& [key, value] : table) {
|
|
if (value == cmType)
|
|
return key;
|
|
}
|
|
return "";
|
|
}
|