ClipboardHistory: Show bitmap width/height/bpp for bitmap clippings

This commit is contained in:
Andreas Kling 2020-09-05 17:05:22 +02:00
parent 0b051a5e15
commit 2e446b662b
Notes: sideshowbarker 2024-07-19 02:54:18 +09:00

View File

@ -26,6 +26,7 @@
#include "ClipboardHistoryModel.h"
#include <AK/NumberFormat.h>
#include <AK/StringBuilder.h>
NonnullRefPtr<ClipboardHistoryModel> ClipboardHistoryModel::create()
{
@ -59,6 +60,18 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
case Column::Data:
if (data_and_type.mime_type.starts_with("text/"))
return String::copy(data_and_type.data);
if (data_and_type.mime_type == "image/x-serenityos") {
StringBuilder builder;
builder.append("[");
builder.append(data_and_type.metadata.get("width").value_or("?"));
builder.append('x');
builder.append(data_and_type.metadata.get("height").value_or("?"));
builder.append('x');
builder.append(data_and_type.metadata.get("bpp").value_or("?"));
builder.append(" bitmap");
builder.append("]");
return builder.to_string();
}
return "<...>";
case Column::Type:
return data_and_type.mime_type;