195 lines
4.9 KiB
C++
195 lines
4.9 KiB
C++
#ifndef TESTPRINTWIDGET_H
|
|
#define TESTPRINTWIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QButtonGroup>
|
|
#include <QTextEdit>
|
|
#include <QLineEdit>
|
|
#include <QXmlStreamReader>
|
|
#include "DialogSaveFile.h"
|
|
#include <QGraphicsView>
|
|
// 包含UI自动生成的头文件
|
|
#include "ui_TestPrintWidget.h"
|
|
|
|
#include "scene/picscene.h"
|
|
|
|
#include "ImageLoader.h"
|
|
#include "ItemEditor.h"
|
|
#include "scene/PicDateItem.h"
|
|
#include "scene/PicImageItem.h"
|
|
#include "scene/ScheduleShiftsEditor.h"
|
|
#include "scene/PicCounterItem.h"
|
|
#include <QScopedPointer>
|
|
|
|
#include "selectcodedlg.h"
|
|
#include <scene/piccodeitem.h>
|
|
#include "CounterVarSet.h"
|
|
#include "scene/BarcodeEditor.h"
|
|
#include "Printsetting.h"
|
|
|
|
class TestPrintWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
TestPrintWidget(QWidget* parent = nullptr);
|
|
~TestPrintWidget();
|
|
|
|
QTextEdit* getQTextEdit();
|
|
PicScene* getPicScene();
|
|
|
|
void getShowSelectItemText();
|
|
void bindSysPara(SysPara *sysPara);
|
|
|
|
void saveFile(const QString& filename = nullptr);
|
|
|
|
void on_KeyUp_clicked();
|
|
void on_KeyLeft_clicked();
|
|
void on_KeyRight_clicked();
|
|
void on_KeyDown_clicked();
|
|
|
|
void on_delButton_pressed();
|
|
|
|
void setPrintSettingWidget(PrintSetting* wid);
|
|
|
|
void addDateTimeItem(const DateItemModel& model, const TextItemModel& textModel);
|
|
|
|
void addScheduleShiftsItem(QVector<ScheduleModel> schedules, TextItemModel txtModel);
|
|
|
|
void addCounterItem(CounterViewModel vm, QSharedPointer<QFont> font = nullptr);
|
|
|
|
int getCounterNum();
|
|
|
|
QString currentFile();
|
|
|
|
// 更新编辑界面内所有计数器的当前值
|
|
void updateCountersCurrVal(const QVector<int> values);
|
|
|
|
public slots:
|
|
void on_enlargeButton_pressed();
|
|
void on_addButton_pressed(const SourceType type = SourceType::UNKNOWN);
|
|
void onEditItemDone();
|
|
|
|
void on_saveButton_pressed();
|
|
void onSaveASFile(QString filename,bool Flag);
|
|
|
|
void openWorkFile(QString filePath);
|
|
|
|
void on_newfileButton_pressed();
|
|
|
|
void slt_BarCodeItemDone();
|
|
|
|
void selectNextItem();
|
|
|
|
void selectPreviousItem();
|
|
|
|
void showBarcodeEditor(const BarcodeViewModel& vm);
|
|
|
|
protected:
|
|
// 重写事件过滤器
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
void showEvent(QShowEvent* event) override;
|
|
|
|
private slots:
|
|
void onSceneFocusedItemPosChanged(QPoint p);
|
|
void onBtn3DClicked();
|
|
void onImageLoaderAccepted();
|
|
void onBtnItemConfigClicked();
|
|
void onItemEditorAccepted();
|
|
|
|
void on_cbResolution_currentIndexChanged(int index);
|
|
|
|
void addDateItem();
|
|
|
|
void onBtnArrowClicked();
|
|
|
|
// 复制
|
|
void on_btn_copy_clicked();
|
|
|
|
// 粘贴
|
|
void on_btn_paste_clicked();
|
|
|
|
void onBtnSaveAsClicked();
|
|
|
|
private:
|
|
// UI对象
|
|
Ui::TestPrintWidget ui;
|
|
SysPara* sysPara = nullptr;
|
|
|
|
// 控件成员变量(关联UI控件)
|
|
QButtonGroup* m_ButtonGroup;
|
|
QTextEdit* m_TextEdit = nullptr;
|
|
QLineEdit* m_LineEdit;
|
|
|
|
/**
|
|
* @brief 对 on_KeyUp_clicked 等按键事件的简便包装
|
|
*
|
|
* @param key
|
|
*/
|
|
void moveSelectedItem(Qt::Key key);
|
|
|
|
PicScene *pPicScene = nullptr; //保存Item的Html
|
|
QGraphicsView *pViewer = nullptr;
|
|
PicTextItem *textItem = nullptr;
|
|
|
|
PrintSetting* m_printSetting = nullptr;
|
|
|
|
PrintSettingModel m_printSettingModel;
|
|
|
|
QString xmlfileName;
|
|
DialogSaveFile *dialogSaveFile;
|
|
|
|
ImageLoader *imageLoader = nullptr;
|
|
ItemEditor * itemEditor = nullptr;
|
|
BarcodeEditor m_barcodeEditor;
|
|
|
|
int editMode;
|
|
//寻找当前选中的图层,没有选中的就不继续处理
|
|
int checkSelectScene();
|
|
|
|
int x_item = 0;
|
|
// 复制
|
|
int pasteTime = 1;
|
|
SourceType m_copiedSourceType = SourceType::UNKNOWN;
|
|
QVariant m_copiedSourceValue;
|
|
QXmlStreamAttributes m_copiedAttrs;
|
|
QString m_copiedHtml;
|
|
bool m_copiedSpecialConditions = false;
|
|
int m_copiedCatchCnt1StartValue = -1;
|
|
int m_copiedCatchCnt1CurrValue = -1;
|
|
int m_copiedCounterType = COUNTER_TYPE_1;
|
|
int m_copiedCounterDigitalNum = 1;
|
|
int m_copiedCounterLetterSpace = 1;
|
|
QString m_copiedCounterFontFamily = "WenQuanYi7";
|
|
QPointF m_copiedPos;
|
|
//判断要复制什么图层,添加该图层
|
|
PicTextItem* checkSelectItem(PicTextItem* srcItem);
|
|
|
|
//保存复制内容
|
|
bool cacheSelectedLayerForPaste(PicTextItem* srcItem);
|
|
|
|
//粘贴
|
|
void pasteCopiedLayer();
|
|
|
|
void selectItemByDirection(bool forward);
|
|
|
|
signals:
|
|
|
|
void sendButtonClickedSignal(int index);
|
|
|
|
void sig_showEditCounter(CounterViewModel viewModel, bool isChange);
|
|
|
|
// 用户请求打开日期类型图元编辑窗口时发送此信号
|
|
void sig_showEditDateTime(DateItemModel dateModel, TextItemModel textModel);
|
|
|
|
void sig_showScheduleShiftsEditor(QVector<ScheduleModel> schedules, TextItemModel txtModel);
|
|
|
|
// 点击确定后,更新打印内容
|
|
void sig_switchWorkFileRequested(const QString& filename);
|
|
|
|
void sig_currentFileChanged();
|
|
};
|
|
|
|
#endif // TESTPRINTWIDGET_H
|