2026年5月23日暂存

This commit is contained in:
2026-05-23 14:16:57 +08:00
parent c8a5a121c9
commit 1cb9d5ac42
59 changed files with 15774 additions and 8662 deletions
+37
View File
@@ -42,6 +42,39 @@ enum SourceType{
COUNTER,
};
class PicTextItem;
/**
* @brief 图元通用属性的ViewModel
*
* 目的:解耦UI编辑器与PicTextItem,支持灵活的数据绑定和批量操作。
* UI修改属性时先更新VM,再决定何时应用到item(实时或延迟)。
*/
struct TextItemModel {
// 图元类型,用于判断是否显示字间距
SourceType sourceType = SourceType::UNKNOWN;
ItemDirectionType direction = NORMAL;
int boldMultiple = 1;
int letterSpace = 0;
bool colorReversal = false;
std::function<QImage()> imageGenerator; // 图片生成函数
// 便利方法:从PicTextItem快照创建VM
static TextItemModel fromItem(PicTextItem *item);
// 检查是否有改动
bool hasDifference(const TextItemModel &other) const {
return sourceType != other.sourceType ||
direction != other.direction ||
boldMultiple != other.boldMultiple ||
letterSpace != other.letterSpace ||
colorReversal != other.colorReversal;
}
};
class PicTextItem : public QGraphicsTextItem
{
Q_OBJECT
@@ -121,6 +154,10 @@ public:
*/
QImage preview();
void setTextItemModel(const TextItemModel& model);
TextItemModel textItemModel();
signals:
void lostFocus(PicTextItem *item);
void selectedChange(QGraphicsItem *item);