1 Star 0 Fork 6

wang_keran001/ukui-clipboard

forked from openKylin/ukui-clipboard 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
data.cpp 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
pangyi 提交于 2024-05-24 17:49 . 适配部分主题控件
#include "data.h"
ContentMenu::ContentMenu(ContentType contentType, const QString &itemName, QObject *parent)
: m_contentType(contentType), m_itemName(itemName), QObject(parent) {
switch (contentType) {
case ContentType::PlainText:
m_iconName = "ukui-idtext-symbolic";
break;
case ContentType::RichText:
m_iconName = "ukui-idtext-symbolic";
break;
case ContentType::Image:
m_iconName = "image-x-generic-symbolic";
break;
case ContentType::Original:
m_iconName = "";
break;
default:
m_iconName = "";
break;
}
}
ContentMenu::ContentMenu(const ContentMenu &rhs)
{
m_contentType = rhs.contentType();
m_itemName = rhs.itemName();
}
ContentMenu &ContentMenu::operator=(const ContentMenu &rhs)
{
m_contentType = rhs.contentType();
m_itemName = rhs.itemName();
return *this;
}
InMemoryImageProvider::InMemoryImageProvider()
: QQuickImageProvider(QQuickImageProvider::Image)
{
}
QImage InMemoryImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
QImage image;
if (m_images.find(id) == m_images.end()) {
*size = QSize(0, 0);
return image;
}
int width = m_images[id].width();
int height = m_images[id].height();
if(size) {
*size = QSize(width, height);
}
image = m_images[id].scaled(requestedSize.width() > 0 ? requestedSize.width() : width, requestedSize.height() > 0 ? requestedSize.height() : height
, Qt::KeepAspectRatio, Qt::SmoothTransformation);
return image;
}
QList<QImage> InMemoryImageProvider::requestAllImage()
{
qDebug()<<"requestAllImage"<<m_images.values();
return m_images.values();
}
void InMemoryImageProvider::addImage(const QImage &image)
{
QString id = "Image" + QString::number(m_imageId);
m_imageId++;
m_images[id] = image;
}
void InMemoryImageProvider::clear()
{
m_images.clear();
m_imageId = 0;
}
int InMemoryImageProvider::imageNumber() const
{
return m_images.size();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wang_keran001/ukui-clipboard.git
git@gitee.com:wang_keran001/ukui-clipboard.git
wang_keran001
ukui-clipboard
ukui-clipboard
openkylin/nile

搜索帮助