QClipboardProxy renamed to ClipboardUtils

This commit is contained in:
Michał Cieślak 2024-08-27 14:44:15 +02:00 committed by Michał
parent 69cdd30c11
commit 9311ebe7fe
4 changed files with 25 additions and 25 deletions

View File

@ -92,8 +92,8 @@ endif()
add_library(StatusQ SHARED add_library(StatusQ SHARED
${STATUSQ_QRC_COMPILED} ${STATUSQ_QRC_COMPILED}
include/StatusQ/QClipboardProxy.h
include/StatusQ/aggregator.h include/StatusQ/aggregator.h
include/StatusQ/clipboardutils.h
include/StatusQ/concatmodel.h include/StatusQ/concatmodel.h
include/StatusQ/fastexpressionfilter.h include/StatusQ/fastexpressionfilter.h
include/StatusQ/fastexpressionrole.h include/StatusQ/fastexpressionrole.h
@ -121,11 +121,11 @@ add_library(StatusQ SHARED
include/StatusQ/stringutilsinternal.h include/StatusQ/stringutilsinternal.h
include/StatusQ/submodelproxymodel.h include/StatusQ/submodelproxymodel.h
include/StatusQ/sumaggregator.h include/StatusQ/sumaggregator.h
include/StatusQ/undefinedfilter.h
include/StatusQ/systemutilsinternal.h include/StatusQ/systemutilsinternal.h
include/StatusQ/undefinedfilter.h
include/StatusQ/writableproxymodel.h include/StatusQ/writableproxymodel.h
src/QClipboardProxy.cpp
src/aggregator.cpp src/aggregator.cpp
src/clipboardutils.cpp
src/concatmodel.cpp src/concatmodel.cpp
src/fastexpressionfilter.cpp src/fastexpressionfilter.cpp
src/fastexpressionrole.cpp src/fastexpressionrole.cpp

View File

@ -7,11 +7,11 @@ class QClipboard;
class QJSEngine; class QJSEngine;
class QQmlEngine; class QQmlEngine;
class QClipboardProxy : public QObject class ClipboardUtils : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(QClipboardProxy) Q_DISABLE_COPY(ClipboardUtils)
Q_PROPERTY(bool hasText READ hasText NOTIFY contentChanged) Q_PROPERTY(bool hasText READ hasText NOTIFY contentChanged)
Q_PROPERTY(QString text READ text NOTIFY contentChanged) Q_PROPERTY(QString text READ text NOTIFY contentChanged)
@ -26,7 +26,7 @@ class QClipboardProxy : public QObject
Q_PROPERTY(bool hasUrls READ hasUrls NOTIFY contentChanged) Q_PROPERTY(bool hasUrls READ hasUrls NOTIFY contentChanged)
Q_PROPERTY(QList<QUrl> urls READ urls NOTIFY contentChanged) Q_PROPERTY(QList<QUrl> urls READ urls NOTIFY contentChanged)
QClipboardProxy(); ClipboardUtils();
bool hasText() const; bool hasText() const;
QString text() const; QString text() const;
@ -49,7 +49,7 @@ public:
Q_UNUSED(engine); Q_UNUSED(engine);
Q_UNUSED(scriptEngine); Q_UNUSED(scriptEngine);
return new QClipboardProxy; return new ClipboardUtils;
} }
Q_INVOKABLE bool isValidImageUrl(const QUrl &url, const QStringList &acceptedExtensions) const; Q_INVOKABLE bool isValidImageUrl(const QUrl &url, const QStringList &acceptedExtensions) const;

View File

@ -1,4 +1,4 @@
#include "StatusQ/QClipboardProxy.h" #include "StatusQ/clipboardutils.h"
#include <QBuffer> #include <QBuffer>
#include <QClipboard> #include <QClipboard>
@ -10,7 +10,7 @@
#include <algorithm> #include <algorithm>
QClipboardProxy::QClipboardProxy() ClipboardUtils::ClipboardUtils()
: m_clipboard(QGuiApplication::clipboard()) : m_clipboard(QGuiApplication::clipboard())
{ {
connect(m_clipboard, &QClipboard::changed, this, [this](QClipboard::Mode mode) { connect(m_clipboard, &QClipboard::changed, this, [this](QClipboard::Mode mode) {
@ -19,38 +19,38 @@ QClipboardProxy::QClipboardProxy()
}); });
} }
bool QClipboardProxy::hasText() const bool ClipboardUtils::hasText() const
{ {
return m_clipboard->mimeData()->hasText(); return m_clipboard->mimeData()->hasText();
} }
QString QClipboardProxy::text() const QString ClipboardUtils::text() const
{ {
return m_clipboard->text(); return m_clipboard->text();
} }
bool QClipboardProxy::hasHtml() const bool ClipboardUtils::hasHtml() const
{ {
return m_clipboard->mimeData()->hasHtml(); return m_clipboard->mimeData()->hasHtml();
} }
QString QClipboardProxy::html() const QString ClipboardUtils::html() const
{ {
auto mimeData = m_clipboard->mimeData(); auto mimeData = m_clipboard->mimeData();
return mimeData ? mimeData->html() : QString{}; return mimeData ? mimeData->html() : QString{};
} }
bool QClipboardProxy::hasImage() const bool ClipboardUtils::hasImage() const
{ {
return m_clipboard->mimeData()->hasImage(); return m_clipboard->mimeData()->hasImage();
} }
QImage QClipboardProxy::image() const QImage ClipboardUtils::image() const
{ {
return m_clipboard->image(); return m_clipboard->image();
} }
QString QClipboardProxy::imageBase64() const QString ClipboardUtils::imageBase64() const
{ {
if (!hasImage()) if (!hasImage())
return {}; return {};
@ -62,17 +62,17 @@ QString QClipboardProxy::imageBase64() const
return QByteArrayLiteral("data:image/jpeg;base64,") + byteArray.toBase64(); return QByteArrayLiteral("data:image/jpeg;base64,") + byteArray.toBase64();
} }
bool QClipboardProxy::hasUrls() const bool ClipboardUtils::hasUrls() const
{ {
return m_clipboard->mimeData()->hasUrls(); return m_clipboard->mimeData()->hasUrls();
} }
QList<QUrl> QClipboardProxy::urls() const QList<QUrl> ClipboardUtils::urls() const
{ {
return m_clipboard->mimeData()->urls(); return m_clipboard->mimeData()->urls();
} }
bool QClipboardProxy::isValidImageUrl(const QUrl& url, const QStringList& acceptedExtensions) const bool ClipboardUtils::isValidImageUrl(const QUrl& url, const QStringList& acceptedExtensions) const
{ {
const auto strippedUrl = url.url(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); const auto strippedUrl = url.url(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);
return std::any_of(acceptedExtensions.constBegin(), acceptedExtensions.constEnd(), [strippedUrl](const auto & ext) { return std::any_of(acceptedExtensions.constBegin(), acceptedExtensions.constEnd(), [strippedUrl](const auto & ext) {
@ -80,7 +80,7 @@ bool QClipboardProxy::isValidImageUrl(const QUrl& url, const QStringList& accept
}); });
} }
qint64 QClipboardProxy::getFileSize(const QUrl& url) const qint64 ClipboardUtils::getFileSize(const QUrl& url) const
{ {
if (url.isLocalFile()) { if (url.isLocalFile()) {
return QFile(url.toLocalFile()).size(); return QFile(url.toLocalFile()).size();
@ -88,12 +88,12 @@ qint64 QClipboardProxy::getFileSize(const QUrl& url) const
return 0; return 0;
} }
void QClipboardProxy::copyTextToClipboard(const QString &text) void ClipboardUtils::copyTextToClipboard(const QString &text)
{ {
m_clipboard->setText(text); m_clipboard->setText(text);
} }
void QClipboardProxy::clear() void ClipboardUtils::clear()
{ {
m_clipboard->clear(); m_clipboard->clear();
} }

View File

@ -3,7 +3,7 @@
#include <QZXing.h> #include <QZXing.h>
#include <qqmlsortfilterproxymodeltypes.h> #include <qqmlsortfilterproxymodeltypes.h>
#include "StatusQ/QClipboardProxy.h" #include "StatusQ/clipboardutils.h"
#include "StatusQ/concatmodel.h" #include "StatusQ/concatmodel.h"
#include "StatusQ/fastexpressionfilter.h" #include "StatusQ/fastexpressionfilter.h"
#include "StatusQ/fastexpressionrole.h" #include "StatusQ/fastexpressionrole.h"
@ -28,8 +28,8 @@
#include "StatusQ/stringutilsinternal.h" #include "StatusQ/stringutilsinternal.h"
#include "StatusQ/submodelproxymodel.h" #include "StatusQ/submodelproxymodel.h"
#include "StatusQ/sumaggregator.h" #include "StatusQ/sumaggregator.h"
#include "StatusQ/undefinedfilter.h"
#include "StatusQ/systemutilsinternal.h" #include "StatusQ/systemutilsinternal.h"
#include "StatusQ/undefinedfilter.h"
#include "StatusQ/writableproxymodel.h" #include "StatusQ/writableproxymodel.h"
#include "wallet/managetokenscontroller.h" #include "wallet/managetokenscontroller.h"
@ -77,7 +77,7 @@ public:
qmlRegisterType<WritableProxyModel>("StatusQ", 0, 1, "WritableProxyModel"); qmlRegisterType<WritableProxyModel>("StatusQ", 0, 1, "WritableProxyModel");
qmlRegisterType<FormattedDoubleProperty>("StatusQ", 0, 1, "FormattedDoubleProperty"); qmlRegisterType<FormattedDoubleProperty>("StatusQ", 0, 1, "FormattedDoubleProperty");
qmlRegisterSingletonType<QClipboardProxy>("StatusQ", 0, 1, "QClipboardProxy", &QClipboardProxy::qmlInstance); qmlRegisterSingletonType<ClipboardUtils>("StatusQ", 0, 1, "QClipboardProxy", &ClipboardUtils::qmlInstance);
qmlRegisterType<ModelEntry>("StatusQ", 0, 1, "ModelEntry"); qmlRegisterType<ModelEntry>("StatusQ", 0, 1, "ModelEntry");
qmlRegisterType<SnapshotObject>("StatusQ", 0, 1, "SnapshotObject"); qmlRegisterType<SnapshotObject>("StatusQ", 0, 1, "SnapshotObject");