2026年5月23日暂存
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user