更新代码

master
feiyangqingyun 2020-12-24 18:00:09 +08:00
parent 13cdeacd63
commit 39dab8c3c0
40 changed files with 243 additions and 402 deletions

View File

@ -13,6 +13,7 @@ Battery::Battery(QWidget *parent) : QWidget(parent)
alarmValue = 30;
step = 0.5;
borderWidth = 5;
borderRadius = 8;
bgRadius = 5;
headRadius = 3;
@ -57,15 +58,15 @@ void Battery::drawBorder(QPainter *painter)
{
painter->save();
qreal headWidth = width() / 10;
qreal batteryWidth = width() - headWidth;
double headWidth = width() / 15;
double batteryWidth = width() - headWidth;
//绘制电池边框
QPointF topLeft(5, 5);
QPointF bottomRight(batteryWidth, height() - 5);
QPointF topLeft(borderWidth, borderWidth);
QPointF bottomRight(batteryWidth, height() - borderWidth);
batteryRect = QRectF(topLeft, bottomRight);
painter->setPen(QPen(borderColorStart, 5));
painter->setPen(QPen(borderColorStart, borderWidth));
painter->setBrush(Qt::NoBrush);
painter->drawRoundedRect(batteryRect, borderRadius, borderRadius);
@ -74,6 +75,10 @@ void Battery::drawBorder(QPainter *painter)
void Battery::drawBg(QPainter *painter)
{
if (value == minValue) {
return;
}
painter->save();
QLinearGradient batteryGradient(QPointF(0, 0), QPointF(0, height()));
@ -86,10 +91,10 @@ void Battery::drawBg(QPainter *painter)
}
int margin = qMin(width(), height()) / 20;
qreal unit = (batteryRect.width() - (margin * 2)) / 100;
qreal width = currentValue * unit;
double unit = (batteryRect.width() - (margin * 2)) / 100;
double width = currentValue * unit;
QPointF topLeft(batteryRect.topLeft().x() + margin, batteryRect.topLeft().y() + margin);
QPointF bottomRight(width + margin + 5, batteryRect.bottomRight().y() - margin);
QPointF bottomRight(width + margin + borderWidth, batteryRect.bottomRight().y() - margin);
QRectF rect(topLeft, bottomRight);
painter->setPen(Qt::NoPen);
@ -122,13 +127,11 @@ void Battery::updateValue()
{
if (isForward) {
currentValue -= step;
if (currentValue <= value) {
timer->stop();
}
} else {
currentValue += step;
if (currentValue >= value) {
timer->stop();
}
@ -137,31 +140,36 @@ void Battery::updateValue()
this->update();
}
qreal Battery::getMinValue() const
double Battery::getMinValue() const
{
return this->minValue;
}
qreal Battery::getMaxValue() const
double Battery::getMaxValue() const
{
return this->maxValue;
}
qreal Battery::getValue() const
double Battery::getValue() const
{
return this->value;
}
qreal Battery::getAlarmValue() const
double Battery::getAlarmValue() const
{
return this->alarmValue;
}
qreal Battery::getStep() const
double Battery::getStep() const
{
return this->step;
}
int Battery::getBorderWidth() const
{
return this->borderWidth;
}
int Battery::getBorderRadius() const
{
return this->borderRadius;
@ -217,7 +225,7 @@ QSize Battery::minimumSizeHint() const
return QSize(30, 10);
}
void Battery::setRange(qreal minValue, qreal maxValue)
void Battery::setRange(double minValue, double maxValue)
{
//如果最小值大于或者等于最大值则不设置
if (minValue >= maxValue) {
@ -240,20 +248,20 @@ void Battery::setRange(qreal minValue, qreal maxValue)
void Battery::setRange(int minValue, int maxValue)
{
setRange((qreal)minValue, (qreal)maxValue);
setRange((double)minValue, (double)maxValue);
}
void Battery::setMinValue(qreal minValue)
void Battery::setMinValue(double minValue)
{
setRange(minValue, maxValue);
}
void Battery::setMaxValue(qreal maxValue)
void Battery::setMaxValue(double maxValue)
{
setRange(minValue, maxValue);
}
void Battery::setValue(qreal value)
void Battery::setValue(double value)
{
//值和当前值一致则无需处理
if (value == this->value) {
@ -272,21 +280,24 @@ void Battery::setValue(qreal value)
} else if (value < currentValue) {
isForward = true;
} else {
this->value = value;
this->update();
return;
}
this->value = value;
this->update();
emit valueChanged(value);
timer->stop();
timer->start();
}
void Battery::setValue(int value)
{
setValue((qreal)value);
setValue((double)value);
}
void Battery::setAlarmValue(qreal alarmValue)
void Battery::setAlarmValue(double alarmValue)
{
if (this->alarmValue != alarmValue) {
this->alarmValue = alarmValue;
@ -296,10 +307,10 @@ void Battery::setAlarmValue(qreal alarmValue)
void Battery::setAlarmValue(int alarmValue)
{
setAlarmValue((qreal)alarmValue);
setAlarmValue((double)alarmValue);
}
void Battery::setStep(qreal step)
void Battery::setStep(double step)
{
if (this->step != step) {
this->step = step;
@ -309,7 +320,15 @@ void Battery::setStep(qreal step)
void Battery::setStep(int step)
{
setStep((qreal)step);
setStep((double)step);
}
void Battery::setBorderWidth(int borderWidth)
{
if (this->borderWidth != borderWidth) {
this->borderWidth = borderWidth;
this->update();
}
}
void Battery::setBorderRadius(int borderRadius)

View File

@ -14,25 +14,20 @@
#include <QWidget>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT Battery : public QWidget
class Q_DECL_EXPORT Battery : public QWidget
#else
class Battery : public QWidget
#endif
{
Q_OBJECT
Q_PROPERTY(qreal minValue READ getMinValue WRITE setMinValue)
Q_PROPERTY(qreal maxValue READ getMaxValue WRITE setMaxValue)
Q_PROPERTY(qreal value READ getValue WRITE setValue)
Q_PROPERTY(qreal alarmValue READ getAlarmValue WRITE setAlarmValue)
Q_PROPERTY(double minValue READ getMinValue WRITE setMinValue)
Q_PROPERTY(double maxValue READ getMaxValue WRITE setMaxValue)
Q_PROPERTY(double value READ getValue WRITE setValue)
Q_PROPERTY(double alarmValue READ getAlarmValue WRITE setAlarmValue)
Q_PROPERTY(qreal step READ getStep WRITE setStep)
Q_PROPERTY(double step READ getStep WRITE setStep)
Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth)
Q_PROPERTY(int borderRadius READ getBorderRadius WRITE setBorderRadius)
Q_PROPERTY(int bgRadius READ getBgRadius WRITE setBgRadius)
Q_PROPERTY(int headRadius READ getHeadRadius WRITE setHeadRadius)
@ -60,74 +55,78 @@ private slots:
void updateValue();
private:
qreal minValue; //最小值
qreal maxValue; //最大值
qreal value; //目标电量
qreal alarmValue; //电池电量警戒值
double minValue; //最小值
double maxValue; //最大值
double value; //目标电量
double alarmValue; //电池电量警戒值
qreal step; //每次移动的步长
int borderRadius; //边框圆角角度
int bgRadius; //背景进度圆角角度
int headRadius; //头部圆角角度
double step; //每次移动的步长
int borderWidth; //边框粗细
int borderRadius; //边框圆角角度
int bgRadius; //背景进度圆角角度
int headRadius; //头部圆角角度
QColor borderColorStart; //边框渐变开始颜色
QColor borderColorEnd; //边框渐变结束颜色
QColor borderColorStart; //边框渐变开始颜色
QColor borderColorEnd; //边框渐变结束颜色
QColor alarmColorStart; //电池低电量时的渐变开始颜色
QColor alarmColorEnd; //电池低电量时的渐变结束颜色
QColor alarmColorStart; //电池低电量时的渐变开始颜色
QColor alarmColorEnd; //电池低电量时的渐变结束颜色
QColor normalColorStart; //电池正常电量时的渐变开始颜色
QColor normalColorEnd; //电池正常电量时的渐变结束颜色
QColor normalColorStart; //电池正常电量时的渐变开始颜色
QColor normalColorEnd; //电池正常电量时的渐变结束颜色
bool isForward; //是否往前移
qreal currentValue; //当前电量
QRectF batteryRect; //电池主体区域
QTimer *timer; //绘制定时器
bool isForward; //是否往前移
double currentValue; //当前电量
QRectF batteryRect; //电池主体区域
QTimer *timer; //绘制定时器
public:
qreal getMinValue() const;
qreal getMaxValue() const;
qreal getValue() const;
qreal getAlarmValue() const;
double getMinValue() const;
double getMaxValue() const;
double getValue() const;
double getAlarmValue() const;
qreal getStep() const;
int getBorderRadius() const;
int getBgRadius() const;
int getHeadRadius() const;
double getStep() const;
int getBorderWidth() const;
int getBorderRadius() const;
int getBgRadius() const;
int getHeadRadius() const;
QColor getBorderColorStart()const;
QColor getBorderColorEnd() const;
QColor getBorderColorStart() const;
QColor getBorderColorEnd() const;
QColor getAlarmColorStart() const;
QColor getAlarmColorEnd() const;
QColor getAlarmColorStart() const;
QColor getAlarmColorEnd() const;
QColor getNormalColorStart()const;
QColor getNormalColorEnd() const;
QColor getNormalColorStart() const;
QColor getNormalColorEnd() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public Q_SLOTS:
//设置范围值
void setRange(qreal minValue, qreal maxValue);
void setRange(double minValue, double maxValue);
void setRange(int minValue, int maxValue);
//设置最大最小值
void setMinValue(qreal minValue);
void setMaxValue(qreal maxValue);
void setMinValue(double minValue);
void setMaxValue(double maxValue);
//设置电池电量值
void setValue(qreal value);
void setValue(double value);
void setValue(int value);
//设置电池电量警戒值
void setAlarmValue(qreal alarmValue);
void setAlarmValue(double alarmValue);
void setAlarmValue(int alarmValue);
//设置步长
void setStep(qreal step);
void setStep(double step);
void setStep(int step);
//设置边框粗细
void setBorderWidth(int borderWidth);
//设置边框圆角角度
void setBorderRadius(int borderRadius);
//设置背景圆角角度
@ -148,7 +147,7 @@ public Q_SLOTS:
void setNormalColorEnd(const QColor &normalColorEnd);
Q_SIGNALS:
void valueChanged(qreal value);
void valueChanged(double value);
};
#endif // BATTERY_H

View File

@ -180,7 +180,7 @@ void ButtonDefence::setButtonStyle(const ButtonDefence::ButtonStyle &buttonStyle
} else if (buttonStyle == ButtonStyle_Msg2) {
type = "msg2";
} else {
type = "custom";
type = "circle";
}
setButtonStatus(buttonStatus);

View File

@ -14,13 +14,7 @@
#include <QWidget>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT ButtonDefence : public QWidget
class Q_DECL_EXPORT ButtonDefence : public QWidget
#else
class ButtonDefence : public QWidget
#endif
@ -37,16 +31,14 @@ class ButtonDefence : public QWidget
Q_PROPERTY(ButtonStatus buttonStatus READ getButtonStatus WRITE setButtonStatus)
public:
//防区样式 圆形、警察、气泡、气泡2、消息、消息2、自定义
//如果设置的自定义的,则图片拓展名 btn_defence_alarm_custom
//防区样式 圆形、警察、气泡、气泡2、消息、消息2
enum ButtonStyle {
ButtonStyle_Circle = 0,
ButtonStyle_Police = 1,
ButtonStyle_Bubble = 2,
ButtonStyle_Bubble2 = 3,
ButtonStyle_Msg = 4,
ButtonStyle_Msg2 = 5,
ButtonStyle_Custom = 6
ButtonStyle_Msg2 = 5
};
//防区状态 布防、撤防、报警、旁路、故障

View File

@ -31,7 +31,7 @@ void frmButtonDefence::initForm()
btn3->setText("#3");
btn3->setGeometry(85, 5, 35, 35);
btnStyle << ui->btnCircle << ui->btnPolice << ui->btnBubble << ui->btnBubble2 << ui->btnMsg << ui->btnMsg2 << ui->btnCustom;
btnStyle << ui->btnCircle << ui->btnPolice << ui->btnBubble << ui->btnBubble2 << ui->btnMsg << ui->btnMsg2;
foreach (QPushButton *btn, btnStyle) {
connect(btn, SIGNAL(clicked(bool)), this, SLOT(changeStyle()));
}
@ -50,16 +50,6 @@ void frmButtonDefence::changeStyle()
btn1->setButtonStyle(style);
btn2->setButtonStyle(style);
btn3->setButtonStyle(style);
if (index == 6) {
btn1->setText("");
btn2->setText("");
btn3->setText("");
} else {
btn1->setText("#1");
btn2->setText("#2");
btn3->setText("#3");
}
}
void frmButtonDefence::changeStatus()
@ -79,10 +69,3 @@ void frmButtonDefence::on_ckCanMove_stateChanged(int arg1)
btn2->setCanMove(canMove);
btn3->setCanMove(canMove);
}
void frmButtonDefence::on_btnPoint_clicked()
{
qDebug() << "btn1" << "x" << btn1->geometry().x() << "y" << btn1->geometry().y();
qDebug() << "btn2" << "x" << btn2->geometry().x() << "y" << btn2->geometry().y();
qDebug() << "btn3" << "x" << btn3->geometry().x() << "y" << btn3->geometry().y();
}

View File

@ -25,8 +25,6 @@ private slots:
void changeStatus();
void on_ckCanMove_stateChanged(int arg1);
void on_btnPoint_clicked();
private:
Ui::frmButtonDefence *ui;
ButtonDefence *btn1;

View File

@ -87,13 +87,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCustom">
<property name="text">
<string>自定义</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
@ -136,13 +129,6 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ckCanMove">
<property name="text">
@ -150,13 +136,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPoint">
<property name="text">
<string>坐标</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -176,21 +155,6 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>btnCircle</tabstop>
<tabstop>btnPolice</tabstop>
<tabstop>btnBubble</tabstop>
<tabstop>btnBubble2</tabstop>
<tabstop>btnMsg</tabstop>
<tabstop>btnMsg2</tabstop>
<tabstop>btnCustom</tabstop>
<tabstop>btnArming</tabstop>
<tabstop>btnDisarming</tabstop>
<tabstop>btnAlarm</tabstop>
<tabstop>btnBypass</tabstop>
<tabstop>btnError</tabstop>
<tabstop>ckCanMove</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -31,10 +31,5 @@
<file>image/btn_defence_error_msg2.png</file>
<file>image/btn_defence_error_police.png</file>
<file>image/bg_call.jpg</file>
<file>image/btn_defence_alarm_custom.png</file>
<file>image/btn_defence_arming_custom.png</file>
<file>image/btn_defence_bypass_custom.png</file>
<file>image/btn_defence_disarming_custom.png</file>
<file>image/btn_defence_error_custom.png</file>
</qresource>
</RCC>

View File

@ -105,7 +105,7 @@ ColorWidget::ColorWidget(QWidget *parent) : QWidget(parent)
}
ColorWidget::~ColorWidget()
{
{
}
void ColorWidget::mousePressEvent(QMouseEvent *e)
@ -128,10 +128,7 @@ void ColorWidget::showColorValue()
int x = QCursor::pos().x();
int y = QCursor::pos().y();
txtPoint->setText(tr("x:%1 y:%2").arg(x).arg(y));
QString strDecimalValue, strHex, strTextColor;
int red, green, blue;
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), x, y, 2, 2);
@ -140,9 +137,10 @@ void ColorWidget::showColorValue()
QPixmap pixmap = screen->grabWindow(QApplication::desktop()->winId(), x, y, 2, 2);
#endif
int red, green, blue;
QString strDecimalValue, strHex;
if (!pixmap.isNull()) {
QImage image = pixmap.toImage();
if (!image.isNull()) {
if (image.valid(0, 0)) {
QColor color = image.pixel(0, 0);
@ -159,13 +157,12 @@ void ColorWidget::showColorValue()
}
}
if (red > 200 && green > 200 && blue > 200) {
strTextColor = "10, 10, 10";
} else {
strTextColor = "255, 255, 255";
}
//根据背景色自动计算合适的前景色
QColor color(red, green, blue);
double gray = (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
QColor textColor = gray > 0.5 ? Qt::black : Qt::white;
QString str = tr("background-color: rgb(%1);color: rgb(%2)").arg(strDecimalValue).arg(strTextColor);
QString str = tr("background:rgb(%1);color:%2").arg(strDecimalValue).arg(textColor.name());
labColor->setStyleSheet(str);
txtRgb->setText(strDecimalValue);
txtWeb->setText(strHex);

View File

@ -9,13 +9,7 @@ class QLabel;
class QLineEdit;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT ColorWidget : public QWidget
class Q_DECL_EXPORT ColorWidget : public QWidget
#else
class ColorWidget : public QWidget
#endif

View File

@ -88,14 +88,15 @@ bool frmCountCode::checkFile(const QString &fileName)
void frmCountCode::countCode(const QString &filePath)
{
QDir dir(filePath);
foreach (QFileInfo fileInfo , dir.entryInfoList()) {
QFileInfoList fileInfos = dir.entryInfoList();
foreach (QFileInfo fileInfo, fileInfos) {
QString fileName = fileInfo.fileName();
if (fileInfo.isFile()) {
QString strFileName = fileInfo.fileName();
if (checkFile(strFileName)) {
if (checkFile(fileName)) {
listFile << fileInfo.filePath();
}
} else {
if(fileInfo.fileName() == "." || fileInfo.fileName() == "..") {
if (fileName == "." || fileName == "..") {
continue;
}

BIN
countcode/snap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@ -3,10 +3,10 @@
/**
* :feiyangqingyun(QQ:517216493) 2016-11-30
* 1:/
* 2:
* 3:
* 4:USD
* 1. /
* 2.
* 3.
* 4. USD
*/
#include <QTableWidget>
@ -14,13 +14,7 @@
class QProcess;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT DeviceSizeTable : public QTableWidget
class Q_DECL_EXPORT DeviceSizeTable : public QTableWidget
#else
class DeviceSizeTable : public QTableWidget
#endif

View File

@ -3,14 +3,14 @@
/**
* FlatUI :feiyangqingyun(QQ:517216493) 2016-12-16
* 1:
* 2:
* 3:
* 4:
* 5:
* 6:
* 7:
* 8:
* 1.
* 2.
* 3.
* 4.
* 5.
* 6.
* 7.
* 8.
*/
#include <QObject>
@ -24,13 +24,7 @@ class QCheckBox;
class QScrollBar;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT FlatUI : public QObject
class Q_DECL_EXPORT FlatUI : public QObject
#else
class FlatUI : public QObject
#endif

View File

@ -3,23 +3,17 @@
/**
* :feiyangqingyun(QQ:517216493) 2019-10-03
* 1:widget
* 2:
* 3:,便
* 4:
* 5:
* 1. widget
* 2.
* 3. ,便
* 4.
* 5.
*/
#include <QWidget>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT FramelessWidget : public QObject
class Q_DECL_EXPORT FramelessWidget : public QObject
#else
class FramelessWidget : public QObject
#endif

View File

@ -3,11 +3,11 @@
/**
* GIF :feiyangqingyun(QQ:517216493) 2019-4-3
* 1:,.
* 2:
* 3:
* 4:
* 5:
* 1. ,.
* 2.
* 3.
* 4.
* 5.
*/
#include <QDialog>
@ -17,13 +17,7 @@ class QLineEdit;
class QLabel;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT GifWidget : public QDialog
class Q_DECL_EXPORT GifWidget : public QDialog
#else
class GifWidget : public QDialog
#endif

View File

@ -3,20 +3,14 @@
/**
* :feiyangqingyun(QQ:517216493) 2016-11-25
* 1:
* 2:
* 1.
* 2.
*/
#include <QWidget>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT ImageSwitch : public QWidget
class Q_DECL_EXPORT ImageSwitch : public QWidget
#else
class ImageSwitch : public QWidget
#endif

View File

@ -4,10 +4,12 @@
#include "qlabel.h"
#include "qlineedit.h"
#include "qboxlayout.h"
#include "qregexp.h"
#include "qvalidator.h"
#include "qevent.h"
#include "qdebug.h"
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
#include "qregexp.h"
#endif
IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
{
@ -53,6 +55,7 @@ IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
txtIP4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(txtIP4, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
//设置IP地址校验过滤
QRegExp regExp("(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})");
QRegExpValidator *validator = new QRegExpValidator(regExp, this);
@ -60,6 +63,7 @@ IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
txtIP2->setValidator(validator);
txtIP3->setValidator(validator);
txtIP4->setValidator(validator);
#endif
//绑定事件过滤器,识别键盘按下
txtIP1->installEventFilter(this);
@ -79,13 +83,13 @@ IPAddress::IPAddress(QWidget *parent) : QWidget(parent)
frame->setStyleSheet(qss.join(""));
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
verticalLayout->setMargin(0);
verticalLayout->setContentsMargins(0, 0, 0, 0);
verticalLayout->setSpacing(0);
verticalLayout->addWidget(frame);
//将控件按照横向布局排列
QHBoxLayout *layout = new QHBoxLayout(frame);
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(txtIP1);
layout->addWidget(labDot1);
@ -153,11 +157,13 @@ QSize IPAddress::minimumSizeHint() const
void IPAddress::setIP(const QString &ip)
{
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
//先检测IP地址是否合法
QRegExp regExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");
if (!regExp.exactMatch(ip)) {
return;
}
#endif
if (this->ip != ip) {
this->ip = ip;

View File

@ -3,12 +3,12 @@
/**
* IP :feiyangqingyun(QQ:517216493) 2017-8-11
* 1:IP,
* 2:IP
* 3:
* 4:退
* 5:IP
* 6://
* 1. IP,
* 2. IP
* 3.
* 4. 退
* 5. IP
* 6. //
*/
#include <QWidget>
@ -17,13 +17,7 @@ class QLabel;
class QLineEdit;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT IPAddress : public QWidget
class Q_DECL_EXPORT IPAddress : public QWidget
#else
class IPAddress : public QWidget
#endif

View File

@ -3,28 +3,22 @@
/**
* :feiyangqingyun(QQ:517216493) 2016-10-16
* 1:,
* 2:
* 3:
* 4:
* 5:
* 6: 绿////
* 7:,使
* 8:
* 9:+
* 10:,
* 1. ,
* 2.
* 3.
* 4.
* 5.
* 6. 绿////
* 7. ,使
* 8.
* 9. +
* 10. ,
*/
#include <QWidget>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT LightButton : public QWidget
class Q_DECL_EXPORT LightButton : public QWidget
#else
class LightButton : public QWidget
#endif

View File

@ -3,23 +3,17 @@
/**
* : :feiyangqingyun(QQ:517216493) 2016-12-10
* 1:
* 2:
* 3:
* 4: ++
* 5:,
* 1.
* 2.
* 3.
* 4. ++
* 5. ,
*/
#include <QObject>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT LunarCalendarInfo : public QObject
class Q_DECL_EXPORT LunarCalendarInfo : public QObject
#else
class LunarCalendarInfo : public QObject
#endif

View File

@ -5,13 +5,7 @@
#include <QDate>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT LunarCalendarItem : public QWidget
class Q_DECL_EXPORT LunarCalendarItem : public QWidget
#else
class LunarCalendarItem : public QWidget
#endif

View File

@ -159,7 +159,7 @@ void LunarCalendarWidget::initWidget()
//星期布局
QHBoxLayout *layoutWeek = new QHBoxLayout(widgetWeek);
layoutWeek->setMargin(0);
layoutWeek->setContentsMargins(0, 0, 0, 0);
layoutWeek->setSpacing(0);
for (int i = 0; i < 7; i++) {
@ -177,7 +177,7 @@ void LunarCalendarWidget::initWidget()
//日期标签布局
QGridLayout *layoutBody = new QGridLayout(widgetBody);
layoutBody->setMargin(1);
layoutBody->setContentsMargins(1, 1, 1, 1);
layoutBody->setHorizontalSpacing(0);
layoutBody->setVerticalSpacing(0);
@ -191,7 +191,7 @@ void LunarCalendarWidget::initWidget()
//主布局
QVBoxLayout *verLayoutCalendar = new QVBoxLayout(this);
verLayoutCalendar->setMargin(0);
verLayoutCalendar->setContentsMargins(0, 0, 0, 0);
verLayoutCalendar->setSpacing(0);
verLayoutCalendar->addWidget(widgetTop);
verLayoutCalendar->addWidget(widgetWeek);

View File

@ -3,15 +3,15 @@
/**
* : :feiyangqingyun(QQ:517216493) 2017-11-17
* 1:///
* 2:///
* 3:///
* 4:///
* 5:,++
* 6:////
* 7:,使
* 8:1901-2099
* 9:便
* 1. ///
* 2. ///
* 3. ///
* 4. ///
* 5. ,++
* 6. ////
* 7. ,使
* 8. 1901-2099
* 9. 便
*/
#include <QWidget>
@ -25,13 +25,7 @@ class QComboBox;
class LunarCalendarItem;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT LunarCalendarWidget : public QWidget
class Q_DECL_EXPORT LunarCalendarWidget : public QWidget
#else
class LunarCalendarWidget : public QWidget
#endif

View File

@ -2,8 +2,8 @@
#include "maskwidget.h"
#include "qmutex.h"
#include "qapplication.h"
#include "qdesktopwidget.h"
#include "qapplication.h"
#include "qdebug.h"
QScopedPointer<MaskWidget> MaskWidget::self;
@ -56,7 +56,7 @@ void MaskWidget::setOpacity(double opacity)
void MaskWidget::setBgColor(const QColor &bgColor)
{
QPalette palette = this->palette();
palette.setBrush(QPalette::Background, bgColor);
palette.setBrush(QPalette::Window, bgColor);
this->setPalette(palette);
}

View File

@ -3,23 +3,17 @@
/**
* :feiyangqingyun(QQ:517216493) 2016-12-26
* 1:,
* 2:,
* 3:
* 4:
* 5:
* 1. ,
* 2. ,
* 3.
* 4.
* 5.
*/
#include <QWidget>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT MaskWidget : public QWidget
class Q_DECL_EXPORT MaskWidget : public QWidget
#else
class MaskWidget : public QWidget
#endif

View File

@ -7,8 +7,12 @@
#include <QtWidgets>
#endif
//图形字体处理类
#ifdef quc
class Q_DECL_EXPORT IconHelper : public QObject
#else
class IconHelper : public QObject
#endif
{
Q_OBJECT

View File

@ -43,6 +43,7 @@ NavButton::NavButton(QWidget *parent) : QPushButton(parent)
hover = false;
setCheckable(true);
setText("导航按钮");
}
void NavButton::enterEvent(QEvent *)

View File

@ -3,26 +3,20 @@
/**
* :feiyangqingyun(QQ:517216493) 2017-12-19
* 1:+++
* 2:
* 3:///
* 4://///
* 5:线/线/线/线/线
* 6://
* 7://
* 8:
* 1. +++
* 2.
* 3. ///
* 4. /////
* 5. 线/线/线/线/线
* 6. //
* 7. //
* 8.
*/
#include <QPushButton>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT NavButton : public QPushButton
class Q_DECL_EXPORT NavButton : public QPushButton
#else
class NavButton : public QPushButton
#endif

View File

@ -33,7 +33,7 @@
<item row="0" column="1">
<widget class="QLineEdit" name="txtNtpIP">
<property name="text">
<string>ntp1.aliyun.com</string>
<string>133.100.11.8</string>
</property>
</widget>
</item>

View File

@ -3,8 +3,8 @@
/**
* Ntp :feiyangqingyun(QQ:517216493) 2017-2-16
* 1:NtpIP
* 2:
* 1. NtpIP
* 2.
*/
#include <QObject>
@ -12,13 +12,7 @@
class QUdpSocket;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT NtpClient : public QObject
class Q_DECL_EXPORT NtpClient : public QObject
#else
class NtpClient : public QObject
#endif
@ -45,10 +39,8 @@ signals:
public slots:
//设置NTP服务器IP
void setNtpIP(const QString &ntpIP);
//获取日期时间
void getDateTime();
};
#endif // NTPCLIENT_H

View File

@ -8,13 +8,7 @@ class QTcpSocket;
class QTcpServer;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT SaveLog : public QObject
class Q_DECL_EXPORT SaveLog : public QObject
#else
class SaveLog : public QObject
#endif

View File

@ -5,7 +5,6 @@
#include "qfile.h"
#include "qtextstream.h"
#include "qstringlist.h"
#include "qdebug.h"
#ifdef Q_OS_WIN
#define NEWLINE "\r\n"
@ -37,6 +36,7 @@ SaveRunTime::SaveRunTime(QObject *parent) : QObject(parent)
saveInterval = 1 * 60 * 1000;
startTime = QDateTime::currentDateTime();
//存储运行时间定时器
timerSave = new QTimer(this);
timerSave->setInterval(saveInterval);
connect(timerSave, SIGNAL(timeout()), this, SLOT(saveLog()));
@ -44,6 +44,9 @@ SaveRunTime::SaveRunTime(QObject *parent) : QObject(parent)
void SaveRunTime::start()
{
//开始时间变量必须在这,在部分嵌入式系统上开机后的时间不准确比如是1970,而后会变成1999或者其他时间
//会在getDiffValue函数执行很久很久
startTime = QDateTime::currentDateTime();
timerSave->start();
initLog();
@ -104,19 +107,16 @@ void SaveRunTime::initLog()
QTextStream stream(&file);
stream << line << NEWLINE;
file.close();
lastID = 0;
}
} else {
if (file.open(QFile::ReadOnly)) {
QString lastLine;
while (!file.atEnd()) {
lastLine = file.readLine();
}
file.close();
QStringList list = lastLine.split("\t");
lastID = list.at(0).toInt();
}
@ -169,7 +169,6 @@ void SaveRunTime::saveLog()
//重新清空文件
file.resize(0);
//如果行数小于2则返回
if (content.count() < 2) {
file.close();

View File

@ -6,13 +6,7 @@
class QTimer;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT SaveRunTime : public QObject
class Q_DECL_EXPORT SaveRunTime : public QObject
#else
class SaveRunTime : public QObject
#endif

View File

@ -3,9 +3,9 @@
/**
* :feiyangqingyun(QQ:517216493) 2016-11-11
* 1:
* 2:
* 3:
* 1.
* 2.
* 3.
*/
#include <QWidget>
@ -46,13 +46,7 @@ private:
};
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT ScreenWidget : public QWidget
class Q_DECL_EXPORT ScreenWidget : public QWidget
#else
class ScreenWidget : public QWidget
#endif

View File

@ -56,7 +56,7 @@ void VideoPanel::initControl()
{
gridLayout = new QGridLayout;
gridLayout->setSpacing(1);
gridLayout->setMargin(0);
gridLayout->setContentsMargins(0, 0, 0, 0);
gridLayout->setObjectName("gridLayout");
this->setLayout(gridLayout);
}

View File

@ -13,13 +13,7 @@ class QLabel;
class QGridLayout;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT VideoPanel : public QWidget
class Q_DECL_EXPORT VideoPanel : public QWidget
#else
class VideoPanel : public QWidget
#endif

View File

@ -81,7 +81,7 @@ void VideoWidget::initFlowPanel()
//用布局顶住,左侧弹簧
QHBoxLayout *layout = new QHBoxLayout;
layout->setSpacing(2);
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->addStretch();
flowPanel->setLayout(layout);
@ -100,7 +100,7 @@ void VideoWidget::initFlowPanel()
icons << QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton);
#else
QList<QChar> chars;
chars << 0xe68d << 0xe672 << 0xe674 << 0xea36 << 0xe74c;
chars << QChar(0xe68d) << QChar(0xe672) << QChar(0xe674) << QChar(0xea36) << QChar(0xe74c);
//判断图形字体是否存在,不存在则加入
QFont iconFont;
@ -277,7 +277,7 @@ void VideoWidget::drawBg(QPainter *painter)
//背景图片为空则绘制文字,否则绘制背景图片
if (bgImage.isNull()) {
painter->setFont(this->font());
painter->setPen(palette().foreground().color());
painter->setPen(palette().windowText().color());
painter->drawText(rect(), Qt::AlignCenter, bgText);
} else {
//居中绘制

View File

@ -23,13 +23,7 @@
class QTimer;
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT VideoWidget : public QWidget
class Q_DECL_EXPORT VideoWidget : public QWidget
#else
class VideoWidget : public QWidget
#endif
@ -223,6 +217,11 @@ signals:
//播放结束
void receivePlayFinsh();
//总时长
void fileLengthReceive(qint64 length);
//当前播放时长
void filePositionReceive(qint64 position);
//收到图片信号
void receiveImage(const QImage &image);

View File

@ -3,22 +3,16 @@
/**
* :feiyangqingyun(QQ:517216493) 2019-2-16
* 1:
* 2:
* 3:
* 1.
* 2.
* 3.
*/
#include <QObject>
#include <QStringList>
#ifdef quc
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
#include <QtDesigner/QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerExportWidget>
#endif
class QDESIGNER_WIDGET_EXPORT ZhToPY : public QObject
class Q_DECL_EXPORT ZhToPY : public QObject
#else
class ZhToPY : public QObject
#endif