mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibGfx+icc: Make device manufacturer and device model clickable
This commit is contained in:
parent
243caa8fa9
commit
b56a145a67
Notes:
sideshowbarker
2024-07-17 06:39:26 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/b56a145a67 Pull-request: https://github.com/SerenityOS/serenity/pull/17123 Reviewed-by: https://github.com/MacDue
3 changed files with 29 additions and 2 deletions
|
@ -388,6 +388,18 @@ ErrorOr<void> parse_reserved(ICCHeader const& header)
|
|||
}
|
||||
}
|
||||
|
||||
URL device_manufacturer_url(DeviceManufacturer device_manufacturer)
|
||||
{
|
||||
return URL(DeprecatedString::formatted("https://www.color.org/signatureRegistry/?entityEntry={:c}{:c}{:c}{:c}-{:08X}",
|
||||
device_manufacturer.c0(), device_manufacturer.c1(), device_manufacturer.c2(), device_manufacturer.c3(), device_manufacturer.value));
|
||||
}
|
||||
|
||||
URL device_model_url(DeviceModel device_model)
|
||||
{
|
||||
return URL(DeprecatedString::formatted("https://www.color.org/signatureRegistry/deviceRegistry/?entityEntry={:c}{:c}{:c}{:c}-{:08X}",
|
||||
device_model.c0(), device_model.c1(), device_model.c2(), device_model.c3(), device_model.value));
|
||||
}
|
||||
|
||||
StringView device_class_name(DeviceClass device_class)
|
||||
{
|
||||
switch (device_class) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCrypto/Hash/MD5.h>
|
||||
|
||||
namespace Gfx::ICC {
|
||||
|
@ -53,6 +54,9 @@ using Creator = DistinctFourCC<FourCCType::Creator>; // IC
|
|||
using TagSignature = DistinctFourCC<FourCCType::TagSignature>; // ICC v4, "9.2 Tag listing"
|
||||
using TagTypeSignature = DistinctFourCC<FourCCType::TagTypeSignature>; // ICC v4, "10 Tag type definitions"
|
||||
|
||||
URL device_manufacturer_url(DeviceManufacturer);
|
||||
URL device_model_url(DeviceModel);
|
||||
|
||||
// ICC v4, 7.2.4 Profile version field
|
||||
class Version {
|
||||
public:
|
||||
|
|
|
@ -4,12 +4,19 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/ICCProfile.h>
|
||||
|
||||
template<class T>
|
||||
static ErrorOr<String> hyperlink(URL const& target, T const& label)
|
||||
{
|
||||
return String::formatted("\033]8;;{}\033\\{}\033]8;;\033\\", target, label);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void out_optional(char const* label, Optional<T> optional)
|
||||
{
|
||||
|
@ -48,8 +55,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (auto color_management_module_bits = flags.color_management_module_bits())
|
||||
outln(" CMM bits: 0x{:04x}", color_management_module_bits);
|
||||
|
||||
out_optional(" device manufacturer", profile->device_manufacturer());
|
||||
out_optional(" device model", profile->device_model());
|
||||
out_optional(" device manufacturer", TRY(profile->device_manufacturer().map([](auto device_manufacturer) {
|
||||
return hyperlink(device_manufacturer_url(device_manufacturer), device_manufacturer);
|
||||
})));
|
||||
out_optional(" device model", TRY(profile->device_model().map([](auto device_model) {
|
||||
return hyperlink(device_model_url(device_model), device_model);
|
||||
})));
|
||||
|
||||
auto device_attributes = profile->device_attributes();
|
||||
outln(" device attributes: 0x{:016x}", device_attributes.bits());
|
||||
|
|
Loading…
Reference in a new issue