修改文件换行符,修正轮班图元长度计算问题

This commit is contained in:
2026-08-19 11:55:10 +08:00
parent 176b53b654
commit a274b75705
116 changed files with 68711 additions and 68660 deletions
+533 -533
View File
File diff suppressed because it is too large Load Diff
+192 -192
View File
@@ -1,192 +1,192 @@
#ifndef BARCODEEDITOR_H
#define BARCODEEDITOR_H
#include <QDialog>
#include "ViewModels.h"
#include "SysPara.h"
#include "dlgQrcodeFormat.h"
#include "DlgBarcodeFormat.h"
#include <QVariant>
#include "ItemGeneralSettings.h"
class DateFormatEditor;
class DateReplaceEditor;
class CounterEditor;
enum BarcodeType {
BARCODE_TYPE_BARCODE = 0,
BARCODE_TYPE_QRCODE = 1,
BARCODE_TYPE_DMCODE = 2,
};
/**
* @brief 条码设置界面所用的视图模型
*
* @remark contentPattern 内可包含变量,如 {t} 表示日期/时间、{c} 表示计数器。
* 仅当 contentPattern 含有相应变量时,counterViewModel / dateViewModel 字段才有意义。
*/
struct BarcodeViewModel {
TextItemModel generalSettingsVM; // 通用设置视图模型
QString contentPattern; // 条形码内容模版,例如 "ABC{t}{c1}"
CounterViewModel counterViewModel; // 计数器视图模型
DateItemModel dateViewModel; // 日期视图模型
BarcodeType type = BARCODE_TYPE_BARCODE; // 条形码 或 二维码
QVariant format; // 条形码/二维码 格式设置,如果是条形码,则实际类型为 DlgBarcodeFormatVM,如果是二维码,则实际类型为 DlgQrcodeFormatVM
std::function<QImage()> imageGenerator; // 条形码/二维码 图片生成函数
/**
* @brief 将vm保存到xml属性集
*
* @param vm 条码视图模型
* @param attrs xml属性集
*/
static void saveToXml(const BarcodeViewModel& vm, QXmlStreamAttributes& attrs);
/**
* @brief 从xml属性集加载条码视图模型
*
* @param attrs xml属性集
* @return BarcodeViewModel 条码视图模型
*/
static BarcodeViewModel loadFromXml(const QXmlStreamAttributes& attrs);
/**
* @brief
*
* @param vm 条码视图模型
* @return QString 字符串表示
*
* @example
* type: 0
* contentPattern: ABC{t}{c1}
* counterViewModel:
* \t counter type: 7
* \t digital number: 2
* \t letter space: 2
* dateViewModel:
* \t pattern: "yyyy-MM-dd HH:mm:ss"
* \t expirationValue: 0
* \t expirationType: 0
* format:
* \t type: "BARCODE_128"
* \t height: 9
* \t width: 36
* \t scale: 1
* \t inkType: 0
* \t txtVisible: false
*/
static QString toString(const BarcodeViewModel& vm);
};
Q_DECLARE_METATYPE(BarcodeViewModel);
namespace Ui {
class BarcodeEditor;
}
class BarcodeEditor : public QDialog
{
Q_OBJECT
public:
explicit BarcodeEditor(QWidget *parent = nullptr);
~BarcodeEditor();
/**
* @brief 注入条形码视图模型(纯结构体,按值拷贝)
*
* @param vm
*/
void bindViewModel(const BarcodeViewModel& vm);
/**
* @brief 获取当前视图模型
*
* @note 调用前会先从各子编辑器收集最新值回写到内部 m_vm,再返回。
*
* @return BarcodeViewModel
*/
BarcodeViewModel viewModel();
void restoreViewModel();
void applyCounterConfigToSysPara();
private slots:
/**
* @brief 条形码内容改变时触发
*
* @param content
*/
void onContentChanged(QString content);
/**
* @brief 条形码、二维码格式更改按钮点击时触发
*
*/
void onBtnFormatClicked();
/**
* @brief 日期按钮点击时触发
*
*/
void onBtnDatetimeClicked();
/**
* @brief 计数器按钮点击时触发
*
*/
void onBtnCounterClicked();
/**
* @brief 确定按钮点击时触发
*
*/
void onCheckBtnClicked();
/**
* @brief 取消按钮点击时触发
*
*/
void onCloseBtnClicked();
/**
* @brief 条形码格式确认时触发
*
*/
void onBarcodeFormatConfirmed();
/**
* @brief 二维码格式确认时触发
*
*/
void onQrcodeFormatConfirmed();
void onTypeChanged(int i);
void on_cbBoxType_currentIndexChanged(int index);
protected:
virtual bool eventFilter(QObject* obj, QEvent* event) override;
private:
Ui::BarcodeEditor *ui;
void applyStyleSheet();
BarcodeViewModel m_vm;
DateFormatEditor *m_dateFormatEditor = nullptr;
DateReplaceEditor *m_dateReplaceEditor = nullptr;
CounterEditor *m_counterEditor = nullptr;
SysPara* m_sysPara = nullptr;
DlgBarcodeFormat m_barcodeFormatEditor;
DlgQrcodeFormat m_qrcodeFormatEditor;
};
#endif // BARCODEEDITOR_H
#ifndef BARCODEEDITOR_H
#define BARCODEEDITOR_H
#include <QDialog>
#include "ViewModels.h"
#include "SysPara.h"
#include "dlgQrcodeFormat.h"
#include "DlgBarcodeFormat.h"
#include <QVariant>
#include "ItemGeneralSettings.h"
class DateFormatEditor;
class DateReplaceEditor;
class CounterEditor;
enum BarcodeType {
BARCODE_TYPE_BARCODE = 0,
BARCODE_TYPE_QRCODE = 1,
BARCODE_TYPE_DMCODE = 2,
};
/**
* @brief 条码设置界面所用的视图模型
*
* @remark contentPattern 内可包含变量,如 {t} 表示日期/时间、{c} 表示计数器。
* 仅当 contentPattern 含有相应变量时,counterViewModel / dateViewModel 字段才有意义。
*/
struct BarcodeViewModel {
TextItemModel generalSettingsVM; // 通用设置视图模型
QString contentPattern; // 条形码内容模版,例如 "ABC{t}{c1}"
CounterViewModel counterViewModel; // 计数器视图模型
DateItemModel dateViewModel; // 日期视图模型
BarcodeType type = BARCODE_TYPE_BARCODE; // 条形码 或 二维码
QVariant format; // 条形码/二维码 格式设置,如果是条形码,则实际类型为 DlgBarcodeFormatVM,如果是二维码,则实际类型为 DlgQrcodeFormatVM
std::function<QImage()> imageGenerator; // 条形码/二维码 图片生成函数
/**
* @brief 将vm保存到xml属性集
*
* @param vm 条码视图模型
* @param attrs xml属性集
*/
static void saveToXml(const BarcodeViewModel& vm, QXmlStreamAttributes& attrs);
/**
* @brief 从xml属性集加载条码视图模型
*
* @param attrs xml属性集
* @return BarcodeViewModel 条码视图模型
*/
static BarcodeViewModel loadFromXml(const QXmlStreamAttributes& attrs);
/**
* @brief
*
* @param vm 条码视图模型
* @return QString 字符串表示
*
* @example
* type: 0
* contentPattern: ABC{t}{c1}
* counterViewModel:
* \t counter type: 7
* \t digital number: 2
* \t letter space: 2
* dateViewModel:
* \t pattern: "yyyy-MM-dd HH:mm:ss"
* \t expirationValue: 0
* \t expirationType: 0
* format:
* \t type: "BARCODE_128"
* \t height: 9
* \t width: 36
* \t scale: 1
* \t inkType: 0
* \t txtVisible: false
*/
static QString toString(const BarcodeViewModel& vm);
};
Q_DECLARE_METATYPE(BarcodeViewModel);
namespace Ui {
class BarcodeEditor;
}
class BarcodeEditor : public QDialog
{
Q_OBJECT
public:
explicit BarcodeEditor(QWidget *parent = nullptr);
~BarcodeEditor();
/**
* @brief 注入条形码视图模型(纯结构体,按值拷贝)
*
* @param vm
*/
void bindViewModel(const BarcodeViewModel& vm);
/**
* @brief 获取当前视图模型
*
* @note 调用前会先从各子编辑器收集最新值回写到内部 m_vm,再返回。
*
* @return BarcodeViewModel
*/
BarcodeViewModel viewModel();
void restoreViewModel();
void applyCounterConfigToSysPara();
private slots:
/**
* @brief 条形码内容改变时触发
*
* @param content
*/
void onContentChanged(QString content);
/**
* @brief 条形码、二维码格式更改按钮点击时触发
*
*/
void onBtnFormatClicked();
/**
* @brief 日期按钮点击时触发
*
*/
void onBtnDatetimeClicked();
/**
* @brief 计数器按钮点击时触发
*
*/
void onBtnCounterClicked();
/**
* @brief 确定按钮点击时触发
*
*/
void onCheckBtnClicked();
/**
* @brief 取消按钮点击时触发
*
*/
void onCloseBtnClicked();
/**
* @brief 条形码格式确认时触发
*
*/
void onBarcodeFormatConfirmed();
/**
* @brief 二维码格式确认时触发
*
*/
void onQrcodeFormatConfirmed();
void onTypeChanged(int i);
void on_cbBoxType_currentIndexChanged(int index);
protected:
virtual bool eventFilter(QObject* obj, QEvent* event) override;
private:
Ui::BarcodeEditor *ui;
void applyStyleSheet();
BarcodeViewModel m_vm;
DateFormatEditor *m_dateFormatEditor = nullptr;
DateReplaceEditor *m_dateReplaceEditor = nullptr;
CounterEditor *m_counterEditor = nullptr;
SysPara* m_sysPara = nullptr;
DlgBarcodeFormat m_barcodeFormatEditor;
DlgQrcodeFormat m_qrcodeFormatEditor;
};
#endif // BARCODEEDITOR_H
+484 -484
View File
@@ -1,484 +1,484 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BarcodeEditor</class>
<widget class="QDialog" name="BarcodeEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font-size: 16px;
}
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QSpinBox::up-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::up-arrow {
image: url(:/image/up_white.png);
}
QSpinBox::down-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::down-arrow {
image: url(:/image/down_white.png);
}
</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<widget class="QPushButton" name="checkBtn">
<property name="geometry">
<rect>
<x>520</x>
<y>540</y>
<width>101</width>
<height>40</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>✓</string>
</property>
</widget>
<widget class="QPushButton" name="closeBtn">
<property name="geometry">
<rect>
<x>640</x>
<y>540</y>
<width>101</width>
<height>40</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>✕</string>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>771</width>
<height>471</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"> QTabWidget {
border: none;
background-color: #7B838E;
}
QTabBar::tab {
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tabGeneralSettings">
<attribute name="title">
<string>整体设置</string>
</attribute>
<widget class="ItemGeneralSettings" name="widGeneralSettings" native="true">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>771</width>
<height>441</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="tabBarcode">
<attribute name="title">
<string>条形码</string>
</attribute>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>20</y>
<width>81</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>内容</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditContent">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>481</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>110</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>类型</string>
</property>
</widget>
<widget class="QComboBox" name="cbBoxType">
<property name="geometry">
<rect>
<x>40</x>
<y>140</y>
<width>191</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>条形码</string>
</property>
</item>
<item>
<property name="text">
<string>QRCode</string>
</property>
</item>
<item>
<property name="text">
<string>DataMatrix</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="btnFormat">
<property name="geometry">
<rect>
<x>260</x>
<y>140</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>码格式</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>420</x>
<y>120</y>
<width>261</width>
<height>231</height>
</rect>
</property>
<property name="title">
<string>嵌入</string>
</property>
<widget class="QPushButton" name="btnDatetime">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>日期</string>
</property>
</widget>
<widget class="QPushButton" name="btnCounter1">
<property name="geometry">
<rect>
<x>60</x>
<y>90</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>计数器</string>
</property>
</widget>
</widget>
</widget>
</widget>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>38</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:#4E679F;</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="styleSheet">
<string notr="true">color:#ffffff;</string>
</property>
<property name="text">
<string>条形码编辑</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ItemGeneralSettings</class>
<extends>QWidget</extends>
<header>scene/ItemGeneralSettings.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>lineEditContent</sender>
<signal>textChanged(QString)</signal>
<receiver>BarcodeEditor</receiver>
<slot>onContentChanged(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>144</y>
</hint>
<hint type="destinationlabel">
<x>-130</x>
<y>136</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnFormat</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onBtnFormatClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>412</x>
<y>231</y>
</hint>
<hint type="destinationlabel">
<x>895</x>
<y>230</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnDatetime</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onBtnDatetimeClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>562</x>
<y>255</y>
</hint>
<hint type="destinationlabel">
<x>915</x>
<y>326</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnCounter1</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onBtnCounterClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>553</x>
<y>300</y>
</hint>
<hint type="destinationlabel">
<x>819</x>
<y>382</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBtn</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onCheckBtnClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>543</x>
<y>558</y>
</hint>
<hint type="destinationlabel">
<x>581</x>
<y>705</y>
</hint>
</hints>
</connection>
<connection>
<sender>closeBtn</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onCloseBtnClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>689</x>
<y>561</y>
</hint>
<hint type="destinationlabel">
<x>708</x>
<y>734</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onContentChanged(QString)</slot>
<slot>onBtnFormatClicked()</slot>
<slot>onBtnDatetimeClicked()</slot>
<slot>onBtnCounterClicked()</slot>
<slot>onCheckBtnClicked()</slot>
<slot>onCloseBtnClicked()</slot>
</slots>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BarcodeEditor</class>
<widget class="QDialog" name="BarcodeEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font-size: 16px;
}
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QSpinBox::up-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::up-arrow {
image: url(:/image/up_white.png);
}
QSpinBox::down-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::down-arrow {
image: url(:/image/down_white.png);
}
</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<widget class="QPushButton" name="checkBtn">
<property name="geometry">
<rect>
<x>520</x>
<y>540</y>
<width>101</width>
<height>40</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>✓</string>
</property>
</widget>
<widget class="QPushButton" name="closeBtn">
<property name="geometry">
<rect>
<x>640</x>
<y>540</y>
<width>101</width>
<height>40</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>✕</string>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>771</width>
<height>471</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"> QTabWidget {
border: none;
background-color: #7B838E;
}
QTabBar::tab {
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tabGeneralSettings">
<attribute name="title">
<string>整体设置</string>
</attribute>
<widget class="ItemGeneralSettings" name="widGeneralSettings" native="true">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>771</width>
<height>441</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="tabBarcode">
<attribute name="title">
<string>条形码</string>
</attribute>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>20</y>
<width>81</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>内容</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditContent">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>481</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>110</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>类型</string>
</property>
</widget>
<widget class="QComboBox" name="cbBoxType">
<property name="geometry">
<rect>
<x>40</x>
<y>140</y>
<width>191</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>条形码</string>
</property>
</item>
<item>
<property name="text">
<string>QRCode</string>
</property>
</item>
<item>
<property name="text">
<string>DataMatrix</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="btnFormat">
<property name="geometry">
<rect>
<x>260</x>
<y>140</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>码格式</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>420</x>
<y>120</y>
<width>261</width>
<height>231</height>
</rect>
</property>
<property name="title">
<string>嵌入</string>
</property>
<widget class="QPushButton" name="btnDatetime">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>日期</string>
</property>
</widget>
<widget class="QPushButton" name="btnCounter1">
<property name="geometry">
<rect>
<x>60</x>
<y>90</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>计数器</string>
</property>
</widget>
</widget>
</widget>
</widget>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>38</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:#4E679F;</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="styleSheet">
<string notr="true">color:#ffffff;</string>
</property>
<property name="text">
<string>条形码编辑</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ItemGeneralSettings</class>
<extends>QWidget</extends>
<header>scene/ItemGeneralSettings.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>lineEditContent</sender>
<signal>textChanged(QString)</signal>
<receiver>BarcodeEditor</receiver>
<slot>onContentChanged(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>144</y>
</hint>
<hint type="destinationlabel">
<x>-130</x>
<y>136</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnFormat</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onBtnFormatClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>412</x>
<y>231</y>
</hint>
<hint type="destinationlabel">
<x>895</x>
<y>230</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnDatetime</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onBtnDatetimeClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>562</x>
<y>255</y>
</hint>
<hint type="destinationlabel">
<x>915</x>
<y>326</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnCounter1</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onBtnCounterClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>553</x>
<y>300</y>
</hint>
<hint type="destinationlabel">
<x>819</x>
<y>382</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBtn</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onCheckBtnClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>543</x>
<y>558</y>
</hint>
<hint type="destinationlabel">
<x>581</x>
<y>705</y>
</hint>
</hints>
</connection>
<connection>
<sender>closeBtn</sender>
<signal>clicked()</signal>
<receiver>BarcodeEditor</receiver>
<slot>onCloseBtnClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>689</x>
<y>561</y>
</hint>
<hint type="destinationlabel">
<x>708</x>
<y>734</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onContentChanged(QString)</slot>
<slot>onBtnFormatClicked()</slot>
<slot>onBtnDatetimeClicked()</slot>
<slot>onBtnCounterClicked()</slot>
<slot>onCheckBtnClicked()</slot>
<slot>onCloseBtnClicked()</slot>
</slots>
</ui>
+137 -137
View File
@@ -1,138 +1,138 @@
#include "CounterEditor.h"
#include "ui_CounterEditor.h"
#include "ViewModels.h"
CounterEditor::CounterEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::CounterEditor)
{
ui->setupUi(this);
connect(ui->checkBoxResetCnt2CurrValue, &QCheckBox::toggled,
this, &CounterEditor::onEditCurrValueToggled);
connect(ui->cbBoxCounterType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onCounterTypeChanged);
connect(ui->cbBoxDigitalNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onDigitalNumChanged);
connect(ui->spinBoxCnt2StartValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2EndValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2RepeateCnt, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2StepValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2CurrValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->checkBoxResetCnt2CurrValue, &QCheckBox::clicked, this, [this](bool) {fetchCounterConfigFromView();} );
connect(ui->eleCNT2IncEn, &QCheckBox::clicked, this, [this](bool) {fetchCounterConfigFromView();} );
setViewModel(m_vm);
}
CounterEditor::~CounterEditor()
{
delete ui;
}
/**
* @brief 设置视图模型并将其更新至UI
*
* @param vm
*/
void CounterEditor::setViewModel(CounterEditorVM vm)
{
m_vm = std::move(vm);
// 根据 VM 中的当前计数器ID 确定显示哪个计数器的配置
CounterEditorVM::CounterSlot& cnt = m_vm.counterType == COUNTER_TYPE_1 ? m_vm.counter1 : m_vm.counter2;
auto b = ui->spinBoxCnt2StartValue->blockSignals(true);
ui->spinBoxCnt2StartValue->setValue(cnt.startValue);
ui->spinBoxCnt2StartValue->blockSignals(b);
b = ui->spinBoxCnt2EndValue->blockSignals(true);
ui->spinBoxCnt2EndValue->setValue(cnt.endValue);
ui->spinBoxCnt2EndValue->blockSignals(b);
b = ui->spinBoxCnt2RepeateCnt->blockSignals(true);
ui->spinBoxCnt2RepeateCnt->setValue(cnt.repeatValue);
ui->spinBoxCnt2RepeateCnt->blockSignals(b);
b = ui->spinBoxCnt2StepValue->blockSignals(true);
ui->spinBoxCnt2StepValue->setValue(cnt.stepValue);
ui->spinBoxCnt2StepValue->blockSignals(b);
b = ui->spinBoxCnt2CurrValue->blockSignals(true);
ui->spinBoxCnt2CurrValue->setValue(cnt.currValue);
ui->spinBoxCnt2CurrValue->blockSignals(b);
b = ui->checkBoxResetCnt2CurrValue->blockSignals(true);
ui->checkBoxResetCnt2CurrValue->setChecked(cnt.editCurrValue);
ui->checkBoxResetCnt2CurrValue->blockSignals(b);
b = ui->eleCNT2IncEn->blockSignals(true);
ui->eleCNT2IncEn->setChecked(cnt.eleEyeIncEn);
ui->eleCNT2IncEn->blockSignals(b);
ui->spinBoxCnt2CurrValue->setEnabled(cnt.editCurrValue);
ui->labelCnt2CurrValue->setText(QString::number(cnt.currValue));
b = ui->cbBoxCounterType->blockSignals(true);
ui->cbBoxCounterType->setCurrentIndex(m_vm.counterType == COUNTER_TYPE_1 ? 0 : 1);
ui->cbBoxCounterType->blockSignals(b);
b = ui->cbBoxDigitalNum->blockSignals(true);
ui->cbBoxDigitalNum->setCurrentIndex(m_vm.digitalNum - 1);
ui->cbBoxDigitalNum->blockSignals(b);
}
/**
* @brief 从界面获取最新配置以刷新视图模型
*
* @return CounterEditorVM 最新的视图模型
*/
CounterEditorVM CounterEditor::viewModel()
{
m_vm.counterType = ui->cbBoxCounterType->currentIndex() == 0 ? COUNTER_TYPE_1 : COUNTER_TYPE_2;
m_vm.digitalNum = ui->cbBoxDigitalNum->currentIndex() + 1;
fetchCounterConfigFromView();
return m_vm;
}
void CounterEditor::onCounterTypeChanged(int i)
{
i = std::max(i, 0);
m_vm.counterType = i == 0 ? COUNTER_TYPE_1 : COUNTER_TYPE_2;
setViewModel(m_vm);
}
void CounterEditor::onDigitalNumChanged(int i)
{
i = std::max(i, 0);
m_vm.digitalNum = i + 1;
}
/**
* @brief 从界面拉取计数器配置
*
* 根据当前所选的计数器ID更新对应的计数器配置
*
*/
void CounterEditor::fetchCounterConfigFromView()
{
CounterEditorVM::CounterSlot& cnt = m_vm.counterType == COUNTER_TYPE_1 ? m_vm.counter1 : m_vm.counter2;
cnt.startValue = ui->spinBoxCnt2StartValue->value();
cnt.endValue = ui->spinBoxCnt2EndValue->value();
cnt.repeatValue = ui->spinBoxCnt2RepeateCnt->value();
cnt.stepValue = ui->spinBoxCnt2StepValue->value();
cnt.currValue = ui->spinBoxCnt2CurrValue->value();
cnt.editCurrValue = ui->checkBoxResetCnt2CurrValue->isChecked();
cnt.eleEyeIncEn = ui->eleCNT2IncEn->isChecked();
}
/**
* @brief 简单启用对应SpinBox
*
*/
void CounterEditor::onEditCurrValueToggled()
{
ui->spinBoxCnt2CurrValue->setEnabled(ui->checkBoxResetCnt2CurrValue->isChecked());
#include "CounterEditor.h"
#include "ui_CounterEditor.h"
#include "ViewModels.h"
CounterEditor::CounterEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::CounterEditor)
{
ui->setupUi(this);
connect(ui->checkBoxResetCnt2CurrValue, &QCheckBox::toggled,
this, &CounterEditor::onEditCurrValueToggled);
connect(ui->cbBoxCounterType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onCounterTypeChanged);
connect(ui->cbBoxDigitalNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CounterEditor::onDigitalNumChanged);
connect(ui->spinBoxCnt2StartValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2EndValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2RepeateCnt, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2StepValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->spinBoxCnt2CurrValue, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int) {fetchCounterConfigFromView();} );
connect(ui->checkBoxResetCnt2CurrValue, &QCheckBox::clicked, this, [this](bool) {fetchCounterConfigFromView();} );
connect(ui->eleCNT2IncEn, &QCheckBox::clicked, this, [this](bool) {fetchCounterConfigFromView();} );
setViewModel(m_vm);
}
CounterEditor::~CounterEditor()
{
delete ui;
}
/**
* @brief 设置视图模型并将其更新至UI
*
* @param vm
*/
void CounterEditor::setViewModel(CounterEditorVM vm)
{
m_vm = std::move(vm);
// 根据 VM 中的当前计数器ID 确定显示哪个计数器的配置
CounterEditorVM::CounterSlot& cnt = m_vm.counterType == COUNTER_TYPE_1 ? m_vm.counter1 : m_vm.counter2;
auto b = ui->spinBoxCnt2StartValue->blockSignals(true);
ui->spinBoxCnt2StartValue->setValue(cnt.startValue);
ui->spinBoxCnt2StartValue->blockSignals(b);
b = ui->spinBoxCnt2EndValue->blockSignals(true);
ui->spinBoxCnt2EndValue->setValue(cnt.endValue);
ui->spinBoxCnt2EndValue->blockSignals(b);
b = ui->spinBoxCnt2RepeateCnt->blockSignals(true);
ui->spinBoxCnt2RepeateCnt->setValue(cnt.repeatValue);
ui->spinBoxCnt2RepeateCnt->blockSignals(b);
b = ui->spinBoxCnt2StepValue->blockSignals(true);
ui->spinBoxCnt2StepValue->setValue(cnt.stepValue);
ui->spinBoxCnt2StepValue->blockSignals(b);
b = ui->spinBoxCnt2CurrValue->blockSignals(true);
ui->spinBoxCnt2CurrValue->setValue(cnt.currValue);
ui->spinBoxCnt2CurrValue->blockSignals(b);
b = ui->checkBoxResetCnt2CurrValue->blockSignals(true);
ui->checkBoxResetCnt2CurrValue->setChecked(cnt.editCurrValue);
ui->checkBoxResetCnt2CurrValue->blockSignals(b);
b = ui->eleCNT2IncEn->blockSignals(true);
ui->eleCNT2IncEn->setChecked(cnt.eleEyeIncEn);
ui->eleCNT2IncEn->blockSignals(b);
ui->spinBoxCnt2CurrValue->setEnabled(cnt.editCurrValue);
ui->labelCnt2CurrValue->setText(QString::number(cnt.currValue));
b = ui->cbBoxCounterType->blockSignals(true);
ui->cbBoxCounterType->setCurrentIndex(m_vm.counterType == COUNTER_TYPE_1 ? 0 : 1);
ui->cbBoxCounterType->blockSignals(b);
b = ui->cbBoxDigitalNum->blockSignals(true);
ui->cbBoxDigitalNum->setCurrentIndex(m_vm.digitalNum - 1);
ui->cbBoxDigitalNum->blockSignals(b);
}
/**
* @brief 从界面获取最新配置以刷新视图模型
*
* @return CounterEditorVM 最新的视图模型
*/
CounterEditorVM CounterEditor::viewModel()
{
m_vm.counterType = ui->cbBoxCounterType->currentIndex() == 0 ? COUNTER_TYPE_1 : COUNTER_TYPE_2;
m_vm.digitalNum = ui->cbBoxDigitalNum->currentIndex() + 1;
fetchCounterConfigFromView();
return m_vm;
}
void CounterEditor::onCounterTypeChanged(int i)
{
i = std::max(i, 0);
m_vm.counterType = i == 0 ? COUNTER_TYPE_1 : COUNTER_TYPE_2;
setViewModel(m_vm);
}
void CounterEditor::onDigitalNumChanged(int i)
{
i = std::max(i, 0);
m_vm.digitalNum = i + 1;
}
/**
* @brief 从界面拉取计数器配置
*
* 根据当前所选的计数器ID更新对应的计数器配置
*
*/
void CounterEditor::fetchCounterConfigFromView()
{
CounterEditorVM::CounterSlot& cnt = m_vm.counterType == COUNTER_TYPE_1 ? m_vm.counter1 : m_vm.counter2;
cnt.startValue = ui->spinBoxCnt2StartValue->value();
cnt.endValue = ui->spinBoxCnt2EndValue->value();
cnt.repeatValue = ui->spinBoxCnt2RepeateCnt->value();
cnt.stepValue = ui->spinBoxCnt2StepValue->value();
cnt.currValue = ui->spinBoxCnt2CurrValue->value();
cnt.editCurrValue = ui->checkBoxResetCnt2CurrValue->isChecked();
cnt.eleEyeIncEn = ui->eleCNT2IncEn->isChecked();
}
/**
* @brief 简单启用对应SpinBox
*
*/
void CounterEditor::onEditCurrValueToggled()
{
ui->spinBoxCnt2CurrValue->setEnabled(ui->checkBoxResetCnt2CurrValue->isChecked());
}
+71 -71
View File
@@ -1,71 +1,71 @@
#ifndef COUNTEREDITOR_H
#define COUNTEREDITOR_H
#include <QWidget>
namespace Ui {
class CounterEditor;
}
/**
* @brief 用于 CounterEditor 的视图模型
*
* 包含了计数器ID、计数器位数以及各个计数器当前的配置
*
*/
struct CounterEditorVM {
int counterType = 7;
int digitalNum = 2;
struct CounterSlot {
int startValue = 1;
int endValue = 9999;
int repeatValue = 1;
int stepValue = 1;
int currValue = 1;
bool editCurrValue = false; // 对应 checkBoxResetCnt2CurrValue:勾选才允许重置/编辑当前值
bool eleEyeIncEn = false; // 对应 eleCNT2IncEn:电眼触发使计数器+1
};
CounterSlot counter1, counter2;
};
using CounterSettings = CounterEditorVM::CounterSlot;
class CounterEditor : public QWidget
{
Q_OBJECT
public:
explicit CounterEditor(QWidget *parent = nullptr);
~CounterEditor();
/**
* @brief 设置 UI 所用的视图模型
*
* @param vm
*/
void setViewModel(CounterEditorVM vm);
/**
* @brief 获取 UI 当前的视图模型
*
* @return CounterEditorVM
*/
CounterEditorVM viewModel();
private slots:
void onEditCurrValueToggled();
void onCounterTypeChanged(int i);
void onDigitalNumChanged(int i);
private:
void fetchCounterConfigFromView();
Ui::CounterEditor *ui;
CounterEditorVM m_vm;
};
#endif // COUNTEREDITOR_H
#ifndef COUNTEREDITOR_H
#define COUNTEREDITOR_H
#include <QWidget>
namespace Ui {
class CounterEditor;
}
/**
* @brief 用于 CounterEditor 的视图模型
*
* 包含了计数器ID、计数器位数以及各个计数器当前的配置
*
*/
struct CounterEditorVM {
int counterType = 7;
int digitalNum = 2;
struct CounterSlot {
int startValue = 1;
int endValue = 9999;
int repeatValue = 1;
int stepValue = 1;
int currValue = 1;
bool editCurrValue = false; // 对应 checkBoxResetCnt2CurrValue:勾选才允许重置/编辑当前值
bool eleEyeIncEn = false; // 对应 eleCNT2IncEn:电眼触发使计数器+1
};
CounterSlot counter1, counter2;
};
using CounterSettings = CounterEditorVM::CounterSlot;
class CounterEditor : public QWidget
{
Q_OBJECT
public:
explicit CounterEditor(QWidget *parent = nullptr);
~CounterEditor();
/**
* @brief 设置 UI 所用的视图模型
*
* @param vm
*/
void setViewModel(CounterEditorVM vm);
/**
* @brief 获取 UI 当前的视图模型
*
* @return CounterEditorVM
*/
CounterEditorVM viewModel();
private slots:
void onEditCurrValueToggled();
void onCounterTypeChanged(int i);
void onDigitalNumChanged(int i);
private:
void fetchCounterConfigFromView();
Ui::CounterEditor *ui;
CounterEditorVM m_vm;
};
#endif // COUNTEREDITOR_H
+796 -796
View File
File diff suppressed because it is too large Load Diff
+104 -104
View File
@@ -1,105 +1,105 @@
#include "DateFormatEditor.h"
#include "ui_DateFormatEditor.h"
DateFormatEditor::DateFormatEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::DateFormatEditor)
{
ui->setupUi(this);
connect(ui->btnPoint,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnColon,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnComma,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSlash,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSemicolon,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnUnderline,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnDash,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnBackSpace,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnHour,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnMinute,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSecond,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnDay,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnMonth,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnYear4,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnYear2,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnWeekOfYear,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnWeek,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSpace, &QPushButton::clicked, this, &DateFormatEditor::buttonClickedSlot);
setViewModel(m_vm);
}
DateFormatEditor::~DateFormatEditor()
{
delete ui;
}
void DateFormatEditor::setViewModel(DateFormatEditorVM vm)
{
m_vm = std::move(vm);
auto b = ui->lineEdit_DateFormat->blockSignals(true);
ui->lineEdit_DateFormat->setText(m_vm.pattern);
ui->lineEdit_DateFormat->blockSignals(b);
b = ui->expirationNumCBox->blockSignals(true);
ui->expirationNumCBox->setValue(m_vm.expirationValue);
ui->expirationNumCBox->blockSignals(b);
b = ui->expirationCBox->blockSignals(true);
ui->expirationCBox->setCurrentIndex(m_vm.expirationType);
ui->expirationCBox->blockSignals(b);
}
DateFormatEditorVM DateFormatEditor::viewModel()
{
m_vm.pattern = ui->lineEdit_DateFormat->text();
m_vm.expirationValue = ui->expirationNumCBox->value();
m_vm.expirationType = (EXPIRATION_TYPE)(ui->expirationCBox->currentIndex());
return m_vm;
}
void DateFormatEditor::buttonClickedSlot()
{
QPushButton* btn = qobject_cast<QPushButton*>(sender());
if(btn == ui->btnPoint){
ui->lineEdit_DateFormat->insert(".");
}else if(btn == ui->btnColon){
ui->lineEdit_DateFormat->insert(":");
}else if(btn == ui->btnComma){
ui->lineEdit_DateFormat->insert(",");
}else if(btn == ui->btnSlash){
ui->lineEdit_DateFormat->insert("/");
}else if(btn == ui->btnSemicolon){
ui->lineEdit_DateFormat->insert(";");
}else if(btn == ui->btnUnderline){
ui->lineEdit_DateFormat->insert("_");
}else if(btn == ui->btnDash){
ui->lineEdit_DateFormat->insert("-");
}else if(btn == ui->btnBackSpace){
ui->lineEdit_DateFormat->backspace();
}else if(btn == ui->btnHour){
ui->lineEdit_DateFormat->insert("HH");
}else if(btn == ui->btnMinute){
ui->lineEdit_DateFormat->insert("mm");
}else if(btn == ui->btnSecond){
ui->lineEdit_DateFormat->insert("ss");
}else if(btn == ui->btnDay){
ui->lineEdit_DateFormat->insert("dd");
}else if(btn == ui->btnMonth){
ui->lineEdit_DateFormat->insert("MM");
}else if(btn == ui->btnYear4){
ui->lineEdit_DateFormat->insert("yyyy");
}else if(btn == ui->btnYear2){
ui->lineEdit_DateFormat->insert("YY");
}
else if(btn == ui->btnWeekOfYear){
ui->lineEdit_DateFormat->insert("c");
}
else if(btn == ui->btnWeek){
ui->lineEdit_DateFormat->insert("w");
}
else if(btn == ui->btnSpace)
ui->lineEdit_DateFormat->insert(" ");
#include "DateFormatEditor.h"
#include "ui_DateFormatEditor.h"
DateFormatEditor::DateFormatEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::DateFormatEditor)
{
ui->setupUi(this);
connect(ui->btnPoint,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnColon,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnComma,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSlash,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSemicolon,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnUnderline,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnDash,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnBackSpace,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnHour,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnMinute,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSecond,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnDay,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnMonth,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnYear4,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnYear2,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnWeekOfYear,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnWeek,&QPushButton::clicked,this,&DateFormatEditor::buttonClickedSlot);
connect(ui->btnSpace, &QPushButton::clicked, this, &DateFormatEditor::buttonClickedSlot);
setViewModel(m_vm);
}
DateFormatEditor::~DateFormatEditor()
{
delete ui;
}
void DateFormatEditor::setViewModel(DateFormatEditorVM vm)
{
m_vm = std::move(vm);
auto b = ui->lineEdit_DateFormat->blockSignals(true);
ui->lineEdit_DateFormat->setText(m_vm.pattern);
ui->lineEdit_DateFormat->blockSignals(b);
b = ui->expirationNumCBox->blockSignals(true);
ui->expirationNumCBox->setValue(m_vm.expirationValue);
ui->expirationNumCBox->blockSignals(b);
b = ui->expirationCBox->blockSignals(true);
ui->expirationCBox->setCurrentIndex(m_vm.expirationType);
ui->expirationCBox->blockSignals(b);
}
DateFormatEditorVM DateFormatEditor::viewModel()
{
m_vm.pattern = ui->lineEdit_DateFormat->text();
m_vm.expirationValue = ui->expirationNumCBox->value();
m_vm.expirationType = (EXPIRATION_TYPE)(ui->expirationCBox->currentIndex());
return m_vm;
}
void DateFormatEditor::buttonClickedSlot()
{
QPushButton* btn = qobject_cast<QPushButton*>(sender());
if(btn == ui->btnPoint){
ui->lineEdit_DateFormat->insert(".");
}else if(btn == ui->btnColon){
ui->lineEdit_DateFormat->insert(":");
}else if(btn == ui->btnComma){
ui->lineEdit_DateFormat->insert(",");
}else if(btn == ui->btnSlash){
ui->lineEdit_DateFormat->insert("/");
}else if(btn == ui->btnSemicolon){
ui->lineEdit_DateFormat->insert(";");
}else if(btn == ui->btnUnderline){
ui->lineEdit_DateFormat->insert("_");
}else if(btn == ui->btnDash){
ui->lineEdit_DateFormat->insert("-");
}else if(btn == ui->btnBackSpace){
ui->lineEdit_DateFormat->backspace();
}else if(btn == ui->btnHour){
ui->lineEdit_DateFormat->insert("HH");
}else if(btn == ui->btnMinute){
ui->lineEdit_DateFormat->insert("mm");
}else if(btn == ui->btnSecond){
ui->lineEdit_DateFormat->insert("ss");
}else if(btn == ui->btnDay){
ui->lineEdit_DateFormat->insert("dd");
}else if(btn == ui->btnMonth){
ui->lineEdit_DateFormat->insert("MM");
}else if(btn == ui->btnYear4){
ui->lineEdit_DateFormat->insert("yyyy");
}else if(btn == ui->btnYear2){
ui->lineEdit_DateFormat->insert("YY");
}
else if(btn == ui->btnWeekOfYear){
ui->lineEdit_DateFormat->insert("c");
}
else if(btn == ui->btnWeek){
ui->lineEdit_DateFormat->insert("w");
}
else if(btn == ui->btnSpace)
ui->lineEdit_DateFormat->insert(" ");
}
+46 -46
View File
@@ -1,46 +1,46 @@
#ifndef DATEFORMATEDITOR_H
#define DATEFORMATEDITOR_H
#include <QWidget>
#include "ViewModels.h"
namespace Ui {
class DateFormatEditor;
}
enum EXPIRATION_TYPE {
EXPIRATION_TYPE_NONE = -1,
EXPIRATION_TYPE_DAY,
EXPIRATION_TYPE_MONTH,
EXPIRATION_TYPE_RESERVED,
};
struct DateFormatEditorVM {
QString pattern;
int expirationValue = 0;
EXPIRATION_TYPE expirationType = EXPIRATION_TYPE_NONE;
};
class DateFormatEditor : public QWidget
{
Q_OBJECT
public:
explicit DateFormatEditor(QWidget *parent = nullptr);
~DateFormatEditor();
void setViewModel(DateFormatEditorVM vm);
DateFormatEditorVM viewModel();
private slots:
void buttonClickedSlot();
private:
Ui::DateFormatEditor *ui;
DateFormatEditorVM m_vm;
};
#endif // DATEFORMATEDITOR_H
#ifndef DATEFORMATEDITOR_H
#define DATEFORMATEDITOR_H
#include <QWidget>
#include "ViewModels.h"
namespace Ui {
class DateFormatEditor;
}
enum EXPIRATION_TYPE {
EXPIRATION_TYPE_NONE = -1,
EXPIRATION_TYPE_DAY,
EXPIRATION_TYPE_MONTH,
EXPIRATION_TYPE_RESERVED,
};
struct DateFormatEditorVM {
QString pattern;
int expirationValue = 0;
EXPIRATION_TYPE expirationType = EXPIRATION_TYPE_NONE;
};
class DateFormatEditor : public QWidget
{
Q_OBJECT
public:
explicit DateFormatEditor(QWidget *parent = nullptr);
~DateFormatEditor();
void setViewModel(DateFormatEditorVM vm);
DateFormatEditorVM viewModel();
private slots:
void buttonClickedSlot();
private:
Ui::DateFormatEditor *ui;
DateFormatEditorVM m_vm;
};
#endif // DATEFORMATEDITOR_H
+443 -443
View File
@@ -1,443 +1,443 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DateFormatEditor</class>
<widget class="QWidget" name="DateFormatEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>764</width>
<height>361</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget{
font-size: 16px;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}</string>
</property>
<widget class="QWidget" name="panel" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>761</width>
<height>361</height>
</rect>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>内容</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_DateFormat">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>60</x>
<y>50</y>
<width>371</width>
<height>30</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>470</x>
<y>26</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>有效期限</string>
</property>
</widget>
<widget class="QComboBox" name="expirationCBox">
<property name="geometry">
<rect>
<x>510</x>
<y>50</y>
<width>231</width>
<height>30</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<item>
<property name="text">
<string>天数</string>
</property>
</item>
<item>
<property name="text">
<string>月 - 精确到日</string>
</property>
</item>
<item>
<property name="text">
<string>月 - 精确到月</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="btnPoint">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>.</string>
</property>
</widget>
<widget class="QPushButton" name="btnColon">
<property name="geometry">
<rect>
<x>70</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>:</string>
</property>
</widget>
<widget class="QPushButton" name="btnComma">
<property name="geometry">
<rect>
<x>120</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>,</string>
</property>
</widget>
<widget class="QPushButton" name="btnSlash">
<property name="geometry">
<rect>
<x>170</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>/</string>
</property>
</widget>
<widget class="QPushButton" name="btnSemicolon">
<property name="geometry">
<rect>
<x>220</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>;</string>
</property>
</widget>
<widget class="QPushButton" name="btnUnderline">
<property name="geometry">
<rect>
<x>270</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
<widget class="QPushButton" name="btnDash">
<property name="geometry">
<rect>
<x>320</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QPushButton" name="btnHour">
<property name="geometry">
<rect>
<x>20</x>
<y>150</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>小时</string>
</property>
</widget>
<widget class="QPushButton" name="btnMinute">
<property name="geometry">
<rect>
<x>150</x>
<y>150</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>分钟</string>
</property>
</widget>
<widget class="QPushButton" name="btnSecond">
<property name="geometry">
<rect>
<x>270</x>
<y>150</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>秒钟</string>
</property>
</widget>
<widget class="QPushButton" name="btnMonth">
<property name="geometry">
<rect>
<x>150</x>
<y>200</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>月</string>
</property>
</widget>
<widget class="QPushButton" name="btnYear4">
<property name="geometry">
<rect>
<x>270</x>
<y>200</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>年2026</string>
</property>
</widget>
<widget class="QPushButton" name="btnDay">
<property name="geometry">
<rect>
<x>20</x>
<y>200</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>日</string>
</property>
</widget>
<widget class="QPushButton" name="btnWeekOfYear">
<property name="geometry">
<rect>
<x>20</x>
<y>250</y>
<width>221</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>年中第几周</string>
</property>
</widget>
<widget class="QPushButton" name="btnYear2">
<property name="geometry">
<rect>
<x>270</x>
<y>250</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>年26</string>
</property>
</widget>
<widget class="QPushButton" name="btnWeek">
<property name="geometry">
<rect>
<x>20</x>
<y>300</y>
<width>141</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>周几</string>
</property>
</widget>
<widget class="QPushButton" name="btnSpace">
<property name="geometry">
<rect>
<x>210</x>
<y>300</y>
<width>155</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>空格</string>
</property>
</widget>
<widget class="QPushButton" name="btnBackSpace">
<property name="geometry">
<rect>
<x>370</x>
<y>100</y>
<width>81</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>&lt;------</string>
</property>
</widget>
<widget class="QSpinBox" name="expirationNumCBox">
<property name="geometry">
<rect>
<x>540</x>
<y>100</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>660</x>
<y>100</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>700</x>
<y>100</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DateFormatEditor</class>
<widget class="QWidget" name="DateFormatEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>764</width>
<height>361</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget{
font-size: 16px;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}</string>
</property>
<widget class="QWidget" name="panel" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>761</width>
<height>361</height>
</rect>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>内容</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_DateFormat">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>60</x>
<y>50</y>
<width>371</width>
<height>30</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>470</x>
<y>26</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>有效期限</string>
</property>
</widget>
<widget class="QComboBox" name="expirationCBox">
<property name="geometry">
<rect>
<x>510</x>
<y>50</y>
<width>231</width>
<height>30</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<item>
<property name="text">
<string>天数</string>
</property>
</item>
<item>
<property name="text">
<string>月 - 精确到日</string>
</property>
</item>
<item>
<property name="text">
<string>月 - 精确到月</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="btnPoint">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>.</string>
</property>
</widget>
<widget class="QPushButton" name="btnColon">
<property name="geometry">
<rect>
<x>70</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>:</string>
</property>
</widget>
<widget class="QPushButton" name="btnComma">
<property name="geometry">
<rect>
<x>120</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>,</string>
</property>
</widget>
<widget class="QPushButton" name="btnSlash">
<property name="geometry">
<rect>
<x>170</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>/</string>
</property>
</widget>
<widget class="QPushButton" name="btnSemicolon">
<property name="geometry">
<rect>
<x>220</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>;</string>
</property>
</widget>
<widget class="QPushButton" name="btnUnderline">
<property name="geometry">
<rect>
<x>270</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
<widget class="QPushButton" name="btnDash">
<property name="geometry">
<rect>
<x>320</x>
<y>100</y>
<width>45</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QPushButton" name="btnHour">
<property name="geometry">
<rect>
<x>20</x>
<y>150</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string>小时</string>
</property>
</widget>
<widget class="QPushButton" name="btnMinute">
<property name="geometry">
<rect>
<x>150</x>
<y>150</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>分钟</string>
</property>
</widget>
<widget class="QPushButton" name="btnSecond">
<property name="geometry">
<rect>
<x>270</x>
<y>150</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>秒钟</string>
</property>
</widget>
<widget class="QPushButton" name="btnMonth">
<property name="geometry">
<rect>
<x>150</x>
<y>200</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>月</string>
</property>
</widget>
<widget class="QPushButton" name="btnYear4">
<property name="geometry">
<rect>
<x>270</x>
<y>200</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>年2026</string>
</property>
</widget>
<widget class="QPushButton" name="btnDay">
<property name="geometry">
<rect>
<x>20</x>
<y>200</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>日</string>
</property>
</widget>
<widget class="QPushButton" name="btnWeekOfYear">
<property name="geometry">
<rect>
<x>20</x>
<y>250</y>
<width>221</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>年中第几周</string>
</property>
</widget>
<widget class="QPushButton" name="btnYear2">
<property name="geometry">
<rect>
<x>270</x>
<y>250</y>
<width>95</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>年26</string>
</property>
</widget>
<widget class="QPushButton" name="btnWeek">
<property name="geometry">
<rect>
<x>20</x>
<y>300</y>
<width>141</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>周几</string>
</property>
</widget>
<widget class="QPushButton" name="btnSpace">
<property name="geometry">
<rect>
<x>210</x>
<y>300</y>
<width>155</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>空格</string>
</property>
</widget>
<widget class="QPushButton" name="btnBackSpace">
<property name="geometry">
<rect>
<x>370</x>
<y>100</y>
<width>81</width>
<height>35</height>
</rect>
</property>
<property name="text">
<string>&lt;------</string>
</property>
</widget>
<widget class="QSpinBox" name="expirationNumCBox">
<property name="geometry">
<rect>
<x>540</x>
<y>100</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>660</x>
<y>100</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>700</x>
<y>100</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
File diff suppressed because it is too large Load Diff
+66 -66
View File
@@ -1,66 +1,66 @@
#ifndef DATEREPLACEEDITOR_H
#define DATEREPLACEEDITOR_H
#include <QWidget>
#include <QStringList>
#include <QList>
#include "ViewModels.h"
class QLineEdit;
namespace Ui {
class DateReplaceEditor;
}
class DateReplaceEditor : public QWidget
{
Q_OBJECT
public:
explicit DateReplaceEditor(QWidget *parent = nullptr);
~DateReplaceEditor();
DateItemModel dateModel();
void setDateModel(const DateItemModel& model);
void init();
void initReplaceValue();
void initShowLineEdit();
void loadMonthShow();
void loadDataShow();
void loadWeekShow();
void loadYearShow();
void loadDayShow();
void loadHourShow();
void getMonthValue();
void getYearValue();
void getHourValue();
void getWeekValue();
void getDayValue();
private slots:
void on_cb_replaceType_currentIndexChanged(int index);
void on_btnUP_clicked();
void on_btnDown_clicked();
void on_btnPreSetValue_clicked();
void onLineEditReplaceChanged(int i, QString txt);
private:
void applyStyleSheet();
Ui::DateReplaceEditor *ui;
int currPage = 0;
QStringList monthList;
QStringList dataList;
QStringList weekList;
QStringList yearList;
QList<int> yearInitList;
QStringList dayList;
QStringList hourList;
};
#endif // DATEREPLACEEDITOR_H
#ifndef DATEREPLACEEDITOR_H
#define DATEREPLACEEDITOR_H
#include <QWidget>
#include <QStringList>
#include <QList>
#include "ViewModels.h"
class QLineEdit;
namespace Ui {
class DateReplaceEditor;
}
class DateReplaceEditor : public QWidget
{
Q_OBJECT
public:
explicit DateReplaceEditor(QWidget *parent = nullptr);
~DateReplaceEditor();
DateItemModel dateModel();
void setDateModel(const DateItemModel& model);
void init();
void initReplaceValue();
void initShowLineEdit();
void loadMonthShow();
void loadDataShow();
void loadWeekShow();
void loadYearShow();
void loadDayShow();
void loadHourShow();
void getMonthValue();
void getYearValue();
void getHourValue();
void getWeekValue();
void getDayValue();
private slots:
void on_cb_replaceType_currentIndexChanged(int index);
void on_btnUP_clicked();
void on_btnDown_clicked();
void on_btnPreSetValue_clicked();
void onLineEditReplaceChanged(int i, QString txt);
private:
void applyStyleSheet();
Ui::DateReplaceEditor *ui;
int currPage = 0;
QStringList monthList;
QStringList dataList;
QStringList weekList;
QStringList yearList;
QList<int> yearInitList;
QStringList dayList;
QStringList hourList;
};
#endif // DATEREPLACEEDITOR_H
+307 -307
View File
@@ -1,307 +1,307 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DateReplaceEditor</class>
<widget class="QWidget" name="DateReplaceEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>661</width>
<height>371</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
</string>
</property>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>70</x>
<y>100</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>名称</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>130</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>170</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>210</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>250</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="cb_replaceType">
<property name="geometry">
<rect>
<x>280</x>
<y>20</y>
<width>181</width>
<height>35</height>
</rect>
</property>
<item>
<property name="text">
<string>数据</string>
</property>
</item>
<item>
<property name="text">
<string>周几</string>
</property>
</item>
<item>
<property name="text">
<string>月</string>
</property>
</item>
<item>
<property name="text">
<string>年</string>
</property>
</item>
<item>
<property name="text">
<string>天数</string>
</property>
</item>
<item>
<property name="text">
<string>小时</string>
</property>
</item>
<item>
<property name="text">
<string>Meridiem</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>220</x>
<y>30</y>
<width>50</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>类型</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>240</x>
<y>100</y>
<width>51</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>代替</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace1">
<property name="geometry">
<rect>
<x>250</x>
<y>130</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace2">
<property name="geometry">
<rect>
<x>250</x>
<y>170</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace4">
<property name="geometry">
<rect>
<x>250</x>
<y>250</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace3">
<property name="geometry">
<rect>
<x>250</x>
<y>210</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="btnUP">
<property name="geometry">
<rect>
<x>530</x>
<y>130</y>
<width>61</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>上</string>
</property>
</widget>
<widget class="QPushButton" name="btnDown">
<property name="geometry">
<rect>
<x>530</x>
<y>210</y>
<width>61</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>下</string>
</property>
</widget>
<widget class="QPushButton" name="btnPreSetValue">
<property name="geometry">
<rect>
<x>80</x>
<y>310</y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>预设值</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DateReplaceEditor</class>
<widget class="QWidget" name="DateReplaceEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>661</width>
<height>371</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
</string>
</property>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>70</x>
<y>100</y>
<width>67</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>名称</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>130</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>170</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>210</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>250</y>
<width>113</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="cb_replaceType">
<property name="geometry">
<rect>
<x>280</x>
<y>20</y>
<width>181</width>
<height>35</height>
</rect>
</property>
<item>
<property name="text">
<string>数据</string>
</property>
</item>
<item>
<property name="text">
<string>周几</string>
</property>
</item>
<item>
<property name="text">
<string>月</string>
</property>
</item>
<item>
<property name="text">
<string>年</string>
</property>
</item>
<item>
<property name="text">
<string>天数</string>
</property>
</item>
<item>
<property name="text">
<string>小时</string>
</property>
</item>
<item>
<property name="text">
<string>Meridiem</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>220</x>
<y>30</y>
<width>50</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>类型</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>240</x>
<y>100</y>
<width>51</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>代替</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace1">
<property name="geometry">
<rect>
<x>250</x>
<y>130</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace2">
<property name="geometry">
<rect>
<x>250</x>
<y>170</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace4">
<property name="geometry">
<rect>
<x>250</x>
<y>250</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Replace3">
<property name="geometry">
<rect>
<x>250</x>
<y>210</y>
<width>231</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="btnUP">
<property name="geometry">
<rect>
<x>530</x>
<y>130</y>
<width>61</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>上</string>
</property>
</widget>
<widget class="QPushButton" name="btnDown">
<property name="geometry">
<rect>
<x>530</x>
<y>210</y>
<width>61</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>下</string>
</property>
</widget>
<widget class="QPushButton" name="btnPreSetValue">
<property name="geometry">
<rect>
<x>80</x>
<y>310</y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>预设值</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
+51 -51
View File
@@ -1,51 +1,51 @@
#include "DlgBarcodeFormat.h"
#include "ui_DlgBarcodeFormat.h"
DlgBarcodeFormat::DlgBarcodeFormat(QWidget *parent) :
QDialog(parent),
ui(new Ui::DlgBarcodeFormat)
{
ui->setupUi(this);
ui->BarCodeType->addItem("BARCODE_128");
ui->BarCodeType->addItem("BARCODE_93");
ui->BarCodeType->addItem("BARCODE_ISBN");
ui->BarCodeType->addItem("BARCODE_EAN");
ui->BarCodeType->addItem("BARCODE_UPC");
ui->BarCodeType->addItem("BARCODE_39");
ui->BarCodeHeigh->addItem(tr("5点"));
ui->BarCodeHeigh->addItem(tr("7点"));
ui->BarCodeHeigh->addItem(tr("9点"));
ui->BarCodeHeigh->addItem(tr("12点"));
ui->BarCodeHeigh->addItem(tr("16点"));
ui->BarCodeHeigh->addItem(tr("24点"));
ui->BarCodeHeigh->setCurrentIndex(2);
ui->BarCodeType->setCurrentIndex(0);
}
DlgBarcodeFormat::~DlgBarcodeFormat()
{
delete ui;
}
void DlgBarcodeFormat::setViewModel(DlgBarcodeFormatVM vm)
{
m_vm = vm;
ui->BarCodeType->setCurrentText(vm.type);
ui->BarCodeHeigh->setCurrentText(tr("%1点").arg(vm.height));
ui->BarCodeDot->setCurrentText(tr("%1点").arg(vm.width));
ui->BarCodeScale->setValue(vm.scale);
ui->checkBoxAddText->setChecked(vm.txtVisible);
}
DlgBarcodeFormatVM DlgBarcodeFormat::viewModel()
{
m_vm.type = ui->BarCodeType->currentText();
m_vm.height = ui->BarCodeHeigh->currentText().remove(tr("点")).toInt();
m_vm.width = ui->BarCodeDot->currentText().remove(tr("点")).toInt();
m_vm.scale = ui->BarCodeScale->value();
m_vm.txtVisible = ui->checkBoxAddText->isChecked();
return m_vm;
}
#include "DlgBarcodeFormat.h"
#include "ui_DlgBarcodeFormat.h"
DlgBarcodeFormat::DlgBarcodeFormat(QWidget *parent) :
QDialog(parent),
ui(new Ui::DlgBarcodeFormat)
{
ui->setupUi(this);
ui->BarCodeType->addItem("BARCODE_128");
ui->BarCodeType->addItem("BARCODE_93");
ui->BarCodeType->addItem("BARCODE_ISBN");
ui->BarCodeType->addItem("BARCODE_EAN");
ui->BarCodeType->addItem("BARCODE_UPC");
ui->BarCodeType->addItem("BARCODE_39");
ui->BarCodeHeigh->addItem(tr("5点"));
ui->BarCodeHeigh->addItem(tr("7点"));
ui->BarCodeHeigh->addItem(tr("9点"));
ui->BarCodeHeigh->addItem(tr("12点"));
ui->BarCodeHeigh->addItem(tr("16点"));
ui->BarCodeHeigh->addItem(tr("24点"));
ui->BarCodeHeigh->setCurrentIndex(2);
ui->BarCodeType->setCurrentIndex(0);
}
DlgBarcodeFormat::~DlgBarcodeFormat()
{
delete ui;
}
void DlgBarcodeFormat::setViewModel(DlgBarcodeFormatVM vm)
{
m_vm = vm;
ui->BarCodeType->setCurrentText(vm.type);
ui->BarCodeHeigh->setCurrentText(tr("%1点").arg(vm.height));
ui->BarCodeDot->setCurrentText(tr("%1点").arg(vm.width));
ui->BarCodeScale->setValue(vm.scale);
ui->checkBoxAddText->setChecked(vm.txtVisible);
}
DlgBarcodeFormatVM DlgBarcodeFormat::viewModel()
{
m_vm.type = ui->BarCodeType->currentText();
m_vm.height = ui->BarCodeHeigh->currentText().remove(tr("点")).toInt();
m_vm.width = ui->BarCodeDot->currentText().remove(tr("点")).toInt();
m_vm.scale = ui->BarCodeScale->value();
m_vm.txtVisible = ui->checkBoxAddText->isChecked();
return m_vm;
}
+40 -40
View File
@@ -1,40 +1,40 @@
#ifndef DLGBARCODEFORMAT_H
#define DLGBARCODEFORMAT_H
#include <QDialog>
#include "ViewModels.h"
namespace Ui {
class DlgBarcodeFormat;
}
struct DlgBarcodeFormatVM {
QString type = "BARCODE_128";
int height = 9;
int width = 1;
int scale = 1;
InkType inkType = INK_TYPE_BLACK;
bool txtVisible = false;
};
Q_DECLARE_METATYPE(DlgBarcodeFormatVM);
class DlgBarcodeFormat : public QDialog
{
Q_OBJECT
public:
explicit DlgBarcodeFormat(QWidget *parent = nullptr);
~DlgBarcodeFormat();
void setViewModel(DlgBarcodeFormatVM vm);
DlgBarcodeFormatVM viewModel();
private:
Ui::DlgBarcodeFormat *ui;
DlgBarcodeFormatVM m_vm;
};
#endif // DLGBARCODEFORMAT_H
#ifndef DLGBARCODEFORMAT_H
#define DLGBARCODEFORMAT_H
#include <QDialog>
#include "ViewModels.h"
namespace Ui {
class DlgBarcodeFormat;
}
struct DlgBarcodeFormatVM {
QString type = "BARCODE_128";
int height = 9;
int width = 1;
int scale = 1;
InkType inkType = INK_TYPE_BLACK;
bool txtVisible = false;
};
Q_DECLARE_METATYPE(DlgBarcodeFormatVM);
class DlgBarcodeFormat : public QDialog
{
Q_OBJECT
public:
explicit DlgBarcodeFormat(QWidget *parent = nullptr);
~DlgBarcodeFormat();
void setViewModel(DlgBarcodeFormatVM vm);
DlgBarcodeFormatVM viewModel();
private:
Ui::DlgBarcodeFormat *ui;
DlgBarcodeFormatVM m_vm;
};
#endif // DLGBARCODEFORMAT_H
+390 -390
View File
@@ -1,390 +1,390 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgBarcodeFormat</class>
<widget class="QDialog" name="DlgBarcodeFormat">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>380</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font-size: 16px;
}
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QSpinBox::up-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::up-arrow {
image: url(:/image/up_white.png);
}
QSpinBox::down-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::down-arrow {
image: url(:/image/down_white.png);
}
</string>
</property>
<widget class="QSpinBox" name="BarCodeScale">
<property name="geometry">
<rect>
<x>280</x>
<y>150</y>
<width>60</width>
<height>31</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>70</x>
<y>120</y>
<width>91</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>条形码高度</string>
</property>
</widget>
<widget class="QComboBox" name="BarCodeDot">
<property name="geometry">
<rect>
<x>70</x>
<y>230</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>1点</string>
</property>
</item>
<item>
<property name="text">
<string>2点</string>
</property>
</item>
<item>
<property name="text">
<string>3点</string>
</property>
</item>
<item>
<property name="text">
<string>4点</string>
</property>
</item>
<item>
<property name="text">
<string>5点</string>
</property>
</item>
<item>
<property name="text">
<string>6点</string>
</property>
</item>
</widget>
<widget class="QCheckBox" name="checkBoxAddText">
<property name="geometry">
<rect>
<x>280</x>
<y>230</y>
<width>150</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>增加数字行</string>
</property>
</widget>
<widget class="QComboBox" name="BarCodeHeigh">
<property name="geometry">
<rect>
<x>70</x>
<y>150</y>
<width>111</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="comboBoxInkColor">
<property name="geometry">
<rect>
<x>280</x>
<y>70</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>黑墨</string>
</property>
</item>
<item>
<property name="text">
<string>白墨</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>70</x>
<y>200</y>
<width>76</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>条码宽度</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>70</x>
<y>40</y>
<width>140</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>条形码类型</string>
</property>
</widget>
<widget class="QComboBox" name="BarCodeType">
<property name="geometry">
<rect>
<x>70</x>
<y>70</y>
<width>161</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="QLabel" name="lab123">
<property name="geometry">
<rect>
<x>280</x>
<y>40</y>
<width>76</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>墨水类型</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>280</x>
<y>120</y>
<width>129</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>显示缩放</string>
</property>
</widget>
<widget class="QPushButton" name="checkBtn">
<property name="geometry">
<rect>
<x>370</x>
<y>300</y>
<width>101</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>✓</string>
</property>
</widget>
</widget>
<tabstops>
<tabstop>BarCodeType</tabstop>
<tabstop>comboBoxInkColor</tabstop>
<tabstop>BarCodeHeigh</tabstop>
<tabstop>BarCodeScale</tabstop>
<tabstop>BarCodeDot</tabstop>
<tabstop>checkBoxAddText</tabstop>
<tabstop>checkBtn</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>checkBtn</sender>
<signal>clicked()</signal>
<receiver>DlgBarcodeFormat</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>412</x>
<y>323</y>
</hint>
<hint type="destinationlabel">
<x>417</x>
<y>460</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgBarcodeFormat</class>
<widget class="QDialog" name="DlgBarcodeFormat">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>380</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font-size: 16px;
}
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QSpinBox::up-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::up-arrow {
image: url(:/image/up_white.png);
}
QSpinBox::down-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::down-arrow {
image: url(:/image/down_white.png);
}
</string>
</property>
<widget class="QSpinBox" name="BarCodeScale">
<property name="geometry">
<rect>
<x>280</x>
<y>150</y>
<width>60</width>
<height>31</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>70</x>
<y>120</y>
<width>91</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>条形码高度</string>
</property>
</widget>
<widget class="QComboBox" name="BarCodeDot">
<property name="geometry">
<rect>
<x>70</x>
<y>230</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>1点</string>
</property>
</item>
<item>
<property name="text">
<string>2点</string>
</property>
</item>
<item>
<property name="text">
<string>3点</string>
</property>
</item>
<item>
<property name="text">
<string>4点</string>
</property>
</item>
<item>
<property name="text">
<string>5点</string>
</property>
</item>
<item>
<property name="text">
<string>6点</string>
</property>
</item>
</widget>
<widget class="QCheckBox" name="checkBoxAddText">
<property name="geometry">
<rect>
<x>280</x>
<y>230</y>
<width>150</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>增加数字行</string>
</property>
</widget>
<widget class="QComboBox" name="BarCodeHeigh">
<property name="geometry">
<rect>
<x>70</x>
<y>150</y>
<width>111</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="comboBoxInkColor">
<property name="geometry">
<rect>
<x>280</x>
<y>70</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>黑墨</string>
</property>
</item>
<item>
<property name="text">
<string>白墨</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>70</x>
<y>200</y>
<width>76</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>条码宽度</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>70</x>
<y>40</y>
<width>140</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>条形码类型</string>
</property>
</widget>
<widget class="QComboBox" name="BarCodeType">
<property name="geometry">
<rect>
<x>70</x>
<y>70</y>
<width>161</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="QLabel" name="lab123">
<property name="geometry">
<rect>
<x>280</x>
<y>40</y>
<width>76</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>墨水类型</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>280</x>
<y>120</y>
<width>129</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>显示缩放</string>
</property>
</widget>
<widget class="QPushButton" name="checkBtn">
<property name="geometry">
<rect>
<x>370</x>
<y>300</y>
<width>101</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>✓</string>
</property>
</widget>
</widget>
<tabstops>
<tabstop>BarCodeType</tabstop>
<tabstop>comboBoxInkColor</tabstop>
<tabstop>BarCodeHeigh</tabstop>
<tabstop>BarCodeScale</tabstop>
<tabstop>BarCodeDot</tabstop>
<tabstop>checkBoxAddText</tabstop>
<tabstop>checkBtn</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>checkBtn</sender>
<signal>clicked()</signal>
<receiver>DlgBarcodeFormat</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>412</x>
<y>323</y>
</hint>
<hint type="destinationlabel">
<x>417</x>
<y>460</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+40 -40
View File
@@ -1,40 +1,40 @@
#include "DlgQrcodeFormat.h"
#include "ui_DlgQrcodeFormat.h"
DlgQrcodeFormat::DlgQrcodeFormat(QWidget *parent) :
QDialog(parent),
ui(new Ui::DlgQrcodeFormat)
{
ui->setupUi(this);
setViewModel(m_vm);
ui->comboBoxType->setEnabled(false);
}
DlgQrcodeFormat::~DlgQrcodeFormat()
{
delete ui;
}
void DlgQrcodeFormat::setViewModel(DlgQrcodeFormatVM vm)
{
m_vm = vm;
ui->comboBoxType->setCurrentIndex(int(vm.type));
ui->comboBoxInkColor->setCurrentIndex(int(vm.inkType));
ui->comboBox_DMType->setCurrentIndex(int(vm.size));
ui->comboBox_QRCodeLevel->setCurrentIndex(int(vm.level));
}
DlgQrcodeFormatVM DlgQrcodeFormat::viewModel()
{
m_vm.type = QRCodeType(ui->comboBoxType->currentIndex());
m_vm.inkType = InkType(ui->comboBoxInkColor->currentIndex());
m_vm.level = QRCodeLevel(ui->comboBox_QRCodeLevel->currentIndex());
m_vm.size = QRCodeSize(ui->comboBox_DMType->currentIndex());
return m_vm;
}
void DlgQrcodeFormat::setCodeType(QString type)
{
// type = "QRCode" "DataMatrix"
ui->comboBoxType->setCurrentText(type);
}
#include "DlgQrcodeFormat.h"
#include "ui_DlgQrcodeFormat.h"
DlgQrcodeFormat::DlgQrcodeFormat(QWidget *parent) :
QDialog(parent),
ui(new Ui::DlgQrcodeFormat)
{
ui->setupUi(this);
setViewModel(m_vm);
ui->comboBoxType->setEnabled(false);
}
DlgQrcodeFormat::~DlgQrcodeFormat()
{
delete ui;
}
void DlgQrcodeFormat::setViewModel(DlgQrcodeFormatVM vm)
{
m_vm = vm;
ui->comboBoxType->setCurrentIndex(int(vm.type));
ui->comboBoxInkColor->setCurrentIndex(int(vm.inkType));
ui->comboBox_DMType->setCurrentIndex(int(vm.size));
ui->comboBox_QRCodeLevel->setCurrentIndex(int(vm.level));
}
DlgQrcodeFormatVM DlgQrcodeFormat::viewModel()
{
m_vm.type = QRCodeType(ui->comboBoxType->currentIndex());
m_vm.inkType = InkType(ui->comboBoxInkColor->currentIndex());
m_vm.level = QRCodeLevel(ui->comboBox_QRCodeLevel->currentIndex());
m_vm.size = QRCodeSize(ui->comboBox_DMType->currentIndex());
return m_vm;
}
void DlgQrcodeFormat::setCodeType(QString type)
{
// type = "QRCode" "DataMatrix"
ui->comboBoxType->setCurrentText(type);
}
+61 -61
View File
@@ -1,61 +1,61 @@
#ifndef DLGQRCODEFORMAT_H
#define DLGQRCODEFORMAT_H
#include <QDialog>
#include "ViewModels.h"
namespace Ui {
class DlgQrcodeFormat;
}
enum QRCodeType {
QR_CODE_TYPE_DATA_MATRIX = 0,
QR_CODE_TYPE_QRCODE = 1,
};
enum QRCodeLevel {
QR_CODE_LEVEL_L = 0,
QR_CODE_LEVEL_M = 1,
QR_CODE_LEVEL_H = 2,
QR_CODE_LEVEL_Q = 3,
};
enum QRCodeSize {
QR_CODE_SIZE_DEFAULT,
QR_CODE_SIZE_8X18,
QR_CODE_SIZE_8X32,
QR_CODE_SIZE_12X26,
QR_CODE_SIZE_12X36,
QR_CODE_SIZE_16X36,
QR_CODE_SIZE_16X48,
};
struct DlgQrcodeFormatVM {
QRCodeType type = QR_CODE_TYPE_QRCODE;
QRCodeLevel level = QR_CODE_LEVEL_L;
QRCodeSize size = QR_CODE_SIZE_DEFAULT;
InkType inkType = INK_TYPE_BLACK;
};
Q_DECLARE_METATYPE(DlgQrcodeFormatVM);
class DlgQrcodeFormat : public QDialog
{
Q_OBJECT
public:
explicit DlgQrcodeFormat(QWidget *parent = nullptr);
~DlgQrcodeFormat();
void setViewModel(DlgQrcodeFormatVM vm);
DlgQrcodeFormatVM viewModel();
void setCodeType(QString type);
private:
Ui::DlgQrcodeFormat *ui;
DlgQrcodeFormatVM m_vm;
};
#endif // DLGQRCODEFORMAT_H
#ifndef DLGQRCODEFORMAT_H
#define DLGQRCODEFORMAT_H
#include <QDialog>
#include "ViewModels.h"
namespace Ui {
class DlgQrcodeFormat;
}
enum QRCodeType {
QR_CODE_TYPE_DATA_MATRIX = 0,
QR_CODE_TYPE_QRCODE = 1,
};
enum QRCodeLevel {
QR_CODE_LEVEL_L = 0,
QR_CODE_LEVEL_M = 1,
QR_CODE_LEVEL_H = 2,
QR_CODE_LEVEL_Q = 3,
};
enum QRCodeSize {
QR_CODE_SIZE_DEFAULT,
QR_CODE_SIZE_8X18,
QR_CODE_SIZE_8X32,
QR_CODE_SIZE_12X26,
QR_CODE_SIZE_12X36,
QR_CODE_SIZE_16X36,
QR_CODE_SIZE_16X48,
};
struct DlgQrcodeFormatVM {
QRCodeType type = QR_CODE_TYPE_QRCODE;
QRCodeLevel level = QR_CODE_LEVEL_L;
QRCodeSize size = QR_CODE_SIZE_DEFAULT;
InkType inkType = INK_TYPE_BLACK;
};
Q_DECLARE_METATYPE(DlgQrcodeFormatVM);
class DlgQrcodeFormat : public QDialog
{
Q_OBJECT
public:
explicit DlgQrcodeFormat(QWidget *parent = nullptr);
~DlgQrcodeFormat();
void setViewModel(DlgQrcodeFormatVM vm);
DlgQrcodeFormatVM viewModel();
void setCodeType(QString type);
private:
Ui::DlgQrcodeFormat *ui;
DlgQrcodeFormatVM m_vm;
};
#endif // DLGQRCODEFORMAT_H
+331 -331
View File
@@ -1,331 +1,331 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgQrcodeFormat</class>
<widget class="QDialog" name="DlgQrcodeFormat">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>380</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget{
font-size: 16px;
}
QWidget {
font-size: 16px;
}
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QSpinBox::up-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::up-arrow {
image: url(:/image/up_white.png);
}
QSpinBox::down-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::down-arrow {
image: url(:/image/down_white.png);
}
</string>
</property>
<widget class="QComboBox" name="comboBoxType">
<property name="geometry">
<rect>
<x>40</x>
<y>60</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>DataMatrix</string>
</property>
</item>
<item>
<property name="text">
<string>QRCode</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="comboBoxInkColor">
<property name="geometry">
<rect>
<x>40</x>
<y>130</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>正相打印</string>
</property>
</item>
<item>
<property name="text">
<string>反相打印</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>180</y>
<width>141</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>DM码尺寸:</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
<widget class="QComboBox" name="comboBox_DMType">
<property name="geometry">
<rect>
<x>40</x>
<y>210</y>
<width>157</width>
<height>31</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>默认</string>
</property>
</item>
<item>
<property name="text">
<string>8 x 18</string>
</property>
</item>
<item>
<property name="text">
<string>8 x 32</string>
</property>
</item>
<item>
<property name="text">
<string>12 x 26</string>
</property>
</item>
<item>
<property name="text">
<string>12 x 36</string>
</property>
</item>
<item>
<property name="text">
<string>16 x 36</string>
</property>
</item>
<item>
<property name="text">
<string>16 x 48</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="comboBox_QRCodeLevel">
<property name="geometry">
<rect>
<x>210</x>
<y>210</y>
<width>156</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>低级</string>
</property>
</item>
<item>
<property name="text">
<string>中级</string>
</property>
</item>
<item>
<property name="text">
<string>高级</string>
</property>
</item>
<item>
<property name="text">
<string>超高级</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>21</y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>类型</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>40</x>
<y>101</y>
<width>141</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>墨水类型</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
<widget class="QPushButton" name="checkBtn">
<property name="geometry">
<rect>
<x>370</x>
<y>300</y>
<width>101</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>✓</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>checkBtn</sender>
<signal>clicked()</signal>
<receiver>DlgQrcodeFormat</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>423</x>
<y>327</y>
</hint>
<hint type="destinationlabel">
<x>463</x>
<y>504</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgQrcodeFormat</class>
<widget class="QDialog" name="DlgQrcodeFormat">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>380</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget{
font-size: 16px;
}
QWidget {
font-size: 16px;
}
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(:/image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QSpinBox::up-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::up-arrow {
image: url(:/image/up_white.png);
}
QSpinBox::down-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::down-arrow {
image: url(:/image/down_white.png);
}
</string>
</property>
<widget class="QComboBox" name="comboBoxType">
<property name="geometry">
<rect>
<x>40</x>
<y>60</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>DataMatrix</string>
</property>
</item>
<item>
<property name="text">
<string>QRCode</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="comboBoxInkColor">
<property name="geometry">
<rect>
<x>40</x>
<y>130</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>正相打印</string>
</property>
</item>
<item>
<property name="text">
<string>反相打印</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>180</y>
<width>141</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>DM码尺寸:</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
<widget class="QComboBox" name="comboBox_DMType">
<property name="geometry">
<rect>
<x>40</x>
<y>210</y>
<width>157</width>
<height>31</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>默认</string>
</property>
</item>
<item>
<property name="text">
<string>8 x 18</string>
</property>
</item>
<item>
<property name="text">
<string>8 x 32</string>
</property>
</item>
<item>
<property name="text">
<string>12 x 26</string>
</property>
</item>
<item>
<property name="text">
<string>12 x 36</string>
</property>
</item>
<item>
<property name="text">
<string>16 x 36</string>
</property>
</item>
<item>
<property name="text">
<string>16 x 48</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="comboBox_QRCodeLevel">
<property name="geometry">
<rect>
<x>210</x>
<y>210</y>
<width>156</width>
<height>31</height>
</rect>
</property>
<item>
<property name="text">
<string>低级</string>
</property>
</item>
<item>
<property name="text">
<string>中级</string>
</property>
</item>
<item>
<property name="text">
<string>高级</string>
</property>
</item>
<item>
<property name="text">
<string>超高级</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>21</y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>类型</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>40</x>
<y>101</y>
<width>141</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>墨水类型</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
<widget class="QPushButton" name="checkBtn">
<property name="geometry">
<rect>
<x>370</x>
<y>300</y>
<width>101</width>
<height>50</height>
</rect>
</property>
<property name="text">
<string>✓</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>checkBtn</sender>
<signal>clicked()</signal>
<receiver>DlgQrcodeFormat</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>423</x>
<y>327</y>
</hint>
<hint type="destinationlabel">
<x>463</x>
<y>504</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+173 -173
View File
@@ -1,174 +1,174 @@
#include "ItemGeneralSettings.h"
#include "ui_ItemGeneralSettings.h"
#include <QDebug>
ItemGeneralSettings::ItemGeneralSettings(QWidget *parent) :
QWidget(parent),
ui(new Ui::ItemGeneralSettings)
{
ui->setupUi(this);
m_directionButtonGroup.addButton(ui->normalRBtn, NORMAL);
m_directionButtonGroup.addButton(ui->verMirrorRBtn, MIRROR_V);
m_directionButtonGroup.addButton(ui->horMirrorRBtn, MIRROR_H);
m_directionButtonGroup.addButton(ui->mirrorRBtn, MIRROR_VH);
m_directionButtonGroup.addButton(ui->m90NHorRBtn, MIRROR_H_R270);
m_directionButtonGroup.addButton(ui->a90RBtn, R90);
m_directionButtonGroup.addButton(ui->m90RBtn, R270);
m_directionButtonGroup.addButton(ui->m90NVerRBtn, MIRROR_V_R270);
connect(&m_directionButtonGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
this, &ItemGeneralSettings::ondirectionChanged);
connect(ui->boldSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ItemGeneralSettings::onBoldSpinBoxValueChanged);
connect(ui->txtSpanSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ItemGeneralSettings::onLetterSpaceSpinBoxChanged);
connect(ui->invertCheckBox, &QCheckBox::stateChanged,
this, [this](int state) { onColorReversalCheckBoxChecked(state == Qt::Checked); });
initUI();
}
ItemGeneralSettings::~ItemGeneralSettings()
{
delete ui;
}
void ItemGeneralSettings::edit(PicTextItem *item)
{
m_currItem = item;
// 从item快照创建ViewModel(如果item为空,使用默认值)
setViewModel(TextItemModel::fromItem(item));
}
void ItemGeneralSettings::initUI()
{
ui->densitySpinBox->setValue(0);
ui->invertCheckBox->setChecked(false);
ui->alternateCheckBox->setChecked(false);
ui->boldSpinBox->setValue(0);
ui->txtSpanSpinBox->setValue(0);
ui->normalRBtn->setChecked(true);
ui->applyCounterCheckBox->setChecked(false);
ui->counterIDSpinBox->setValue(0);
}
void ItemGeneralSettings::setViewModel(const TextItemModel &vm)
{
m_vmSnapshot = vm;
m_vm = vm;
// 阻止信号以避免重复回调
auto blockBold = ui->boldSpinBox->blockSignals(true);
auto blockSpan = ui->txtSpanSpinBox->blockSignals(true);
auto blockInvert = ui->invertCheckBox->blockSignals(true);
// 根据m_vm更新UI显示
ui->boldSpinBox->setValue(m_vm.boldMultiple);
ui->txtSpanSpinBox->setValue(m_vm.letterSpace);
auto dirBtn = m_directionButtonGroup.button(m_vm.direction);
if (dirBtn) {
dirBtn->setChecked(true);
}
ui->invertCheckBox->setChecked(m_vm.colorReversal);
// 恢复信号
ui->boldSpinBox->blockSignals(blockBold);
ui->txtSpanSpinBox->blockSignals(blockSpan);
ui->invertCheckBox->blockSignals(blockInvert);
// 字间距可见性由item的类型决定
switch(m_vm.sourceType) {
case SourceType::TEXT:
case SourceType::DATETIME:
case SourceType::SCHEDULE_SHIFT:
ui->letterSpacePanel->setVisible(true);
break;
case SourceType::UNKNOWN:
default:
ui->letterSpacePanel->setVisible(false);
break;
}
updatePreview();
}
void ItemGeneralSettings::applyToItem(PicTextItem *item)
{
if (!item) {
return;
}
// VM的属性被逐一应用到item
item->setDirection(m_vm.direction);
item->setBoldMultiple(m_vm.boldMultiple);
item->setLetterSpace(m_vm.letterSpace);
item->setColorReversal(m_vm.colorReversal);
item->applyModify();
}
void ItemGeneralSettings::ondirectionChanged(int dir)
{
// 只更新VM,不直接修改item
m_vm.direction = ItemDirectionType(dir);
updatePreview();
}
void ItemGeneralSettings::onBoldSpinBoxValueChanged(int multiple)
{
// 只更新VM
m_vm.boldMultiple = multiple;
updatePreview();
}
void ItemGeneralSettings::onLetterSpaceSpinBoxChanged(int space)
{
// 只更新VM
m_vm.letterSpace = space;
updatePreview();
}
void ItemGeneralSettings::onColorReversalCheckBoxChecked(bool b)
{
// 只更新VM
m_vm.colorReversal = b;
updatePreview();
}
void ItemGeneralSettings::updatePreview()
{
// 预览需要基于item的source和m_vm的属性组合渲染
// 如果m_currItem为空,显示空图像
if (!m_currItem) {
if(m_vm.imageGenerator) {
ui->previewWidget->setImg(m_vm.imageGenerator());
}
else {
ui->previewWidget->setImg(QImage());
}
return;
}
// 临时应用VM到item以获取预览,随后还原
auto backupDir = m_currItem->direction();
auto backupBold = m_currItem->boldMultiple();
auto backupSpace = m_currItem->letterSpace();
auto backupReverse = m_currItem->colorReversal();
m_currItem->setDirection(m_vm.direction);
m_currItem->setBoldMultiple(m_vm.boldMultiple);
m_currItem->setLetterSpace(m_vm.letterSpace);
m_currItem->setColorReversal(m_vm.colorReversal);
m_currItem->applyModify();
ui->previewWidget->setImg(m_currItem->preview());
// 还原原始状态(preview()后item的属性不应该被留下改动)
m_currItem->setDirection(backupDir);
m_currItem->setBoldMultiple(backupBold);
m_currItem->setLetterSpace(backupSpace);
m_currItem->setColorReversal(backupReverse);
m_currItem->applyModify();
#include "ItemGeneralSettings.h"
#include "ui_ItemGeneralSettings.h"
#include <QDebug>
ItemGeneralSettings::ItemGeneralSettings(QWidget *parent) :
QWidget(parent),
ui(new Ui::ItemGeneralSettings)
{
ui->setupUi(this);
m_directionButtonGroup.addButton(ui->normalRBtn, NORMAL);
m_directionButtonGroup.addButton(ui->verMirrorRBtn, MIRROR_V);
m_directionButtonGroup.addButton(ui->horMirrorRBtn, MIRROR_H);
m_directionButtonGroup.addButton(ui->mirrorRBtn, MIRROR_VH);
m_directionButtonGroup.addButton(ui->m90NHorRBtn, MIRROR_H_R270);
m_directionButtonGroup.addButton(ui->a90RBtn, R90);
m_directionButtonGroup.addButton(ui->m90RBtn, R270);
m_directionButtonGroup.addButton(ui->m90NVerRBtn, MIRROR_V_R270);
connect(&m_directionButtonGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
this, &ItemGeneralSettings::ondirectionChanged);
connect(ui->boldSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ItemGeneralSettings::onBoldSpinBoxValueChanged);
connect(ui->txtSpanSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ItemGeneralSettings::onLetterSpaceSpinBoxChanged);
connect(ui->invertCheckBox, &QCheckBox::stateChanged,
this, [this](int state) { onColorReversalCheckBoxChecked(state == Qt::Checked); });
initUI();
}
ItemGeneralSettings::~ItemGeneralSettings()
{
delete ui;
}
void ItemGeneralSettings::edit(PicTextItem *item)
{
m_currItem = item;
// 从item快照创建ViewModel(如果item为空,使用默认值)
setViewModel(TextItemModel::fromItem(item));
}
void ItemGeneralSettings::initUI()
{
ui->densitySpinBox->setValue(0);
ui->invertCheckBox->setChecked(false);
ui->alternateCheckBox->setChecked(false);
ui->boldSpinBox->setValue(0);
ui->txtSpanSpinBox->setValue(0);
ui->normalRBtn->setChecked(true);
ui->applyCounterCheckBox->setChecked(false);
ui->counterIDSpinBox->setValue(0);
}
void ItemGeneralSettings::setViewModel(const TextItemModel &vm)
{
m_vmSnapshot = vm;
m_vm = vm;
// 阻止信号以避免重复回调
auto blockBold = ui->boldSpinBox->blockSignals(true);
auto blockSpan = ui->txtSpanSpinBox->blockSignals(true);
auto blockInvert = ui->invertCheckBox->blockSignals(true);
// 根据m_vm更新UI显示
ui->boldSpinBox->setValue(m_vm.boldMultiple);
ui->txtSpanSpinBox->setValue(m_vm.letterSpace);
auto dirBtn = m_directionButtonGroup.button(m_vm.direction);
if (dirBtn) {
dirBtn->setChecked(true);
}
ui->invertCheckBox->setChecked(m_vm.colorReversal);
// 恢复信号
ui->boldSpinBox->blockSignals(blockBold);
ui->txtSpanSpinBox->blockSignals(blockSpan);
ui->invertCheckBox->blockSignals(blockInvert);
// 字间距可见性由item的类型决定
switch(m_vm.sourceType) {
case SourceType::TEXT:
case SourceType::DATETIME:
case SourceType::SCHEDULE_SHIFT:
ui->letterSpacePanel->setVisible(true);
break;
case SourceType::UNKNOWN:
default:
ui->letterSpacePanel->setVisible(false);
break;
}
updatePreview();
}
void ItemGeneralSettings::applyToItem(PicTextItem *item)
{
if (!item) {
return;
}
// VM的属性被逐一应用到item
item->setDirection(m_vm.direction);
item->setBoldMultiple(m_vm.boldMultiple);
item->setLetterSpace(m_vm.letterSpace);
item->setColorReversal(m_vm.colorReversal);
item->applyModify();
}
void ItemGeneralSettings::ondirectionChanged(int dir)
{
// 只更新VM,不直接修改item
m_vm.direction = ItemDirectionType(dir);
updatePreview();
}
void ItemGeneralSettings::onBoldSpinBoxValueChanged(int multiple)
{
// 只更新VM
m_vm.boldMultiple = multiple;
updatePreview();
}
void ItemGeneralSettings::onLetterSpaceSpinBoxChanged(int space)
{
// 只更新VM
m_vm.letterSpace = space;
updatePreview();
}
void ItemGeneralSettings::onColorReversalCheckBoxChecked(bool b)
{
// 只更新VM
m_vm.colorReversal = b;
updatePreview();
}
void ItemGeneralSettings::updatePreview()
{
// 预览需要基于item的source和m_vm的属性组合渲染
// 如果m_currItem为空,显示空图像
if (!m_currItem) {
if(m_vm.imageGenerator) {
ui->previewWidget->setImg(m_vm.imageGenerator());
}
else {
ui->previewWidget->setImg(QImage());
}
return;
}
// 临时应用VM到item以获取预览,随后还原
auto backupDir = m_currItem->direction();
auto backupBold = m_currItem->boldMultiple();
auto backupSpace = m_currItem->letterSpace();
auto backupReverse = m_currItem->colorReversal();
m_currItem->setDirection(m_vm.direction);
m_currItem->setBoldMultiple(m_vm.boldMultiple);
m_currItem->setLetterSpace(m_vm.letterSpace);
m_currItem->setColorReversal(m_vm.colorReversal);
m_currItem->applyModify();
ui->previewWidget->setImg(m_currItem->preview());
// 还原原始状态(preview()后item的属性不应该被留下改动)
m_currItem->setDirection(backupDir);
m_currItem->setBoldMultiple(backupBold);
m_currItem->setLetterSpace(backupSpace);
m_currItem->setColorReversal(backupReverse);
m_currItem->applyModify();
}
+88 -88
View File
@@ -1,88 +1,88 @@
#ifndef ITEMGENERALSETTINGS_H
#define ITEMGENERALSETTINGS_H
#include <QWidget>
#include <QButtonGroup>
#include "pictextitem.h"
#include <QPainter>
#include <QImage>
namespace Ui {
class ItemGeneralSettings;
}
class ItemGeneralSettings : public QWidget
{
Q_OBJECT
public:
explicit ItemGeneralSettings(QWidget *parent = nullptr);
~ItemGeneralSettings();
/**
* @brief 加载PicTextItem的属性到ViewModel,初始化UI
*
* 原因:UI应该显示item的状态,但不应该直接持有指针长期修改。
* edit()后,用户对UI的编辑会更新m_vm,而不是直接改item。
*/
void edit(PicTextItem* item);
/**
* @brief 设置当前ViewModel
*
* @param vm
*/
void setViewModel(const TextItemModel& vm);
/**
* @brief 获取当前ViewModel
*
* 调用者可以检查是否有改动,并决定是否应用
*/
TextItemModel viewModel() const { return m_vm; }
/**
* @brief 将ViewModel的属性应用到指定的PicTextItem
*
* 解耦的核心:UI不再直接修改item,而是通过VM进行间接修改。
* 这支持撤销/重做、批量编辑等高级功能。
*/
void applyToItem(PicTextItem* item);
/**
* @brief 当前编辑的item源引用(可能为空)
*
* 主要用于获取preview()时作为示例源,不用于直接修改
*/
PicTextItem* currentItem() { return m_currItem; }
void initUI();
private slots:
void ondirectionChanged(int dir);
void onBoldSpinBoxValueChanged(int multiple);
void onLetterSpaceSpinBoxChanged(int space);
void onColorReversalCheckBoxChecked(bool b);
private:
/**
* @brief 刷新预览,基于当前VM和item的source渲染
*/
void updatePreview();
Ui::ItemGeneralSettings *ui;
QButtonGroup m_directionButtonGroup;
// 原始item的快照,用于preview()和后续应用
PicTextItem* m_currItem = nullptr;
// UI编辑的状态,独立于m_currItem
TextItemModel m_vm;
// 初始加载时的VM状态,用于检测改动
TextItemModel m_vmSnapshot;
QPainter m_painter;
};
#endif // ITEMGENERALSETTINGS_H
#ifndef ITEMGENERALSETTINGS_H
#define ITEMGENERALSETTINGS_H
#include <QWidget>
#include <QButtonGroup>
#include "pictextitem.h"
#include <QPainter>
#include <QImage>
namespace Ui {
class ItemGeneralSettings;
}
class ItemGeneralSettings : public QWidget
{
Q_OBJECT
public:
explicit ItemGeneralSettings(QWidget *parent = nullptr);
~ItemGeneralSettings();
/**
* @brief 加载PicTextItem的属性到ViewModel,初始化UI
*
* 原因:UI应该显示item的状态,但不应该直接持有指针长期修改。
* edit()后,用户对UI的编辑会更新m_vm,而不是直接改item。
*/
void edit(PicTextItem* item);
/**
* @brief 设置当前ViewModel
*
* @param vm
*/
void setViewModel(const TextItemModel& vm);
/**
* @brief 获取当前ViewModel
*
* 调用者可以检查是否有改动,并决定是否应用
*/
TextItemModel viewModel() const { return m_vm; }
/**
* @brief 将ViewModel的属性应用到指定的PicTextItem
*
* 解耦的核心:UI不再直接修改item,而是通过VM进行间接修改。
* 这支持撤销/重做、批量编辑等高级功能。
*/
void applyToItem(PicTextItem* item);
/**
* @brief 当前编辑的item源引用(可能为空)
*
* 主要用于获取preview()时作为示例源,不用于直接修改
*/
PicTextItem* currentItem() { return m_currItem; }
void initUI();
private slots:
void ondirectionChanged(int dir);
void onBoldSpinBoxValueChanged(int multiple);
void onLetterSpaceSpinBoxChanged(int space);
void onColorReversalCheckBoxChecked(bool b);
private:
/**
* @brief 刷新预览,基于当前VM和item的source渲染
*/
void updatePreview();
Ui::ItemGeneralSettings *ui;
QButtonGroup m_directionButtonGroup;
// 原始item的快照,用于preview()和后续应用
PicTextItem* m_currItem = nullptr;
// UI编辑的状态,独立于m_currItem
TextItemModel m_vm;
// 初始加载时的VM状态,用于检测改动
TextItemModel m_vmSnapshot;
QPainter m_painter;
};
#endif // ITEMGENERALSETTINGS_H
File diff suppressed because it is too large Load Diff
+9
View File
@@ -97,6 +97,15 @@ void PicDateItem::setSource(QVariant var)
if(m_model.datetimePattern.isEmpty())
return;
// 重新计算最长显示尺寸(以防 font()/letterSpace 改变时未重算)
m_maxDateTimeStr = generateMaxDateTimeString(m_model, font());
if (m_maxDateTimeStr.isEmpty()) {
m_maxSize = QSize();
} else {
QFontMetrics fm(font());
m_maxSize = QSize(fm.horizontalAdvance(m_maxDateTimeStr), fm.height());
}
m_currDateTimeStr = ItemUtils::generateTxtFromDateItemModel(m_model, QDateTime::currentDateTime());
applyModify();
}
+37 -1
View File
@@ -1,6 +1,8 @@
#include "PicScheduleShiftItem.h"
#include <algorithm>
#include "LogInfo.h"
#include <QFontMetrics>
#include <QPainter>
PicScheduleShiftItem::PicScheduleShiftItem(QGraphicsItem *parent, QGraphicsScene *scene, const SourceType type)
:PicTextItem(parent, scene, type)
@@ -19,6 +21,9 @@ QVariant PicScheduleShiftItem::source()
void PicScheduleShiftItem::setSource(QVariant var)
{
// 重新计算基于当前字体的最大名称像素宽度
m_maxSize = calcMaxSize();
m_currScheduleName = findScheduleName(QTime::currentTime());
applyModify();
}
@@ -31,6 +36,8 @@ const QVector<ScheduleModel>& PicScheduleShiftItem::schedules() const
void PicScheduleShiftItem::setSchedules(QVector<ScheduleModel> schedules)
{
m_schedules = std::move(schedules);
m_maxSize = calcMaxSize();
m_currScheduleName = findScheduleName(QTime::currentTime());
applyModify();
}
@@ -95,11 +102,40 @@ QImage PicScheduleShiftItem::itemImage()
auto str = m_currScheduleName;
if(str.isEmpty()) {
QImage();
return QImage();
}
return strToImage(str);
}
QSize PicScheduleShiftItem::calcMaxSize()
{
if (m_schedules.isEmpty())
return QSize();
QFontMetrics fm(font());
int bestW = 0;
for (const auto &mdl : m_schedules) {
int w = fm.horizontalAdvance(mdl.name);
if (w > bestW) bestW = w;
}
return QSize(bestW, fm.height());
}
QRectF PicScheduleShiftItem::boundingRect() const
{
if (!m_itemImage.isNull()) {
return QRectF(0, 0, m_itemImage.width(), m_itemImage.height());
}
int w = m_maxSize.width();
int h = m_maxSize.height();
if (w <= 0 || h <= 0)
return QGraphicsTextItem::boundingRect();
qreal bw = qreal(w) * qMax(1, m_boldMultiple);
return QRectF(0, 0, bw, qreal(h));
}
QString PicScheduleShiftItem::findScheduleName(const QTime &time)
{
if(m_schedules.isEmpty())
+6
View File
@@ -5,6 +5,7 @@
#include <QTime>
#include <QString>
#include <QTimer>
#include <QSize>
struct ScheduleModel
{
@@ -45,6 +46,11 @@ private:
QVector<ScheduleModel> m_schedules;
QTimer m_updateTimer;
QString m_currScheduleName;
QSize m_maxSize; // 缓存最长名称的像素宽高
virtual QRectF boundingRect() const override;
QSize calcMaxSize();
};
#endif // PICSCHEDULESHIFTITEM_H
+288 -288
View File
@@ -1,288 +1,288 @@
#include "ScheduleShiftsEditor.h"
#include "ui_ScheduleShiftsEditor.h"
#include <QMouseEvent>
#include <QTimer>
#include <QModelIndex>
#include "PicScheduleShiftItem.h"
#include <QGridLayout>
#include <QDebug>
#include <QTableWidget>
#include <algorithm>
#include <QScrollBar>
ScheduleShiftsEditor::ScheduleShiftsEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::ScheduleShiftsEditor)
{
ui->setupUi(this);
m_generalSettings = new ItemGeneralSettings();
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setMargin(0);
layout->addWidget(m_generalSettings);
ui->generalSettingsTab->setLayout(layout);
// 禁用编辑
ui->tableSchedules->setEditTriggers(QTableWidget::NoEditTriggers);
ui->tableSchedules->setColumnWidth(0, 50);
ui->tableSchedules->setColumnWidth(1, 100);
ui->tableSchedules->setColumnWidth(2, 340);
ui->tableSchedules->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
ui->tableSchedules->horizontalHeader()->setVisible(true);
ui->tableSchedules->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->tableSchedules->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
ui->tableSchedules->verticalScrollBar()->scroll(0, 0);
// ui->tableSchedules->setModel(m_viewModel);
connect(ui->tableSchedules, &QTableWidget::itemSelectionChanged, this, &ScheduleShiftsEditor::onTableSelectionChanged);
connect(ui->tableSchedules, &QTableWidget::currentItemChanged, this, [this](QTableWidgetItem*, QTableWidgetItem*){onTableSelectionChanged();});
connect(ui->tableSchedules, &QTableWidget::currentCellChanged, this, [this](int, int, int, int){onTableSelectionChanged();});
connect(ui->LineEditScheduleName, &QLineEdit::textChanged, this, &ScheduleShiftsEditor::btnAddEnbCheck);
connect(ui->timeEdit, &QTimeEdit::timeChanged, this, [this](const QTime&) {btnAddEnbCheck("");});
ui->btnAdd->setEnabled(false);
ui->btnRemove->setEnabled(false);
applyStyleSheet();
}
ScheduleShiftsEditor::~ScheduleShiftsEditor()
{
delete ui;
}
void ScheduleShiftsEditor::setItemModel(QVector<ScheduleModel> schedulesModel, TextItemModel txtModel)
{
m_generalSettings->setViewModel(txtModel);
m_dataModel = schedulesModel;
applyDataModel();
ui->timeEdit->setTime(QTime(0, 0));
}
TextItemModel ScheduleShiftsEditor::textItemModel()
{
return m_generalSettings->viewModel();
}
const QVector<ScheduleModel>& ScheduleShiftsEditor::scheduleModel() const
{
return m_dataModel;
}
void ScheduleShiftsEditor::onBtnCloseClicked()
{
emit rejected();
}
void ScheduleShiftsEditor::onBtnAddClicked()
{
if(m_dataModel.size() >= 24) {
qWarning() << "The schedule shift has already reached the maximum number of 24 schedules.";
return;
}
auto t = ui->timeEdit->time();
auto b = std::binary_search(m_dataModel.begin(), m_dataModel.end(), ScheduleModel{t, QString()});
if(b) {
qWarning() << "The timestamp has already exist. " << t.toString("hh:mm");
return;
}
if(ui->LineEditScheduleName->text().isEmpty()) {
qWarning() << "The schedule name is empty.";
return;
}
ScheduleModel model;
model.startTime = t;
model.name = ui->LineEditScheduleName->text();
auto it = std::upper_bound(m_dataModel.begin(), m_dataModel.end(), model);
m_dataModel.insert(it, model);
qDebug() << "Schedule time: " << model.startTime.toString("hh:mm") << ", name: " << model.name << ", has added.";
applyDataModel();
ui->LineEditScheduleName->clear();
ui->btnRemove->setEnabled(false);
}
void ScheduleShiftsEditor::onBtnRemoveClicked()
{
if(ui->tableSchedules->currentRow() >= 0 && ui->tableSchedules->currentRow() < m_dataModel.size()) {
m_dataModel.remove(ui->tableSchedules->currentRow());
applyDataModel();
}
}
void ScheduleShiftsEditor::onTableSelectionChanged()
{
ui->btnRemove->setEnabled(ui->tableSchedules->currentRow() != -1);
}
void ScheduleShiftsEditor::btnAddEnbCheck(const QString &txt)
{
Q_UNUSED(txt);
ScheduleModel model {ui->timeEdit->time(), ""};
ui->btnAdd->setEnabled(!std::binary_search(m_dataModel.begin(), m_dataModel.end(), model) && !ui->LineEditScheduleName->text().isEmpty());
}
void ScheduleShiftsEditor::onBtnOkClicked()
{
emit accepted();
}
void ScheduleShiftsEditor::applyDataModel()
{
auto b = ui->tableSchedules->blockSignals(true);
ui->tableSchedules->clearContents();
ui->tableSchedules->setRowCount(m_dataModel.size());
for(int i = 0; i < m_dataModel.size(); ++i) {
QString time = m_dataModel[i].startTime.toString("hh:mm");
ui->tableSchedules->setItem(i, 0, new QTableWidgetItem(QString::number(i + 1)));
ui->tableSchedules->setItem(i, 1, new QTableWidgetItem(time));
ui->tableSchedules->setItem(i, 2, new QTableWidgetItem(m_dataModel[i].name));
}
ui->tableSchedules->blockSignals(b);
auto txt = QString::number(24 - m_dataModel.size());
ui->LabNbRemains->setText(QString::number(24 - m_dataModel.size()));
}
void ScheduleShiftsEditor::applyStyleSheet()
{
QString styleSheet =
R"(
/*
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
*/
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 100px;
height: 50px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QTabWidget::pane {
border: 1px solid #dddddd;
background-color: #ffffff;
}
QTabBar::tab:focus {
outline: none;
}
QTabBar::tab {
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
)";
// QFile stylesFile(":/styles.qss");
// QTextStream ts(&stylesFile);
// auto str = ts.readAll();
// setStyleSheet(str);
// ui->tabWidget->setStyleSheet(str);
// // this->setStyleSheet(styleSheet);
}
SelectedStyleTimeEdit::SelectedStyleTimeEdit(QWidget *parent)
:QTimeEdit(parent)
{
lineEdit()->installEventFilter(this);
}
SelectedStyleTimeEdit::~SelectedStyleTimeEdit()
{
lineEdit()->removeEventFilter(this);
}
bool SelectedStyleTimeEdit::eventFilter(QObject *obj, QEvent *event)
{
if (obj == lineEdit() && event->type() == QEvent::MouseButtonPress) {
// 先让父类处理(这会让内部状态更新)
bool result = QTimeEdit::eventFilter(obj, event);
// 延迟执行选中,确保currentSection已经更新
QTimer::singleShot(0, this, [this]() {
QDateTimeEdit::Section section = currentSection();
setSelectedSection(section);
});
return result;
}
return QTimeEdit::eventFilter(obj, event);
}
#include "ScheduleShiftsEditor.h"
#include "ui_ScheduleShiftsEditor.h"
#include <QMouseEvent>
#include <QTimer>
#include <QModelIndex>
#include "PicScheduleShiftItem.h"
#include <QGridLayout>
#include <QDebug>
#include <QTableWidget>
#include <algorithm>
#include <QScrollBar>
ScheduleShiftsEditor::ScheduleShiftsEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::ScheduleShiftsEditor)
{
ui->setupUi(this);
m_generalSettings = new ItemGeneralSettings();
QGridLayout* layout = new QGridLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setMargin(0);
layout->addWidget(m_generalSettings);
ui->generalSettingsTab->setLayout(layout);
// 禁用编辑
ui->tableSchedules->setEditTriggers(QTableWidget::NoEditTriggers);
ui->tableSchedules->setColumnWidth(0, 50);
ui->tableSchedules->setColumnWidth(1, 100);
ui->tableSchedules->setColumnWidth(2, 340);
ui->tableSchedules->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
ui->tableSchedules->horizontalHeader()->setVisible(true);
ui->tableSchedules->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->tableSchedules->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
ui->tableSchedules->verticalScrollBar()->scroll(0, 0);
// ui->tableSchedules->setModel(m_viewModel);
connect(ui->tableSchedules, &QTableWidget::itemSelectionChanged, this, &ScheduleShiftsEditor::onTableSelectionChanged);
connect(ui->tableSchedules, &QTableWidget::currentItemChanged, this, [this](QTableWidgetItem*, QTableWidgetItem*){onTableSelectionChanged();});
connect(ui->tableSchedules, &QTableWidget::currentCellChanged, this, [this](int, int, int, int){onTableSelectionChanged();});
connect(ui->LineEditScheduleName, &QLineEdit::textChanged, this, &ScheduleShiftsEditor::btnAddEnbCheck);
connect(ui->timeEdit, &QTimeEdit::timeChanged, this, [this](const QTime&) {btnAddEnbCheck("");});
ui->btnAdd->setEnabled(false);
ui->btnRemove->setEnabled(false);
applyStyleSheet();
}
ScheduleShiftsEditor::~ScheduleShiftsEditor()
{
delete ui;
}
void ScheduleShiftsEditor::setItemModel(QVector<ScheduleModel> schedulesModel, TextItemModel txtModel)
{
m_generalSettings->setViewModel(txtModel);
m_dataModel = schedulesModel;
applyDataModel();
ui->timeEdit->setTime(QTime(0, 0));
}
TextItemModel ScheduleShiftsEditor::textItemModel()
{
return m_generalSettings->viewModel();
}
const QVector<ScheduleModel>& ScheduleShiftsEditor::scheduleModel() const
{
return m_dataModel;
}
void ScheduleShiftsEditor::onBtnCloseClicked()
{
emit rejected();
}
void ScheduleShiftsEditor::onBtnAddClicked()
{
if(m_dataModel.size() >= 24) {
qWarning() << "The schedule shift has already reached the maximum number of 24 schedules.";
return;
}
auto t = ui->timeEdit->time();
auto b = std::binary_search(m_dataModel.begin(), m_dataModel.end(), ScheduleModel{t, QString()});
if(b) {
qWarning() << "The timestamp has already exist. " << t.toString("hh:mm");
return;
}
if(ui->LineEditScheduleName->text().isEmpty()) {
qWarning() << "The schedule name is empty.";
return;
}
ScheduleModel model;
model.startTime = t;
model.name = ui->LineEditScheduleName->text();
auto it = std::upper_bound(m_dataModel.begin(), m_dataModel.end(), model);
m_dataModel.insert(it, model);
qDebug() << "Schedule time: " << model.startTime.toString("hh:mm") << ", name: " << model.name << ", has added.";
applyDataModel();
ui->LineEditScheduleName->clear();
ui->btnRemove->setEnabled(false);
}
void ScheduleShiftsEditor::onBtnRemoveClicked()
{
if(ui->tableSchedules->currentRow() >= 0 && ui->tableSchedules->currentRow() < m_dataModel.size()) {
m_dataModel.remove(ui->tableSchedules->currentRow());
applyDataModel();
}
}
void ScheduleShiftsEditor::onTableSelectionChanged()
{
ui->btnRemove->setEnabled(ui->tableSchedules->currentRow() != -1);
}
void ScheduleShiftsEditor::btnAddEnbCheck(const QString &txt)
{
Q_UNUSED(txt);
ScheduleModel model {ui->timeEdit->time(), ""};
ui->btnAdd->setEnabled(!std::binary_search(m_dataModel.begin(), m_dataModel.end(), model) && !ui->LineEditScheduleName->text().isEmpty());
}
void ScheduleShiftsEditor::onBtnOkClicked()
{
emit accepted();
}
void ScheduleShiftsEditor::applyDataModel()
{
auto b = ui->tableSchedules->blockSignals(true);
ui->tableSchedules->clearContents();
ui->tableSchedules->setRowCount(m_dataModel.size());
for(int i = 0; i < m_dataModel.size(); ++i) {
QString time = m_dataModel[i].startTime.toString("hh:mm");
ui->tableSchedules->setItem(i, 0, new QTableWidgetItem(QString::number(i + 1)));
ui->tableSchedules->setItem(i, 1, new QTableWidgetItem(time));
ui->tableSchedules->setItem(i, 2, new QTableWidgetItem(m_dataModel[i].name));
}
ui->tableSchedules->blockSignals(b);
auto txt = QString::number(24 - m_dataModel.size());
ui->LabNbRemains->setText(QString::number(24 - m_dataModel.size()));
}
void ScheduleShiftsEditor::applyStyleSheet()
{
QString styleSheet =
R"(
/*
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
*/
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 100px;
height: 50px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QTabWidget::pane {
border: 1px solid #dddddd;
background-color: #ffffff;
}
QTabBar::tab:focus {
outline: none;
}
QTabBar::tab {
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
)";
// QFile stylesFile(":/styles.qss");
// QTextStream ts(&stylesFile);
// auto str = ts.readAll();
// setStyleSheet(str);
// ui->tabWidget->setStyleSheet(str);
// // this->setStyleSheet(styleSheet);
}
SelectedStyleTimeEdit::SelectedStyleTimeEdit(QWidget *parent)
:QTimeEdit(parent)
{
lineEdit()->installEventFilter(this);
}
SelectedStyleTimeEdit::~SelectedStyleTimeEdit()
{
lineEdit()->removeEventFilter(this);
}
bool SelectedStyleTimeEdit::eventFilter(QObject *obj, QEvent *event)
{
if (obj == lineEdit() && event->type() == QEvent::MouseButtonPress) {
// 先让父类处理(这会让内部状态更新)
bool result = QTimeEdit::eventFilter(obj, event);
// 延迟执行选中,确保currentSection已经更新
QTimer::singleShot(0, this, [this]() {
QDateTimeEdit::Section section = currentSection();
setSelectedSection(section);
});
return result;
}
return QTimeEdit::eventFilter(obj, event);
}
+64 -64
View File
@@ -1,64 +1,64 @@
#ifndef SCHEDULESHIFTSEDITOR_H
#define SCHEDULESHIFTSEDITOR_H
#include <QWidget>
#include <QTime>
#include <QTimeEdit>
#include <QStandardItemModel>
#include "PicScheduleShiftItem.h"
#include "ItemGeneralSettings.h"
namespace Ui {
class ScheduleShiftsEditor;
}
/**
* @brief 重写实现以实现一个自定义的QTimeEdit组件,用于选择时间时,点击时间选择器的部分时,能够选中所选的部分,而不仅仅是移动光标
*/
class SelectedStyleTimeEdit : public QTimeEdit
{
Q_OBJECT
public:
SelectedStyleTimeEdit(QWidget *parent = nullptr);
virtual ~SelectedStyleTimeEdit();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
};
class ScheduleShiftsEditor : public QWidget
{
Q_OBJECT
public:
explicit ScheduleShiftsEditor(QWidget *parent = nullptr);
~ScheduleShiftsEditor();
void setItemModel(QVector<ScheduleModel> schedulesModel, TextItemModel txtModel);
TextItemModel textItemModel();
const QVector<ScheduleModel>& scheduleModel() const;
signals:
void accepted();
void rejected();
private slots:
void onBtnOkClicked();
void onBtnCloseClicked();
void onBtnAddClicked();
void onBtnRemoveClicked();
void onTableSelectionChanged();
void btnAddEnbCheck(const QString& txt);
private:
void applyDataModel();
void applyStyleSheet();
Ui::ScheduleShiftsEditor *ui;
QVector<ScheduleModel> m_dataModel;
ItemGeneralSettings* m_generalSettings = nullptr;
};
#endif // SCHEDULESHIFTSEDITOR_H
#ifndef SCHEDULESHIFTSEDITOR_H
#define SCHEDULESHIFTSEDITOR_H
#include <QWidget>
#include <QTime>
#include <QTimeEdit>
#include <QStandardItemModel>
#include "PicScheduleShiftItem.h"
#include "ItemGeneralSettings.h"
namespace Ui {
class ScheduleShiftsEditor;
}
/**
* @brief 重写实现以实现一个自定义的QTimeEdit组件,用于选择时间时,点击时间选择器的部分时,能够选中所选的部分,而不仅仅是移动光标
*/
class SelectedStyleTimeEdit : public QTimeEdit
{
Q_OBJECT
public:
SelectedStyleTimeEdit(QWidget *parent = nullptr);
virtual ~SelectedStyleTimeEdit();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
};
class ScheduleShiftsEditor : public QWidget
{
Q_OBJECT
public:
explicit ScheduleShiftsEditor(QWidget *parent = nullptr);
~ScheduleShiftsEditor();
void setItemModel(QVector<ScheduleModel> schedulesModel, TextItemModel txtModel);
TextItemModel textItemModel();
const QVector<ScheduleModel>& scheduleModel() const;
signals:
void accepted();
void rejected();
private slots:
void onBtnOkClicked();
void onBtnCloseClicked();
void onBtnAddClicked();
void onBtnRemoveClicked();
void onTableSelectionChanged();
void btnAddEnbCheck(const QString& txt);
private:
void applyDataModel();
void applyStyleSheet();
Ui::ScheduleShiftsEditor *ui;
QVector<ScheduleModel> m_dataModel;
ItemGeneralSettings* m_generalSettings = nullptr;
};
#endif // SCHEDULESHIFTSEDITOR_H
File diff suppressed because it is too large Load Diff