mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00

We currently have a single IPC to set clipboard data. We will also need an IPC to retrieve that data from the UI. This defines system clipboard data in LibWeb to handle this transfer, and adds the IPC to provide it.
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibURL/Parser.h>
|
|
#include <UI/Qt/StringUtils.h>
|
|
|
|
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
|
|
{
|
|
auto utf8_data = qstring.toUtf8();
|
|
return AK::ByteString(utf8_data.data(), utf8_data.size());
|
|
}
|
|
|
|
AK::ByteString ak_byte_string_from_qbytearray(QByteArray const& qbytearray)
|
|
{
|
|
return AK::ByteString(qbytearray.data(), qbytearray.size());
|
|
}
|
|
|
|
String ak_string_from_qstring(QString const& qstring)
|
|
{
|
|
auto utf8_data = qstring.toUtf8();
|
|
return MUST(String::from_utf8(StringView(utf8_data.data(), utf8_data.size())));
|
|
}
|
|
|
|
QString qstring_from_ak_string(StringView ak_string)
|
|
{
|
|
return QString::fromUtf8(ak_string.characters_without_null_termination(), static_cast<qsizetype>(ak_string.length()));
|
|
}
|
|
|
|
QByteArray qbytearray_from_ak_string(StringView ak_string)
|
|
{
|
|
return { ak_string.characters_without_null_termination(), static_cast<qsizetype>(ak_string.length()) };
|
|
}
|
|
|
|
Optional<URL::URL> ak_url_from_qstring(QString const& qstring)
|
|
{
|
|
auto utf8_data = qstring.toUtf8();
|
|
return URL::Parser::basic_parse(StringView(utf8_data.data(), utf8_data.size()));
|
|
}
|
|
|
|
URL::URL ak_url_from_qurl(QUrl const& qurl)
|
|
{
|
|
return ak_url_from_qstring(qurl.toString()).value();
|
|
}
|