提交 lekok
|
@ -0,0 +1,38 @@
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Custom
|
||||||
|
*.pro.user
|
||||||
|
*.pro.user.*
|
||||||
|
*.rar
|
|
@ -0,0 +1,244 @@
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include "BasicColorArea.h"
|
||||||
|
|
||||||
|
BasicColorArea::BasicColorArea(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
//initColorItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicColorArea::~BasicColorArea()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicColorArea::initColorItems(bool bAlpha)
|
||||||
|
{
|
||||||
|
BasicColorItem *pItem11 = new BasicColorItem(QColor(0, 0, 0,255));
|
||||||
|
BasicColorItem *pItem12 = new BasicColorItem(QColor(51, 51, 51,255));
|
||||||
|
BasicColorItem *pItem13 = new BasicColorItem(QColor(102, 102, 102,255));
|
||||||
|
BasicColorItem *pItem14 = new BasicColorItem(QColor(153, 153, 153,255));
|
||||||
|
BasicColorItem *pItem15 = new BasicColorItem(QColor(204, 204, 204,255));
|
||||||
|
BasicColorItem *pItem16 = new BasicColorItem(QColor(221, 221, 221,255));
|
||||||
|
BasicColorItem *pItem17 = new BasicColorItem(QColor(238, 238, 238,255));
|
||||||
|
BasicColorItem *pItem18 = new BasicColorItem(QColor(255, 255, 255,255));
|
||||||
|
QHBoxLayout *pLayout1 = new QHBoxLayout;
|
||||||
|
pLayout1->setMargin(0);
|
||||||
|
pLayout1->setSpacing(2);
|
||||||
|
pLayout1->addWidget(pItem11);
|
||||||
|
pLayout1->addWidget(pItem12);
|
||||||
|
pLayout1->addWidget(pItem13);
|
||||||
|
pLayout1->addWidget(pItem14);
|
||||||
|
pLayout1->addWidget(pItem15);
|
||||||
|
pLayout1->addWidget(pItem16);
|
||||||
|
pLayout1->addWidget(pItem17);
|
||||||
|
pLayout1->addWidget(pItem18);
|
||||||
|
|
||||||
|
// BasicColorItem *pItem21 = new BasicColorItem(QColor(207, 42, 39,255));
|
||||||
|
// BasicColorItem *pItem22 = new BasicColorItem(QColor(255, 153, 0,255));
|
||||||
|
// BasicColorItem *pItem23 = new BasicColorItem(QColor(255, 255, 0,255));
|
||||||
|
// BasicColorItem *pItem24 = new BasicColorItem(QColor(0, 158, 15,255));
|
||||||
|
// BasicColorItem *pItem25 = new BasicColorItem(QColor(0, 255, 255,255));
|
||||||
|
// BasicColorItem *pItem26 = new BasicColorItem(QColor(43, 120, 228,255));
|
||||||
|
// BasicColorItem *pItem27 = new BasicColorItem(QColor(153, 0, 255,255));
|
||||||
|
// BasicColorItem *pItem28 = new BasicColorItem(QColor(255, 0, 255,255));
|
||||||
|
BasicColorItem *pItem21 = new BasicColorItem(QColor(255, 0, 0,255));
|
||||||
|
BasicColorItem *pItem22 = new BasicColorItem(QColor(0, 255, 0,255));
|
||||||
|
BasicColorItem *pItem23 = new BasicColorItem(QColor(0, 0, 255,255));
|
||||||
|
BasicColorItem *pItem24 = new BasicColorItem(QColor(255, 255, 0,255));
|
||||||
|
BasicColorItem *pItem25 = new BasicColorItem(QColor(0, 255, 255,255));
|
||||||
|
BasicColorItem *pItem26 = new BasicColorItem(QColor(255, 0, 255,255));
|
||||||
|
BasicColorItem *pItem27 = new BasicColorItem(QColor(255, 128, 255,255));
|
||||||
|
BasicColorItem *pItem28 = new BasicColorItem(QColor(128, 0, 128,255));
|
||||||
|
|
||||||
|
QHBoxLayout *pLayout2 = new QHBoxLayout;
|
||||||
|
pLayout2->setMargin(0);
|
||||||
|
pLayout2->setSpacing(2);
|
||||||
|
pLayout2->addWidget(pItem21);
|
||||||
|
pLayout2->addWidget(pItem22);
|
||||||
|
pLayout2->addWidget(pItem23);
|
||||||
|
pLayout2->addWidget(pItem24);
|
||||||
|
pLayout2->addWidget(pItem25);
|
||||||
|
pLayout2->addWidget(pItem26);
|
||||||
|
pLayout2->addWidget(pItem27);
|
||||||
|
pLayout2->addWidget(pItem28);
|
||||||
|
|
||||||
|
BasicColorItem *pItem31 = new BasicColorItem(QColor(234, 153, 153,255));
|
||||||
|
BasicColorItem *pItem32 = new BasicColorItem(QColor(249, 203, 156,255));
|
||||||
|
BasicColorItem *pItem33 = new BasicColorItem(QColor(255, 229, 153,255));
|
||||||
|
BasicColorItem *pItem34 = new BasicColorItem(QColor(182, 215, 168,255));
|
||||||
|
BasicColorItem *pItem35 = new BasicColorItem(QColor(162, 196, 201,255));
|
||||||
|
BasicColorItem *pItem36 = new BasicColorItem(QColor(159, 197, 248,255));
|
||||||
|
BasicColorItem *pItem37 = new BasicColorItem(QColor(180, 167, 214,255));
|
||||||
|
BasicColorItem *pItem38 = new BasicColorItem(QColor(213, 166, 189,255));
|
||||||
|
QHBoxLayout *pLayout3 = new QHBoxLayout;
|
||||||
|
pLayout3->setMargin(0);
|
||||||
|
pLayout3->setSpacing(2);
|
||||||
|
pLayout3->addWidget(pItem31);
|
||||||
|
pLayout3->addWidget(pItem32);
|
||||||
|
pLayout3->addWidget(pItem33);
|
||||||
|
pLayout3->addWidget(pItem34);
|
||||||
|
pLayout3->addWidget(pItem35);
|
||||||
|
pLayout3->addWidget(pItem36);
|
||||||
|
pLayout3->addWidget(pItem37);
|
||||||
|
pLayout3->addWidget(pItem38);
|
||||||
|
|
||||||
|
BasicColorItem *pItem41 = new BasicColorItem(QColor(224, 102, 102,255));
|
||||||
|
BasicColorItem *pItem42 = new BasicColorItem(QColor(246, 178, 107,255));
|
||||||
|
BasicColorItem *pItem43 = new BasicColorItem(QColor(255, 217, 102,255));
|
||||||
|
BasicColorItem *pItem44 = new BasicColorItem(QColor(147, 196, 125,255));
|
||||||
|
BasicColorItem *pItem45 = new BasicColorItem(QColor(118, 165, 175,255));
|
||||||
|
BasicColorItem *pItem46 = new BasicColorItem(QColor(111, 168, 220,255));
|
||||||
|
BasicColorItem *pItem47 = new BasicColorItem(QColor(142, 124, 195,255));
|
||||||
|
BasicColorItem *pItem48 = new BasicColorItem(QColor(194, 123, 160,255));
|
||||||
|
QHBoxLayout *pLayout4 = new QHBoxLayout;
|
||||||
|
pLayout4->setMargin(0);
|
||||||
|
pLayout4->setSpacing(2);
|
||||||
|
pLayout4->addWidget(pItem41);
|
||||||
|
pLayout4->addWidget(pItem42);
|
||||||
|
pLayout4->addWidget(pItem43);
|
||||||
|
pLayout4->addWidget(pItem44);
|
||||||
|
pLayout4->addWidget(pItem45);
|
||||||
|
pLayout4->addWidget(pItem46);
|
||||||
|
pLayout4->addWidget(pItem47);
|
||||||
|
pLayout4->addWidget(pItem48);
|
||||||
|
|
||||||
|
BasicColorItem *pItem51 = new BasicColorItem(QColor(204, 0, 0,255));
|
||||||
|
BasicColorItem *pItem52 = new BasicColorItem(QColor(230, 145, 56,255));
|
||||||
|
BasicColorItem *pItem53 = new BasicColorItem(QColor(241, 194, 50,255));
|
||||||
|
BasicColorItem *pItem54 = new BasicColorItem(QColor(106, 168, 79,255));
|
||||||
|
BasicColorItem *pItem55 = new BasicColorItem(QColor(69, 129, 142,255));
|
||||||
|
BasicColorItem *pItem56 = new BasicColorItem(QColor(89, 126, 170,255));
|
||||||
|
BasicColorItem *pItem57 = new BasicColorItem(QColor(103, 78, 167,255));
|
||||||
|
BasicColorItem *pItem58 = new BasicColorItem(QColor(166, 77, 121,255));
|
||||||
|
QHBoxLayout *pLayout5 = new QHBoxLayout;
|
||||||
|
pLayout5->setMargin(0);
|
||||||
|
pLayout5->setSpacing(2);
|
||||||
|
pLayout5->addWidget(pItem51);
|
||||||
|
pLayout5->addWidget(pItem52);
|
||||||
|
pLayout5->addWidget(pItem53);
|
||||||
|
pLayout5->addWidget(pItem54);
|
||||||
|
pLayout5->addWidget(pItem55);
|
||||||
|
pLayout5->addWidget(pItem56);
|
||||||
|
pLayout5->addWidget(pItem57);
|
||||||
|
pLayout5->addWidget(pItem58);
|
||||||
|
|
||||||
|
BasicColorItem *pItem61 = new BasicColorItem(QColor(153, 0, 0,255));
|
||||||
|
BasicColorItem *pItem62 = new BasicColorItem(QColor(180, 95, 6,255));
|
||||||
|
BasicColorItem *pItem63 = new BasicColorItem(QColor(119, 144, 0,255));
|
||||||
|
BasicColorItem *pItem64 = new BasicColorItem(QColor(56, 118, 29,255));
|
||||||
|
BasicColorItem *pItem65 = new BasicColorItem(QColor(19, 79, 92,255));
|
||||||
|
BasicColorItem *pItem66 = new BasicColorItem(QColor(8, 83, 148,255));
|
||||||
|
BasicColorItem *pItem67 = new BasicColorItem(QColor(52, 28, 117,255));
|
||||||
|
BasicColorItem *pItem68 = new BasicColorItem(QColor(116, 27, 71,255));
|
||||||
|
QHBoxLayout *pLayout6 = new QHBoxLayout;
|
||||||
|
pLayout6->setMargin(0);
|
||||||
|
pLayout6->setSpacing(2);
|
||||||
|
pLayout6->addWidget(pItem61);
|
||||||
|
pLayout6->addWidget(pItem62);
|
||||||
|
pLayout6->addWidget(pItem63);
|
||||||
|
pLayout6->addWidget(pItem64);
|
||||||
|
pLayout6->addWidget(pItem65);
|
||||||
|
pLayout6->addWidget(pItem66);
|
||||||
|
pLayout6->addWidget(pItem67);
|
||||||
|
pLayout6->addWidget(pItem68);
|
||||||
|
|
||||||
|
BasicColorItem *pItem71 = new BasicColorItem(QColor(102, 0, 0,255));
|
||||||
|
BasicColorItem *pItem72 = new BasicColorItem(QColor(120, 63, 4,255));
|
||||||
|
BasicColorItem *pItem73 = new BasicColorItem(QColor(127, 96, 0,255));
|
||||||
|
BasicColorItem *pItem74 = new BasicColorItem(QColor(39, 78, 19,255));
|
||||||
|
BasicColorItem *pItem75 = new BasicColorItem(QColor(12, 52, 61,255));
|
||||||
|
BasicColorItem *pItem76 = new BasicColorItem(QColor(7, 55, 99,255));
|
||||||
|
BasicColorItem *pItem77 = new BasicColorItem(QColor(32, 18, 77,255));
|
||||||
|
QColor qLast=Qt::transparent;
|
||||||
|
if(bAlpha==false)
|
||||||
|
qLast=QColor(71, 17, 48,255);
|
||||||
|
|
||||||
|
BasicColorItem *pItem78 = new BasicColorItem(qLast);
|
||||||
|
QHBoxLayout *pLayout7 = new QHBoxLayout;
|
||||||
|
pLayout7->setMargin(0);
|
||||||
|
pLayout7->setSpacing(2);
|
||||||
|
pLayout7->addWidget(pItem71);
|
||||||
|
pLayout7->addWidget(pItem72);
|
||||||
|
pLayout7->addWidget(pItem73);
|
||||||
|
pLayout7->addWidget(pItem74);
|
||||||
|
pLayout7->addWidget(pItem75);
|
||||||
|
pLayout7->addWidget(pItem76);
|
||||||
|
pLayout7->addWidget(pItem77);
|
||||||
|
pLayout7->addWidget(pItem78);
|
||||||
|
|
||||||
|
QVBoxLayout *pVLayout = new QVBoxLayout(this);
|
||||||
|
pVLayout->setMargin(0);
|
||||||
|
pVLayout->setSpacing(2);
|
||||||
|
pVLayout->addLayout(pLayout1);
|
||||||
|
pVLayout->addLayout(pLayout2);
|
||||||
|
pVLayout->addLayout(pLayout3);
|
||||||
|
pVLayout->addLayout(pLayout4);
|
||||||
|
pVLayout->addLayout(pLayout5);
|
||||||
|
pVLayout->addLayout(pLayout6);
|
||||||
|
pVLayout->addLayout(pLayout7);
|
||||||
|
|
||||||
|
connect(pItem11, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem12, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem13, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem14, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem15, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem16, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem17, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem18, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
|
||||||
|
connect(pItem21, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem22, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem23, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem24, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem25, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem26, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem27, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem28, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
|
||||||
|
connect(pItem31, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem32, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem33, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem34, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem35, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem36, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem37, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem38, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
|
||||||
|
connect(pItem41, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem42, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem43, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem44, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem45, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem46, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem47, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem48, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
|
||||||
|
connect(pItem51, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem52, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem53, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem54, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem55, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem56, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem57, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem58, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
|
||||||
|
connect(pItem61, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem62, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem63, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem64, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem65, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem66, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem67, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem68, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
|
||||||
|
connect(pItem71, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem72, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem73, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem74, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem75, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem76, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem77, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem78, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
// 基本颜色区域
|
||||||
|
|
||||||
|
#ifndef BASICCOLORAREA_H
|
||||||
|
#define BASICCOLORAREA_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "BasicColorItem.h"
|
||||||
|
|
||||||
|
class BasicColorArea : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
BasicColorArea(QWidget *parent);
|
||||||
|
~BasicColorArea();
|
||||||
|
void initColorItems(bool bAlpha);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void colorItemSelcSignal(const QColor &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BASICCOLORAREA_H
|
|
@ -0,0 +1,90 @@
|
||||||
|
#include <QPainter>
|
||||||
|
#include "BasicColorItem.h"
|
||||||
|
|
||||||
|
#define ITEM_EDGE_LENGTH 25
|
||||||
|
|
||||||
|
BasicColorItem::BasicColorItem(const QColor &c, QWidget *parent)
|
||||||
|
: QLabel(parent)
|
||||||
|
, m_bMouseIn(false)
|
||||||
|
{
|
||||||
|
setFixedSize(ITEM_EDGE_LENGTH, ITEM_EDGE_LENGTH);
|
||||||
|
setColor(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicColorItem::~BasicColorItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor BasicColorItem::getColor()
|
||||||
|
{
|
||||||
|
return m_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicColorItem::paintEvent(QPaintEvent *ev)
|
||||||
|
{
|
||||||
|
QLabel::paintEvent(ev);
|
||||||
|
if (m_bMouseIn)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
painter.setPen(QPen(Qt::white, 3));
|
||||||
|
painter.drawRect(1, 1, ITEM_EDGE_LENGTH - 3, ITEM_EDGE_LENGTH - 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicColorItem::mousePressEvent(QMouseEvent *)
|
||||||
|
{
|
||||||
|
emit itemClickedSignal(m_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicColorItem::enterEvent(QEvent *)
|
||||||
|
{
|
||||||
|
m_bMouseIn = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicColorItem::leaveEvent(QEvent *)
|
||||||
|
{
|
||||||
|
m_bMouseIn = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicColorItem::setColor(const QColor &c)
|
||||||
|
{
|
||||||
|
if(c==Qt::transparent)
|
||||||
|
{
|
||||||
|
QImage itemImg = QImage(ITEM_EDGE_LENGTH, ITEM_EDGE_LENGTH, QImage::Format_RGB32);
|
||||||
|
QPainter painter(&itemImg);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
painter.drawImage(0, 0, itemImg);
|
||||||
|
QPen pen;
|
||||||
|
painter.setBrush(Qt::white);
|
||||||
|
painter.drawRect(0, 0, width(), height());
|
||||||
|
|
||||||
|
//pen.setStyle(Qt::DashLine);
|
||||||
|
pen.setColor(Qt::red); // 设置画笔为黄色
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawLine(0,0,width()-1,height()-1);
|
||||||
|
painter.end();
|
||||||
|
this->setPixmap(QPixmap::fromImage(itemImg));
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QImage itemImg = QImage(ITEM_EDGE_LENGTH, ITEM_EDGE_LENGTH, QImage::Format_ARGB32);
|
||||||
|
QPainter painter(&itemImg);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
painter.drawImage(0, 0, itemImg);
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(c);
|
||||||
|
painter.drawRect(0, 0, width(), height());
|
||||||
|
painter.end();
|
||||||
|
this->setPixmap(QPixmap::fromImage(itemImg));
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_color = c;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
// 基本颜色项
|
||||||
|
|
||||||
|
#ifndef BASICCOLORITEM_H
|
||||||
|
#define BASICCOLORITEM_H
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
class BasicColorItem : public QLabel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
BasicColorItem(const QColor &, QWidget *parent = 0);
|
||||||
|
~BasicColorItem();
|
||||||
|
QColor getColor();
|
||||||
|
void setColor(const QColor &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
void mousePressEvent(QMouseEvent *ev);
|
||||||
|
void enterEvent(QEvent *);
|
||||||
|
void leaveEvent(QEvent *);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void itemClickedSignal(const QColor &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_bMouseIn;
|
||||||
|
QColor m_color;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BASICCOLORITEM_H
|
|
@ -0,0 +1,703 @@
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include "ColorDialog.h"
|
||||||
|
#include "ui_ColorDialog.h"
|
||||||
|
|
||||||
|
class ColorDialog::ColorSetting
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Ui::ColorDialog ui;
|
||||||
|
int m_iHue;
|
||||||
|
int m_iSaturation;
|
||||||
|
int m_iBrightness;
|
||||||
|
bool m_bPressed;
|
||||||
|
QPoint m_ptPress;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorSetting()
|
||||||
|
: m_iHue(0)
|
||||||
|
, m_iSaturation(0)
|
||||||
|
, m_iBrightness(0)
|
||||||
|
, m_bPressed(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~ColorSetting()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ColorDialog::ColorDialog(QColor cr,bool bAlpha,QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_pSetting(new ColorSetting)
|
||||||
|
, m_bNotEdit(false)
|
||||||
|
{
|
||||||
|
m_pSetting->ui.setupUi(this);
|
||||||
|
m_pSetting->ui.basicColorWgt->initColorItems(bAlpha);
|
||||||
|
m_pSetting->ui.hLabel->setVisible(false);
|
||||||
|
m_pSetting->ui.hSpinBox->setVisible(false);
|
||||||
|
m_pSetting->ui.sLabel->setVisible(false);
|
||||||
|
m_pSetting->ui.sSpinBox->setVisible(false);
|
||||||
|
m_pSetting->ui.vLabel->setVisible(false);
|
||||||
|
m_pSetting->ui.vSpinBox->setVisible(false);
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
//标题
|
||||||
|
m_pTitleLbl = new QLabel(this);
|
||||||
|
m_pTitleLbl->setText(tr("Select color"));
|
||||||
|
m_pTitleLbl->setStyleSheet("background-color:rgba(206,206,206,255);color:rgba(0,0,0,255);");
|
||||||
|
//m_pTitleLbl->setFixedSize(190, 34);
|
||||||
|
// m_pTitleLbl->setStyleSheet("background-color:rgba(216,216,0,255);");
|
||||||
|
// m_pTitleLbl->setStyleSheet("color:rgba(0,0,0,255);");
|
||||||
|
m_pSetting->ui.topWgt->setStyleSheet("background-color:rgba(206,206,206,255);");
|
||||||
|
//关闭按钮
|
||||||
|
m_pCloseBtn = new QPushButton(this);
|
||||||
|
m_pCloseBtn->setFixedSize(22, 34);
|
||||||
|
m_pCloseBtn->setObjectName("m_pCloseBtn");
|
||||||
|
m_pCloseBtn->setVisible(false);
|
||||||
|
|
||||||
|
m_buttonRole = Yes;
|
||||||
|
setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
|
||||||
|
setWindowModality(Qt::WindowModal);
|
||||||
|
//setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
this->installEventFilter(this);
|
||||||
|
|
||||||
|
QRegExp rx("(\\d?[a-f]?){0,6}");
|
||||||
|
m_pSetting->ui.colorEdit->setValidator(new QRegExpValidator(rx, this));
|
||||||
|
m_pSetting->ui.colorEdit->setText("00000000");
|
||||||
|
|
||||||
|
this->setFocusPolicy(Qt::ClickFocus);
|
||||||
|
|
||||||
|
initSignalAndSlotConn();
|
||||||
|
|
||||||
|
|
||||||
|
setStyleSheet("QSpinBox::arrow{background-color:#8d8d8d;}");
|
||||||
|
|
||||||
|
m_pSetting->ui.okBtn->setProperty("ssType", "progManageTool");
|
||||||
|
m_pSetting->ui.okBtn->setStyleSheet("QPushButton{background:rgba(28,154,210,255);}");
|
||||||
|
m_pSetting->ui.cancelBtn->setProperty("ssType", "progManageTool");
|
||||||
|
m_pSetting->ui.cancelBtn->setStyleSheet("QPushButton{background:rgba(28,154,210,255);}");
|
||||||
|
m_pSetting->ui.addCustomColorBtn->setProperty("ssType", "progManageTool");
|
||||||
|
m_pSetting->ui.addCustomColorBtn->setStyleSheet("QPushButton{background:rgba(28,154,210,255);}");
|
||||||
|
|
||||||
|
if(bAlpha==false)
|
||||||
|
{
|
||||||
|
m_pSetting->ui.aSpinBox->setVisible(false);
|
||||||
|
m_pSetting->ui.label_2->setVisible(false);
|
||||||
|
m_pSetting->ui.line->setVisible(false);
|
||||||
|
// m_pSetting->ui.line_2->setVisible(false);
|
||||||
|
cr.setAlpha(255);
|
||||||
|
}
|
||||||
|
m_pSetting->ui.previewWgt->setCurColor(cr);
|
||||||
|
colorItemSelcSlot(cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorDialog::~ColorDialog()
|
||||||
|
{
|
||||||
|
delete m_pSetting;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorDialog::ButtonRole ColorDialog::showDialog()
|
||||||
|
{
|
||||||
|
show();
|
||||||
|
QEventLoop evtLoop;
|
||||||
|
m_pEvtLoop = &evtLoop;
|
||||||
|
evtLoop.exec();
|
||||||
|
|
||||||
|
m_pEvtLoop = NULL;
|
||||||
|
hide();
|
||||||
|
return m_buttonRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::setCurColor(const QColor &c)
|
||||||
|
{
|
||||||
|
colorItemSelcSlot(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor ColorDialog::getColor()
|
||||||
|
{
|
||||||
|
QColor color;
|
||||||
|
color.setHsv(m_pSetting->m_iHue, m_pSetting->m_iSaturation, m_pSetting->m_iBrightness);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRgb ColorDialog::getRgb()
|
||||||
|
{
|
||||||
|
QColor color;
|
||||||
|
color.setHsv(m_pSetting->m_iHue, m_pSetting->m_iSaturation, m_pSetting->m_iBrightness);
|
||||||
|
return color.rgb();
|
||||||
|
}
|
||||||
|
QColor ColorDialog::getRgba()
|
||||||
|
{
|
||||||
|
|
||||||
|
return m_pSetting->ui.previewWgt->getNewColor();
|
||||||
|
}
|
||||||
|
bool ColorDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||||
|
{
|
||||||
|
switch (ev->type())
|
||||||
|
{
|
||||||
|
case QEvent::MouseButtonPress:
|
||||||
|
{
|
||||||
|
QMouseEvent *e = dynamic_cast<QMouseEvent *>(ev);
|
||||||
|
if (e->pos().y() > 29)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (e->buttons() & Qt::LeftButton)
|
||||||
|
{
|
||||||
|
m_pSetting->m_bPressed = true;
|
||||||
|
m_pSetting->m_ptPress = e->globalPos() - this->frameGeometry().topLeft();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEvent::MouseButtonRelease:
|
||||||
|
{
|
||||||
|
m_pSetting->m_bPressed = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEvent::MouseMove:
|
||||||
|
{
|
||||||
|
QMouseEvent *e = dynamic_cast<QMouseEvent *>(ev);
|
||||||
|
if (m_pSetting->m_bPressed)
|
||||||
|
{
|
||||||
|
move(this->mapToGlobal(e->pos() - m_pSetting->m_ptPress));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEvent::Resize:
|
||||||
|
{
|
||||||
|
m_pTitleLbl->move(8, 0);
|
||||||
|
m_pCloseBtn->move(width() - 24, -8);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QWidget::eventFilter(obj, ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::show()
|
||||||
|
{
|
||||||
|
QWidget::show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::initSignalAndSlotConn()
|
||||||
|
{
|
||||||
|
connect(m_pSetting->ui.hColorWgt, SIGNAL(hueChangedSignal(int)), m_pSetting->ui.svColorWgt, SLOT(hueChangedSlot(int)));
|
||||||
|
connect(m_pSetting->ui.svColorWgt, SIGNAL(svChangedSignal(int, int, int)), m_pSetting->ui.previewWgt, SLOT(svChangedSlot(int, int, int)));
|
||||||
|
//选中色预览窗
|
||||||
|
connect(m_pSetting->ui.previewWgt, SIGNAL(svChangedSignal(int, int, int)), this, SLOT(updateEditData(int, int, int)));
|
||||||
|
connect(m_pSetting->ui.basicColorWgt, SIGNAL(colorItemSelcSignal(const QColor &)), this, SLOT(colorItemSelcSlot(const QColor &)));
|
||||||
|
connect(m_pSetting->ui.customColorWgt, SIGNAL(colorItemSelcSignal(const QColor &)), this, SLOT(colorItemSelcSlot(const QColor &)));
|
||||||
|
connect(m_pSetting->ui.colorEdit, SIGNAL(textEdited(const QString &)), this, SLOT(editChangedSlot(const QString &)));
|
||||||
|
connect(m_pSetting->ui.colorEdit, SIGNAL(editingFinished()), this, SLOT(editFinishedSlot()));
|
||||||
|
|
||||||
|
connect(m_pSetting->ui.addCustomColorBtn, SIGNAL(clicked()), this, SLOT(addCustomColorSlot()));
|
||||||
|
connect(m_pSetting->ui.okBtn, SIGNAL(clicked()), this, SLOT(okBtnClickedSlot()));
|
||||||
|
connect(m_pSetting->ui.cancelBtn, SIGNAL(clicked()), this, SLOT(cancelBtnClickedSlot()));
|
||||||
|
connect(m_pCloseBtn, SIGNAL(clicked()), this, SLOT(cancelBtnClickedSlot()));
|
||||||
|
|
||||||
|
// connect(m_pSetting->ui.hSpinBox, SIGNAL(valueChanged(int)), this, SLOT(hValueChangedSlot(int)));
|
||||||
|
// connect(m_pSetting->ui.sSpinBox, SIGNAL(valueChanged(int)), this, SLOT(sValueChangedSlot(int)));
|
||||||
|
// connect(m_pSetting->ui.vSpinBox, SIGNAL(valueChanged(int)), this, SLOT(vValueChangedSlot(int)));
|
||||||
|
connect(m_pSetting->ui.rSpinBox, SIGNAL(valueChanged(int)), this, SLOT(rValueChangedSlot(int)));
|
||||||
|
connect(m_pSetting->ui.gSpinBox, SIGNAL(valueChanged(int)), this, SLOT(gValueChangedSlot(int)));
|
||||||
|
connect(m_pSetting->ui.bSpinBox, SIGNAL(valueChanged(int)), this, SLOT(bValueChangedSlot(int)));
|
||||||
|
connect(m_pSetting->ui.aSpinBox, SIGNAL(valueChanged(int)), this, SLOT(aValueChangedSlot(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::updateRGBColor(const QColor &color)
|
||||||
|
{
|
||||||
|
m_pSetting->ui.previewWgt->setNewColor(color);
|
||||||
|
m_pSetting->ui.rSpinBox->setValue(color.red());
|
||||||
|
m_pSetting->ui.gSpinBox->setValue(color.green());
|
||||||
|
m_pSetting->ui.bSpinBox->setValue(color.blue());
|
||||||
|
m_pSetting->ui.aSpinBox->setValue(color.alpha());
|
||||||
|
|
||||||
|
QString strR = QString::number(color.red(), 16);
|
||||||
|
QString strG = QString::number(color.green(), 16);
|
||||||
|
QString strB = QString::number(color.blue(), 16);
|
||||||
|
QString strA = QString::number(color.alpha(), 16);
|
||||||
|
if(strR.length()==1)
|
||||||
|
strR.prepend("0");
|
||||||
|
if(strG.length()==1)
|
||||||
|
strG.prepend("0");
|
||||||
|
if(strB.length()==1)
|
||||||
|
strB.prepend("0");
|
||||||
|
if(strA.length()==1)
|
||||||
|
strA.prepend("0");
|
||||||
|
|
||||||
|
QString strRgb = strR+strG+strB+strA;
|
||||||
|
m_pSetting->ui.colorEdit->setText(strRgb);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorDialog::colorItemSelcSlot(const QColor &c)
|
||||||
|
{
|
||||||
|
if(c==Qt::transparent)
|
||||||
|
{
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
m_pSetting->ui.hColorWgt->setHue(c.hue());
|
||||||
|
m_pSetting->ui.svColorWgt->setColor(c);
|
||||||
|
m_pSetting->ui.aSpinBox->setValue(0);
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
m_pSetting->ui.hColorWgt->setHue(c.hue());
|
||||||
|
m_pSetting->ui.svColorWgt->setColor(c);
|
||||||
|
m_pSetting->ui.aSpinBox->setValue(c.alpha());
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::addCustomColorSlot()
|
||||||
|
{
|
||||||
|
QColor color(m_pSetting->ui.rSpinBox->value(),m_pSetting->ui.gSpinBox->value(),m_pSetting->ui.bSpinBox->value(),m_pSetting->ui.aSpinBox->value());
|
||||||
|
// color.setHsv(m_pSetting->m_iHue, m_pSetting->m_iSaturation, m_pSetting->m_iBrightness);
|
||||||
|
// color.setH(m_pSetting->m_iHue, m_pSetting->m_iSaturation, m_pSetting->m_iBrightness);
|
||||||
|
// color.setRgba(m_pSetting->ui.aSpinBox->value(),m_pSetting->ui.aSpinBox->value(),m_pSetting->ui.aSpinBox->value(),m_pSetting->ui.aSpinBox->value()));
|
||||||
|
m_pSetting->ui.customColorWgt->setGivenColor(m_pSetting->ui.previewWgt->getNewColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::okBtnClickedSlot()
|
||||||
|
{
|
||||||
|
QColor color;
|
||||||
|
color.setHsv(m_pSetting->m_iHue, m_pSetting->m_iSaturation, m_pSetting->m_iBrightness);
|
||||||
|
m_pSetting->ui.previewWgt->setCurColor(color);
|
||||||
|
|
||||||
|
m_buttonRole = Yes;
|
||||||
|
if (m_pEvtLoop != NULL)
|
||||||
|
{
|
||||||
|
m_pEvtLoop->exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::cancelBtnClickedSlot()
|
||||||
|
{
|
||||||
|
m_buttonRole = No;
|
||||||
|
if (m_pEvtLoop != NULL)
|
||||||
|
{
|
||||||
|
m_pEvtLoop->exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::editChangedSlot(const QString &strColor)
|
||||||
|
{
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
int r, g, b;
|
||||||
|
int a=255;
|
||||||
|
switch (strColor.length())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
r = g = b = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
r = g = 0;
|
||||||
|
bool ok;
|
||||||
|
b = strColor.toInt(&ok, 16);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
QString strR = QString("%1%2").arg(strColor.left(1), strColor.left(1));
|
||||||
|
QString strG = QString("%1%2").arg(strColor.mid(1, 1), strColor.mid(1, 1));
|
||||||
|
QString strB = QString("%1%2").arg(strColor.right(1), strColor.right(1));
|
||||||
|
bool ok;
|
||||||
|
r = strR.toInt(&ok, 16);
|
||||||
|
g = strG.toInt(&ok, 16);
|
||||||
|
b = strB.toInt(&ok, 16);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
r = 0;
|
||||||
|
QString strG = QString("%1").arg(strColor.left(2));
|
||||||
|
QString strB = QString("%1").arg(strColor.right(2));
|
||||||
|
bool ok;
|
||||||
|
g = strG.toInt(&ok, 16);
|
||||||
|
b = strB.toInt(&ok, 16);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
QString strR = QString("%1").arg(strColor.left(1));
|
||||||
|
QString strG = QString("%1").arg(strColor.mid(1, 2));
|
||||||
|
QString strB = QString("%1").arg(strColor.right(2));
|
||||||
|
bool ok;
|
||||||
|
r = strR.toInt(&ok, 16);
|
||||||
|
g = strG.toInt(&ok, 16);
|
||||||
|
b = strB.toInt(&ok, 16);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
QString strR = QString("%1").arg(strColor.left(2));
|
||||||
|
QString strG = QString("%1").arg(strColor.mid(2, 2));
|
||||||
|
QString strB = QString("%1").arg(strColor.right(2));
|
||||||
|
bool ok;
|
||||||
|
r = strR.toInt(&ok, 16);
|
||||||
|
g = strG.toInt(&ok, 16);
|
||||||
|
b = strB.toInt(&ok, 16);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
QString strR = QString("%1").arg(strColor.left(2));
|
||||||
|
QString strG = QString("%1").arg(strColor.mid(2, 2));
|
||||||
|
QString strB = QString("%1").arg(strColor.mid(2,2));
|
||||||
|
QString strA = QString("%1").arg(strColor.right(2));
|
||||||
|
bool ok;
|
||||||
|
r = strR.toInt(&ok, 16);
|
||||||
|
g = strG.toInt(&ok, 16);
|
||||||
|
b = strB.toInt(&ok, 16);
|
||||||
|
a = strA.toInt(&ok, 16);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor color;
|
||||||
|
color.setRgb(r, g, b , a);
|
||||||
|
int h, s, v;
|
||||||
|
h = m_pSetting->m_iHue = color.hue();
|
||||||
|
s = m_pSetting->m_iSaturation = color.saturation();
|
||||||
|
v = m_pSetting->m_iBrightness = color.value();
|
||||||
|
m_pSetting->ui.hColorWgt->setHue(h);
|
||||||
|
m_pSetting->ui.svColorWgt->setHsv(h, s, v);
|
||||||
|
m_pSetting->ui.previewWgt->setNewColor(color);
|
||||||
|
|
||||||
|
m_pSetting->ui.hSpinBox->setValue(h);
|
||||||
|
m_pSetting->ui.sSpinBox->setValue(s);
|
||||||
|
m_pSetting->ui.vSpinBox->setValue(v);
|
||||||
|
m_pSetting->ui.rSpinBox->setValue(r);
|
||||||
|
m_pSetting->ui.gSpinBox->setValue(g);
|
||||||
|
m_pSetting->ui.bSpinBox->setValue(b);
|
||||||
|
m_pSetting->ui.aSpinBox->setValue(a);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::editFinishedSlot()
|
||||||
|
{
|
||||||
|
QString strColor = m_pSetting->ui.colorEdit->text();
|
||||||
|
switch (strColor.length())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
m_pSetting->ui.colorEdit->setText("000000ff");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
m_pSetting->ui.colorEdit->setText(strColor.prepend("00000"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
m_pSetting->ui.colorEdit->setText(strColor.prepend("0000"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
QString strR = QString("%1%2").arg(strColor.left(1), strColor.left(1));
|
||||||
|
QString strG = QString("%1%2").arg(strColor.mid(1, 1), strColor.mid(1, 1));
|
||||||
|
QString strB = QString("%1%2").arg(strColor.right(1), strColor.right(1));
|
||||||
|
m_pSetting->ui.colorEdit->setText(strR.append(strG).append(strB));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
QString strG = QString("%1").arg(strColor.left(2));
|
||||||
|
QString strB = QString("%1").arg(strColor.right(2));
|
||||||
|
m_pSetting->ui.colorEdit->setText(strG.append(strB).prepend("00"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
QString strR = QString("%1").arg(strColor.left(1));
|
||||||
|
QString strG = QString("%1").arg(strColor.mid(1, 2));
|
||||||
|
QString strB = QString("%1").arg(strColor.right(2));
|
||||||
|
m_pSetting->ui.colorEdit->setText(strR.append(strG).append(strB).prepend("0"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::hValueChangedSlot(int h)
|
||||||
|
{
|
||||||
|
if (m_bNotEdit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
m_pSetting->m_iHue = h;
|
||||||
|
m_pSetting->ui.hColorWgt->setHue(h);
|
||||||
|
QColor color;
|
||||||
|
color.setHsv(h, m_pSetting->m_iSaturation, m_pSetting->m_iBrightness);
|
||||||
|
m_pSetting->ui.svColorWgt->setHue(h);
|
||||||
|
updateRGBColor(color);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::sValueChangedSlot(int s)
|
||||||
|
{
|
||||||
|
if (m_bNotEdit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
m_pSetting->m_iSaturation = s;
|
||||||
|
QColor color;
|
||||||
|
color.setHsv(m_pSetting->m_iHue, s, m_pSetting->m_iBrightness);
|
||||||
|
m_pSetting->ui.svColorWgt->setSaturation(s);
|
||||||
|
updateRGBColor(color);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::vValueChangedSlot(int v)
|
||||||
|
{
|
||||||
|
if (m_bNotEdit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
m_pSetting->m_iBrightness = v;
|
||||||
|
QColor color;
|
||||||
|
color.setHsv(m_pSetting->m_iHue, m_pSetting->m_iSaturation, v);
|
||||||
|
m_pSetting->ui.svColorWgt->setBrightness(v);
|
||||||
|
updateRGBColor(color);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::rValueChangedSlot(int r)
|
||||||
|
{
|
||||||
|
if (m_bNotEdit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
int iGreen = m_pSetting->ui.gSpinBox->value();
|
||||||
|
int iBlue = m_pSetting->ui.bSpinBox->value();
|
||||||
|
int ialpha = m_pSetting->ui.aSpinBox->value();
|
||||||
|
QColor color;
|
||||||
|
color.setRgb(r, iGreen, iBlue,ialpha);
|
||||||
|
int h = m_pSetting->m_iHue = color.hue();
|
||||||
|
int s = m_pSetting->m_iSaturation = color.saturation();
|
||||||
|
int v = m_pSetting->m_iBrightness = color.value();
|
||||||
|
|
||||||
|
m_pSetting->ui.hColorWgt->setHue(h);
|
||||||
|
m_pSetting->ui.svColorWgt->setHsv(h, s, v);
|
||||||
|
m_pSetting->ui.previewWgt->setNewColor(color);
|
||||||
|
|
||||||
|
m_pSetting->ui.hSpinBox->setValue(h);
|
||||||
|
m_pSetting->ui.sSpinBox->setValue(s);
|
||||||
|
m_pSetting->ui.vSpinBox->setValue(v);
|
||||||
|
|
||||||
|
|
||||||
|
QString strR = QString::number(r, 16);
|
||||||
|
QString strG = QString::number(iGreen, 16);
|
||||||
|
QString strB = QString::number(iBlue, 16);
|
||||||
|
QString strA = QString::number(ialpha, 16);
|
||||||
|
|
||||||
|
if(strR.length()==1)
|
||||||
|
strR.prepend("0");
|
||||||
|
if(strG.length()==1)
|
||||||
|
strG.prepend("0");
|
||||||
|
if(strB.length()==1)
|
||||||
|
strB.prepend("0");
|
||||||
|
if(strA.length()==1)
|
||||||
|
strA.prepend("0");
|
||||||
|
|
||||||
|
QString strRgb = strR+strG+strB+strA;
|
||||||
|
// QString("%1%2%3%4").arg(QString("%1").arg(strR.size() == 1 ? strR.prepend("0") : strR),
|
||||||
|
// QString("%1").arg(strG.size() == 1 ? strG.prepend("0") : strG),
|
||||||
|
// QString("%1").arg(strB.size() == 1 ? strB.prepend("0") : strB),
|
||||||
|
// QString("%1").arg(strA.size() == 1 ? strB.prepend("0") : strA) );
|
||||||
|
m_pSetting->ui.colorEdit->setText(strRgb);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::gValueChangedSlot(int g)
|
||||||
|
{
|
||||||
|
if (m_bNotEdit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
int iRed = m_pSetting->ui.rSpinBox->value();
|
||||||
|
int iBlue = m_pSetting->ui.bSpinBox->value();
|
||||||
|
int ialpha = m_pSetting->ui.aSpinBox->value();
|
||||||
|
QColor color;
|
||||||
|
color.setRgb(iRed, g, iBlue,ialpha);
|
||||||
|
int h = m_pSetting->m_iHue = color.hue();
|
||||||
|
int s = m_pSetting->m_iSaturation = color.saturation();
|
||||||
|
int v = m_pSetting->m_iBrightness = color.value();
|
||||||
|
|
||||||
|
m_pSetting->ui.hColorWgt->setHue(h);
|
||||||
|
m_pSetting->ui.svColorWgt->setHsv(h, s, v);
|
||||||
|
m_pSetting->ui.previewWgt->setNewColor(color);
|
||||||
|
|
||||||
|
m_pSetting->ui.hSpinBox->setValue(h);
|
||||||
|
m_pSetting->ui.sSpinBox->setValue(s);
|
||||||
|
m_pSetting->ui.vSpinBox->setValue(v);
|
||||||
|
|
||||||
|
QString strR = QString::number(iRed, 16);
|
||||||
|
QString strG = QString::number(g, 16);
|
||||||
|
QString strB = QString::number(iBlue, 16);
|
||||||
|
QString strA = QString::number(ialpha, 16);
|
||||||
|
|
||||||
|
if(strR.length()==1)
|
||||||
|
strR.prepend("0");
|
||||||
|
if(strG.length()==1)
|
||||||
|
strG.prepend("0");
|
||||||
|
if(strB.length()==1)
|
||||||
|
strB.prepend("0");
|
||||||
|
if(strA.length()==1)
|
||||||
|
strA.prepend("0");
|
||||||
|
QString strRgb = strR+strG+strB+strA;
|
||||||
|
m_pSetting->ui.colorEdit->setText(strRgb);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::bValueChangedSlot(int b)
|
||||||
|
{
|
||||||
|
if (m_bNotEdit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
int iRed = m_pSetting->ui.rSpinBox->value();
|
||||||
|
int iGreen = m_pSetting->ui.gSpinBox->value();
|
||||||
|
int ialpha = m_pSetting->ui.aSpinBox->value();
|
||||||
|
QColor color;
|
||||||
|
color.setRgb(iRed, iGreen, b,ialpha);
|
||||||
|
int h = m_pSetting->m_iHue = color.hue();
|
||||||
|
int s = m_pSetting->m_iSaturation = color.saturation();
|
||||||
|
int v = m_pSetting->m_iBrightness = color.value();
|
||||||
|
|
||||||
|
m_pSetting->ui.hColorWgt->setHue(h);
|
||||||
|
m_pSetting->ui.svColorWgt->setHsv(h, s, v);
|
||||||
|
m_pSetting->ui.previewWgt->setNewColor(color);
|
||||||
|
|
||||||
|
m_pSetting->ui.hSpinBox->setValue(h);
|
||||||
|
m_pSetting->ui.sSpinBox->setValue(s);
|
||||||
|
m_pSetting->ui.vSpinBox->setValue(v);
|
||||||
|
|
||||||
|
QString strR = QString::number(iRed, 16);
|
||||||
|
QString strG = QString::number(iGreen, 16);
|
||||||
|
QString strB = QString::number(b, 16);
|
||||||
|
QString strA = QString::number(ialpha, 16);
|
||||||
|
|
||||||
|
if(strR.length()==1)
|
||||||
|
strR.prepend("0");
|
||||||
|
if(strG.length()==1)
|
||||||
|
strG.prepend("0");
|
||||||
|
if(strB.length()==1)
|
||||||
|
strB.prepend("0");
|
||||||
|
if(strA.length()==1)
|
||||||
|
strA.prepend("0");
|
||||||
|
QString strRgb = strR+strG+strB+strA;
|
||||||
|
m_pSetting->ui.colorEdit->setText(strRgb);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
||||||
|
void ColorDialog::aValueChangedSlot(int a)
|
||||||
|
{
|
||||||
|
int iRed = m_pSetting->ui.rSpinBox->value();
|
||||||
|
int iGreen = m_pSetting->ui.gSpinBox->value();
|
||||||
|
int iBlue = m_pSetting->ui.bSpinBox->value();
|
||||||
|
QColor color;
|
||||||
|
color.setRgb(iRed, iGreen, iBlue,a);
|
||||||
|
m_pSetting->ui.previewWgt->setNewColor(color);
|
||||||
|
QString strR = QString::number(iRed, 16);
|
||||||
|
QString strG = QString::number(iGreen, 16);
|
||||||
|
QString strB = QString::number(iBlue, 16);
|
||||||
|
QString strA = QString::number(a, 16);
|
||||||
|
|
||||||
|
if(strR.length()==1)
|
||||||
|
strR.prepend("0");
|
||||||
|
if(strG.length()==1)
|
||||||
|
strG.prepend("0");
|
||||||
|
if(strB.length()==1)
|
||||||
|
strB.prepend("0");
|
||||||
|
if(strA.length()==1)
|
||||||
|
strA.prepend("0");
|
||||||
|
QString strRgb = strR+strG+strB+strA;
|
||||||
|
m_pSetting->ui.colorEdit->setText(strRgb);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorDialog::updateEditData(int h, int s, int v)
|
||||||
|
{
|
||||||
|
m_bNotEdit = true;
|
||||||
|
|
||||||
|
m_pSetting->m_iHue = h;
|
||||||
|
m_pSetting->m_iSaturation = s;
|
||||||
|
m_pSetting->m_iBrightness = v;
|
||||||
|
QColor color;
|
||||||
|
color.setHsv(h, s, v);
|
||||||
|
m_pSetting->ui.hSpinBox->setValue(h);
|
||||||
|
m_pSetting->ui.sSpinBox->setValue(s);
|
||||||
|
m_pSetting->ui.vSpinBox->setValue(v);
|
||||||
|
m_pSetting->ui.rSpinBox->setValue(color.red());
|
||||||
|
m_pSetting->ui.gSpinBox->setValue(color.green());
|
||||||
|
m_pSetting->ui.bSpinBox->setValue(color.blue());
|
||||||
|
|
||||||
|
|
||||||
|
QString strR = QString::number(color.red(), 16);
|
||||||
|
QString strG = QString::number(color.green(), 16);
|
||||||
|
QString strB = QString::number(color.blue(), 16);
|
||||||
|
QString strA = QString::number(m_pSetting->ui.aSpinBox->value(), 16);
|
||||||
|
if(strR.length()==1)
|
||||||
|
strR.prepend("0");
|
||||||
|
if(strG.length()==1)
|
||||||
|
strG.prepend("0");
|
||||||
|
if(strB.length()==1)
|
||||||
|
strB.prepend("0");
|
||||||
|
if(strA.length()==1)
|
||||||
|
strA.prepend("0");
|
||||||
|
QString strRgb = strR+strG+strB+strA;
|
||||||
|
m_pSetting->ui.colorEdit->setText(strRgb);
|
||||||
|
|
||||||
|
// QString strRgb = QString("%1%2%3%4").arg(QString("%1").arg(strR.size() == 1 ? strR.prepend("0") : strR),
|
||||||
|
// QString("%1").arg(strG.size() == 1 ? strG.prepend("0") : strG),
|
||||||
|
// QString("%1").arg(strB.size() == 1 ? strB.prepend("0") : strB),
|
||||||
|
// QString("%1").arg(strA.size() == 1 ? strB.prepend("0") : strA) );
|
||||||
|
// m_pSetting->ui.colorEdit->setText(strRgb);
|
||||||
|
|
||||||
|
m_bNotEdit = false;
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
#ifndef COLORDIALOG_H
|
||||||
|
#define COLORDIALOG_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QEventLoop>
|
||||||
|
|
||||||
|
class ColorDialog : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum ButtonRole{Yes, No};
|
||||||
|
ColorDialog(QColor cr,bool bAlpha,QWidget *parent = nullptr);
|
||||||
|
~ColorDialog();
|
||||||
|
ButtonRole showDialog();
|
||||||
|
void setCurColor(const QColor &);
|
||||||
|
QColor getColor();
|
||||||
|
QRgb getRgb();
|
||||||
|
QColor getRgba();
|
||||||
|
ButtonRole m_buttonRole;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *, QEvent *);
|
||||||
|
void show();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initSignalAndSlotConn();
|
||||||
|
void updateRGBColor(const QColor &);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void colorItemSelcSlot(const QColor &);
|
||||||
|
void addCustomColorSlot();
|
||||||
|
void okBtnClickedSlot();
|
||||||
|
void cancelBtnClickedSlot();
|
||||||
|
void editChangedSlot(const QString &);
|
||||||
|
void editFinishedSlot();
|
||||||
|
|
||||||
|
void hValueChangedSlot(int);
|
||||||
|
void sValueChangedSlot(int);
|
||||||
|
void vValueChangedSlot(int);
|
||||||
|
void rValueChangedSlot(int);
|
||||||
|
void gValueChangedSlot(int);
|
||||||
|
void bValueChangedSlot(int);
|
||||||
|
void aValueChangedSlot(int);
|
||||||
|
void updateEditData(int, int, int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ColorSetting;
|
||||||
|
ColorSetting * const m_pSetting;
|
||||||
|
QLabel *m_pTitleLbl;
|
||||||
|
QPushButton *m_pCloseBtn;
|
||||||
|
QEventLoop *m_pEvtLoop;
|
||||||
|
bool m_bNotEdit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COLORDIALOG_H
|
|
@ -0,0 +1,934 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ColorDialog</class>
|
||||||
|
<widget class="QWidget" name="ColorDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>752</width>
|
||||||
|
<height>415</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>ColorDialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">/*主界面样式表*/
|
||||||
|
QWidget
|
||||||
|
{
|
||||||
|
border:none;
|
||||||
|
color:white;
|
||||||
|
font-family:微软雅黑;
|
||||||
|
font-size:14px;
|
||||||
|
outline:0px;
|
||||||
|
background:transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
#topWgt
|
||||||
|
{
|
||||||
|
border-width:4 4 4 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
主体背景
|
||||||
|
*/
|
||||||
|
#mainWgt
|
||||||
|
{
|
||||||
|
border-width:4 4 4 4;
|
||||||
|
}
|
||||||
|
QLineEdit
|
||||||
|
{
|
||||||
|
background:#25272b;
|
||||||
|
border:1px solid #276d94;
|
||||||
|
padding-left:5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGroupBox
|
||||||
|
{
|
||||||
|
border:2px solid #276d94;
|
||||||
|
margin-top:10px;
|
||||||
|
}
|
||||||
|
QGroupBox::title
|
||||||
|
{
|
||||||
|
left:10px;
|
||||||
|
bottom:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*1-按钮开始*/
|
||||||
|
QPushButton
|
||||||
|
{
|
||||||
|
background:#b82525;
|
||||||
|
border-radius:3px;
|
||||||
|
padding-top:-2px;
|
||||||
|
}
|
||||||
|
QPushButton:hover
|
||||||
|
{
|
||||||
|
background:#d4352d;
|
||||||
|
}
|
||||||
|
QPushButton:pressed
|
||||||
|
{
|
||||||
|
background:#ab2922;
|
||||||
|
}
|
||||||
|
/*1-按钮结束*/
|
||||||
|
|
||||||
|
QSpinBox
|
||||||
|
{
|
||||||
|
border:1px solid #276d94;
|
||||||
|
background-color:#25272b;
|
||||||
|
min-height: 26px;
|
||||||
|
min-width: 70px;
|
||||||
|
}
|
||||||
|
QSpinBox::up-arrow
|
||||||
|
{
|
||||||
|
border-left:8px solid #25272b;
|
||||||
|
border-right:8px solid #25272b;
|
||||||
|
border-bottom:8px solid #276d94;
|
||||||
|
width:0px;
|
||||||
|
height: 0px;
|
||||||
|
}
|
||||||
|
QSpinBox::up-arrow:pressed
|
||||||
|
{
|
||||||
|
border-bottom:9px solid #81c3d7;
|
||||||
|
}
|
||||||
|
QSpinBox::up-button
|
||||||
|
{
|
||||||
|
margin-right:4px;
|
||||||
|
min-width: 16px;
|
||||||
|
min-height: 13px;
|
||||||
|
background-color:#25272b;
|
||||||
|
}
|
||||||
|
QSpinBox::down-arrow
|
||||||
|
{
|
||||||
|
border-left:8px solid #25272b;
|
||||||
|
border-right:8px solid #25272b;
|
||||||
|
border-top:8px solid #276d94;
|
||||||
|
width:0px;
|
||||||
|
height: 0px;
|
||||||
|
}
|
||||||
|
QSpinBox::down-arrow:pressed
|
||||||
|
{
|
||||||
|
border-top:9px solid #81c3d7;
|
||||||
|
}
|
||||||
|
QSpinBox::down-button
|
||||||
|
{
|
||||||
|
margin-right:4px;
|
||||||
|
min-width:16px;
|
||||||
|
min-height:13px;
|
||||||
|
background-color:#25272b;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="topWgt" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>35</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>35</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(216, 216, 216);</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" name="hLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>250</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tone(H):</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="sLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>330</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Saturation(S):</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="vLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>400</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Brightness(V):</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox" name="hSpinBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>480</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="accelerated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string>度</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>360</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox" name="sSpinBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>560</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="accelerated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox" name="vSpinBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>630</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="accelerated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="mainWgt" native="true">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(216, 216, 216);
|
||||||
|
color: rgb(0, 0, 0);</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QGroupBox" name="basicGroup">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>12</x>
|
||||||
|
<y>5</y>
|
||||||
|
<width>228</width>
|
||||||
|
<height>216</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Basic color</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="BasicColorArea" name="basicColorWgt" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>214</width>
|
||||||
|
<height>191</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>214</width>
|
||||||
|
<height>191</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox" name="customGroup">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>12</x>
|
||||||
|
<y>232</y>
|
||||||
|
<width>228</width>
|
||||||
|
<height>81</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Custom color</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="CustomColorArea" name="customColorWgt" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>214</width>
|
||||||
|
<height>52</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>214</width>
|
||||||
|
<height>52</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>17</x>
|
||||||
|
<y>327</y>
|
||||||
|
<width>220</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>12</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>12</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>#</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="colorEdit">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addCustomColorBtn">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Add to custom</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget1">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>253</x>
|
||||||
|
<y>7</y>
|
||||||
|
<width>491</width>
|
||||||
|
<height>272</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="SVColorArea" name="svColorWgt" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>256</width>
|
||||||
|
<height>256</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>256</width>
|
||||||
|
<height>256</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="HColorArea" name="hColorWgt" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>34</width>
|
||||||
|
<height>270</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>34</width>
|
||||||
|
<height>270</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="rSpinBox">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="accelerated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="bLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Blue(B):</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="gLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Green(G):</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="gSpinBox">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="accelerated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="bSpinBox">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="accelerated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="rLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>66</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Red(R):</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>2</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">border-top: 1px solid gray; </string>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>transparency:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="aSpinBox">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>72</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="accelerated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>266</x>
|
||||||
|
<y>290</y>
|
||||||
|
<width>260</width>
|
||||||
|
<height>70</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="curColorLbl">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cur color</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="PreviewColorArea" name="previewWgt" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>166</width>
|
||||||
|
<height>68</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>166</width>
|
||||||
|
<height>68</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="newColorLbl">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>New color</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget5">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>590</x>
|
||||||
|
<y>320</y>
|
||||||
|
<width>138</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="okBtn">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>62</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>62</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ok</string>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cancelBtn">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>62</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>62</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>BasicColorArea</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">ColorDialog\basiccolorarea.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>CustomColorArea</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>ColorDialog\customcolorarea.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>SVColorArea</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>ColorDialog\svcolorarea.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>HColorArea</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>ColorDialog\hcolorarea.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>PreviewColorArea</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>ColorDialog\previewcolorarea.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -0,0 +1,113 @@
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include "CustomColorArea.h"
|
||||||
|
|
||||||
|
CustomColorArea::CustomColorArea(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_iCurIndex(0)
|
||||||
|
{
|
||||||
|
initColorItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomColorArea::~CustomColorArea()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomColorArea::setGivenColor(const QColor &c)
|
||||||
|
{
|
||||||
|
int iIndex = m_iCurIndex % 16;
|
||||||
|
BasicColorItem *pCurItem = m_mapIndexToItem[iIndex];
|
||||||
|
pCurItem->setColor(c);
|
||||||
|
m_iCurIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomColorArea::initColorItems()
|
||||||
|
{
|
||||||
|
BasicColorItem *pItem11 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem12 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem13 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem14 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem15 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem16 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem17 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem18 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
QHBoxLayout *pLayout1 = new QHBoxLayout;
|
||||||
|
pLayout1->setMargin(0);
|
||||||
|
pLayout1->setSpacing(2);
|
||||||
|
pLayout1->addWidget(pItem11);
|
||||||
|
pLayout1->addWidget(pItem12);
|
||||||
|
pLayout1->addWidget(pItem13);
|
||||||
|
pLayout1->addWidget(pItem14);
|
||||||
|
pLayout1->addWidget(pItem15);
|
||||||
|
pLayout1->addWidget(pItem16);
|
||||||
|
pLayout1->addWidget(pItem17);
|
||||||
|
pLayout1->addWidget(pItem18);
|
||||||
|
|
||||||
|
BasicColorItem *pItem21 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem22 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem23 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem24 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem25 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem26 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem27 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
BasicColorItem *pItem28 = new BasicColorItem(QColor(255, 255, 255, 255));
|
||||||
|
QHBoxLayout *pLayout2 = new QHBoxLayout;
|
||||||
|
pLayout2->setMargin(0);
|
||||||
|
pLayout2->setSpacing(2);
|
||||||
|
pLayout2->addWidget(pItem21);
|
||||||
|
pLayout2->addWidget(pItem22);
|
||||||
|
pLayout2->addWidget(pItem23);
|
||||||
|
pLayout2->addWidget(pItem24);
|
||||||
|
pLayout2->addWidget(pItem25);
|
||||||
|
pLayout2->addWidget(pItem26);
|
||||||
|
pLayout2->addWidget(pItem27);
|
||||||
|
pLayout2->addWidget(pItem28);
|
||||||
|
|
||||||
|
QVBoxLayout *pVLayout = new QVBoxLayout(this);
|
||||||
|
pVLayout->setMargin(0);
|
||||||
|
pVLayout->setSpacing(2);
|
||||||
|
pVLayout->addLayout(pLayout1);
|
||||||
|
pVLayout->addLayout(pLayout2);
|
||||||
|
|
||||||
|
m_mapIndexToItem.insert(0, pItem11);
|
||||||
|
m_mapIndexToItem.insert(1, pItem21);
|
||||||
|
m_mapIndexToItem.insert(2, pItem12);
|
||||||
|
m_mapIndexToItem.insert(3, pItem22);
|
||||||
|
m_mapIndexToItem.insert(4, pItem13);
|
||||||
|
m_mapIndexToItem.insert(5, pItem23);
|
||||||
|
m_mapIndexToItem.insert(6, pItem14);
|
||||||
|
m_mapIndexToItem.insert(7, pItem24);
|
||||||
|
m_mapIndexToItem.insert(8, pItem15);
|
||||||
|
m_mapIndexToItem.insert(9, pItem25);
|
||||||
|
m_mapIndexToItem.insert(10, pItem16);
|
||||||
|
m_mapIndexToItem.insert(11, pItem26);
|
||||||
|
m_mapIndexToItem.insert(12, pItem17);
|
||||||
|
m_mapIndexToItem.insert(13, pItem27);
|
||||||
|
m_mapIndexToItem.insert(14, pItem18);
|
||||||
|
m_mapIndexToItem.insert(15, pItem28);
|
||||||
|
|
||||||
|
connect(pItem11, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem12, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem13, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem14, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem15, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem16, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem17, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem18, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
|
||||||
|
connect(pItem21, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem22, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem23, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem24, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem25, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem26, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem27, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
connect(pItem28, SIGNAL(itemClickedSignal(const QColor &)), this, SIGNAL(colorItemSelcSignal(const QColor &)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomColorArea::setGivenItemColor(int iIndex, const QColor &c)
|
||||||
|
{
|
||||||
|
BasicColorItem *pCurItem = m_mapIndexToItem[iIndex];
|
||||||
|
pCurItem->setColor(c);
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
// 自定义颜色区域
|
||||||
|
|
||||||
|
#ifndef CUSTOMCOLORAREA_H
|
||||||
|
#define CUSTOMCOLORAREA_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMap>
|
||||||
|
#include "BasicColorItem.h"
|
||||||
|
|
||||||
|
class CustomColorArea : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CustomColorArea(QWidget *parent);
|
||||||
|
~CustomColorArea();
|
||||||
|
void setGivenColor(const QColor &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initColorItems();
|
||||||
|
void setGivenItemColor(int iIndex, const QColor &);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void colorItemSelcSignal(const QColor &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<int, BasicColorItem *> m_mapIndexToItem;
|
||||||
|
int m_iCurIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CUSTOMCOLORAREA_H
|
|
@ -0,0 +1,77 @@
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QLinearGradient>
|
||||||
|
#include <QtMath>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "HColorArea.h"
|
||||||
|
|
||||||
|
HColorArea::HColorArea(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_hue(0.0)
|
||||||
|
, m_iHue(0)
|
||||||
|
{
|
||||||
|
createHuePixmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
HColorArea::~HColorArea()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HColorArea::setHue(int h)
|
||||||
|
{
|
||||||
|
m_hue = (double)h / 360;
|
||||||
|
m_iHue = h;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HColorArea::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.drawPixmap(0, 0, m_huePixmap);
|
||||||
|
|
||||||
|
int iHeight = m_iColorHeight - m_hue * m_iColorHeight;
|
||||||
|
QPolygonF triangle;
|
||||||
|
triangle.append(QPointF(m_iColorWidth, iHeight + topMargin));
|
||||||
|
triangle.append(QPointF(width(), iHeight));
|
||||||
|
triangle.append(QPointF(width(), iHeight + 2 * topMargin - 1));
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(Qt::white);
|
||||||
|
painter.drawPolygon(triangle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HColorArea::mousePressEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
double tempValue = 1 - (double)(ev->pos().y() - topMargin) / m_iColorHeight;
|
||||||
|
m_hue = qBound(0.0, tempValue, 1.0);
|
||||||
|
update();
|
||||||
|
m_iHue = m_hue * 360;
|
||||||
|
emit hueChangedSignal(m_iHue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HColorArea::mouseMoveEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
double tempValue = 1 - (double)(ev->pos().y() - topMargin) / m_iColorHeight;
|
||||||
|
m_hue = qBound(0.0, tempValue, 1.0);
|
||||||
|
update();
|
||||||
|
m_iHue = m_hue * 360;
|
||||||
|
emit hueChangedSignal(m_iHue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HColorArea::createHuePixmap()
|
||||||
|
{
|
||||||
|
m_huePixmap = QPixmap(34, 270);
|
||||||
|
m_huePixmap.fill(Qt::transparent);
|
||||||
|
QPainter painter(&m_huePixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
QLinearGradient hueGradient(0, m_iColorHeight, 0, 0);
|
||||||
|
for (double i = 0; i < 1.0; i += 1.0 / 16)
|
||||||
|
{
|
||||||
|
hueGradient.setColorAt(i, QColor::fromHsvF(i, 1, 1, 1));
|
||||||
|
}
|
||||||
|
hueGradient.setColorAt(1, QColor::fromHsvF(0, 1, 1, 1));
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(QBrush(hueGradient));
|
||||||
|
painter.drawRect(0, topMargin, m_iColorWidth, m_iColorHeight);
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
功能:界面中的色调区域
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HCOLORAREA_H
|
||||||
|
#define HCOLORAREA_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class HColorArea : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
HColorArea(QWidget *parent);
|
||||||
|
~HColorArea();
|
||||||
|
void setHue(int);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void createHuePixmap(); //创建pixmap
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void hueChangedSignal(int); //色调值改变发出信号
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPixmap m_huePixmap;
|
||||||
|
double m_hue;
|
||||||
|
int m_iHue;
|
||||||
|
const int m_iColorHeight=256; //颜色区域的高度
|
||||||
|
const int m_iColorWidth=25; //颜色区域的宽度
|
||||||
|
const int topMargin = 7;
|
||||||
|
const int rightMargin = 9;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HCOLORAREA_H
|
|
@ -0,0 +1,55 @@
|
||||||
|
#include <QStylePainter>
|
||||||
|
#include "PreviewColorArea.h"
|
||||||
|
|
||||||
|
PreviewColorArea::PreviewColorArea(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_curColor(Qt::black)
|
||||||
|
, m_newColor(Qt::black)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviewColorArea::~PreviewColorArea()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewColorArea::setCurColor(const QColor &c)
|
||||||
|
{
|
||||||
|
m_curColor = c;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewColorArea::setNewColor(const QColor &c)
|
||||||
|
{
|
||||||
|
m_newColor = c;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewColorArea::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QStylePainter painter(this);
|
||||||
|
paint(painter, geometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewColorArea::resizeEvent(QResizeEvent *)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewColorArea::paint(QPainter &painter, QRect rect) const
|
||||||
|
{
|
||||||
|
int iMiddleWidth = rect.width() / 2;
|
||||||
|
int iHeight = rect.height();
|
||||||
|
painter.fillRect(0, 0, iMiddleWidth, iHeight, m_curColor);
|
||||||
|
painter.fillRect(iMiddleWidth, 0, iMiddleWidth, iHeight, m_newColor);
|
||||||
|
painter.setPen(QPen(Qt::black, 1));
|
||||||
|
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewColorArea::svChangedSlot(int h, int s, int v)
|
||||||
|
{
|
||||||
|
m_newColor.setHsv(h, s, v);
|
||||||
|
update();
|
||||||
|
emit svChangedSignal(h, s, v);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
// 颜色预览区域
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PREVIEWCOLORAREA_H
|
||||||
|
#define PREVIEWCOLORAREA_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class PreviewColorArea : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PreviewColorArea(QWidget *parent);
|
||||||
|
~PreviewColorArea();
|
||||||
|
|
||||||
|
void setCurColor(const QColor &);
|
||||||
|
void setNewColor(const QColor &);
|
||||||
|
QColor getNewColor(){ return m_newColor;}
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void paint(QPainter &painter, QRect) const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void svChangedSlot(int, int, int);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void svChangedSignal(int, int, int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QColor m_curColor;
|
||||||
|
QColor m_newColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PREVIEWCOLORAREA_H
|
|
@ -0,0 +1,132 @@
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QtMath>
|
||||||
|
#include "SVColorArea.h"
|
||||||
|
|
||||||
|
SVColorArea::SVColorArea(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_iHue(0)
|
||||||
|
, m_iSaturation(0)
|
||||||
|
, m_iBrightness(0)
|
||||||
|
, m_iAreaWidth(256)
|
||||||
|
{
|
||||||
|
createSVPixmap();
|
||||||
|
createVPixmap();
|
||||||
|
updateSVPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
SVColorArea::~SVColorArea()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::setHue(int h)
|
||||||
|
{
|
||||||
|
m_iHue = h;
|
||||||
|
updateSVPixmap();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::setSaturation(int s)
|
||||||
|
{
|
||||||
|
m_iSaturation = s;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::setBrightness(int v)
|
||||||
|
{
|
||||||
|
m_iBrightness = v;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::setHsv(int h, int s, int v)
|
||||||
|
{
|
||||||
|
m_iHue = h;
|
||||||
|
m_iSaturation = s;
|
||||||
|
m_iBrightness = v;
|
||||||
|
updateSVPixmap();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::setColor(const QColor &c)
|
||||||
|
{
|
||||||
|
m_iHue = c.hue();
|
||||||
|
m_iSaturation = c.saturation();
|
||||||
|
m_iBrightness = c.value();
|
||||||
|
updateSVPixmap();
|
||||||
|
emit svChangedSignal(m_iHue, m_iSaturation, m_iBrightness);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
//画正方形的颜色区域
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.drawPixmap(0, 0, m_svPixmap);
|
||||||
|
painter.drawPixmap(0, 0, m_vPixmap);
|
||||||
|
|
||||||
|
//画颜色选取点的圆圈(亮度>128为黑色;<128为白色)
|
||||||
|
painter.setPen(QPen(m_iBrightness > 128 ? Qt::black : Qt::white, 2));
|
||||||
|
QPointF selecPos = QPointF(m_iSaturation, 255 - m_iBrightness);
|
||||||
|
painter.drawEllipse(selecPos, 6, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::mousePressEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
m_iSaturation = qBound(0, ev->x(), 255);
|
||||||
|
m_iBrightness = qBound(0, 255 - ev->y(), 255);
|
||||||
|
emit svChangedSignal(m_iHue, m_iSaturation, m_iBrightness);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::mouseMoveEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
m_iSaturation = qBound(0, ev->x(), 255);
|
||||||
|
m_iBrightness = qBound(0, 255 - ev->y(), 255);
|
||||||
|
emit svChangedSignal(m_iHue, m_iSaturation, m_iBrightness);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::createVPixmap()
|
||||||
|
{
|
||||||
|
m_vPixmap = QPixmap(m_iAreaWidth, m_iAreaWidth);
|
||||||
|
m_vPixmap.fill(Qt::transparent);
|
||||||
|
QPainter painter(&m_vPixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
QLinearGradient vGradient(0, 0, 0, m_iAreaWidth);
|
||||||
|
vGradient.setColorAt(0, QColor(0, 0, 0, 0));
|
||||||
|
vGradient.setColorAt(1, QColor(0, 0, 0, 255));
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(QBrush(vGradient));
|
||||||
|
painter.drawRect(0, 0, m_iAreaWidth, m_iAreaWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::createSVPixmap()
|
||||||
|
{
|
||||||
|
m_svPixmap = QPixmap(m_iAreaWidth, m_iAreaWidth);
|
||||||
|
m_svPixmap.fill(Qt::transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::updateSVPixmap()
|
||||||
|
{
|
||||||
|
QColor newColor;
|
||||||
|
newColor.setHsv(m_iHue, 255, 255);
|
||||||
|
QPainter painter(&m_svPixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
QLinearGradient svGradient(0, 0, m_iAreaWidth, 0);
|
||||||
|
svGradient.setColorAt(1, newColor);
|
||||||
|
svGradient.setColorAt(0, QColor("#ffffff"));
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(QBrush(svGradient));
|
||||||
|
painter.drawRect(0, 0, m_iAreaWidth, m_iAreaWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SVColorArea::hueChangedSlot(int h)
|
||||||
|
{
|
||||||
|
m_iHue = h;
|
||||||
|
updateSVPixmap();
|
||||||
|
emit svChangedSignal(m_iHue, m_iSaturation, m_iBrightness);
|
||||||
|
update();
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
功能:界面中的饱和度(S)与亮度(V)区域
|
||||||
|
大小256 * 256
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SVCOLORAREA_H
|
||||||
|
#define SVCOLORAREA_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class SVColorArea : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SVColorArea(QWidget *parent);
|
||||||
|
~SVColorArea();
|
||||||
|
void setHue(int);
|
||||||
|
void setSaturation(int);
|
||||||
|
void setBrightness(int);
|
||||||
|
void setHsv(int, int, int);
|
||||||
|
void setColor(const QColor &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *); //paint事件
|
||||||
|
void mousePressEvent(QMouseEvent *); //鼠标按下事件
|
||||||
|
void mouseMoveEvent(QMouseEvent *); //鼠标移动事件
|
||||||
|
|
||||||
|
private:
|
||||||
|
void drawSVPixmap();
|
||||||
|
void createVPixmap(); //创建亮度渐变的pixmap
|
||||||
|
void createSVPixmap(); //创建正方形区域的pixmap
|
||||||
|
void updateSVPixmap(); //更新正方形区域的pixmap
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void hueChangedSlot(int);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void svChangedSignal(int, int, int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_iHue;
|
||||||
|
int m_iSaturation;
|
||||||
|
int m_iBrightness;
|
||||||
|
const int m_iAreaWidth; //正方形区域的宽度
|
||||||
|
QPixmap m_svPixmap; //正方形区域的pixmap
|
||||||
|
QPixmap m_vPixmap; //亮度渐变的pixmap
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SVCOLORAREA_H
|
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 143 B |
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 65 KiB |
|
@ -0,0 +1,216 @@
|
||||||
|
#
|
||||||
|
# This file is part of JQLibrary
|
||||||
|
#
|
||||||
|
# Copyright: Jason
|
||||||
|
#
|
||||||
|
# Contact email: 188080501@qq.com
|
||||||
|
#
|
||||||
|
# GNU Lesser General Public License Usage
|
||||||
|
# Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
# General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
# Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
# LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
# following information to ensure the GNU Lesser General Public License
|
||||||
|
# requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
#
|
||||||
|
|
||||||
|
QT *= core gui
|
||||||
|
|
||||||
|
CONFIG *= c++11
|
||||||
|
|
||||||
|
INCLUDEPATH *= \
|
||||||
|
$$PWD/include/
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQBarcode.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQBarcode.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQBarcode.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contains( QT, bluetooth ) : exists( $$PWD/src/JQBluetooth.cpp ) {
|
||||||
|
|
||||||
|
mac | ios {
|
||||||
|
DEFINES += JQBLUETOOTH_UUIDMODE
|
||||||
|
}
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQBluetooth.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQBluetooth.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQChecksum.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQChecksum.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQChecksum.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQExcel.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQExcel.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQExcel.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQFile.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQFile.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQFile.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unix | linux | mingw {
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQFilePack.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQFilePack.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQFilePack.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQFoundation.cpp ) {
|
||||||
|
|
||||||
|
DEFINES += JQFOUNDATION_LIB
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQFoundation.h
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/jqdeclare.hpp
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQFoundation.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/jqgpio.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/jqgpio.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/jqgpio.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contains( QT, network ) : contains( QT, concurrent ) : exists( $$PWD/src/JQHttpServer.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQHttpServer.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQHttpServer.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ios : exists( $$PWD/src/JQiOS.cpp ) {
|
||||||
|
|
||||||
|
LIBS *= -framework Foundation -framework UIKit
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQiOS.h
|
||||||
|
|
||||||
|
OBJECTIVE_SOURCES *= $$PWD/src/JQiOS.mm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQLanguage.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQLanguage.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQLanguage.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contains( QT, network ) : exists( $$PWD/src/JQNet.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQNet.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQNet.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contains( QT, serialport ) : exists( $$PWD/src/JQSerialPort.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQSerialPort.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQSerialPort.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQSettings.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQSettings.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQSettings.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/JQSms.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQSms.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQSms.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contains( QT, network ) : exists( $$PWD/src/JQSystemFlag.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQSystemFlag.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQSystemFlag.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists( $$PWD/src/jqthread.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/jqthread.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/jqthread.cpp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contains( QT, webenginewidgets ) : exists( $$PWD/src/JQWebEngine.cpp ) {
|
||||||
|
|
||||||
|
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
|
||||||
|
|
||||||
|
HEADERS *= $$PWD/include/JQWebEngine.h
|
||||||
|
|
||||||
|
SOURCES *= $$PWD/src/JQWebEngine.cpp
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
#include "jqdeclare.hpp"
|
|
@ -0,0 +1,282 @@
|
||||||
|
/*
|
||||||
|
This file is part of JQLibrary
|
||||||
|
|
||||||
|
Copyright: Jason
|
||||||
|
|
||||||
|
Contact email: 188080501@qq.com
|
||||||
|
|
||||||
|
GNU Lesser General Public License Usage
|
||||||
|
Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
following information to ensure the GNU Lesser General Public License
|
||||||
|
requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef JQHTTPSERVER_H_
|
||||||
|
#define JQHTTPSERVER_H_
|
||||||
|
|
||||||
|
#ifndef QT_NETWORK_LIB
|
||||||
|
# error("Please add network in pro file")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef QT_CONCURRENT_LIB
|
||||||
|
# error("Please add concurrent in pro file")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// C++ lib import
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// Qt lib import
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QHostAddress>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
// JQLibrary lib import
|
||||||
|
#include <JQDeclare>
|
||||||
|
|
||||||
|
class QIODevice;
|
||||||
|
class QThreadPool;
|
||||||
|
class QHostAddress;
|
||||||
|
class QTimer;
|
||||||
|
class QImage;
|
||||||
|
class QTcpServer;
|
||||||
|
class QLocalServer;
|
||||||
|
class QSslCertificate;
|
||||||
|
class QSslKey;
|
||||||
|
class QSslConfiguration;
|
||||||
|
|
||||||
|
namespace JQHttpServer
|
||||||
|
{
|
||||||
|
|
||||||
|
class JQLIBRARY_EXPORT Session: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY( Session )
|
||||||
|
|
||||||
|
public:
|
||||||
|
Session( const QPointer< QIODevice > &tcpSocket );
|
||||||
|
|
||||||
|
~Session();
|
||||||
|
|
||||||
|
inline void setHandleAcceptedCallback(const std::function< void(const QPointer< Session > &) > &callback) { handleAcceptedCallback_ = callback; }
|
||||||
|
|
||||||
|
QString requestSource() const;
|
||||||
|
|
||||||
|
QString requestMethod() const;
|
||||||
|
|
||||||
|
QString requestUrl() const;
|
||||||
|
|
||||||
|
QString requestCrlf() const;
|
||||||
|
|
||||||
|
QMap< QString, QString > requestHeader() const;
|
||||||
|
|
||||||
|
QByteArray requestBody() const;
|
||||||
|
|
||||||
|
QString requestUrlPath() const;
|
||||||
|
|
||||||
|
QStringList requestUrlPathSplitToList() const;
|
||||||
|
|
||||||
|
QMap< QString, QString > requestUrlQuery() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void replyText(const QString &replyData, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyRedirects(const QUrl &targetUrl, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyJsonObject(const QJsonObject &jsonObject, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyJsonArray(const QJsonArray &jsonArray, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyFile(const QString &filePath, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyFile(const QString &fileName, const QByteArray &fileData, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyImage(const QImage &image, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyImage(const QString &imageFilePath, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyBytes(const QByteArray &bytes, const int &httpStatusCode = 200);
|
||||||
|
|
||||||
|
void replyOptions();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void inspectionBufferSetup1();
|
||||||
|
|
||||||
|
void inspectionBufferSetup2();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer< QIODevice > ioDevice_;
|
||||||
|
std::function< void(const QPointer< Session > &) > handleAcceptedCallback_;
|
||||||
|
QSharedPointer< QTimer > timerForClose_;
|
||||||
|
|
||||||
|
QByteArray buffer_;
|
||||||
|
|
||||||
|
QString requestSource_;
|
||||||
|
QString requestMethod_;
|
||||||
|
QString requestUrl_;
|
||||||
|
QString requestCrlf_;
|
||||||
|
|
||||||
|
QMap< QString, QString > requestHeader_;
|
||||||
|
bool headerAcceptedFinish_ = false;
|
||||||
|
qint64 contentLength_ = -1;
|
||||||
|
bool alreadyReply_ = false;
|
||||||
|
|
||||||
|
QByteArray requestBody_;
|
||||||
|
|
||||||
|
qint64 waitWrittenByteCount_ = 0;
|
||||||
|
QSharedPointer< QIODevice > ioDeviceForReply_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class JQLIBRARY_EXPORT AbstractManage: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY( AbstractManage )
|
||||||
|
|
||||||
|
public:
|
||||||
|
AbstractManage(const int &handleMaxThreadCount);
|
||||||
|
|
||||||
|
virtual ~AbstractManage();
|
||||||
|
|
||||||
|
inline void setHttpAcceptedCallback(const std::function< void(const QPointer< Session > &session) > &httpAcceptedCallback) { httpAcceptedCallback_ = httpAcceptedCallback; }
|
||||||
|
|
||||||
|
inline QSharedPointer< QThreadPool > handleThreadPool() { return handleThreadPool_; }
|
||||||
|
|
||||||
|
inline QSharedPointer< QThreadPool > serverThreadPool() { return serverThreadPool_; }
|
||||||
|
|
||||||
|
virtual bool isRunning() = 0;
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
bool begin();
|
||||||
|
|
||||||
|
void close();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool onStart() = 0;
|
||||||
|
|
||||||
|
virtual void onFinish() = 0;
|
||||||
|
|
||||||
|
bool startServerThread();
|
||||||
|
|
||||||
|
void stopHandleThread();
|
||||||
|
|
||||||
|
void stopServerThread();
|
||||||
|
|
||||||
|
void newSession(const QPointer< Session > &session);
|
||||||
|
|
||||||
|
void handleAccepted(const QPointer< Session > &session);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void readyToClose();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QSharedPointer< QThreadPool > serverThreadPool_;
|
||||||
|
QSharedPointer< QThreadPool > handleThreadPool_;
|
||||||
|
|
||||||
|
QMutex mutex_;
|
||||||
|
|
||||||
|
std::function< void(const QPointer< Session > &session) > httpAcceptedCallback_;
|
||||||
|
|
||||||
|
QSet< Session * > availableSessions_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class JQLIBRARY_EXPORT TcpServerManage: public AbstractManage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY( TcpServerManage )
|
||||||
|
|
||||||
|
public:
|
||||||
|
TcpServerManage(const int &handleMaxThreadCount = 2);
|
||||||
|
|
||||||
|
~TcpServerManage();
|
||||||
|
|
||||||
|
bool listen(const QHostAddress &address, const quint16 &port);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isRunning();
|
||||||
|
|
||||||
|
bool onStart();
|
||||||
|
|
||||||
|
void onFinish();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer< QTcpServer > tcpServer_;
|
||||||
|
|
||||||
|
QHostAddress listenAddress_ = QHostAddress::Any;
|
||||||
|
quint16 listenPort_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef QT_NO_SSL
|
||||||
|
class SslServerHelper;
|
||||||
|
|
||||||
|
class JQLIBRARY_EXPORT SslServerManage: public AbstractManage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY( SslServerManage )
|
||||||
|
|
||||||
|
public:
|
||||||
|
SslServerManage(const int &handleMaxThreadCount = 2);
|
||||||
|
|
||||||
|
~SslServerManage();
|
||||||
|
|
||||||
|
bool listen(
|
||||||
|
const QHostAddress &address,
|
||||||
|
const quint16 &port,
|
||||||
|
const QString &crtFilePath,
|
||||||
|
const QString &keyFilePath,
|
||||||
|
const QList< QPair< QString, bool > > &caFileList = { } // [ { filePath, isPem } ]
|
||||||
|
);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isRunning();
|
||||||
|
|
||||||
|
bool onStart();
|
||||||
|
|
||||||
|
void onFinish();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer< SslServerHelper > tcpServer_;
|
||||||
|
|
||||||
|
QHostAddress listenAddress_ = QHostAddress::Any;
|
||||||
|
quint16 listenPort_ = 0;
|
||||||
|
|
||||||
|
QSharedPointer< QSslConfiguration > sslConfiguration_;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class JQLIBRARY_EXPORT LocalServerManage: public AbstractManage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY( LocalServerManage )
|
||||||
|
|
||||||
|
public:
|
||||||
|
LocalServerManage(const int &handleMaxThreadCount);
|
||||||
|
|
||||||
|
~LocalServerManage();
|
||||||
|
|
||||||
|
bool listen(const QString &name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isRunning();
|
||||||
|
|
||||||
|
bool onStart();
|
||||||
|
|
||||||
|
void onFinish();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer< QLocalServer > localServer_;
|
||||||
|
|
||||||
|
QString listenName_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif//JQHTTPSERVER_H_
|
|
@ -0,0 +1,198 @@
|
||||||
|
/*
|
||||||
|
This file is part of JQLibrary
|
||||||
|
|
||||||
|
Copyright: Jason
|
||||||
|
|
||||||
|
Contact email: 188080501@qq.com
|
||||||
|
|
||||||
|
GNU Lesser General Public License Usage
|
||||||
|
Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
following information to ensure the GNU Lesser General Public License
|
||||||
|
requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef JQLIBRARY_INCLUDE_JQNET_H_
|
||||||
|
#define JQLIBRARY_INCLUDE_JQNET_H_
|
||||||
|
|
||||||
|
#ifndef QT_NETWORK_LIB
|
||||||
|
# error("Please add network in pro file")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// C++ lib import
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// Qt lib import
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QHttpMultiPart>
|
||||||
|
#include <QNetworkInterface>
|
||||||
|
#include <QNetworkAddressEntry>
|
||||||
|
|
||||||
|
// JQLibrary lib import
|
||||||
|
#include <JQDeclare>
|
||||||
|
|
||||||
|
namespace JQNet
|
||||||
|
{
|
||||||
|
|
||||||
|
QNetworkAddressEntry getNetworkAddressEntry();
|
||||||
|
|
||||||
|
QPair< QNetworkAddressEntry, QNetworkInterface > getNetworkAddressEntryWithNetworkInterface(const bool &ridVm = true);
|
||||||
|
|
||||||
|
QString getHostName();
|
||||||
|
|
||||||
|
bool tcpReachable(const QString &hostName, const quint16 &port, const int &timeout = 5000);
|
||||||
|
|
||||||
|
#ifdef JQFOUNDATION_LIB
|
||||||
|
bool pingIp(const QHostAddress &hostAddress);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class JQLIBRARY_EXPORT HTTP
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY( HTTP )
|
||||||
|
|
||||||
|
public:
|
||||||
|
HTTP() = default;
|
||||||
|
|
||||||
|
~HTTP() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline QNetworkAccessManager &manage() { return manage_; }
|
||||||
|
|
||||||
|
|
||||||
|
bool get(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
void get(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data) > &onFinished,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &code, const QByteArray &data) > &onError,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
bool deleteResource(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
void deleteResource(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data) > &onFinished,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &code, const QByteArray &data) > &onError,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
bool post(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
QList< QNetworkReply::RawHeaderPair > &targetRawHeaderPairs,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
bool post(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QSharedPointer< QHttpMultiPart > &multiPart,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
void post(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data) > &onFinished,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &code, const QByteArray &data) > &onError,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
bool put(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
bool put(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QSharedPointer< QHttpMultiPart > &multiPart,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
void put(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data) > &onFinished,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &code, const QByteArray &data) > &onError,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
#if !( defined Q_OS_LINUX ) && ( QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) )
|
||||||
|
bool patch(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
|
||||||
|
void patch(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data) > &onFinished,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &code, const QByteArray &data) > &onError,
|
||||||
|
const int &timeout = 30 * 1000
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > get(const QString &url, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > get(const QNetworkRequest &request, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > deleteResource(const QString &url, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > deleteResource(const QNetworkRequest &request, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > post(const QString &url, const QByteArray &body, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > post(const QNetworkRequest &request, const QByteArray &body, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QPair< QList< QNetworkReply::RawHeaderPair >, QByteArray > > post2(const QNetworkRequest &request, const QByteArray &body, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > post(const QNetworkRequest &request, const QSharedPointer< QHttpMultiPart > &multiPart, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > put(const QString &url, const QByteArray &body, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > put(const QNetworkRequest &request, const QByteArray &body, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > put(const QNetworkRequest &request, const QSharedPointer< QHttpMultiPart > &multiPart, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
#if !( defined Q_OS_LINUX ) && ( QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) )
|
||||||
|
static QPair< bool, QByteArray > patch(const QString &url, const QByteArray &body, const int &timeout = 30 * 1000);
|
||||||
|
|
||||||
|
static QPair< bool, QByteArray > patch(const QNetworkRequest &request, const QByteArray &body, const int &timeout = 30 * 1000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handle(
|
||||||
|
QNetworkReply *reply, const int &timeout,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data) > &onFinished,
|
||||||
|
const std::function< void(const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &code, const QByteArray &data) > &onError,
|
||||||
|
const std::function< void() > &onTimeout
|
||||||
|
);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkAccessManager manage_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif//JQLIBRARY_INCLUDE_JQNET_H_
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*
|
||||||
|
This file is part of JQLibrary
|
||||||
|
|
||||||
|
Copyright: Jason
|
||||||
|
|
||||||
|
Contact email: 188080501@qq.com
|
||||||
|
|
||||||
|
GNU Lesser General Public License Usage
|
||||||
|
Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
following information to ensure the GNU Lesser General Public License
|
||||||
|
requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef JQLIBRARY_INCLUDE_JQDECLARE_HPP_
|
||||||
|
#define JQLIBRARY_INCLUDE_JQDECLARE_HPP_
|
||||||
|
|
||||||
|
// Macro define
|
||||||
|
#define JQPROPERTYDECLARE(Type, name, setName, ...) \
|
||||||
|
private: \
|
||||||
|
Type name ## _ __VA_ARGS__; \
|
||||||
|
public: \
|
||||||
|
inline const Type &name() const { return name ## _; } \
|
||||||
|
inline void setName(const Type &name) { name ## _ = name; } \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#define JQPROPERTYDECLAREWITHSLOT(Type, name, setName, ...) \
|
||||||
|
private: \
|
||||||
|
Type name ## _ __VA_ARGS__; \
|
||||||
|
public Q_SLOTS: \
|
||||||
|
Type name() const { return name ## _; } \
|
||||||
|
void setName(const Type &name) { name ## _ = name; } \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#define JQPTRPROPERTYDECLARE(Type, name, setName, ...) \
|
||||||
|
private: \
|
||||||
|
Type *name ## _ __VA_ARGS__; \
|
||||||
|
public: \
|
||||||
|
inline const Type *name() const \
|
||||||
|
{ return name ## _; } \
|
||||||
|
inline void setName(const Type &name) \
|
||||||
|
{ if ( name ## _ ) { delete name ## _; } \
|
||||||
|
name ## _ = new Type( name ); } \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#define JQ_READ_AND_SET_PROPERTY( Type, name, setName ) \
|
||||||
|
public: \
|
||||||
|
inline const Type &name() const { return name ## _; } \
|
||||||
|
inline void setName(const Type &name) { name ## _ = name; } \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#define JQ_STATIC_READ_AND_SET_PROPERTY( Type, name, setName ) \
|
||||||
|
public: \
|
||||||
|
static inline const Type &name() { return name ## _; } \
|
||||||
|
static inline void setName(const Type &name) { name ## _ = name; } \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#define JQ_STATIC_SET_PROPERTY( Type, name, setName ) \
|
||||||
|
public: \
|
||||||
|
static inline void setName(const Type &name) { name ## _ = name; } \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#define RUNONOUTRANGEHELPER2( x, y ) x ## y
|
||||||
|
#define RUNONOUTRANGEHELPER( x, y ) RUNONOUTRANGEHELPER2( x, y )
|
||||||
|
#define RUNONOUTRANGE( ... ) \
|
||||||
|
auto RUNONOUTRANGEHELPER( runOnOutRangeCallback, __LINE__ ) = __VA_ARGS__; \
|
||||||
|
QSharedPointer< int > RUNONOUTRANGEHELPER( runOnOutRange, __LINE__ )( \
|
||||||
|
new int, \
|
||||||
|
[ RUNONOUTRANGEHELPER( runOnOutRangeCallback, __LINE__ ) ](int *data) \
|
||||||
|
{ \
|
||||||
|
RUNONOUTRANGEHELPER( runOnOutRangeCallback, __LINE__ )(); \
|
||||||
|
delete data; \
|
||||||
|
} ); \
|
||||||
|
if ( RUNONOUTRANGEHELPER( runOnOutRange, __LINE__ ).data() == nullptr ) { exit( -1 ); }
|
||||||
|
|
||||||
|
#define RUNONOUTRANGETIMER( message ) \
|
||||||
|
const auto &&runOnOutRangeTimerTime = QDateTime::currentMSecsSinceEpoch(); \
|
||||||
|
RUNONOUTRANGE( [ = ]() \
|
||||||
|
{ \
|
||||||
|
qDebug() << message << ( QDateTime::currentMSecsSinceEpoch() - runOnOutRangeTimerTime ); \
|
||||||
|
} )
|
||||||
|
|
||||||
|
#define JQCONST( property ) \
|
||||||
|
static_cast< const decltype( property ) >( property )
|
||||||
|
|
||||||
|
#define JQTICKCOUNTERMESSAGE( message ) \
|
||||||
|
{ \
|
||||||
|
static JQTickCounter tickCounter; \
|
||||||
|
tickCounter.tick(); \
|
||||||
|
qDebug() << message << tickCounter.tickPerSecond(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define JQBUILDDATETIMESTRING \
|
||||||
|
( QDateTime( \
|
||||||
|
QLocale( QLocale::English ).toDate( QString( __DATE__ ).replace( " ", " 0" ), "MMM dd yyyy"), \
|
||||||
|
QTime::fromString( __TIME__, "hh:mm:ss" ) \
|
||||||
|
).toString( "yyyy-MM-dd hh:mm:ss" ).toLatin1().data() )
|
||||||
|
|
||||||
|
#define JQONLYONCE \
|
||||||
|
if ( [](){ static auto flag = true; if ( flag ) { flag = false; return true; } return false; }() )
|
||||||
|
|
||||||
|
#define JQOSKIPFIRST \
|
||||||
|
if ( [](){ static auto flag = true; if ( flag ) { flag = false; return false; } return true; }() )
|
||||||
|
|
||||||
|
// Export
|
||||||
|
#ifdef JQLIBRARY_EXPORT_ENABLE
|
||||||
|
# ifdef JQLIBRARY_EXPORT_MODE
|
||||||
|
# define JQLIBRARY_EXPORT Q_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define JQLIBRARY_EXPORT Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define JQLIBRARY_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif//JQLIBRARY_INCLUDE_JQDECLARE_HPP_
|
|
@ -0,0 +1,669 @@
|
||||||
|
/*
|
||||||
|
This file is part of JQLibrary
|
||||||
|
|
||||||
|
Copyright: Jason
|
||||||
|
|
||||||
|
Contact email: 188080501@qq.com
|
||||||
|
|
||||||
|
GNU Lesser General Public License Usage
|
||||||
|
Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
following information to ensure the GNU Lesser General Public License
|
||||||
|
requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "JQNet.h"
|
||||||
|
|
||||||
|
// Qt lib import
|
||||||
|
#include <QEventLoop>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QHostInfo>
|
||||||
|
#include <QTcpSocket>
|
||||||
|
|
||||||
|
// JQLibrary lib import
|
||||||
|
#ifdef JQFOUNDATION_LIB
|
||||||
|
# include "JQFoundation.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QNetworkAddressEntry JQNet::getNetworkAddressEntry()
|
||||||
|
{
|
||||||
|
return getNetworkAddressEntryWithNetworkInterface().first;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< QNetworkAddressEntry, QNetworkInterface > JQNet::getNetworkAddressEntryWithNetworkInterface(const bool &ridVm)
|
||||||
|
{
|
||||||
|
for ( const auto &interface: static_cast< const QList< QNetworkInterface > >( QNetworkInterface::allInterfaces() ) )
|
||||||
|
{
|
||||||
|
if ( interface.flags() != ( QNetworkInterface::IsUp |
|
||||||
|
QNetworkInterface::IsRunning |
|
||||||
|
QNetworkInterface::CanBroadcast |
|
||||||
|
QNetworkInterface::CanMulticast ) ) { continue; }
|
||||||
|
|
||||||
|
if ( ridVm && interface.humanReadableName().startsWith( "vm" ) ) { continue; }
|
||||||
|
|
||||||
|
for ( const auto &entry: static_cast< QList<QNetworkAddressEntry> >( interface.addressEntries() ) )
|
||||||
|
{
|
||||||
|
if ( entry.ip().toIPv4Address() )
|
||||||
|
{
|
||||||
|
return { entry, interface };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { };
|
||||||
|
}
|
||||||
|
|
||||||
|
QString JQNet::getHostName()
|
||||||
|
{
|
||||||
|
#if ( defined Q_OS_MAC )
|
||||||
|
return QHostInfo::localHostName().replace( ".local", "" );
|
||||||
|
#else
|
||||||
|
return QHostInfo::localHostName();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JQNet::tcpReachable(const QString &hostName, const quint16 &port, const int &timeout)
|
||||||
|
{
|
||||||
|
QTcpSocket socket;
|
||||||
|
|
||||||
|
socket.connectToHost( hostName, port );
|
||||||
|
socket.waitForConnected( timeout );
|
||||||
|
|
||||||
|
return socket.state() == QAbstractSocket::ConnectedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef JQFOUNDATION_LIB
|
||||||
|
bool JQNet::pingIp(const QHostAddress &hostAddress)
|
||||||
|
{
|
||||||
|
// qDebug() << "NetworkManage::pingIp:" << hostAddress.toString();
|
||||||
|
|
||||||
|
QPair< int, QByteArray > pingResult = { -1, { } };
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
pingResult = JQFoundation::startProcessAndReadOutput( "ping", { "-c1", "-W300", hostAddress.toString() } );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
pingResult = JQFoundation::startProcessAndReadOutput( "ping", { "-n", "1", "-w", "300", hostAddress.toString() } );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ( pingResult.first == 0 ) && ( pingResult.second.size() > 20 ) && ( pingResult.second.count( hostAddress.toString().toUtf8() ) > 1 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// HTTP
|
||||||
|
bool JQNet::HTTP::get(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
QByteArray &target, const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
target.clear();
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
auto reply = manage_.get( request );
|
||||||
|
bool failFlag = false;
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
[ & ](const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( 1 );
|
||||||
|
},
|
||||||
|
[ & ](const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( 0 );
|
||||||
|
},
|
||||||
|
[ & ]()
|
||||||
|
{
|
||||||
|
failFlag = true;
|
||||||
|
eventLoop.exit( 0 );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventLoop.exec() && !failFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JQNet::HTTP::get(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &)> &onFinished,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &)> &onError,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto reply = manage_.get( request );
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
onFinished,
|
||||||
|
onError,
|
||||||
|
[ onError ]()
|
||||||
|
{
|
||||||
|
onError( { }, QNetworkReply::TimeoutError, { } );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JQNet::HTTP::deleteResource(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
target.clear();
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
auto reply = manage_.deleteResource( request );
|
||||||
|
bool failFlag = false;
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
[ & ](const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( 1 );
|
||||||
|
},
|
||||||
|
[ & ](const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( 0 );
|
||||||
|
},
|
||||||
|
[ & ]()
|
||||||
|
{
|
||||||
|
failFlag = true;
|
||||||
|
eventLoop.exit( 0 );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventLoop.exec() && !failFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JQNet::HTTP::deleteResource(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &)> &onFinished,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &)> &onError,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto reply = manage_.deleteResource( request );
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
onFinished,
|
||||||
|
onError,
|
||||||
|
[ onError ]()
|
||||||
|
{
|
||||||
|
onError( { }, QNetworkReply::TimeoutError, { } );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JQNet::HTTP::post(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
QList< QNetworkReply::RawHeaderPair > &targetRawHeaderPairs,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
target.clear();
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
auto reply = manage_.post( request, body );
|
||||||
|
bool failFlag = false;
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
[ &targetRawHeaderPairs, &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &rawHeaderPairs, const QByteArray &data)
|
||||||
|
{
|
||||||
|
targetRawHeaderPairs = rawHeaderPairs;
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( true );
|
||||||
|
},
|
||||||
|
[ &targetRawHeaderPairs, &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &rawHeaderPairs, const QNetworkReply::NetworkError &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
targetRawHeaderPairs = rawHeaderPairs;
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
},
|
||||||
|
[ &failFlag, &eventLoop ]()
|
||||||
|
{
|
||||||
|
failFlag = true;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventLoop.exec() && !failFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JQNet::HTTP::post(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QSharedPointer< QHttpMultiPart > &multiPart,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
target.clear();
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
auto reply = manage_.post( request, multiPart.data() );
|
||||||
|
bool failFlag = false;
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( true );
|
||||||
|
},
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
},
|
||||||
|
[ &failFlag, &eventLoop ]()
|
||||||
|
{
|
||||||
|
failFlag = true;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventLoop.exec() && !failFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JQNet::HTTP::post(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &)> &onFinished,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &)> &onError,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto reply = manage_.post( request, body );
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
onFinished,
|
||||||
|
onError,
|
||||||
|
[ onError ]()
|
||||||
|
{
|
||||||
|
onError( { }, QNetworkReply::TimeoutError, { } );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JQNet::HTTP::put(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
target.clear();
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
auto reply = manage_.put( request, body );
|
||||||
|
bool failFlag = false;
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( true );
|
||||||
|
},
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
},
|
||||||
|
[ &failFlag, &eventLoop ]()
|
||||||
|
{
|
||||||
|
failFlag = true;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventLoop.exec() && !failFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JQNet::HTTP::put(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QSharedPointer< QHttpMultiPart > &multiPart,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
target.clear();
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
auto reply = manage_.put( request, multiPart.data() );
|
||||||
|
bool failFlag = false;
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( true );
|
||||||
|
},
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError & /*e*/, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
},
|
||||||
|
[ &failFlag, &eventLoop ]()
|
||||||
|
{
|
||||||
|
failFlag = true;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventLoop.exec() && !failFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JQNet::HTTP::put(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &)> &onFinished,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &)> &onError,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto reply = manage_.put( request, body );
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
onFinished,
|
||||||
|
onError,
|
||||||
|
[ onError ]()
|
||||||
|
{
|
||||||
|
onError( { }, QNetworkReply::TimeoutError, { } );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !( defined Q_OS_LINUX ) && ( QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) )
|
||||||
|
bool JQNet::HTTP::patch(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
QByteArray &target,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
target.clear();
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
auto reply = manage_.sendCustomRequest( request, "PATCH", body );
|
||||||
|
bool failFlag = false;
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( true );
|
||||||
|
},
|
||||||
|
[ &target, &eventLoop ](const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &data)
|
||||||
|
{
|
||||||
|
target = data;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
},
|
||||||
|
[ &failFlag, &eventLoop ]()
|
||||||
|
{
|
||||||
|
failFlag = true;
|
||||||
|
eventLoop.exit( false );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return eventLoop.exec() && !failFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JQNet::HTTP::patch(
|
||||||
|
const QNetworkRequest &request,
|
||||||
|
const QByteArray &body,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &)> &onFinished,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &)> &onError,
|
||||||
|
const int &timeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto reply = manage_.sendCustomRequest( request, "PATCH", body );
|
||||||
|
|
||||||
|
this->handle(
|
||||||
|
reply,
|
||||||
|
timeout,
|
||||||
|
onFinished,
|
||||||
|
onError,
|
||||||
|
[ onError ]()
|
||||||
|
{
|
||||||
|
onError( { }, QNetworkReply::TimeoutError, { } );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::get(const QString &url, const int &timeout)
|
||||||
|
{
|
||||||
|
QNetworkRequest networkRequest( ( QUrl( url ) ) );
|
||||||
|
QByteArray buf;
|
||||||
|
|
||||||
|
const auto &&flag = HTTP().get( networkRequest, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::get(const QNetworkRequest &request, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.get( request, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::deleteResource(const QString &url, const int &timeout)
|
||||||
|
{
|
||||||
|
QNetworkRequest networkRequest( ( QUrl( url ) ) );
|
||||||
|
QByteArray buf;
|
||||||
|
|
||||||
|
const auto &&flag = HTTP().deleteResource( networkRequest, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::deleteResource(const QNetworkRequest &request, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.deleteResource( request, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::post(const QString &url, const QByteArray &body, const int &timeout)
|
||||||
|
{
|
||||||
|
QNetworkRequest networkRequest( ( QUrl( url ) ) );
|
||||||
|
QList< QNetworkReply::RawHeaderPair > rawHeaderPairs;
|
||||||
|
QByteArray buf;
|
||||||
|
|
||||||
|
networkRequest.setRawHeader( "Content-Type", "application/x-www-form-urlencoded" );
|
||||||
|
|
||||||
|
const auto &&flag = HTTP().post( networkRequest, body, rawHeaderPairs, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::post(const QNetworkRequest &request, const QByteArray &body, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
QList< QNetworkReply::RawHeaderPair > rawHeaderPairs;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.post( request, body, rawHeaderPairs, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QPair< QList< QNetworkReply::RawHeaderPair >, QByteArray > > JQNet::HTTP::post2(const QNetworkRequest &request, const QByteArray &body, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
QList< QNetworkReply::RawHeaderPair > rawHeaderPairs;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.post( request, body, rawHeaderPairs, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, { rawHeaderPairs, buf } };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::post(const QNetworkRequest &request, const QSharedPointer<QHttpMultiPart> &multiPart, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.post( request, multiPart, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::put(const QString &url, const QByteArray &body, const int &timeout)
|
||||||
|
{
|
||||||
|
QNetworkRequest networkRequest( ( QUrl( url ) ) );
|
||||||
|
QByteArray buf;
|
||||||
|
|
||||||
|
networkRequest.setRawHeader( "Content-Type", "application/x-www-form-urlencoded" );
|
||||||
|
|
||||||
|
const auto &&flag = HTTP().put( networkRequest, body, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::put(const QNetworkRequest &request, const QByteArray &body, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.put( request, body, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::put(const QNetworkRequest &request, const QSharedPointer< QHttpMultiPart > &multiPart, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.put( request, multiPart, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !( defined Q_OS_LINUX ) && ( QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) )
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::patch(const QString &url, const QByteArray &body, const int &timeout)
|
||||||
|
{
|
||||||
|
QNetworkRequest networkRequest( ( QUrl( url ) ) );
|
||||||
|
QByteArray buf;
|
||||||
|
|
||||||
|
networkRequest.setRawHeader( "Content-Type", "application/x-www-form-urlencoded" );
|
||||||
|
|
||||||
|
const auto &&flag = HTTP().patch( networkRequest, body, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< bool, QByteArray > JQNet::HTTP::patch(const QNetworkRequest &request, const QByteArray &body, const int &timeout)
|
||||||
|
{
|
||||||
|
QByteArray buf;
|
||||||
|
HTTP http;
|
||||||
|
|
||||||
|
const auto &&flag = http.patch( request, body, buf, timeout );
|
||||||
|
|
||||||
|
return { flag, buf };
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void JQNet::HTTP::handle(
|
||||||
|
QNetworkReply *reply, const int &timeout,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QByteArray &)> &onFinished,
|
||||||
|
const std::function<void (const QList< QNetworkReply::RawHeaderPair > &, const QNetworkReply::NetworkError &, const QByteArray &data)> &onError,
|
||||||
|
const std::function<void ()> &onTimeout
|
||||||
|
)
|
||||||
|
{
|
||||||
|
QSharedPointer< bool > isCalled( new bool( false ) );
|
||||||
|
|
||||||
|
QTimer *timer = nullptr;
|
||||||
|
if ( timeout )
|
||||||
|
{
|
||||||
|
timer = new QTimer;
|
||||||
|
timer->setSingleShot(true);
|
||||||
|
|
||||||
|
QObject::connect( timer, &QTimer::timeout, [ timer, onTimeout, isCalled ]()
|
||||||
|
{
|
||||||
|
if ( *isCalled ) { return; }
|
||||||
|
*isCalled = true;
|
||||||
|
|
||||||
|
onTimeout();
|
||||||
|
timer->deleteLater();
|
||||||
|
} );
|
||||||
|
timer->start( timeout );
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject::connect( reply, &QNetworkReply::finished, [ reply, timer, onFinished, isCalled ]()
|
||||||
|
{
|
||||||
|
if ( *isCalled ) { return; }
|
||||||
|
*isCalled = true;
|
||||||
|
|
||||||
|
if ( timer )
|
||||||
|
{
|
||||||
|
timer->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &&acceptedData = reply->readAll();
|
||||||
|
const auto &rawHeaderPairs = reply->rawHeaderPairs();
|
||||||
|
|
||||||
|
onFinished( rawHeaderPairs, acceptedData );
|
||||||
|
} );
|
||||||
|
|
||||||
|
#ifndef QT_NO_SSL
|
||||||
|
if ( reply->url().toString().toLower().startsWith( "https" ) )
|
||||||
|
{
|
||||||
|
QObject::connect( reply, static_cast< void( QNetworkReply::* )( const QList< QSslError > & ) >( &QNetworkReply::sslErrors ), [ reply ](const QList< QSslError > &errors)
|
||||||
|
{
|
||||||
|
qDebug() << "HTTP::handle: ignoreSslErrors:" << errors;
|
||||||
|
reply->ignoreSslErrors();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QObject::connect( reply, static_cast< void( QNetworkReply::* )( QNetworkReply::NetworkError ) >( &QNetworkReply::error ), [ reply, timer, onError, isCalled ](const QNetworkReply::NetworkError &code)
|
||||||
|
{
|
||||||
|
if ( *isCalled ) { return; }
|
||||||
|
*isCalled = true;
|
||||||
|
|
||||||
|
if ( timer )
|
||||||
|
{
|
||||||
|
timer->deleteLater();
|
||||||
|
}
|
||||||
|
const auto &&acceptedData = reply->readAll();
|
||||||
|
const auto &rawHeaderPairs = reply->rawHeaderPairs();
|
||||||
|
|
||||||
|
onError( rawHeaderPairs, code, acceptedData );
|
||||||
|
} );
|
||||||
|
}
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
@ -0,0 +1,493 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2019-04-10T23:15:55
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
VERSION = 1.1.46
|
||||||
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
|
QT += core gui
|
||||||
|
QT += network
|
||||||
|
QT += core network concurrent
|
||||||
|
#QT += axcontainer
|
||||||
|
QT += xlsx
|
||||||
|
QT += serialport
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia multimediawidgets network
|
||||||
|
|
||||||
|
#TARGET = LedOK
|
||||||
|
TARGET = $$quote(LedOK Express)
|
||||||
|
TEMPLATE = app
|
||||||
|
# The following define makes your compiler emit warnings if you use
|
||||||
|
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||||
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
# deprecated API in order to know how to port your code away from it.
|
||||||
|
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
# You can also make your code fail to compile if you use deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
CONFIG += c++11
|
||||||
|
#CONFIG += qaxcontainer
|
||||||
|
SOURCES += \
|
||||||
|
ColorDialog/BasicColorArea.cpp \
|
||||||
|
ColorDialog/BasicColorItem.cpp \
|
||||||
|
ColorDialog/ColorDialog.cpp \
|
||||||
|
ColorDialog/CustomColorArea.cpp \
|
||||||
|
ColorDialog/HColorArea.cpp \
|
||||||
|
ColorDialog/PreviewColorArea.cpp \
|
||||||
|
ColorDialog/SVColorArea.cpp \
|
||||||
|
LoQClass/extendedgroupbox.cpp \
|
||||||
|
LoQClass/locolorselector.cpp \
|
||||||
|
LoQClass/lodateselector.cpp \
|
||||||
|
LoQClass/loglwindow.cpp \
|
||||||
|
LoQClass/loqgraphicsobject.cpp \
|
||||||
|
LoQClass/loqgraphicsvideoitem.cpp \
|
||||||
|
LoQClass/loqgraphicsview.cpp \
|
||||||
|
LoQClass/loqheaderviewcheckbox.cpp \
|
||||||
|
LoQClass/loqlineedit.cpp \
|
||||||
|
LoQClass/loqtreewidget.cpp \
|
||||||
|
LoQClass/loqvideosurface.cpp \
|
||||||
|
LoUIClass/aboutdlg.cpp \
|
||||||
|
LoUIClass/changepasswordform.cpp \
|
||||||
|
LoUIClass/customprogressindicator.cpp \
|
||||||
|
LoUIClass/loemptydialog.cpp \
|
||||||
|
LoUIClass/louimsgboxokcancel.cpp \
|
||||||
|
LoUIClass/pixbmpshowdialog.cpp \
|
||||||
|
LoUIClass/qiplineedit.cpp \
|
||||||
|
LoUIClass/softconfigdialog.cpp \
|
||||||
|
LoUIClass/switchcontrol.cpp \
|
||||||
|
LoUIClass/taesclass.cpp \
|
||||||
|
LoUIClass/updateledset3dialog.cpp \
|
||||||
|
LoUIClass/updaterdialog.cpp \
|
||||||
|
LoUIClass/updaterfirmwaredialog.cpp \
|
||||||
|
LoUIClass/x_checkboxdelegate.cpp \
|
||||||
|
LoUIClass/x_spinboxdelegate.cpp \
|
||||||
|
LoUIClass/x_timeeditdelegate.cpp \
|
||||||
|
LoUIClass/x_uimsgboxok.cpp \
|
||||||
|
LoUIClass/x_uimsgboxokcancel.cpp \
|
||||||
|
LoUIClass/x_uimsgboxonlyclosebtn.cpp \
|
||||||
|
LoUIClass/x_uimsgboxyesnocancel.cpp \
|
||||||
|
ccrashstack.cpp \
|
||||||
|
communication/hpptclient.cpp \
|
||||||
|
communication/network.cpp \
|
||||||
|
communication/taserialthread.cpp \
|
||||||
|
globaldefine.cpp \
|
||||||
|
jsondecoderloop.cpp \
|
||||||
|
loappconfig.cpp \
|
||||||
|
loapptools.cpp \
|
||||||
|
main.cpp \
|
||||||
|
mainwindow.cpp \
|
||||||
|
mdevicemanager.cpp \
|
||||||
|
mdevicesetting.cpp \
|
||||||
|
mguangyingpinwidget.cpp \
|
||||||
|
mprogrammanagera.cpp \
|
||||||
|
mtitlebar.cpp \
|
||||||
|
mtabwidget.cpp \
|
||||||
|
mprogrammanager.cpp \
|
||||||
|
publishform.cpp \
|
||||||
|
tipdialog.cpp \
|
||||||
|
wDevicesManager/controladvparamwidget.cpp \
|
||||||
|
wDevicesManager/controlbrightnessautowidget.cpp \
|
||||||
|
wDevicesManager/controlbrightnessmanualwidget.cpp \
|
||||||
|
wDevicesManager/controlbrightnessschedule.cpp \
|
||||||
|
wDevicesManager/controlbrightnessscheduleedit.cpp \
|
||||||
|
wDevicesManager/controlbrightnesswidget.cpp \
|
||||||
|
wDevicesManager/controlencryptwidget.cpp \
|
||||||
|
wDevicesManager/controlhdmimanual.cpp \
|
||||||
|
wDevicesManager/controlhdmischedule.cpp \
|
||||||
|
wDevicesManager/controlhdmiwidget.cpp \
|
||||||
|
wDevicesManager/controlnetconfigwidget.cpp \
|
||||||
|
wDevicesManager/controlpowermanual.cpp \
|
||||||
|
wDevicesManager/controlpowerschedule.cpp \
|
||||||
|
wDevicesManager/controlpowerwidget.cpp \
|
||||||
|
wDevicesManager/controltestwidget.cpp \
|
||||||
|
wDevicesManager/controlverifyclockwidget.cpp \
|
||||||
|
wDevicesManager/controlvolumemanual.cpp \
|
||||||
|
wDevicesManager/controlvolumeschedule.cpp \
|
||||||
|
wDevicesManager/controlvolumewidget.cpp \
|
||||||
|
wDevicesManager/devicescontrollwidget.cpp \
|
||||||
|
wDevicesManager/inputpassworddialog.cpp \
|
||||||
|
wDevicesManager/ledcard.cpp \
|
||||||
|
wDevicesManager/specialdlg.cpp \
|
||||||
|
wDevicesManager/subspecifyip.cpp \
|
||||||
|
wDevicesManager/subspecifyiprange.cpp \
|
||||||
|
wDevicesManager/threadupgradeapk.cpp \
|
||||||
|
wDevicesManager/upgradeapkdialog.cpp \
|
||||||
|
wDevicesManager/wdevicesitem.cpp \
|
||||||
|
wDevicesManager/wupgradeapkitem.cpp \
|
||||||
|
wProgramManager/mconverter.cpp \
|
||||||
|
wProgramManager/sendprogramdialog.cpp \
|
||||||
|
wProgramManager/threadexportprogrampro.cpp \
|
||||||
|
wProgramManager/threadsendpro.cpp \
|
||||||
|
wProgramManager/usbdetectdialog.cpp \
|
||||||
|
wProgramManager/usbdiskfuncdialog.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclock.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclockattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclock.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclockattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/egif.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/egifattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovie.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovieattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobject.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobjectattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephoto.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephotoattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etemp.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etempattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etext.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextflipattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextinput.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextscrollattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextstaticattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimer.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimerattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweather.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweatherattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindow.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindowattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/fyxcircleprogress.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/imagecutwidget.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/qffwidget.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/videodec.cpp \
|
||||||
|
wProgramManager/wEditProgram/wattrview.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpageattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpageitem.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpageitemwidget.cpp \
|
||||||
|
wProgramManager/wEditProgram/wplanitem.cpp \
|
||||||
|
wProgramManager/wEditProgram/wplanlist.cpp \
|
||||||
|
wProgramManager/wexportprogramitem.cpp \
|
||||||
|
wProgramManager/wnewprogram.cpp \
|
||||||
|
LoQClass/loqdialog.cpp \
|
||||||
|
LoQClass/loqpushbutton.cpp \
|
||||||
|
wProgramManager/weditprogram.cpp \
|
||||||
|
LoQClass/loqmainwindow.cpp \
|
||||||
|
LoQClass/loqtitlebar.cpp \
|
||||||
|
LoQClass/loqwindowtitlebar.cpp \
|
||||||
|
wProgramManager/wEditProgram/wmaintoolbar.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpagelist.cpp \
|
||||||
|
wProgramManager/wEditProgram/wdrawingboard.cpp \
|
||||||
|
wProgramManager/wprogramitem.cpp \
|
||||||
|
wProgramManager/wprogrampublishitem.cpp \
|
||||||
|
wProgramManagerA/wprogramitema.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
ColorDialog/BasicColorArea.h \
|
||||||
|
ColorDialog/BasicColorItem.h \
|
||||||
|
ColorDialog/ColorDialog.h \
|
||||||
|
ColorDialog/CustomColorArea.h \
|
||||||
|
ColorDialog/HColorArea.h \
|
||||||
|
ColorDialog/PreviewColorArea.h \
|
||||||
|
ColorDialog/SVColorArea.h \
|
||||||
|
LoQClass/extendedgroupbox.h \
|
||||||
|
LoQClass/locolorselector.h \
|
||||||
|
LoQClass/lodateselector.h \
|
||||||
|
LoQClass/loglwindow.h \
|
||||||
|
LoQClass/loqgraphicsobject.h \
|
||||||
|
LoQClass/loqgraphicsvideoitem.h \
|
||||||
|
LoQClass/loqgraphicsview.h \
|
||||||
|
LoQClass/loqheaderviewcheckbox.h \
|
||||||
|
LoQClass/loqlineedit.h \
|
||||||
|
LoQClass/loqmacro.h \
|
||||||
|
LoQClass/loqtreewidget.h \
|
||||||
|
LoQClass/loqvideosurface.h \
|
||||||
|
LoUIClass/aboutdlg.h \
|
||||||
|
LoUIClass/changepasswordform.h \
|
||||||
|
LoUIClass/customprogressindicator.h \
|
||||||
|
LoUIClass/loemptydialog.h \
|
||||||
|
LoUIClass/louimsgboxokcancel.h \
|
||||||
|
LoUIClass/pixbmpshowdialog.h \
|
||||||
|
LoUIClass/qiplineedit.h \
|
||||||
|
LoUIClass/softconfigdialog.h \
|
||||||
|
LoUIClass/switchcontrol.h \
|
||||||
|
LoUIClass/taesclass.h \
|
||||||
|
LoUIClass/updateledset3dialog.h \
|
||||||
|
LoUIClass/updaterdialog.h \
|
||||||
|
LoUIClass/updaterfirmwaredialog.h \
|
||||||
|
LoUIClass/x_checkboxdelegate.h \
|
||||||
|
LoUIClass/x_spinboxdelegate.h \
|
||||||
|
LoUIClass/x_timeeditdelegate.h \
|
||||||
|
LoUIClass/x_uimsgboxok.h \
|
||||||
|
LoUIClass/x_uimsgboxokcancel.h \
|
||||||
|
LoUIClass/x_uimsgboxonlyclosebtn.h \
|
||||||
|
LoUIClass/x_uimsgboxyesnocancel.h \
|
||||||
|
ccrashstack.h \
|
||||||
|
communication/hpptclient.h \
|
||||||
|
communication/network.h \
|
||||||
|
communication/taserialthread.h \
|
||||||
|
globaldefine.h \
|
||||||
|
jsondecoderloop.h \
|
||||||
|
loappconfig.h \
|
||||||
|
loapptools.h \
|
||||||
|
mainwindow.h \
|
||||||
|
mdevicemanager.h \
|
||||||
|
mdevicesetting.h \
|
||||||
|
mguangyingpinwidget.h \
|
||||||
|
mprogrammanagera.h \
|
||||||
|
mtitlebar.h \
|
||||||
|
mtabwidget.h \
|
||||||
|
mprogrammanager.h \
|
||||||
|
publishform.h \
|
||||||
|
tipdialog.h \
|
||||||
|
wDevicesManager/controladvparamwidget.h \
|
||||||
|
wDevicesManager/controlbrightnessautowidget.h \
|
||||||
|
wDevicesManager/controlbrightnessmanualwidget.h \
|
||||||
|
wDevicesManager/controlbrightnessschedule.h \
|
||||||
|
wDevicesManager/controlbrightnessscheduleedit.h \
|
||||||
|
wDevicesManager/controlbrightnesswidget.h \
|
||||||
|
wDevicesManager/controlencryptwidget.h \
|
||||||
|
wDevicesManager/controlhdmimanual.h \
|
||||||
|
wDevicesManager/controlhdmischedule.h \
|
||||||
|
wDevicesManager/controlhdmiwidget.h \
|
||||||
|
wDevicesManager/controlnetconfigwidget.h \
|
||||||
|
wDevicesManager/controlpowermanual.h \
|
||||||
|
wDevicesManager/controlpowerschedule.h \
|
||||||
|
wDevicesManager/controlpowerwidget.h \
|
||||||
|
wDevicesManager/controltestwidget.h \
|
||||||
|
wDevicesManager/controlverifyclockwidget.h \
|
||||||
|
wDevicesManager/controlvolumemanual.h \
|
||||||
|
wDevicesManager/controlvolumeschedule.h \
|
||||||
|
wDevicesManager/controlvolumewidget.h \
|
||||||
|
wDevicesManager/devicescontrollwidget.h \
|
||||||
|
wDevicesManager/inputpassworddialog.h \
|
||||||
|
wDevicesManager/ledcard.h \
|
||||||
|
wDevicesManager/specialdlg.h \
|
||||||
|
wDevicesManager/subspecifyip.h \
|
||||||
|
wDevicesManager/subspecifyiprange.h \
|
||||||
|
wDevicesManager/threadupgradeapk.h \
|
||||||
|
wDevicesManager/upgradeapkdialog.h \
|
||||||
|
wDevicesManager/wdevicesitem.h \
|
||||||
|
wDevicesManager/wupgradeapkitem.h \
|
||||||
|
wProgramManager/mconverter.h \
|
||||||
|
wProgramManager/sendprogramdialog.h \
|
||||||
|
wProgramManager/threadexportprogrampro.h \
|
||||||
|
wProgramManager/threadsendpro.h \
|
||||||
|
wProgramManager/usbdetectdialog.h \
|
||||||
|
wProgramManager/usbdiskfuncdialog.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclock.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclockattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclock.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclockattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/egif.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/egifattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovie.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovieattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobject.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobjectattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephoto.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephotoattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etemp.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etempattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etext.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextflipattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextinput.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextscrollattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextstaticattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimer.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimerattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweather.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweatherattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindow.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindowattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/fyxcircleprogress.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/imagecutwidget.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/qffwidget.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/videodec.h \
|
||||||
|
wProgramManager/wEditProgram/wattrview.h \
|
||||||
|
wProgramManager/wEditProgram/wpageattr.h \
|
||||||
|
wProgramManager/wEditProgram/wpageitem.h \
|
||||||
|
wProgramManager/wEditProgram/wpageitemwidget.h \
|
||||||
|
wProgramManager/wEditProgram/wplanitem.h \
|
||||||
|
wProgramManager/wEditProgram/wplanlist.h \
|
||||||
|
wProgramManager/wexportprogramitem.h \
|
||||||
|
wProgramManager/wnewprogram.h \
|
||||||
|
LoQClass/loqdialog.h \
|
||||||
|
LoQClass/loqpushbutton.h \
|
||||||
|
wProgramManager/weditprogram.h \
|
||||||
|
LoQClass/loqmainwindow.h \
|
||||||
|
LoQClass/loqtitlebar.h \
|
||||||
|
LoQClass/loqwindowtitlebar.h \
|
||||||
|
wProgramManager/wEditProgram/wmaintoolbar.h \
|
||||||
|
wProgramManager/wEditProgram/wpagelist.h \
|
||||||
|
wProgramManager/wEditProgram/wdrawingboard.h \
|
||||||
|
wProgramManager/wprogramitem.h \
|
||||||
|
wProgramManager/wprogrampublishitem.h \
|
||||||
|
wProgramManagerA/wprogramitema.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
ColorDialog/ColorDialog.ui \
|
||||||
|
LoUIClass/aboutdlg.ui \
|
||||||
|
LoUIClass/changepasswordform.ui \
|
||||||
|
LoUIClass/loemptydialog.ui \
|
||||||
|
LoUIClass/louimsgboxokcancel.ui \
|
||||||
|
LoUIClass/pixbmpshowdialog.ui \
|
||||||
|
LoUIClass/softconfigdialog.ui \
|
||||||
|
LoUIClass/updateledset3dialog.ui \
|
||||||
|
LoUIClass/updaterdialog.ui \
|
||||||
|
LoUIClass/updaterfirmwaredialog.ui \
|
||||||
|
LoUIClass/x_uimsgboxok.ui \
|
||||||
|
LoUIClass/x_uimsgboxokcancel.ui \
|
||||||
|
LoUIClass/x_uimsgboxonlyclosebtn.ui \
|
||||||
|
LoUIClass/x_uimsgboxyesnocancel.ui \
|
||||||
|
mainwindow.ui \
|
||||||
|
mdevicemanager.ui \
|
||||||
|
mdevicesetting.ui \
|
||||||
|
mguangyingpinwidget.ui \
|
||||||
|
mprogrammanager.ui \
|
||||||
|
mprogrammanagera.ui \
|
||||||
|
publishform.ui \
|
||||||
|
tipdialog.ui \
|
||||||
|
wDevicesManager/controladvparamwidget.ui \
|
||||||
|
wDevicesManager/controlbrightnessautowidget.ui \
|
||||||
|
wDevicesManager/controlbrightnessmanualwidget.ui \
|
||||||
|
wDevicesManager/controlbrightnessschedule.ui \
|
||||||
|
wDevicesManager/controlbrightnessscheduleedit.ui \
|
||||||
|
wDevicesManager/controlbrightnesswidget.ui \
|
||||||
|
wDevicesManager/controlencryptwidget.ui \
|
||||||
|
wDevicesManager/controlhdmimanual.ui \
|
||||||
|
wDevicesManager/controlhdmischedule.ui \
|
||||||
|
wDevicesManager/controlhdmiwidget.ui \
|
||||||
|
wDevicesManager/controlnetconfigwidget.ui \
|
||||||
|
wDevicesManager/controlpowermanual.ui \
|
||||||
|
wDevicesManager/controlpowerschedule.ui \
|
||||||
|
wDevicesManager/controlpowerwidget.ui \
|
||||||
|
wDevicesManager/controltestwidget.ui \
|
||||||
|
wDevicesManager/controlverifyclockwidget.ui \
|
||||||
|
wDevicesManager/controlvolumemanual.ui \
|
||||||
|
wDevicesManager/controlvolumeschedule.ui \
|
||||||
|
wDevicesManager/controlvolumewidget.ui \
|
||||||
|
wDevicesManager/devicescontrollwidget.ui \
|
||||||
|
wDevicesManager/inputpassworddialog.ui \
|
||||||
|
wDevicesManager/specialdlg.ui \
|
||||||
|
wDevicesManager/subspecifyip.ui \
|
||||||
|
wDevicesManager/subspecifyiprange.ui \
|
||||||
|
wDevicesManager/upgradeapkdialog.ui \
|
||||||
|
wProgramManager/sendprogramdialog.ui \
|
||||||
|
wProgramManager/usbdetectdialog.ui \
|
||||||
|
wProgramManager/usbdiskfuncdialog.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclockattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclockattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/egifattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovieattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobjectattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephotoattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etempattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextflipattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextinput.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextscrollattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextstaticattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimerattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweatherattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindowattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/imagecutwidget.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/qffwidget.ui \
|
||||||
|
wProgramManager/wEditProgram/wattrview.ui \
|
||||||
|
wProgramManager/wEditProgram/wpageattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wpageitemwidget.ui \
|
||||||
|
wProgramManager/wEditProgram/wplanitem.ui \
|
||||||
|
wProgramManager/wnewprogram.ui \
|
||||||
|
wProgramManager/weditprogram.ui
|
||||||
|
|
||||||
|
# Default rules for deployment.
|
||||||
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
qss/MainWnd.css \
|
||||||
|
qss/MainTab.css \
|
||||||
|
qss/TabDeviceManager.css \
|
||||||
|
qss/TabProgramManager.css \
|
||||||
|
qss/TabPMEditProgram.css \
|
||||||
|
res/Logo.ico
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
icons.qrc \
|
||||||
|
images.qrc \
|
||||||
|
languages.qrc \
|
||||||
|
qss.qrc
|
||||||
|
|
||||||
|
TRANSLATIONS += Languages/zhCN.ts Languages/enUS.ts Languages/jaJP.ts Languages/zhTH.ts
|
||||||
|
|
||||||
|
#DEFINES += QT_NO_CAST_FROM_ASCII
|
||||||
|
|
||||||
|
win32:RC_ICONS = res/Logo.ico
|
||||||
|
osx:ICON = res/Logo.icns
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/include
|
||||||
|
win32 {
|
||||||
|
LIBS += -L$$PWD/lib -lquazip
|
||||||
|
}
|
||||||
|
win64 {
|
||||||
|
LIBS += -L$$PWD/lib64 -lquazip
|
||||||
|
}
|
||||||
|
win32 {
|
||||||
|
INCLUDEPATH += $$PWD/ffmpeg-4.2.2-win32-dev/include
|
||||||
|
LIBS += $$PWD/ffmpeg-4.2.2-win32-dev/lib/avformat.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avcodec.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avdevice.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avfilter.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avutil.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/postproc.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/swresample.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/swscale.lib
|
||||||
|
}
|
||||||
|
|
||||||
|
include(./JQLibrary/JQLibrary.pri)
|
||||||
|
include(./QSimpleUpdater/QSimpleUpdater.pri)
|
||||||
|
|
||||||
|
#QMAKE_CXXFLAGS_RELEASE += -g
|
||||||
|
#QMAKE_CFLAGS_RELEASE += -g
|
||||||
|
#QMAKE_LFLAGS_RELEASE = -mthreads -Wl,#其中最后的逗号注意添加,如果不添加可能编译不过
|
||||||
|
##禁止优化
|
||||||
|
#QMAKE_CFLAGS_RELEASE -= -O2
|
||||||
|
#QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||||
|
|
||||||
|
#QMAKE_CXXFLAGS_RELEASE += -g
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#QMAKE_CFLAGS_RELEASE += -g
|
||||||
|
#QMAKE_LFLAGS_RELEASE = -mthreads -W
|
||||||
|
#LIBS += -ldbghelp
|
||||||
|
#QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
|
||||||
|
#QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
|
||||||
|
#QMAKE_LFLAGS_RELEASE += /MAP /DEBUG /opt:ref /INCREMENTAL:NO
|
||||||
|
#QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO /DEBUG
|
||||||
|
#INCLUDEPATH +="G:\Dev\QT\LedOK-master\LedOK-master\ffmpeg\include"
|
||||||
|
#INCLUDEPATH +="G:\Dev\QT\LedOK-master\LedOK-master\sdl\include"
|
||||||
|
|
||||||
|
#LIBS += -Lffmpeg/Lib/ffmpeg/lib -lavutil -lavformat -lavcodec -lavdevice -lavfilter -lpostproc -lswresample -lswscale
|
||||||
|
#LIBS += -LG:\Dev\QT\LedOK-master\LedOK-master\ffmpeg\lib -lavutil -lavformat -lavcodec -lavdevice -lavfilter -lpostproc -lswresample -lswscale
|
||||||
|
#LIBS += -LG:\Dev\QT\LedOK-master\LedOK-master\sdl\lib -lSDL2
|
||||||
|
|
||||||
|
#RC_FILE=main.rc
|
||||||
|
|
||||||
|
|
||||||
|
unix|win32: LIBS += -L$$PWD/wProgramManager/wEditProgram/wElement/mpv/ -llibmpv.dll
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/wProgramManager/wEditProgram/wElement/mpv
|
||||||
|
DEPENDPATH += $$PWD/wProgramManager/wEditProgram/wElement/mpv
|
||||||
|
|
||||||
|
LIBS += -L$$PWD/../ffmpeg/lib/\
|
||||||
|
-lavcodec \
|
||||||
|
-lavdevice \
|
||||||
|
-lavfilter \
|
||||||
|
-lavformat \
|
||||||
|
-lavutil \
|
||||||
|
-lswresample \
|
||||||
|
-lswscale\
|
||||||
|
|
||||||
|
#SDL2
|
||||||
|
LIBS += -L$$PWD/../SDL2/lib/\
|
||||||
|
-lSDL2
|
||||||
|
INCLUDEPATH += $$PWD/../ffmpeg/include \
|
||||||
|
$$PWD/../SDL2/include
|
|
@ -0,0 +1,471 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2019-04-10T23:15:55
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core gui
|
||||||
|
QT += network
|
||||||
|
QT += core network concurrent
|
||||||
|
QT += axcontainer
|
||||||
|
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia multimediawidgets network
|
||||||
|
|
||||||
|
#TARGET = LedOK
|
||||||
|
TARGET = $$quote(Xanadu Express)
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
# The following define makes your compiler emit warnings if you use
|
||||||
|
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||||
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
# deprecated API in order to know how to port your code away from it.
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
# You can also make your code fail to compile if you use deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
CONFIG += c++11
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
LoQClass/extendedgroupbox.cpp \
|
||||||
|
LoQClass/locolorselector.cpp \
|
||||||
|
LoQClass/lodateselector.cpp \
|
||||||
|
LoQClass/loglwindow.cpp \
|
||||||
|
LoQClass/loqgraphicsobject.cpp \
|
||||||
|
LoQClass/loqgraphicsvideoitem.cpp \
|
||||||
|
LoQClass/loqheaderviewcheckbox.cpp \
|
||||||
|
LoQClass/loqlineedit.cpp \
|
||||||
|
LoQClass/loqtreewidget.cpp \
|
||||||
|
LoQClass/loqvideosurface.cpp \
|
||||||
|
LoQClass/qexcel.cpp \
|
||||||
|
LoQClass/readexcel.cpp \
|
||||||
|
LoUIClass/aboutdlg.cpp \
|
||||||
|
LoUIClass/customprogressindicator.cpp \
|
||||||
|
LoUIClass/loemptydialog.cpp \
|
||||||
|
LoUIClass/louimsgboxokcancel.cpp \
|
||||||
|
LoUIClass/qiplineedit.cpp \
|
||||||
|
LoUIClass/switchcontrol.cpp \
|
||||||
|
LoUIClass/x_spinboxdelegate.cpp \
|
||||||
|
LoUIClass/x_timeeditdelegate.cpp \
|
||||||
|
LoUIClass/x_uimsgboxok.cpp \
|
||||||
|
LoUIClass/x_uimsgboxokcancel.cpp \
|
||||||
|
LoUIClass/x_uimsgboxyesnocancel.cpp \
|
||||||
|
backup/mprogrammanager.cpp \
|
||||||
|
communication/hpptclient.cpp \
|
||||||
|
communication/network.cpp \
|
||||||
|
globaldefine.cpp \
|
||||||
|
importbninprogramdlg.cpp \
|
||||||
|
jsondecoderloop.cpp \
|
||||||
|
loappconfig.cpp \
|
||||||
|
loapptools.cpp \
|
||||||
|
main.cpp \
|
||||||
|
mainwindow.cpp \
|
||||||
|
mdevicemanager.cpp \
|
||||||
|
mdevicesetting.cpp \
|
||||||
|
mprogrammanagera.cpp \
|
||||||
|
mtitlebar.cpp \
|
||||||
|
mtabwidget.cpp \
|
||||||
|
mprogrammanager.cpp \
|
||||||
|
publishform.cpp \
|
||||||
|
switchcontrol.cpp \
|
||||||
|
tipdialog.cpp \
|
||||||
|
wDevicesManager/controlbrightnessautowidget.cpp \
|
||||||
|
wDevicesManager/controlbrightnessmanualwidget.cpp \
|
||||||
|
wDevicesManager/controlbrightnessschedule.cpp \
|
||||||
|
wDevicesManager/controlbrightnessscheduleedit.cpp \
|
||||||
|
wDevicesManager/controlbrightnesswidget.cpp \
|
||||||
|
wDevicesManager/controlencryptwidget.cpp \
|
||||||
|
wDevicesManager/controlhdmimanual.cpp \
|
||||||
|
wDevicesManager/controlhdmischedule.cpp \
|
||||||
|
wDevicesManager/controlhdmiwidget.cpp \
|
||||||
|
wDevicesManager/controlnetconfigwidget.cpp \
|
||||||
|
wDevicesManager/controlpowermanual.cpp \
|
||||||
|
wDevicesManager/controlpowerschedule.cpp \
|
||||||
|
wDevicesManager/controlpowerwidget.cpp \
|
||||||
|
wDevicesManager/controlverifyclockwidget.cpp \
|
||||||
|
wDevicesManager/devicescontrollwidget.cpp \
|
||||||
|
wDevicesManager/inputpassworddialog.cpp \
|
||||||
|
wDevicesManager/ledcard.cpp \
|
||||||
|
wDevicesManager/specialdlg.cpp \
|
||||||
|
wDevicesManager/subspecifyip.cpp \
|
||||||
|
wDevicesManager/subspecifyiprange.cpp \
|
||||||
|
wDevicesManager/wdevicesitem.cpp \
|
||||||
|
wProgramManager/mconverter.cpp \
|
||||||
|
wProgramManager/sendprogramdialog.cpp \
|
||||||
|
wProgramManager/threadsendpro.cpp \
|
||||||
|
wProgramManager/usbdiskfuncdialog.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/backup/etext.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclock.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclockattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclock.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclockattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/egif.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/egifattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovie.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovieattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobject.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobjectattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephoto.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephotoattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etemp.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etempattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etext.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextflipattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextinput.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextscrollattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextstaticattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimer.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimerattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweather.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweatherattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindow.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindowattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wElement/fyxcircleprogress.cpp \
|
||||||
|
wProgramManager/wEditProgram/wattrview.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpageattr.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpageitem.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpageitemwidget.cpp \
|
||||||
|
wProgramManager/wEditProgram/wplanitem.cpp \
|
||||||
|
wProgramManager/wEditProgram/wplanlist.cpp \
|
||||||
|
wProgramManager/wnewprogram.cpp \
|
||||||
|
LoQClass/loqdialog.cpp \
|
||||||
|
LoQClass/loqpushbutton.cpp \
|
||||||
|
wProgramManager/weditprogram.cpp \
|
||||||
|
LoQClass/loqmainwindow.cpp \
|
||||||
|
LoQClass/loqtitlebar.cpp \
|
||||||
|
LoQClass/loqwindowtitlebar.cpp \
|
||||||
|
wProgramManager/wEditProgram/wmaintoolbar.cpp \
|
||||||
|
wProgramManager/wEditProgram/wpagelist.cpp \
|
||||||
|
wProgramManager/wEditProgram/wdrawingboard.cpp \
|
||||||
|
wProgramManager/wprogramitem.cpp \
|
||||||
|
wProgramManager/wprogrampublishitem.cpp \
|
||||||
|
wProgramManagerA/wprogramitema.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
LoQClass/extendedgroupbox.h \
|
||||||
|
LoQClass/locolorselector.h \
|
||||||
|
LoQClass/lodateselector.h \
|
||||||
|
LoQClass/loglwindow.h \
|
||||||
|
LoQClass/loqgraphicsobject.h \
|
||||||
|
LoQClass/loqgraphicsvideoitem.h \
|
||||||
|
LoQClass/loqheaderviewcheckbox.h \
|
||||||
|
LoQClass/loqlineedit.h \
|
||||||
|
LoQClass/loqmacro.h \
|
||||||
|
LoQClass/loqtreewidget.h \
|
||||||
|
LoQClass/loqvideosurface.h \
|
||||||
|
LoQClass/qexcel.h \
|
||||||
|
LoQClass/readexcel.h \
|
||||||
|
LoUIClass/aboutdlg.h \
|
||||||
|
LoUIClass/customprogressindicator.h \
|
||||||
|
LoUIClass/loemptydialog.h \
|
||||||
|
LoUIClass/louimsgboxok.h \
|
||||||
|
LoUIClass/louimsgboxokcancel.h \
|
||||||
|
LoUIClass/qiplineedit.h \
|
||||||
|
LoUIClass/switchcontrol.h \
|
||||||
|
LoUIClass/x_spinboxdelegate.h \
|
||||||
|
LoUIClass/x_timeeditdelegate.h \
|
||||||
|
LoUIClass/x_uimsgboxok.h \
|
||||||
|
LoUIClass/x_uimsgboxokcancel.h \
|
||||||
|
LoUIClass/x_uimsgboxyesnocancel.h \
|
||||||
|
backup/mprogrammanager.h \
|
||||||
|
communication/hpptclient - 副本.h \
|
||||||
|
communication/hpptclient.h \
|
||||||
|
communication/network.h \
|
||||||
|
globaldefine.h \
|
||||||
|
importbninprogramdlg.h \
|
||||||
|
include/JlCompress.h \
|
||||||
|
include/ioapi.h \
|
||||||
|
include/minizip_crypt.h \
|
||||||
|
include/quaadler32.h \
|
||||||
|
include/quachecksum32.h \
|
||||||
|
include/quacrc32.h \
|
||||||
|
include/quagzipfile.h \
|
||||||
|
include/quaziodevice.h \
|
||||||
|
include/quazip.h \
|
||||||
|
include/quazip_global.h \
|
||||||
|
include/quazipdir.h \
|
||||||
|
include/quazipfile.h \
|
||||||
|
include/quazipfileinfo.h \
|
||||||
|
include/quazipnewinfo.h \
|
||||||
|
include/unzip.h \
|
||||||
|
include/zconf.h \
|
||||||
|
include/zip.h \
|
||||||
|
include/zlib.h \
|
||||||
|
jsondecoderloop.h \
|
||||||
|
loappconfig.h \
|
||||||
|
loapptools.h \
|
||||||
|
mainwindow.h \
|
||||||
|
mdevicemanager.h \
|
||||||
|
mdevicesetting.h \
|
||||||
|
mprogrammanagera.h \
|
||||||
|
mtitlebar.h \
|
||||||
|
mtabwidget.h \
|
||||||
|
mprogrammanager.h \
|
||||||
|
publishform.h \
|
||||||
|
sdl/include/SDL.h \
|
||||||
|
sdl/include/SDL_assert.h \
|
||||||
|
sdl/include/SDL_atomic.h \
|
||||||
|
sdl/include/SDL_audio.h \
|
||||||
|
sdl/include/SDL_bits.h \
|
||||||
|
sdl/include/SDL_blendmode.h \
|
||||||
|
sdl/include/SDL_clipboard.h \
|
||||||
|
sdl/include/SDL_config.h \
|
||||||
|
sdl/include/SDL_cpuinfo.h \
|
||||||
|
sdl/include/SDL_egl.h \
|
||||||
|
sdl/include/SDL_endian.h \
|
||||||
|
sdl/include/SDL_error.h \
|
||||||
|
sdl/include/SDL_events.h \
|
||||||
|
sdl/include/SDL_filesystem.h \
|
||||||
|
sdl/include/SDL_gamecontroller.h \
|
||||||
|
sdl/include/SDL_gesture.h \
|
||||||
|
sdl/include/SDL_haptic.h \
|
||||||
|
sdl/include/SDL_hints.h \
|
||||||
|
sdl/include/SDL_joystick.h \
|
||||||
|
sdl/include/SDL_keyboard.h \
|
||||||
|
sdl/include/SDL_keycode.h \
|
||||||
|
sdl/include/SDL_loadso.h \
|
||||||
|
sdl/include/SDL_log.h \
|
||||||
|
sdl/include/SDL_main.h \
|
||||||
|
sdl/include/SDL_messagebox.h \
|
||||||
|
sdl/include/SDL_metal.h \
|
||||||
|
sdl/include/SDL_mouse.h \
|
||||||
|
sdl/include/SDL_mutex.h \
|
||||||
|
sdl/include/SDL_name.h \
|
||||||
|
sdl/include/SDL_opengl.h \
|
||||||
|
sdl/include/SDL_opengl_glext.h \
|
||||||
|
sdl/include/SDL_opengles.h \
|
||||||
|
sdl/include/SDL_opengles2.h \
|
||||||
|
sdl/include/SDL_opengles2_gl2.h \
|
||||||
|
sdl/include/SDL_opengles2_gl2ext.h \
|
||||||
|
sdl/include/SDL_opengles2_gl2platform.h \
|
||||||
|
sdl/include/SDL_opengles2_khrplatform.h \
|
||||||
|
sdl/include/SDL_pixels.h \
|
||||||
|
sdl/include/SDL_platform.h \
|
||||||
|
sdl/include/SDL_power.h \
|
||||||
|
sdl/include/SDL_quit.h \
|
||||||
|
sdl/include/SDL_rect.h \
|
||||||
|
sdl/include/SDL_render.h \
|
||||||
|
sdl/include/SDL_revision.h \
|
||||||
|
sdl/include/SDL_rwops.h \
|
||||||
|
sdl/include/SDL_scancode.h \
|
||||||
|
sdl/include/SDL_sensor.h \
|
||||||
|
sdl/include/SDL_shape.h \
|
||||||
|
sdl/include/SDL_stdinc.h \
|
||||||
|
sdl/include/SDL_surface.h \
|
||||||
|
sdl/include/SDL_system.h \
|
||||||
|
sdl/include/SDL_syswm.h \
|
||||||
|
sdl/include/SDL_test.h \
|
||||||
|
sdl/include/SDL_test_assert.h \
|
||||||
|
sdl/include/SDL_test_common.h \
|
||||||
|
sdl/include/SDL_test_compare.h \
|
||||||
|
sdl/include/SDL_test_crc32.h \
|
||||||
|
sdl/include/SDL_test_font.h \
|
||||||
|
sdl/include/SDL_test_fuzzer.h \
|
||||||
|
sdl/include/SDL_test_harness.h \
|
||||||
|
sdl/include/SDL_test_images.h \
|
||||||
|
sdl/include/SDL_test_log.h \
|
||||||
|
sdl/include/SDL_test_md5.h \
|
||||||
|
sdl/include/SDL_test_memory.h \
|
||||||
|
sdl/include/SDL_test_random.h \
|
||||||
|
sdl/include/SDL_thread.h \
|
||||||
|
sdl/include/SDL_timer.h \
|
||||||
|
sdl/include/SDL_touch.h \
|
||||||
|
sdl/include/SDL_types.h \
|
||||||
|
sdl/include/SDL_version.h \
|
||||||
|
sdl/include/SDL_video.h \
|
||||||
|
sdl/include/SDL_vulkan.h \
|
||||||
|
sdl/include/begin_code.h \
|
||||||
|
sdl/include/close_code.h \
|
||||||
|
switchcontrol.h \
|
||||||
|
tipdialog.h \
|
||||||
|
wDevicesManager/controlbrightnessautowidget.h \
|
||||||
|
wDevicesManager/controlbrightnessmanualwidget.h \
|
||||||
|
wDevicesManager/controlbrightnessschedule.h \
|
||||||
|
wDevicesManager/controlbrightnessscheduleedit.h \
|
||||||
|
wDevicesManager/controlbrightnesswidget.h \
|
||||||
|
wDevicesManager/controlencryptwidget.h \
|
||||||
|
wDevicesManager/controlhdmimanual.h \
|
||||||
|
wDevicesManager/controlhdmischedule.h \
|
||||||
|
wDevicesManager/controlhdmiwidget.h \
|
||||||
|
wDevicesManager/controlnetconfigwidget.h \
|
||||||
|
wDevicesManager/controlpowermanual.h \
|
||||||
|
wDevicesManager/controlpowerschedule.h \
|
||||||
|
wDevicesManager/controlpowerwidget.h \
|
||||||
|
wDevicesManager/controlverifyclockwidget.h \
|
||||||
|
wDevicesManager/devicescontrollwidget.h \
|
||||||
|
wDevicesManager/inputpassworddialog.h \
|
||||||
|
wDevicesManager/ledcard.h \
|
||||||
|
wDevicesManager/specialdlg.h \
|
||||||
|
wDevicesManager/subspecifyip.h \
|
||||||
|
wDevicesManager/subspecifyiprange.h \
|
||||||
|
wDevicesManager/wdevicesitem.h \
|
||||||
|
wProgramManager/mconverter.h \
|
||||||
|
wProgramManager/sendprogramdialog.h \
|
||||||
|
wProgramManager/threadsendpro.h \
|
||||||
|
wProgramManager/usbdiskfuncdialog.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/backup/etext.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclock.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclockattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclock.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclockattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/egif.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/egifattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovie.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovieattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobject.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobjectattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephoto.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephotoattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etemp.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etempattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etext.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextflipattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextinput.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextscrollattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextstaticattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimer.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimerattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweather.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweatherattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindow.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindowattr.h \
|
||||||
|
wProgramManager/wEditProgram/wElement/fyxcircleprogress.h \
|
||||||
|
wProgramManager/wEditProgram/wattrview.h \
|
||||||
|
wProgramManager/wEditProgram/wpageattr.h \
|
||||||
|
wProgramManager/wEditProgram/wpageitem.h \
|
||||||
|
wProgramManager/wEditProgram/wpageitemwidget.h \
|
||||||
|
wProgramManager/wEditProgram/wplanitem.h \
|
||||||
|
wProgramManager/wEditProgram/wplanlist.h \
|
||||||
|
wProgramManager/wnewprogram.h \
|
||||||
|
LoQClass/loqdialog.h \
|
||||||
|
LoQClass/loqpushbutton.h \
|
||||||
|
wProgramManager/weditprogram.h \
|
||||||
|
LoQClass/loqmainwindow.h \
|
||||||
|
LoQClass/loqtitlebar.h \
|
||||||
|
LoQClass/loqwindowtitlebar.h \
|
||||||
|
wProgramManager/wEditProgram/wmaintoolbar.h \
|
||||||
|
wProgramManager/wEditProgram/wpagelist.h \
|
||||||
|
wProgramManager/wEditProgram/wdrawingboard.h \
|
||||||
|
wProgramManager/wprogramitem.h \
|
||||||
|
wProgramManager/wprogrampublishitem.h \
|
||||||
|
wProgramManagerA/wprogramitema.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
LoUIClass/aboutdlg.ui \
|
||||||
|
LoUIClass/loemptydialog.ui \
|
||||||
|
LoUIClass/louimsgboxokcancel.ui \
|
||||||
|
LoUIClass/x_uimsgboxok.ui \
|
||||||
|
LoUIClass/x_uimsgboxokcancel.ui \
|
||||||
|
LoUIClass/x_uimsgboxyesnocancel.ui \
|
||||||
|
mainwindow.ui \
|
||||||
|
mdevicemanager.ui \
|
||||||
|
mdevicesetting.ui \
|
||||||
|
mprogrammanager.ui \
|
||||||
|
mprogrammanagera.ui \
|
||||||
|
publishform.ui \
|
||||||
|
tipdialog.ui \
|
||||||
|
wDevicesManager/controlbrightnessautowidget.ui \
|
||||||
|
wDevicesManager/controlbrightnessmanualwidget.ui \
|
||||||
|
wDevicesManager/controlbrightnessschedule.ui \
|
||||||
|
wDevicesManager/controlbrightnessscheduleedit.ui \
|
||||||
|
wDevicesManager/controlbrightnesswidget.ui \
|
||||||
|
wDevicesManager/controlencryptwidget.ui \
|
||||||
|
wDevicesManager/controlhdmimanual.ui \
|
||||||
|
wDevicesManager/controlhdmischedule.ui \
|
||||||
|
wDevicesManager/controlhdmiwidget.ui \
|
||||||
|
wDevicesManager/controlnetconfigwidget.ui \
|
||||||
|
wDevicesManager/controlpowermanual.ui \
|
||||||
|
wDevicesManager/controlpowerschedule.ui \
|
||||||
|
wDevicesManager/controlpowerwidget.ui \
|
||||||
|
wDevicesManager/controlverifyclockwidget.ui \
|
||||||
|
wDevicesManager/devicescontrollwidget.ui \
|
||||||
|
wDevicesManager/inputpassworddialog.ui \
|
||||||
|
wDevicesManager/specialdlg.ui \
|
||||||
|
wDevicesManager/subspecifyip.ui \
|
||||||
|
wDevicesManager/subspecifyiprange.ui \
|
||||||
|
wProgramManager/sendprogramdialog.ui \
|
||||||
|
wProgramManager/usbdiskfuncdialog.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/eaclockattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/edclockattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/egifattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/emovieattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/eobjectattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/ephotoattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etempattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextflipattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextinput.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextscrollattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etextstaticattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/etimerattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/eweatherattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wElement/ewindowattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wattrview.ui \
|
||||||
|
wProgramManager/wEditProgram/wpageattr.ui \
|
||||||
|
wProgramManager/wEditProgram/wpageitemwidget.ui \
|
||||||
|
wProgramManager/wEditProgram/wplanitem.ui \
|
||||||
|
wProgramManager/wnewprogram.ui \
|
||||||
|
wProgramManager/weditprogram.ui
|
||||||
|
|
||||||
|
# Default rules for deployment.
|
||||||
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
qss/MainWnd.css \
|
||||||
|
qss/MainTab.css \
|
||||||
|
qss/TabDeviceManager.css \
|
||||||
|
qss/TabProgramManager.css \
|
||||||
|
qss/TabPMEditProgram.css \
|
||||||
|
res/Logo.ico
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
icons.qrc \
|
||||||
|
images.qrc \
|
||||||
|
languages.qrc \
|
||||||
|
qss.qrc
|
||||||
|
|
||||||
|
TRANSLATIONS += Languages/zhCN.ts Languages/enUS.ts Languages/jaJP.ts
|
||||||
|
|
||||||
|
#DEFINES += QT_NO_CAST_FROM_ASCII
|
||||||
|
win32:RC_ICONS = res/Logo.ico
|
||||||
|
osx:ICON = res/Logo.icns
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/include
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
LIBS += -L$$PWD/lib -lquazipd
|
||||||
|
} else {
|
||||||
|
LIBS += -L$$PWD/lib -lquazip
|
||||||
|
}
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
INCLUDEPATH += $$PWD/ffmpeg-4.2.2-win32-dev/include
|
||||||
|
LIBS += $$PWD/ffmpeg-4.2.2-win32-dev/lib/avformat.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avcodec.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avdevice.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avfilter.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/avutil.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/postproc.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/swresample.lib \
|
||||||
|
$$PWD/ffmpeg-4.2.2-win32-dev/lib/swscale.lib
|
||||||
|
}
|
||||||
|
|
||||||
|
include(./JQLibrary/JQLibrary.pri)
|
||||||
|
|
||||||
|
#INCLUDEPATH +="G:\Dev\QT\LedOK-master\LedOK-master\ffmpeg\include"
|
||||||
|
#INCLUDEPATH +="G:\Dev\QT\LedOK-master\LedOK-master\sdl\include"
|
||||||
|
|
||||||
|
#LIBS += -Lffmpeg/Lib/ffmpeg/lib -lavutil -lavformat -lavcodec -lavdevice -lavfilter -lpostproc -lswresample -lswscale
|
||||||
|
#LIBS += -LG:\Dev\QT\LedOK-master\LedOK-master\ffmpeg\lib -lavutil -lavformat -lavcodec -lavdevice -lavfilter -lpostproc -lswresample -lswscale
|
||||||
|
#LIBS += -LG:\Dev\QT\LedOK-master\LedOK-master\sdl\lib -lSDL2
|
||||||
|
|
||||||
|
SUBDIRS += \
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include "extendedgroupbox.h"
|
||||||
|
ExtendedGroupBox::ExtendedGroupBox(QWidget *parent /*= nullptr*/, State state /*= STATE_NORMAL*/)
|
||||||
|
: QGroupBox(parent)
|
||||||
|
{
|
||||||
|
setObjectName("ExtendedGroupBox");
|
||||||
|
setCheckable(true);
|
||||||
|
state_ = state;
|
||||||
|
if (state_ == STATE_NORMAL)
|
||||||
|
{
|
||||||
|
//隐藏垂直边框
|
||||||
|
setFlat(true);
|
||||||
|
}
|
||||||
|
connect(this, SIGNAL(clicked(bool)), this, SLOT(onChecked(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtendedGroupBox::ExtendedGroupBox(const QString &title, QWidget *parent /*= nullptr*/, State state /*= STATE_NORMAL*/)
|
||||||
|
: QGroupBox(title, parent)
|
||||||
|
{
|
||||||
|
setObjectName("ExtendedGroupBox");
|
||||||
|
setCheckable(true);
|
||||||
|
state_ = state;
|
||||||
|
if (state_ == STATE_NORMAL)
|
||||||
|
{
|
||||||
|
//隐藏垂直边框
|
||||||
|
setFlat(true);
|
||||||
|
}
|
||||||
|
// this->toggled();
|
||||||
|
|
||||||
|
connect(this, SIGNAL(toggled(bool)), this, SLOT(onChecked(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtendedGroupBox::onChecked(bool checked)
|
||||||
|
{
|
||||||
|
if (checked)
|
||||||
|
{
|
||||||
|
//显示垂直边框
|
||||||
|
QList<QWidget *> widgets = findChildren<QWidget *>();
|
||||||
|
for (auto iter = widgets.begin(); iter != widgets.end(); ++iter)
|
||||||
|
{
|
||||||
|
(*iter)->setVisible(true);
|
||||||
|
}
|
||||||
|
state_ = STATE_EXPAND;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//隐藏垂直边框
|
||||||
|
QList<QWidget *> widgets = findChildren<QWidget *>();
|
||||||
|
for (auto iter = widgets.begin(); iter != widgets.end(); ++iter)
|
||||||
|
(*iter)->setVisible(false);
|
||||||
|
// QList<QLayout *> layouts = findChildren<QLayout *>();
|
||||||
|
// for (auto iter1 = layouts.begin(); iter1 != layouts.end(); ++iter1)
|
||||||
|
// (*iter1)->setVisible(false);
|
||||||
|
|
||||||
|
// QLayout aa;
|
||||||
|
// a->
|
||||||
|
state_ = STATE_NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtendedGroupBox::State ExtendedGroupBox::getState() const
|
||||||
|
{
|
||||||
|
return state_;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef EXTENDEDGROUPBOX_H
|
||||||
|
#define EXTENDEDGROUPBOX_H
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
class ExtendedGroupBox : public QGroupBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum State
|
||||||
|
{
|
||||||
|
STATE_NORMAL,
|
||||||
|
STATE_EXPAND
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
ExtendedGroupBox(QWidget *parent = nullptr, State state = STATE_NORMAL);
|
||||||
|
ExtendedGroupBox(const QString &title, QWidget *parent = nullptr, State state = STATE_NORMAL);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onChecked(bool checked);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void addWidget(QWidget *widget);
|
||||||
|
State getState() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
State state_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EXTENDEDGROUPBOX_H
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include "locolorselector.h"
|
||||||
|
#include "./ColorDialog/ColorDialog.h"
|
||||||
|
LoColorSelector::LoColorSelector(QWidget *parent) :
|
||||||
|
QPushButton(parent),
|
||||||
|
m_text(""),
|
||||||
|
m_color(Qt::transparent)
|
||||||
|
{ init(); }
|
||||||
|
|
||||||
|
LoColorSelector::LoColorSelector(const QString &text, const QColor &color, QWidget *parent):
|
||||||
|
QPushButton(parent),
|
||||||
|
m_text(text),
|
||||||
|
m_color(color)
|
||||||
|
{ init(); }
|
||||||
|
|
||||||
|
void LoColorSelector::init()
|
||||||
|
{
|
||||||
|
setText(m_text);
|
||||||
|
setColor(m_color);
|
||||||
|
connect(this, SIGNAL(clicked()), this, SLOT(onColorChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoColorSelector::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
QFont ft = font();
|
||||||
|
QString sColor;
|
||||||
|
if(color.alpha() == 0) {
|
||||||
|
ft.setStrikeOut(true);
|
||||||
|
} else {
|
||||||
|
ft.setStrikeOut(false);
|
||||||
|
}
|
||||||
|
sColor = QString("background-color: rgba(%1, %2, %3, %4);color: rgba(%5, %6, %7, %8);").
|
||||||
|
arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()).arg(255-color.red()).arg(255-color.green()).arg(255-color.blue()).arg(255);
|
||||||
|
setStyleSheet(sColor);
|
||||||
|
// QString strFontColor;
|
||||||
|
// strFontColor = QString("color: rgba(%1, %2, %3, %4);").
|
||||||
|
// arg(255-color.red()).arg(255-color.green()).arg(255-color.blue()).arg(255);
|
||||||
|
// setStyleSheet(strFontColor);
|
||||||
|
|
||||||
|
setFont(ft);
|
||||||
|
m_color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoColorSelector::onColorChanged()
|
||||||
|
{
|
||||||
|
bool bAlpha=true;
|
||||||
|
// if(this->text()=="T")
|
||||||
|
// bAlpha=false;
|
||||||
|
ColorDialog *m_pColorDlg = new ColorDialog(m_color,bAlpha,this);
|
||||||
|
connect(m_pColorDlg, SIGNAL(accepted()), this, SLOT(onAccepted()));
|
||||||
|
m_pColorDlg->showDialog();
|
||||||
|
if(m_pColorDlg->m_buttonRole==m_pColorDlg->Yes)
|
||||||
|
{
|
||||||
|
QColor color=m_pColorDlg->getRgba();
|
||||||
|
// m_color.setAlpha(255);
|
||||||
|
// QColor color = ColorDialog::getColor();//::getColor(m_color, nullptr, tr("Select Color"), QColorDialog::ShowAlphaChannel);
|
||||||
|
if(color.isValid()) {
|
||||||
|
setColor(color);
|
||||||
|
|
||||||
|
emit sColorChanged(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef LOCOLORSELECTOR_H
|
||||||
|
#define LOCOLORSELECTOR_H
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QPushButton>
|
||||||
|
class LoColorSelector : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoColorSelector(QWidget *parent = nullptr);
|
||||||
|
explicit LoColorSelector(const QString &text, const QColor &color, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
QColor color() const { return m_color; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sColorChanged(const QColor &);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void onColorChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_text;
|
||||||
|
QColor m_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOCOLORSELECTOR_H
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include "lodateselector.h"
|
||||||
|
#include "LoUIClass/x_uimsgboxonlyclosebtn.h"
|
||||||
|
LoDateSelector::LoDateSelector(QWidget *parent) :
|
||||||
|
QPushButton(parent)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoDateSelector::onClicked(bool)
|
||||||
|
{
|
||||||
|
|
||||||
|
// LoQDialog *w = new LoQDialog(this);
|
||||||
|
// QCalendarWidget *wDate = new QCalendarWidget();
|
||||||
|
// QVBoxLayout *layout = new QVBoxLayout();
|
||||||
|
// layout->addWidget(wDate, 1);
|
||||||
|
// connect(wDate, SIGNAL(clicked(const QDate &)), w, SLOT(accept()));
|
||||||
|
// connect(wDate, SIGNAL(clicked(const QDate &)), this, SIGNAL(sDateSelected(const QDate &)));
|
||||||
|
// w->setLayout(layout);
|
||||||
|
// w->exec();
|
||||||
|
x_uiMsgBoxOnlyCloseBtn *w = new x_uiMsgBoxOnlyCloseBtn(tr("Date selector"),this);
|
||||||
|
QCalendarWidget *wDate = new QCalendarWidget();
|
||||||
|
connect(wDate, SIGNAL(clicked(const QDate &)), w, SLOT(accept()));
|
||||||
|
connect(wDate, SIGNAL(clicked(const QDate &)), this, SIGNAL(sDateSelected(const QDate &)));
|
||||||
|
w->InSertDateSelector(wDate);
|
||||||
|
w->exec();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef LODATESELECTOR_H
|
||||||
|
#define LODATESELECTOR_H
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QCalendarWidget>
|
||||||
|
#include <LoQClass/loqdialog.h>
|
||||||
|
|
||||||
|
class LoDateSelector : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoDateSelector(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sDateSelected(const QDate &);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onClicked(bool);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LODATESELECTOR_H
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include "loglwindow.h"
|
||||||
|
|
||||||
|
LoGLWindow::LoGLWindow(QScreen *screen)
|
||||||
|
: QWindow(screen)
|
||||||
|
{
|
||||||
|
setSurfaceType(OpenGLSurface);
|
||||||
|
create();
|
||||||
|
// Create an OpenGL context
|
||||||
|
m_context = new QOpenGLContext;
|
||||||
|
m_context->create();
|
||||||
|
// Setup scene and render it
|
||||||
|
m_context->makeCurrent(this);
|
||||||
|
initializeOpenGLFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LoGLWindow::vendor() { return QString(reinterpret_cast<const char *>(glGetString(GL_VENDOR))); }
|
||||||
|
QString LoGLWindow::renderer() { return QString(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); }
|
||||||
|
QString LoGLWindow::version() { return QString(reinterpret_cast<const char *>(glGetString(GL_VERSION))); }
|
||||||
|
QString LoGLWindow::extensions() { return QString(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))); }
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef LOGLWINDOW_H
|
||||||
|
#define LOGLWINDOW_H
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QWindow>
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
#include <QOpenGLFunctions>
|
||||||
|
|
||||||
|
class LoGLWindow : public QWindow, protected QOpenGLFunctions
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
LoGLWindow(QScreen *screen = nullptr);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString vendor();
|
||||||
|
QString renderer();
|
||||||
|
QString version();
|
||||||
|
QString extensions();
|
||||||
|
|
||||||
|
public:
|
||||||
|
QOpenGLContext *context() { return m_context; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QOpenGLContext *m_context;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGLWINDOW_H
|
|
@ -0,0 +1,65 @@
|
||||||
|
#include "loqdialog.h"
|
||||||
|
|
||||||
|
LoQDialog::LoQDialog(QWidget *parent) : QDialog(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
setWindowFlags(windowFlags() &
|
||||||
|
~Qt::WindowContextHelpButtonHint |
|
||||||
|
Qt::Dialog|Qt::FramelessWindowHint
|
||||||
|
//|Qt::Tool
|
||||||
|
);
|
||||||
|
setWindowModality(Qt::WindowModal);
|
||||||
|
|
||||||
|
// setWindowFlags(windowFlags() &
|
||||||
|
// ~Qt::WindowContextHelpButtonHint |
|
||||||
|
// Qt::FramelessWindowHint |
|
||||||
|
// Qt::Tool);
|
||||||
|
// setWindowFlags(windowFlags() &
|
||||||
|
// ~Qt::WindowContextHelpButtonHint |
|
||||||
|
// Qt::FramelessWindowHint |
|
||||||
|
// Qt::Tool);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQDialog::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
QRect gRect = this->geometry();
|
||||||
|
gRect.setWidth(gRect.width() - 10);
|
||||||
|
gRect.setHeight(gRect.height() - 10);
|
||||||
|
gRect.setX(gRect.x() + 5);
|
||||||
|
gRect.setY(gRect.y() + 5);
|
||||||
|
|
||||||
|
if(gRect.contains(event->globalPos())) {
|
||||||
|
m_winMove = true;
|
||||||
|
m_winOrgPoint = event->globalPos();
|
||||||
|
m_winWorldPoint = this->frameGeometry().topLeft();
|
||||||
|
} else {
|
||||||
|
// Resize the window
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQDialog::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
//return;
|
||||||
|
if(m_winMove) {
|
||||||
|
if (event->buttons() & Qt::LeftButton) {
|
||||||
|
QPoint relativePos = event->globalPos() - m_winOrgPoint;
|
||||||
|
this->move(m_winWorldPoint + relativePos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQDialog::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
m_winMove = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void LoQDialog::showEvent(QShowEvent *event) {
|
||||||
|
this->setAttribute(Qt::WA_Mapped);
|
||||||
|
QWidget::showEvent(event);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef LOQDIALOG_H
|
||||||
|
#define LOQDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
class LoQDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQDialog(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_winMove=false;
|
||||||
|
QPoint m_winOrgPoint;
|
||||||
|
QPoint m_winWorldPoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQDIALOG_H
|
|
@ -0,0 +1,578 @@
|
||||||
|
#include "loqgraphicsobject.h"
|
||||||
|
#include "QCoreApplication"
|
||||||
|
LoQGraphicsObject::LoQGraphicsObject(InteractiveType type, QGraphicsItem *parent) :
|
||||||
|
QGraphicsObject(parent),
|
||||||
|
m_interactiveType(type),
|
||||||
|
m_movable(false),
|
||||||
|
m_handleLen(10),
|
||||||
|
m_rLimit(INVALID_RECT)
|
||||||
|
{
|
||||||
|
setGeometry(0, 0, 100, 100);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
LoQGraphicsObject::LoQGraphicsObject(QRectF rect, InteractiveType type, QGraphicsItem *parent) :
|
||||||
|
QGraphicsObject(parent),
|
||||||
|
m_interactiveType(type),
|
||||||
|
m_movable(false),
|
||||||
|
m_handleLen(10),
|
||||||
|
m_rLimit(INVALID_RECT)
|
||||||
|
{
|
||||||
|
setGeometry(rect);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
LoQGraphicsObject::LoQGraphicsObject(qreal x, qreal y, qreal w, qreal h, InteractiveType type, QGraphicsItem *parent) :
|
||||||
|
QGraphicsObject(parent),
|
||||||
|
m_interactiveType(type),
|
||||||
|
m_movable(false),
|
||||||
|
m_handleLen(10),
|
||||||
|
m_rLimit(INVALID_RECT)
|
||||||
|
{
|
||||||
|
setGeometry(x, y, w, h);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::setInteractiveType(InteractiveType type)
|
||||||
|
{
|
||||||
|
m_interactiveType = type;
|
||||||
|
GraphicsItemFlags flag = flags();
|
||||||
|
if(Dynamic == m_interactiveType) {
|
||||||
|
flag |= ItemIsMovable;
|
||||||
|
flag |= ItemIsSelectable;
|
||||||
|
flag &= ~ItemIsFocusable;
|
||||||
|
} else {
|
||||||
|
flag &= ~ItemIsMovable;
|
||||||
|
flag &= ~ItemIsSelectable;
|
||||||
|
flag &= ~ItemIsFocusable;
|
||||||
|
}
|
||||||
|
setFlags(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::init()
|
||||||
|
{
|
||||||
|
setInteractiveType(m_interactiveType);
|
||||||
|
|
||||||
|
m_handlePen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||||
|
m_handlePen.setWidth(1);
|
||||||
|
|
||||||
|
QVector<qreal> dashes;
|
||||||
|
qreal space = 2;
|
||||||
|
qreal solid = 2;
|
||||||
|
dashes << solid << space << solid <<space;
|
||||||
|
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||||
|
m_borderPen.setDashPattern(dashes);
|
||||||
|
m_borderPen.setWidth(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF LoQGraphicsObject::boundingRect() const
|
||||||
|
{
|
||||||
|
qreal x, y, w, h;
|
||||||
|
QRectF r = rect();
|
||||||
|
x = r.x() - m_handleLen;
|
||||||
|
y = r.y() - m_handleLen;
|
||||||
|
w = r.width() + m_handleLen * 2;
|
||||||
|
h = r.height() + m_handleLen * 2;
|
||||||
|
return QRectF(x, y, w, h);
|
||||||
|
}
|
||||||
|
//绘制选中和未选中的区域边框
|
||||||
|
void LoQGraphicsObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
painter->save();
|
||||||
|
//绘制边框
|
||||||
|
QPen pen; // creates a default pen
|
||||||
|
|
||||||
|
// pen.setStyle(Qt::DashDotLine);
|
||||||
|
// QLinearGradient svGradient(0, 0, 2, 0);
|
||||||
|
// svGradient.setColorAt(1, QColor("#00ff00"));
|
||||||
|
// svGradient.setColorAt(0, QColor("#ffffff"));
|
||||||
|
// QBrush myBrush(svGradient);
|
||||||
|
|
||||||
|
QString qexeFullPath = QCoreApplication::applicationDirPath();
|
||||||
|
QString qtBordImage=qexeFullPath+"/m/"+"M8_8.bmp";
|
||||||
|
QPixmap aa(qtBordImage);
|
||||||
|
int iBordWidth=aa.height();
|
||||||
|
pen.setWidth(iBordWidth);
|
||||||
|
QBrush myBrush(aa);
|
||||||
|
//myBrush.setTexture(aa);
|
||||||
|
pen.setBrush(myBrush);
|
||||||
|
pen.setCapStyle(Qt::RoundCap);
|
||||||
|
pen.setJoinStyle(Qt::RoundJoin);
|
||||||
|
|
||||||
|
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
|
path.moveTo(iBordWidth/2,iBordWidth/2);
|
||||||
|
path.lineTo(rect().right()-iBordWidth/2,iBordWidth/2);
|
||||||
|
path.lineTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||||
|
path.lineTo(iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||||
|
path.lineTo(iBordWidth/2,iBordWidth/2);
|
||||||
|
painter->setPen(pen);
|
||||||
|
painter->drawPath(path);
|
||||||
|
|
||||||
|
QMatrix matrix2;
|
||||||
|
matrix2.rotate(90);
|
||||||
|
QBrush myBrush2;
|
||||||
|
QPixmap bb=aa.transformed(matrix2, Qt::SmoothTransformation);
|
||||||
|
myBrush2.setTexture(bb);
|
||||||
|
QPen pen2;
|
||||||
|
pen2.setBrush(myBrush2);
|
||||||
|
QPainterPath path2;
|
||||||
|
path2.moveTo(rect().right()-iBordWidth/2,iBordWidth/2);
|
||||||
|
path2.lineTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||||
|
painter->setPen(pen2);
|
||||||
|
painter->drawPath(path2);
|
||||||
|
|
||||||
|
//QMatrix matrix3;
|
||||||
|
//matrix3.rotate(0);
|
||||||
|
// QBrush myBrush3;
|
||||||
|
// QPainterPath path3;
|
||||||
|
//// myBrush3.setTexture(aa);
|
||||||
|
//// pen.setBrush(myBrush);
|
||||||
|
//// painter->setPen(pen);
|
||||||
|
// path3.moveTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||||
|
// path3.lineTo(iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||||
|
// painter->drawPath(path3);
|
||||||
|
|
||||||
|
// QMatrix matrix4;
|
||||||
|
// matrix4.rotate(270);
|
||||||
|
// QBrush myBrush4;
|
||||||
|
// QPainterPath path4;
|
||||||
|
// myBrush4.setTexture(aa.transformed(matrix4, Qt::SmoothTransformation));
|
||||||
|
// pen.setBrush(myBrush4);
|
||||||
|
// path4.moveTo(iBordWidth/2,rect().bottom()-iBordWidth/2);
|
||||||
|
// path4.lineTo(iBordWidth/2,iBordWidth/2);
|
||||||
|
// painter->drawPath(path4);
|
||||||
|
|
||||||
|
if(isSelected()) {
|
||||||
|
QPainterPath pRect;
|
||||||
|
pRect.addRect(rect());
|
||||||
|
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0)));
|
||||||
|
painter->setPen(m_borderPen);
|
||||||
|
painter->drawPath(pRect);
|
||||||
|
QPainterPath pHandle;
|
||||||
|
pHandle.addRect(m_rLT);
|
||||||
|
pHandle.addRect(m_rT);
|
||||||
|
pHandle.addRect(m_rRT);
|
||||||
|
pHandle.addRect(m_rL);
|
||||||
|
pHandle.addRect(m_rR);
|
||||||
|
pHandle.addRect(m_rLB);
|
||||||
|
pHandle.addRect(m_rB);
|
||||||
|
pHandle.addRect(m_rRB);
|
||||||
|
painter->setPen(m_handlePen);
|
||||||
|
painter->drawPath(pHandle);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 125, 0)));
|
||||||
|
|
||||||
|
QPainterPath pRect;
|
||||||
|
pRect.addRect(rect());
|
||||||
|
painter->setPen(m_borderPen);
|
||||||
|
painter->drawPath(pRect);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//磁条吸附时两化吸附的边
|
||||||
|
QPen CitiePen=QPen(QColor::fromRgb(0, 255, 0),1,Qt::SolidLine);
|
||||||
|
painter->setPen(CitiePen);
|
||||||
|
//if(bMousePress)
|
||||||
|
{
|
||||||
|
if (bLeftCitie) {
|
||||||
|
painter->setPen(CitiePen);
|
||||||
|
//painter->drawLine(QPointF(rect().x(),rect().y()-100),QPointF(rect().x(),rect().bottom()+100));
|
||||||
|
painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().bottomLeft()));
|
||||||
|
}
|
||||||
|
if (bTopCitie) {
|
||||||
|
painter->setPen(CitiePen);
|
||||||
|
painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().topRight()));
|
||||||
|
}
|
||||||
|
if (bRightCitie) {
|
||||||
|
painter->setPen(CitiePen);
|
||||||
|
painter->drawLine(QPointF(rect().topRight()),QPointF(rect().bottomRight()));
|
||||||
|
}
|
||||||
|
if (bBottomCitie) {
|
||||||
|
painter->setPen(CitiePen);
|
||||||
|
painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// QPen(const QBrush &brush,
|
||||||
|
// qreal width,
|
||||||
|
// Qt::PenStyle style = Qt::SolidLine,
|
||||||
|
// Qt::PenCapStyle cap = Qt::SquareCap,
|
||||||
|
// Qt::PenJoinStyle join = Qt::BevelJoin);
|
||||||
|
// QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
|
||||||
|
|
||||||
|
|
||||||
|
//painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight()));
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
void LoQGraphicsObject::setBrightBianLeft(bool b)
|
||||||
|
{
|
||||||
|
//if(bMousePress)
|
||||||
|
// {
|
||||||
|
// bLeftCitie=b;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// bLeftCitie=false;
|
||||||
|
// }
|
||||||
|
bLeftCitie=b;
|
||||||
|
updateGeometry();
|
||||||
|
|
||||||
|
}
|
||||||
|
void LoQGraphicsObject::setBrightBianRight(bool b)
|
||||||
|
{
|
||||||
|
// if(bMousePress)
|
||||||
|
// {
|
||||||
|
// bRightCitie=b;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// bRightCitie=false;
|
||||||
|
// }
|
||||||
|
bRightCitie=b;
|
||||||
|
updateGeometry();
|
||||||
|
|
||||||
|
}
|
||||||
|
void LoQGraphicsObject::setBrightBianTop(bool b)
|
||||||
|
{
|
||||||
|
// if(bMousePress)
|
||||||
|
// {
|
||||||
|
// bTopCitie=b;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// bTopCitie=false;
|
||||||
|
// }
|
||||||
|
bTopCitie=b;
|
||||||
|
updateGeometry();
|
||||||
|
|
||||||
|
}
|
||||||
|
void LoQGraphicsObject::setBrightBianbottom(bool b)
|
||||||
|
{
|
||||||
|
// if(bMousePress)
|
||||||
|
// {
|
||||||
|
// bBottomCitie=b;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// bBottomCitie=false;
|
||||||
|
// }
|
||||||
|
bBottomCitie=b;
|
||||||
|
updateGeometry();
|
||||||
|
|
||||||
|
}
|
||||||
|
void LoQGraphicsObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// return;
|
||||||
|
if(false == m_movable) return;
|
||||||
|
|
||||||
|
qreal cx, cy, cw, ch;
|
||||||
|
qreal mx, my, mw, mh;
|
||||||
|
QPointF ePos = pointToParent(event->pos());
|
||||||
|
QPointF absoluteOfs = ePos - m_pOrg;
|
||||||
|
|
||||||
|
mx = m_rOrg.x();
|
||||||
|
my = m_rOrg.y();
|
||||||
|
mw = m_w;
|
||||||
|
mh = m_h;
|
||||||
|
|
||||||
|
if(m_hDir != NONE) {
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
switch(m_hDir) {
|
||||||
|
case LT:
|
||||||
|
cx = m_rOrg.x() + absoluteOfs.x();
|
||||||
|
cy = m_rOrg.y() + absoluteOfs.y();
|
||||||
|
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||||
|
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||||
|
mx = cx;
|
||||||
|
my = cy;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(mx < 0) mx = 0;
|
||||||
|
if(my < 0) my = 0;
|
||||||
|
}
|
||||||
|
mw = m_rOrg.right() - mx;
|
||||||
|
mh = m_rOrg.bottom() - my;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T:
|
||||||
|
cy = m_rOrg.y() + absoluteOfs.y();
|
||||||
|
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||||
|
my = cy;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(my < 0) my = 0;
|
||||||
|
}
|
||||||
|
mh = m_rOrg.bottom() - my;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RT:
|
||||||
|
cy = m_rOrg.y() + absoluteOfs.y();
|
||||||
|
cw = m_rOrg.width() + absoluteOfs.x();
|
||||||
|
if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen;
|
||||||
|
if(cw < m_handleLen) cw = m_handleLen;
|
||||||
|
my = cy;
|
||||||
|
mw = cw;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(my < 0) my = 0;
|
||||||
|
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||||
|
}
|
||||||
|
mh = m_rOrg.bottom() - my;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case L:
|
||||||
|
cx = m_rOrg.x() + absoluteOfs.x();
|
||||||
|
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||||
|
mx = cx;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(mx < 0) mx = 0;
|
||||||
|
}
|
||||||
|
mw = m_rOrg.right() - mx;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R:
|
||||||
|
cw = m_rOrg.width() + absoluteOfs.x();
|
||||||
|
if(cw < m_handleLen) cw = m_handleLen;
|
||||||
|
mw = cw;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LB:
|
||||||
|
cx = m_rOrg.x() + absoluteOfs.x();
|
||||||
|
ch = m_rOrg.height() + absoluteOfs.y();
|
||||||
|
if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen;
|
||||||
|
if(ch < m_handleLen) ch = m_handleLen;
|
||||||
|
mx = cx;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(mx < 0) mx = 0;
|
||||||
|
}
|
||||||
|
mw = m_rOrg.right() - mx;
|
||||||
|
mh = ch;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B:
|
||||||
|
ch = m_rOrg.height() + absoluteOfs.y();
|
||||||
|
if(ch < m_handleLen) ch = m_handleLen;
|
||||||
|
mh = ch;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RB:
|
||||||
|
cw = m_rOrg.width() + absoluteOfs.x();
|
||||||
|
ch = m_rOrg.height() + absoluteOfs.y();
|
||||||
|
if(cw < m_handleLen) cw = m_handleLen;
|
||||||
|
if(ch < m_handleLen) ch = m_handleLen;
|
||||||
|
mw = cw;
|
||||||
|
mh = ch;
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx;
|
||||||
|
if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPos(mx, my);
|
||||||
|
m_w = mw;
|
||||||
|
m_h = mh;
|
||||||
|
adjustHandle();
|
||||||
|
updateGeometry(m_rOrg);
|
||||||
|
rectChanged(rect());
|
||||||
|
} else {
|
||||||
|
mx = m_rOrg.x() + absoluteOfs.x();
|
||||||
|
my = m_rOrg.y() + absoluteOfs.y();
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
if(mx < 0) mx = 0;
|
||||||
|
if(my < 0) my = 0;
|
||||||
|
if(mx + mw > m_rLimit.width()) mx = m_rLimit.width() - mw;
|
||||||
|
if(my + mh > m_rLimit.height()) my = m_rLimit.height() - mh;
|
||||||
|
}
|
||||||
|
setPos(mx, my);
|
||||||
|
}
|
||||||
|
|
||||||
|
geometryChanged(geometry());
|
||||||
|
if(bMousePress)
|
||||||
|
{
|
||||||
|
|
||||||
|
emit sigCiTie(true,m_hDir);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::setRLimit(const QRectF &r)
|
||||||
|
{
|
||||||
|
if(m_rLimit != INVALID_RECT) {
|
||||||
|
qreal mx, my, mw, mh;
|
||||||
|
qreal scale_w = r.width() / m_rLimit.width();
|
||||||
|
qreal scale_h = r.height() / m_rLimit.height();
|
||||||
|
mx = std::round(x() * scale_w);
|
||||||
|
my = std::round(y() * scale_h);
|
||||||
|
mw = std::round(m_w * scale_w);
|
||||||
|
mh = std::round(m_h * scale_h);
|
||||||
|
setPos(mx, my);
|
||||||
|
m_w = mw;
|
||||||
|
m_h = mh;
|
||||||
|
adjustHandle();
|
||||||
|
geometryChanged(geometry());
|
||||||
|
}
|
||||||
|
m_rLimit = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(Qt::LeftButton == event->button()) {
|
||||||
|
|
||||||
|
m_hDir = handleDir(event->pos());
|
||||||
|
m_pOrg = pointToParent(event->pos());
|
||||||
|
m_rOrg = geometry();
|
||||||
|
m_movable = true;
|
||||||
|
bMousePress=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
QGraphicsItem::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
bMousePress=false;
|
||||||
|
|
||||||
|
if(Qt::LeftButton == event->button()) {
|
||||||
|
m_hDir = NONE;
|
||||||
|
m_movable = false;
|
||||||
|
bLeftCitie=false;
|
||||||
|
bRightCitie=false;
|
||||||
|
bTopCitie=false;
|
||||||
|
bBottomCitie=false;
|
||||||
|
m_keyPressId++;
|
||||||
|
emit sigCiTie(false,m_keyPressId);
|
||||||
|
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::setGeometry(const QRectF &r)
|
||||||
|
{
|
||||||
|
if(r != geometry()) {
|
||||||
|
prepareGeometryChange();
|
||||||
|
setPos(r.x(), r.y());
|
||||||
|
m_w = r.width();
|
||||||
|
m_h = r.height();
|
||||||
|
adjustHandle();
|
||||||
|
emit rectChanged(rect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::updateGeometry()
|
||||||
|
{
|
||||||
|
QRectF r = geometry();
|
||||||
|
qreal x, y, w, h;
|
||||||
|
x = r.x() - m_handleLen;
|
||||||
|
y = r.y() - m_handleLen;
|
||||||
|
w = r.width() + m_handleLen * 2;
|
||||||
|
h = r.height() + m_handleLen * 2;
|
||||||
|
r = QRectF(x, y, w, h);
|
||||||
|
if(nullptr != scene()) {
|
||||||
|
scene()->update(r);
|
||||||
|
}
|
||||||
|
emit requestUpdate(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsObject::updateGeometry(const QRectF &gC, const QRectF &gL)
|
||||||
|
{
|
||||||
|
qreal x, y, w, h;
|
||||||
|
QRectF gCur, gLast;
|
||||||
|
x = gC.x() - m_handleLen;
|
||||||
|
y = gC.y() - m_handleLen;
|
||||||
|
w = gC.width() + m_handleLen * 2;
|
||||||
|
h = gC.height() + m_handleLen * 2;
|
||||||
|
gCur = QRectF(x, y, w, h);
|
||||||
|
x = gL.x() - m_handleLen;
|
||||||
|
y = gL.y() - m_handleLen;
|
||||||
|
w = gL.width() + m_handleLen * 2;
|
||||||
|
h = gL.height() + m_handleLen * 2;
|
||||||
|
gLast = QRectF(x, y, w, h);
|
||||||
|
qreal l = (gCur.left() < gLast.left()) ? gCur.left() : gLast.left();
|
||||||
|
qreal t = (gCur.top() < gLast.top()) ? gCur.top() : gLast.top();
|
||||||
|
qreal r = (gCur.right() > gLast.right()) ? gCur.right() : gLast.right();
|
||||||
|
qreal b = (gCur.bottom() > gLast.bottom()) ? gCur.bottom() : gLast.bottom();
|
||||||
|
QRectF gFlash = QRectF(QPointF(l, t), QPointF(r, b));
|
||||||
|
if(nullptr != scene()) {
|
||||||
|
scene()->update(gFlash);
|
||||||
|
}
|
||||||
|
emit requestUpdate(gFlash);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF LoQGraphicsObject::pointToParent(const QPointF &p)
|
||||||
|
{
|
||||||
|
qreal px, py;
|
||||||
|
px = p.x() + x();
|
||||||
|
py = p.y() + y();
|
||||||
|
return QPointF(px, py);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoQGraphicsObject::HANDLE_DIR LoQGraphicsObject::handleDir(const QPointF &p)
|
||||||
|
{
|
||||||
|
HANDLE_DIR hDir = NONE;
|
||||||
|
if(isSelected()) {
|
||||||
|
if(m_rLT.contains(p)) hDir = LT;
|
||||||
|
else if(m_rT.contains(p)) hDir = T;
|
||||||
|
else if(m_rRT.contains(p)) hDir = RT;
|
||||||
|
else if(m_rL.contains(p)) hDir = L;
|
||||||
|
else if(m_rR.contains(p)) hDir = R;
|
||||||
|
else if(m_rLB.contains(p)) hDir = LB;
|
||||||
|
else if(m_rB.contains(p)) hDir = B;
|
||||||
|
else if(m_rRB.contains(p)) hDir = RB;
|
||||||
|
}
|
||||||
|
return hDir;
|
||||||
|
}
|
||||||
|
//拖拽的虚线矩形
|
||||||
|
void LoQGraphicsObject::adjustHandle()
|
||||||
|
{
|
||||||
|
const QRectF &r = rect();
|
||||||
|
//左上角
|
||||||
|
m_rLT = QRectF(r.left() - m_handleLen/2,
|
||||||
|
r.top() - m_handleLen/2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
//上中
|
||||||
|
m_rT = QRectF(r.center().x() - m_handleLen / 2,
|
||||||
|
r.top() - m_handleLen/2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
//右上角
|
||||||
|
m_rRT = QRectF(r.right()-m_handleLen/2,
|
||||||
|
r.top() - m_handleLen/2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
//左中
|
||||||
|
m_rL = QRectF(r.left() - m_handleLen/2,
|
||||||
|
r.center().y() - m_handleLen / 2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
//右中
|
||||||
|
m_rR = QRectF(r.right()-m_handleLen/2,
|
||||||
|
r.center().y() - m_handleLen / 2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
//左下角
|
||||||
|
m_rLB = QRectF(r.left() - m_handleLen/2,
|
||||||
|
r.bottom()-m_handleLen / 2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
//中下
|
||||||
|
m_rB = QRectF(r.center().x() - m_handleLen / 2,
|
||||||
|
r.bottom()-m_handleLen / 2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
//右下角
|
||||||
|
m_rRB = QRectF(r.right()-m_handleLen / 2,
|
||||||
|
r.bottom()-m_handleLen / 2,
|
||||||
|
m_handleLen, m_handleLen);
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
#ifndef LOQGRAPHICSOBJECT_H
|
||||||
|
#define LOQGRAPHICSOBJECT_H
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsObject>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
#define INVALID_RECT QRect(-1, -5, -6, -8)
|
||||||
|
|
||||||
|
class LoQGraphicsObject : public QGraphicsObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NONE = 0,
|
||||||
|
LT,
|
||||||
|
T,
|
||||||
|
RT,
|
||||||
|
L,
|
||||||
|
R,
|
||||||
|
LB,
|
||||||
|
B,
|
||||||
|
RB
|
||||||
|
} HANDLE_DIR;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum InteractiveType {
|
||||||
|
Dynamic = 0,
|
||||||
|
Static,
|
||||||
|
Custom
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LoQGraphicsObject(InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||||
|
LoQGraphicsObject(QRectF rect, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||||
|
LoQGraphicsObject(qreal x, qreal y, qreal w, qreal h, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual QRectF boundingRect() const override;
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
virtual void setInteractiveType(InteractiveType type = Dynamic);
|
||||||
|
|
||||||
|
public:
|
||||||
|
InteractiveType interactiveType() const { return m_interactiveType; }
|
||||||
|
QRectF rect() const { return QRectF(0, 0, m_w, m_h); }
|
||||||
|
QRectF geometry() const { return QRectF(x(), y(), m_w, m_h); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setRLimit(const QRectF &r);
|
||||||
|
QRectF rLimit() const { return m_rLimit; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void requestUpdate(const QRectF &);
|
||||||
|
void geometryChanged(const QRectF &);
|
||||||
|
void rectChanged(const QRectF &);
|
||||||
|
|
||||||
|
void sigCiTie(bool,int);
|
||||||
|
public slots:
|
||||||
|
void setGeometry (qreal x, qreal y, qreal w, qreal h) { setGeometry(QRectF(x, y, w, h)); }
|
||||||
|
void setGeometry (const QRectF &r);
|
||||||
|
void updateGeometry();
|
||||||
|
void updateGeometry(const QRectF &gLast) { updateGeometry(geometry(), gLast); }
|
||||||
|
void updateGeometry(const QRectF &gCur, const QRectF &gLast);
|
||||||
|
void setBrightBianLeft(bool);
|
||||||
|
void setBrightBianTop(bool);
|
||||||
|
void setBrightBianRight(bool);
|
||||||
|
void setBrightBianbottom(bool);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int handleLen() const { return m_handleLen; }
|
||||||
|
QPointF pointToParent(const QPointF &p);
|
||||||
|
HANDLE_DIR handleDir(const QPointF &p);
|
||||||
|
void adjustHandle();
|
||||||
|
|
||||||
|
private:
|
||||||
|
InteractiveType m_interactiveType;
|
||||||
|
bool m_movable;
|
||||||
|
int m_handleLen;
|
||||||
|
QPen m_handlePen;
|
||||||
|
QPen m_borderPen;
|
||||||
|
|
||||||
|
private:
|
||||||
|
qreal m_w;
|
||||||
|
qreal m_h;
|
||||||
|
QRectF m_rLT;
|
||||||
|
QRectF m_rT;
|
||||||
|
|
||||||
|
QRectF m_rRT;
|
||||||
|
QRectF m_rL;
|
||||||
|
QRectF m_rR;
|
||||||
|
QRectF m_rLB;
|
||||||
|
QRectF m_rB;
|
||||||
|
QRectF m_rRB;
|
||||||
|
QRectF m_rOrg;
|
||||||
|
QPointF m_pOrg;
|
||||||
|
HANDLE_DIR m_hDir;
|
||||||
|
QRectF m_rLimit;
|
||||||
|
bool bMousePress=false;
|
||||||
|
bool bLeftCitie=false;
|
||||||
|
bool bRightCitie=false;
|
||||||
|
bool bTopCitie=false;
|
||||||
|
bool bBottomCitie=false;
|
||||||
|
int m_keyPressId=0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQGRAPHICSOBJECT_H
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "loqgraphicsvideoitem.h"
|
||||||
|
#include "loappconfig.h"
|
||||||
|
|
||||||
|
LoQGraphicsVideoItem::LoQGraphicsVideoItem(QGraphicsItem *parent) :
|
||||||
|
QGraphicsVideoItem(parent),
|
||||||
|
m_painterCompositionMode(QPainter::CompositionMode_SourceOver)
|
||||||
|
{
|
||||||
|
QString glVendor = LoAppConfig::getInstance()->OpenGLVendor();
|
||||||
|
if(glVendor.contains("NVIDIA Corporation")) { // QPainter::RasterOp_SourceAndNotDestination
|
||||||
|
m_painterCompositionMode = QPainter::RasterOp_SourceAndNotDestination;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQGraphicsVideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
if(m_painterCompositionMode != QPainter::CompositionMode_SourceOver) {
|
||||||
|
painter->save();
|
||||||
|
painter->setCompositionMode(static_cast<QPainter::CompositionMode>(m_painterCompositionMode));
|
||||||
|
QGraphicsVideoItem::paint(painter, option, widget);
|
||||||
|
painter->restore();
|
||||||
|
} else {
|
||||||
|
QGraphicsVideoItem::paint(painter, option, widget);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef LOQGRAPHICSVIDEOITEM_H
|
||||||
|
#define LOQGRAPHICSVIDEOITEM_H
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QGraphicsVideoItem>
|
||||||
|
|
||||||
|
class LoQGraphicsVideoItem : public QGraphicsVideoItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQGraphicsVideoItem(QGraphicsItem *parent = nullptr);
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_painterCompositionMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQGRAPHICSVIDEOITEM_H
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include "loqgraphicsview.h"
|
||||||
|
|
||||||
|
LoQGraphicsview::LoQGraphicsview()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void LoQGraphicsview::paintEvent(QPaintEvent * event)
|
||||||
|
{
|
||||||
|
QGraphicsView::paintEvent(event);
|
||||||
|
QPainter painter(this);
|
||||||
|
QPen CitiePen=QPen(QColor::fromRgb(255, 0, 0),2,Qt::SolidLine);
|
||||||
|
painter.setPen(CitiePen);
|
||||||
|
painter.drawLine(QPointF(0,0),QPointF(400,400));
|
||||||
|
if(true)
|
||||||
|
{
|
||||||
|
switch (0) {
|
||||||
|
case 0:
|
||||||
|
painter.setPen(CitiePen);
|
||||||
|
painter.drawLine(QPointF(0,0),QPointF(400,400));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
painter.setPen(CitiePen);
|
||||||
|
painter.drawLine(QPointF(rect().topLeft()),QPointF(rect().topRight()));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
painter.setPen(CitiePen);
|
||||||
|
painter.drawLine(QPointF(rect().topRight()),QPointF(rect().bottomRight()));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
painter.setPen(CitiePen);
|
||||||
|
painter.drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef LOQGRAPHICSVIEW_H
|
||||||
|
#define LOQGRAPHICSVIEW_H
|
||||||
|
|
||||||
|
#include <QGraphicsView>
|
||||||
|
class LoQGraphicsview : public QGraphicsView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LoQGraphicsview();
|
||||||
|
virtual void paintEvent(QPaintEvent * event) ;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQGRAPHICSVIEW_H
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "loqheaderviewcheckbox.h"
|
||||||
|
|
||||||
|
LoQHeaderViewCheckBox::LoQHeaderViewCheckBox(Qt::Orientation orientation, QWidget *parent, const QString &id) : QHeaderView(orientation, parent)
|
||||||
|
{
|
||||||
|
qDebug() <<"LoQHeaderViewCheckBox -s";
|
||||||
|
m_checkBox = new QCheckBox(this);
|
||||||
|
m_checkBox->setProperty("ssType", "header");
|
||||||
|
m_checkBox->setProperty("ssName", "selectAll");
|
||||||
|
m_checkBox->setProperty("ssId" , id);
|
||||||
|
m_checkBox->setChecked(false);
|
||||||
|
connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(sigCheckAll(bool)));
|
||||||
|
qDebug() <<"LoQHeaderViewCheckBox -o";
|
||||||
|
}
|
||||||
|
void LoQHeaderViewCheckBox::HideHeaderCheckBox(bool b)
|
||||||
|
{
|
||||||
|
qDebug() <<"HideHeaderCheckBox -s";
|
||||||
|
if(b)
|
||||||
|
m_checkBox->hide();
|
||||||
|
else {
|
||||||
|
m_checkBox->show();
|
||||||
|
}
|
||||||
|
qDebug() <<"HideHeaderCheckBox -o";
|
||||||
|
}
|
||||||
|
void LoQHeaderViewCheckBox::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
|
||||||
|
{
|
||||||
|
qDebug() <<"paintSection -s";
|
||||||
|
QHeaderView::paintSection(painter, rect, logicalIndex);
|
||||||
|
if (logicalIndex == 0) {
|
||||||
|
m_checkBox->setGeometry(rect);
|
||||||
|
}
|
||||||
|
qDebug() <<"paintSection -o";
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQHeaderViewCheckBox::onAllChecked(bool f)
|
||||||
|
{
|
||||||
|
qDebug() <<"onAllChecked -s";
|
||||||
|
m_checkBox->blockSignals(true);
|
||||||
|
m_checkBox->setChecked(f);
|
||||||
|
m_checkBox->blockSignals(false);
|
||||||
|
qDebug() <<"onAllChecked -o";
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef LOQHEADERVIEWCHECKBOX_H
|
||||||
|
#define LOQHEADERVIEWCHECKBOX_H
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
class LoQHeaderViewCheckBox : public QHeaderView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQHeaderViewCheckBox(Qt::Orientation orientation, QWidget *parent = nullptr, const QString &id = "none");
|
||||||
|
void HideHeaderCheckBox(bool b);
|
||||||
|
protected:
|
||||||
|
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sigCheckAll(bool);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onAllChecked(bool f);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QCheckBox *m_checkBox;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQHEADERVIEWCHECKBOX_H
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "loqlineedit.h"
|
||||||
|
|
||||||
|
LoQLineEdit::LoQLineEdit(QWidget *parent) : QLineEdit(parent)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(onTextChanged(const QString &)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQLineEdit::onTextChanged(const QString &text)
|
||||||
|
{
|
||||||
|
emit sigTextChanged(this, text);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef LOQLINEEDIT_H
|
||||||
|
#define LOQLINEEDIT_H
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class LoQLineEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQLineEdit(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sigTextChanged(LoQLineEdit *obj, const QString &text);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onTextChanged(const QString &text);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQLINEEDIT_H
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef LOQMACRO_H
|
||||||
|
#define LOQMACRO_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define LoQ_PROPERTY(type, name) \
|
||||||
|
public slots: type get##name() const { return m_##name; } \
|
||||||
|
public slots: void set##name(const type &a) { m_##name = a; } \
|
||||||
|
signals: void name##Changed(const type &); \
|
||||||
|
private: \
|
||||||
|
Q_PROPERTY(type name MEMBER m_##name READ get##name WRITE set##name NOTIFY name##Changed) \
|
||||||
|
type m_##name;
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif // LOQMACRO_H
|
|
@ -0,0 +1,172 @@
|
||||||
|
#include "loqmainwindow.h"
|
||||||
|
#include "QtMath"
|
||||||
|
LoQMainWindow::LoQMainWindow(QWidget *parent) :
|
||||||
|
QMainWindow(parent),
|
||||||
|
m_winMove(false)
|
||||||
|
{
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground,true);
|
||||||
|
setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
// ui->centralWidget->setMouseTracking(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQMainWindow::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
QRect gRect = this->geometry();
|
||||||
|
gRect.setWidth(gRect.width() - 10);
|
||||||
|
gRect.setHeight(gRect.height() - 10);
|
||||||
|
gRect.setX(gRect.x() + 5);
|
||||||
|
gRect.setY(gRect.y() + 5);
|
||||||
|
QPoint pointXiangDui = event->pos();
|
||||||
|
if((pointXiangDui.y()<100&&pointXiangDui.x()>5)&&(pointXiangDui.y()<100&&pointXiangDui.x()<gRect.width()-5))
|
||||||
|
{
|
||||||
|
if(gRect.contains(event->globalPos())) {
|
||||||
|
m_winMove = true;
|
||||||
|
m_winOrgPoint = event->globalPos();
|
||||||
|
m_winWorldPoint = this->frameGeometry().topLeft();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Resize the window
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_winMove = false;
|
||||||
|
m_iCalCursorPos = CalCursorPos(event->pos(),CalCursorCol(event->pos()));
|
||||||
|
if (event->button() == Qt::LeftButton /*&& Qt::WindowMaximized != windowState()*/)
|
||||||
|
{
|
||||||
|
if(m_iCalCursorPos != CENTER)
|
||||||
|
{
|
||||||
|
m_bLeftPress = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_rtPreGeometry = geometry();
|
||||||
|
m_ptViewMousePos = event->globalPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQMainWindow::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(m_winMove) {
|
||||||
|
if (event->buttons() & Qt::LeftButton) {
|
||||||
|
QPoint relativePos = event->globalPos() - m_winOrgPoint;
|
||||||
|
this->move(m_winWorldPoint + relativePos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//窗体不是最大的话就改变鼠标的形状
|
||||||
|
if(Qt::WindowMaximized != windowState())
|
||||||
|
{
|
||||||
|
setCursorShape(CalCursorPos(event->pos(),CalCursorCol(event->pos())));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//获取当前的点,这个点是全局的
|
||||||
|
QPoint ptCurrentPos = QCursor::pos();
|
||||||
|
//计算出移动的位置,当前点 - 鼠标左键按下的点
|
||||||
|
QPoint ptMoveSize = ptCurrentPos - m_ptViewMousePos;
|
||||||
|
QRect rtTempGeometry = m_rtPreGeometry;
|
||||||
|
if(m_bLeftPress)
|
||||||
|
{
|
||||||
|
switch(m_iCalCursorPos)
|
||||||
|
{
|
||||||
|
case TOPLEFT:
|
||||||
|
rtTempGeometry.setTopLeft(m_rtPreGeometry.topLeft()+ptMoveSize);
|
||||||
|
break;
|
||||||
|
case TOP:
|
||||||
|
rtTempGeometry.setTop(m_rtPreGeometry.top()+ptMoveSize.y());
|
||||||
|
break;
|
||||||
|
case TOPRIGHT:
|
||||||
|
rtTempGeometry.setTopRight(m_rtPreGeometry.topRight()+ptMoveSize);
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
rtTempGeometry.setLeft(m_rtPreGeometry.left()+ptMoveSize.x());
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
rtTempGeometry.setRight(m_rtPreGeometry.right()+ptMoveSize.x());
|
||||||
|
break;
|
||||||
|
case BUTTOMLEFT:
|
||||||
|
rtTempGeometry.setBottomLeft(m_rtPreGeometry.bottomLeft()+ptMoveSize);
|
||||||
|
break;
|
||||||
|
case BUTTOM:
|
||||||
|
rtTempGeometry.setBottom(m_rtPreGeometry.bottom()+ptMoveSize.y());
|
||||||
|
break;
|
||||||
|
case BUTTOMRIGHT:
|
||||||
|
rtTempGeometry.setBottomRight(m_rtPreGeometry.bottomRight()+ptMoveSize);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//移动窗体,如果比最小窗体大,就移动
|
||||||
|
if(rtTempGeometry.width() >= 200 && rtTempGeometry.height() >= 300)
|
||||||
|
setGeometry(rtTempGeometry);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQMainWindow::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
|
||||||
|
m_winMove = false;
|
||||||
|
}
|
||||||
|
m_bLeftPress = false;
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQMainWindow::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QStyleOption opt;
|
||||||
|
opt.init(this);
|
||||||
|
QPainter p(this);
|
||||||
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int LoQMainWindow::CalCursorCol(QPoint pt)
|
||||||
|
{
|
||||||
|
return (pt.x() < FRAMESHAPE ? 1 : ((pt.x() > this->width() - FRAMESHAPE) ? 3 : 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
int LoQMainWindow::CalCursorPos(QPoint pt, int colPos)
|
||||||
|
{
|
||||||
|
return ((pt.y() < FRAMESHAPE ? 10 : ((pt.y() > this->height() - FRAMESHAPE) ? 30 : 20)) + colPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQMainWindow::setCursorShape(int CalPos)
|
||||||
|
{
|
||||||
|
Qt::CursorShape cursor;
|
||||||
|
switch(CalPos)
|
||||||
|
{
|
||||||
|
case TOPLEFT:
|
||||||
|
case BUTTOMRIGHT:
|
||||||
|
cursor = Qt::SizeFDiagCursor;
|
||||||
|
break;
|
||||||
|
case TOPRIGHT:
|
||||||
|
case BUTTOMLEFT:
|
||||||
|
cursor = Qt::SizeBDiagCursor;
|
||||||
|
break;
|
||||||
|
case TOP:
|
||||||
|
case BUTTOM:
|
||||||
|
cursor = Qt::SizeVerCursor;
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
case RIGHT:
|
||||||
|
cursor = Qt::SizeHorCursor;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cursor = Qt::ArrowCursor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setCursor(cursor);
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
#ifndef LOQMAINWINDOW_H
|
||||||
|
#define LOQMAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QStyleOption>
|
||||||
|
|
||||||
|
class LoQMainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQMainWindow(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
virtual void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_winMove=false;
|
||||||
|
QPoint m_winOrgPoint;
|
||||||
|
QPoint m_winWorldPoint;
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TOPLEFT = 11,
|
||||||
|
TOP = 12,
|
||||||
|
TOPRIGHT = 13,
|
||||||
|
LEFT = 21,
|
||||||
|
CENTER = 22,
|
||||||
|
RIGHT = 23,
|
||||||
|
BUTTOMLEFT = 31,
|
||||||
|
BUTTOM = 32,
|
||||||
|
BUTTOMRIGHT = 33
|
||||||
|
};
|
||||||
|
|
||||||
|
#define FRAMESHAPE 10
|
||||||
|
|
||||||
|
int CalCursorCol(QPoint pt); //计算鼠标X的位置
|
||||||
|
int CalCursorPos(QPoint pt, int colPos); //计算鼠标的位置
|
||||||
|
void setCursorShape(int CalPos); //设置鼠标对应位置的形状
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_iCalCursorPos;
|
||||||
|
bool m_bLeftPress;
|
||||||
|
QRect m_rtPreGeometry;
|
||||||
|
QPoint m_ptViewMousePos;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQMAINWINDOW_H
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include "loqpushbutton.h"
|
||||||
|
|
||||||
|
LoQPushButton::LoQPushButton(QWidget *parent) :
|
||||||
|
QPushButton(parent),
|
||||||
|
m_customData(nullptr)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
LoQPushButton::LoQPushButton(const QString &text, QWidget *parent) :
|
||||||
|
QPushButton(text, parent),
|
||||||
|
m_customData(nullptr)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
LoQPushButton::LoQPushButton(const QIcon& icon, const QString &text, QWidget *parent) :
|
||||||
|
QPushButton(icon, text, parent),
|
||||||
|
m_customData(nullptr)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQPushButton::onClicked(bool f)
|
||||||
|
{
|
||||||
|
emit sigClicked(this, f);
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef LOQPUSHBUTTON_H
|
||||||
|
#define LOQPUSHBUTTON_H
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
class LoQPushButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQPushButton(QWidget *parent = nullptr);
|
||||||
|
explicit LoQPushButton(const QString &text, QWidget *parent = nullptr);
|
||||||
|
LoQPushButton(const QIcon& icon, const QString &text, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setCustomData(void *data) { m_customData = data; }
|
||||||
|
void* customData() { return m_customData; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sigClicked(LoQPushButton* obj, bool f);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onClicked(bool f);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void *m_customData;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQPUSHBUTTON_H
|
|
@ -0,0 +1,80 @@
|
||||||
|
#include "loqtitlebar.h"
|
||||||
|
#include "QDebug"
|
||||||
|
LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
bn_Minimize = new QPushButton(this);
|
||||||
|
bn_Maximize = new QPushButton(this);
|
||||||
|
bn_Close = new QPushButton(this);
|
||||||
|
|
||||||
|
bn_Minimize->setObjectName("bnMinimize");
|
||||||
|
bn_Maximize->setObjectName("bnMaximize");
|
||||||
|
bn_Close->setObjectName("bnClose");
|
||||||
|
|
||||||
|
bn_Minimize->setToolTip(tr("Minimize"));
|
||||||
|
bn_Maximize->setToolTip(tr("Maximize"));
|
||||||
|
bn_Close->setToolTip(tr("Close"));
|
||||||
|
|
||||||
|
connect(bn_Minimize, SIGNAL(clicked(bool)), window(), SLOT(showMinimized()));
|
||||||
|
connect(bn_Maximize, SIGNAL(clicked(bool)), this, SLOT(onBnMaximizeClicked()));
|
||||||
|
connect(bn_Close, SIGNAL(clicked(bool)), window(), SLOT(close()));
|
||||||
|
}
|
||||||
|
void LoQTitleBar::hideMixmumButton()
|
||||||
|
{
|
||||||
|
bn_Minimize->hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
void LoQTitleBar::refreshLable()
|
||||||
|
{
|
||||||
|
bn_Minimize->setToolTip(tr("Minimize"));
|
||||||
|
bn_Maximize->setToolTip(tr("Maximize"));
|
||||||
|
bn_Close->setToolTip(tr("Close"));
|
||||||
|
|
||||||
|
}
|
||||||
|
bool LoQTitleBar::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::WindowStateChange:
|
||||||
|
case QEvent::Resize:
|
||||||
|
updateMaximize();
|
||||||
|
return true;
|
||||||
|
// case QEvent::MouseButtonPress: {
|
||||||
|
// QMouseEvent *e = static_cast<QMouseEvent*>(event);
|
||||||
|
// if(this->geometry().contains(e->pos())){
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return QWidget::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQTitleBar::updateMaximize()
|
||||||
|
{
|
||||||
|
QWidget *pWindow = window();
|
||||||
|
if (pWindow->isTopLevel()) {
|
||||||
|
bool bMaximize = pWindow->isMaximized();
|
||||||
|
if (bMaximize) {
|
||||||
|
bn_Maximize->setToolTip(tr("Restore"));
|
||||||
|
} else {
|
||||||
|
bn_Maximize->setToolTip(tr("Maximize"));
|
||||||
|
}
|
||||||
|
bn_Maximize->setStyle(QApplication::style());
|
||||||
|
}
|
||||||
|
bn_Minimize->setToolTip(tr("Minimize"));
|
||||||
|
bn_Close->setToolTip(tr("Close"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQTitleBar::onBnMaximizeClicked()
|
||||||
|
{
|
||||||
|
QWidget *pWindow = window();
|
||||||
|
if(pWindow->isMaximized()) {
|
||||||
|
pWindow->showNormal();
|
||||||
|
qDebug()<<"showNormal";
|
||||||
|
} else {
|
||||||
|
pWindow->showMaximized();
|
||||||
|
qDebug()<<"showMaximized";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef LOQTITLEBAR_H
|
||||||
|
#define LOQTITLEBAR_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
class LoQTitleBar : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQTitleBar(QWidget *parent = nullptr);
|
||||||
|
void hideMixmumButton();
|
||||||
|
void refreshLable();
|
||||||
|
protected:
|
||||||
|
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void updateMaximize();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onBnMaximizeClicked();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QPushButton *bn_Minimize;
|
||||||
|
QPushButton *bn_Maximize;
|
||||||
|
QPushButton *bn_Close;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQTITLEBAR_H
|
|
@ -0,0 +1,119 @@
|
||||||
|
#include "loqtreewidget.h"
|
||||||
|
|
||||||
|
LoQTreeWidget::LoQTreeWidget(QWidget *parent) :
|
||||||
|
QTreeWidget(parent),
|
||||||
|
m_checkState(CheckNone)
|
||||||
|
{
|
||||||
|
qDebug() <<"LoQTreeWidget::LoQTreeWidget -s";
|
||||||
|
m_header = new LoQHeaderViewCheckBox(Qt::Horizontal, this);
|
||||||
|
setHeader(m_header);
|
||||||
|
setProperty("ssType", "topList");
|
||||||
|
connect(m_header, SIGNAL(sigCheckAll(bool)), this, SLOT(onCheckAll(bool)));
|
||||||
|
connect(this, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onItemClicked(QTreeWidgetItem*,int)));
|
||||||
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
qDebug() <<"LoQTreeWidget::LoQTreeWidget -o";
|
||||||
|
|
||||||
|
}
|
||||||
|
void LoQTreeWidget::HideHeaderCheckBox(bool b)
|
||||||
|
{
|
||||||
|
qDebug() <<"HideHeaderCheckBox -s";
|
||||||
|
m_header->HideHeaderCheckBox(b);
|
||||||
|
qDebug() <<"HideHeaderCheckBox -o";
|
||||||
|
}
|
||||||
|
void LoQTreeWidget::adjustCheckState()
|
||||||
|
{
|
||||||
|
qDebug() <<"adjustCheckState -s";
|
||||||
|
bool isAllChecked = true;
|
||||||
|
int cnt = topLevelItemCount();
|
||||||
|
if(cnt == 0) {
|
||||||
|
isAllChecked = false;
|
||||||
|
m_checkState = CheckNone;
|
||||||
|
} else {
|
||||||
|
int k = 0;
|
||||||
|
for(int i=0; i<cnt; i++) {
|
||||||
|
if(!this->isRowHidden(i,indexFromItem(topLevelItem(i)->parent())))
|
||||||
|
{
|
||||||
|
if(topLevelItem(i)->checkState(0) == Qt::Unchecked) {
|
||||||
|
isAllChecked = false;
|
||||||
|
} else {
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(k > 1) {
|
||||||
|
m_checkState = CheckMulti;
|
||||||
|
} else if(k > 0) {
|
||||||
|
m_checkState = CheckOne;
|
||||||
|
} else {
|
||||||
|
m_checkState = CheckNone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_header->onAllChecked(isAllChecked);
|
||||||
|
sigCheckStateChanged(m_checkState);
|
||||||
|
qDebug() <<"adjustCheckState -o";
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* LoQTreeWidget::itemChecked()
|
||||||
|
{
|
||||||
|
qDebug() <<"itemChecked -s";
|
||||||
|
QTreeWidgetItem *res = nullptr;
|
||||||
|
int cnt = topLevelItemCount();
|
||||||
|
for(int i=0; i<cnt; i++) {
|
||||||
|
QTreeWidgetItem *item = topLevelItem(i);
|
||||||
|
if(Qt::Checked == item->checkState(0)) {
|
||||||
|
res = item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug() <<"itemChecked -o";
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQTreeWidget::onCheckAll(bool checked)
|
||||||
|
{
|
||||||
|
qDebug() <<"onCheckAll -s";
|
||||||
|
int cnt = topLevelItemCount();
|
||||||
|
for(int i=0; i<cnt; i++) {
|
||||||
|
if(checked)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if(this->isRowHidden(i,indexFromItem(topLevelItem(i)->parent())))
|
||||||
|
{
|
||||||
|
topLevelItem(i)->setCheckState(0, Qt::Unchecked);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
topLevelItem(i)->setCheckState(0, Qt::Checked);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
topLevelItem(i)->setCheckState(0, Qt::Unchecked);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// topLevelItem(i)->setCheckState(0, checked ? Qt::Checked : Qt::Unchecked);
|
||||||
|
adjustCheckState();
|
||||||
|
qDebug() <<"onCheckAll -o";
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoQTreeWidget::onItemClicked(QTreeWidgetItem *item, int column)
|
||||||
|
{
|
||||||
|
qDebug() <<"onItemClicked -s";
|
||||||
|
if(column > 0) {
|
||||||
|
item->setCheckState(0, item->checkState(0) == Qt::Unchecked ? Qt::Checked : Qt::Unchecked);
|
||||||
|
}
|
||||||
|
adjustCheckState();
|
||||||
|
qDebug() <<"onItemClicked -o";
|
||||||
|
}
|
||||||
|
QModelIndex LoQTreeWidget::indexFromItem(QTreeWidgetItem *item, int column) const
|
||||||
|
{
|
||||||
|
qDebug() <<"onItemClicked -s";
|
||||||
|
return QTreeWidget::indexFromItem(item, column);
|
||||||
|
qDebug() <<"onItemClicked -o";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef LOQTREEWIDGET_H
|
||||||
|
#define LOQTREEWIDGET_H
|
||||||
|
|
||||||
|
#include <QTreeWidget>
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
#include <LoQClass/loqheaderviewcheckbox.h>
|
||||||
|
|
||||||
|
class LoQTreeWidget : public QTreeWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum CheckState {
|
||||||
|
CheckNone,
|
||||||
|
CheckOne,
|
||||||
|
CheckMulti
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LoQTreeWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void adjustCheckState();
|
||||||
|
QTreeWidgetItem* itemChecked();
|
||||||
|
QModelIndex indexFromItem(QTreeWidgetItem *item, int column = 0) const;//add by alahover 20200306
|
||||||
|
void HideHeaderCheckBox(bool b);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sigCheckStateChanged(int);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onCheckAll(bool checked);
|
||||||
|
void onItemClicked(QTreeWidgetItem *item, int column);
|
||||||
|
|
||||||
|
private:
|
||||||
|
LoQHeaderViewCheckBox *m_header;
|
||||||
|
int m_checkState;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQTREEWIDGET_H
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include "loqvideosurface.h"
|
||||||
|
|
||||||
|
LoQVideoSurface::LoQVideoSurface(QObject *parent) :
|
||||||
|
QAbstractVideoSurface(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QList<QVideoFrame::PixelFormat> LoQVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(handleType);
|
||||||
|
QList<QVideoFrame::PixelFormat> listPixelFormats;
|
||||||
|
listPixelFormats << QVideoFrame::Format_ARGB32
|
||||||
|
<< QVideoFrame::Format_ARGB32_Premultiplied
|
||||||
|
<< QVideoFrame::Format_RGB32
|
||||||
|
<< QVideoFrame::Format_RGB24
|
||||||
|
<< QVideoFrame::Format_RGB565
|
||||||
|
<< QVideoFrame::Format_RGB555
|
||||||
|
<< QVideoFrame::Format_ARGB8565_Premultiplied
|
||||||
|
<< QVideoFrame::Format_BGRA32
|
||||||
|
<< QVideoFrame::Format_BGRA32_Premultiplied
|
||||||
|
<< QVideoFrame::Format_BGR32
|
||||||
|
<< QVideoFrame::Format_BGR24
|
||||||
|
<< QVideoFrame::Format_BGR565
|
||||||
|
<< QVideoFrame::Format_BGR555
|
||||||
|
<< QVideoFrame::Format_BGRA5658_Premultiplied
|
||||||
|
<< QVideoFrame::Format_AYUV444
|
||||||
|
<< QVideoFrame::Format_AYUV444_Premultiplied
|
||||||
|
<< QVideoFrame::Format_YUV444
|
||||||
|
<< QVideoFrame::Format_YUV420P
|
||||||
|
<< QVideoFrame::Format_YV12
|
||||||
|
<< QVideoFrame::Format_UYVY
|
||||||
|
<< QVideoFrame::Format_YUYV
|
||||||
|
<< QVideoFrame::Format_NV12
|
||||||
|
<< QVideoFrame::Format_NV21
|
||||||
|
<< QVideoFrame::Format_IMC1
|
||||||
|
<< QVideoFrame::Format_IMC2
|
||||||
|
<< QVideoFrame::Format_IMC3
|
||||||
|
<< QVideoFrame::Format_IMC4
|
||||||
|
<< QVideoFrame::Format_Y8
|
||||||
|
<< QVideoFrame::Format_Y16
|
||||||
|
<< QVideoFrame::Format_Jpeg
|
||||||
|
<< QVideoFrame::Format_CameraRaw
|
||||||
|
<< QVideoFrame::Format_AdobeDng;
|
||||||
|
// Return the formats you will support
|
||||||
|
return listPixelFormats;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoQVideoSurface::present(const QVideoFrame &frame)
|
||||||
|
{
|
||||||
|
// Handle the frame and do your processing
|
||||||
|
if (frame.isValid())
|
||||||
|
{
|
||||||
|
QVideoFrame cloneFrame(frame);
|
||||||
|
emit frameAvailable(cloneFrame);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef LOQVIDEOSURFACE_H
|
||||||
|
#define LOQVIDEOSURFACE_H
|
||||||
|
|
||||||
|
#include <QAbstractVideoSurface>
|
||||||
|
|
||||||
|
class LoQVideoSurface : public QAbstractVideoSurface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQVideoSurface(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual QList<QVideoFrame::PixelFormat>supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override;
|
||||||
|
virtual bool present(const QVideoFrame &frame) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void frameAvailable(QVideoFrame &frame);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQVIDEOSURFACE_H
|
|
@ -0,0 +1,56 @@
|
||||||
|
#include "loqwindowtitlebar.h"
|
||||||
|
|
||||||
|
LoQWindowTitleBar::LoQWindowTitleBar(QWidget *parent) :
|
||||||
|
LoQTitleBar(parent)
|
||||||
|
{
|
||||||
|
QHBoxLayout *pLayout = new QHBoxLayout(this);
|
||||||
|
pLayout->addStretch();
|
||||||
|
pLayout->addWidget(bn_Minimize);
|
||||||
|
pLayout->addWidget(bn_Maximize);
|
||||||
|
pLayout->addWidget(bn_Close);
|
||||||
|
pLayout->setContentsMargins(3, 3, 3, 0);
|
||||||
|
setLayout(pLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoQWindowTitleBar::LoQWindowTitleBar(const QString &text, QWidget *parent) :
|
||||||
|
LoQTitleBar(parent)
|
||||||
|
{
|
||||||
|
m_wText = new QLabel(text, this);
|
||||||
|
m_wText->adjustSize();
|
||||||
|
|
||||||
|
QHBoxLayout *pLayout = new QHBoxLayout(this);
|
||||||
|
pLayout->addStretch();
|
||||||
|
pLayout->addWidget(m_wText);
|
||||||
|
pLayout->addStretch();
|
||||||
|
pLayout->addWidget(bn_Minimize);
|
||||||
|
pLayout->addWidget(bn_Maximize);
|
||||||
|
pLayout->addWidget(bn_Close);
|
||||||
|
pLayout->setContentsMargins(3, 3, 3, 0);
|
||||||
|
setLayout(pLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoQWindowTitleBar::LoQWindowTitleBar(const QPixmap &icon, const QString &text, QWidget *parent) :
|
||||||
|
LoQTitleBar(parent)
|
||||||
|
{
|
||||||
|
m_wIcon = new QLabel(this);
|
||||||
|
m_wIcon->setPixmap(icon);
|
||||||
|
m_wIcon->adjustSize();
|
||||||
|
|
||||||
|
m_wText = new QLabel(text, this);
|
||||||
|
m_wText->adjustSize();
|
||||||
|
|
||||||
|
QHBoxLayout *pLayout = new QHBoxLayout(this);
|
||||||
|
pLayout->addWidget(m_wIcon);
|
||||||
|
pLayout->addStretch();
|
||||||
|
pLayout->addWidget(m_wText);
|
||||||
|
pLayout->addStretch();
|
||||||
|
pLayout->addWidget(bn_Minimize);
|
||||||
|
pLayout->addWidget(bn_Maximize);
|
||||||
|
pLayout->addWidget(bn_Close);
|
||||||
|
pLayout->setContentsMargins(3, 3, 3, 0);
|
||||||
|
setLayout(pLayout);
|
||||||
|
}
|
||||||
|
void LoQWindowTitleBar::RenameTitle(QString strName)
|
||||||
|
{
|
||||||
|
m_wText->setText(strName);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef LOQWINDOWTITLEBAR_H
|
||||||
|
#define LOQWINDOWTITLEBAR_H
|
||||||
|
|
||||||
|
#include <LoQClass/loqtitlebar.h>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
class LoQWindowTitleBar : public LoQTitleBar
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LoQWindowTitleBar(QWidget *parent = nullptr);
|
||||||
|
LoQWindowTitleBar(const QString &text, QWidget *parent = nullptr);
|
||||||
|
LoQWindowTitleBar(const QPixmap &icon, const QString &text, QWidget *parent = nullptr);
|
||||||
|
void RenameTitle(QString strName);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel *m_wIcon;
|
||||||
|
QLabel *m_wText;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOQWINDOWTITLEBAR_H
|
|
@ -0,0 +1,335 @@
|
||||||
|
#include <QAxObject>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "qexcel.h"
|
||||||
|
#include "QMessageBox"
|
||||||
|
#include <objbase.h>
|
||||||
|
|
||||||
|
QExcel::QExcel(QString xlsFilePath, QObject *parent)
|
||||||
|
{
|
||||||
|
excel = nullptr;
|
||||||
|
workBooks = nullptr;
|
||||||
|
workBook = nullptr;
|
||||||
|
sheets = nullptr;
|
||||||
|
sheet = nullptr;
|
||||||
|
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||||
|
|
||||||
|
excel = new QAxObject("Excel.Application");
|
||||||
|
excel->setProperty("Visible", false);
|
||||||
|
workBooks = excel->querySubObject("Workbooks");
|
||||||
|
if(workBooks!=nullptr)
|
||||||
|
{
|
||||||
|
QFile file(xlsFilePath);
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
workBooks->dynamicCall("Open(const QString&)", xlsFilePath);
|
||||||
|
workBook = excel->querySubObject("ActiveWorkBook");
|
||||||
|
sheets = workBook->querySubObject("WorkSheets");
|
||||||
|
}
|
||||||
|
m_bSupportExcel=true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QMessageBox::information(nullptr, "Title", tr("no support QExcel"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||||
|
m_bSupportExcel=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QExcel::~QExcel()
|
||||||
|
{
|
||||||
|
if(excel!=nullptr)
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::close()
|
||||||
|
{
|
||||||
|
excel->dynamicCall("Quit()");
|
||||||
|
delete sheet;
|
||||||
|
delete sheets;
|
||||||
|
delete workBook;
|
||||||
|
delete workBooks;
|
||||||
|
delete excel;
|
||||||
|
|
||||||
|
excel = nullptr;
|
||||||
|
workBooks = nullptr;
|
||||||
|
workBook = nullptr;
|
||||||
|
sheets = nullptr;
|
||||||
|
sheet = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAxObject *QExcel::getWorkBooks()
|
||||||
|
{
|
||||||
|
return workBooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAxObject *QExcel::getWorkBook()
|
||||||
|
{
|
||||||
|
return workBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAxObject *QExcel::getWorkSheets()
|
||||||
|
{
|
||||||
|
return sheets;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAxObject *QExcel::getWorkSheet()
|
||||||
|
{
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::selectSheet(const QString& sheetName)
|
||||||
|
{
|
||||||
|
sheet = sheets->querySubObject("Item(const QString&)", sheetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::deleteSheet(const QString& sheetName)
|
||||||
|
{
|
||||||
|
QAxObject * a = sheets->querySubObject("Item(const QString&)", sheetName);
|
||||||
|
a->dynamicCall("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::deleteSheet(int sheetIndex)
|
||||||
|
{
|
||||||
|
QAxObject * a = sheets->querySubObject("Item(int)", sheetIndex);
|
||||||
|
a->dynamicCall("delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::selectSheet(int sheetIndex)
|
||||||
|
{
|
||||||
|
sheet = sheets->querySubObject("Item(int)", sheetIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellString(int row, int column, const QString& value)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Cells(int,int)", row, column);
|
||||||
|
range->dynamicCall("SetValue(const QString&)", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellFontBold(int row, int column, bool isBold)
|
||||||
|
{
|
||||||
|
QString cell;
|
||||||
|
cell.append(QChar(column - 1 + 'A'));
|
||||||
|
cell.append(QString::number(row));
|
||||||
|
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range = range->querySubObject("Font");
|
||||||
|
range->setProperty("Bold", isBold);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellFontSize(int row, int column, int size)
|
||||||
|
{
|
||||||
|
QString cell;
|
||||||
|
cell.append(QChar(column - 1 + 'A'));
|
||||||
|
cell.append(QString::number(row));
|
||||||
|
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range = range->querySubObject("Font");
|
||||||
|
range->setProperty("Size", size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::mergeCells(const QString& cell)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->setProperty("VerticalAlignment", -4108);//xlCenter
|
||||||
|
range->setProperty("WrapText", true);
|
||||||
|
range->setProperty("MergeCells", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::mergeCells(int topLeftRow, int topLeftColumn, int bottomRightRow, int bottomRightColumn)
|
||||||
|
{
|
||||||
|
QString cell;
|
||||||
|
cell.append(QChar(topLeftColumn - 1 + 'A'));
|
||||||
|
cell.append(QString::number(topLeftRow));
|
||||||
|
cell.append(":");
|
||||||
|
cell.append(QChar(bottomRightColumn - 1 + 'A'));
|
||||||
|
cell.append(QString::number(bottomRightRow));
|
||||||
|
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->setProperty("VerticalAlignment", -4108);//xlCenter
|
||||||
|
range->setProperty("WrapText", true);
|
||||||
|
range->setProperty("MergeCells", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant QExcel::getCellValue(int row, int column)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Cells(int,int)", row, column);
|
||||||
|
return range->property("Value");
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::save()
|
||||||
|
{
|
||||||
|
workBook->dynamicCall("Save()");
|
||||||
|
}
|
||||||
|
|
||||||
|
int QExcel::getSheetsCount()
|
||||||
|
{
|
||||||
|
return sheets->property("Count").toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QExcel::getSheetName()
|
||||||
|
{
|
||||||
|
return sheet->property("Name").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QExcel::getSheetName(int sheetIndex)
|
||||||
|
{
|
||||||
|
QAxObject * a = sheets->querySubObject("Item(int)", sheetIndex);
|
||||||
|
return a->property("Name").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::getUsedRange(int *topLeftRow, int *topLeftColumn, int *bottomRightRow, int *bottomRightColumn)
|
||||||
|
{
|
||||||
|
QAxObject *usedRange = sheet->querySubObject("UsedRange");
|
||||||
|
*topLeftRow = usedRange->property("Row").toInt();
|
||||||
|
*topLeftColumn = usedRange->property("Column").toInt();
|
||||||
|
|
||||||
|
QAxObject *rows = usedRange->querySubObject("Rows");
|
||||||
|
*bottomRightRow = *topLeftRow + rows->property("Count").toInt() - 1;
|
||||||
|
|
||||||
|
QAxObject *columns = usedRange->querySubObject("Columns");
|
||||||
|
*bottomRightColumn = *topLeftColumn + columns->property("Count").toInt() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setColumnWidth(int column, int width)
|
||||||
|
{
|
||||||
|
QString columnName;
|
||||||
|
columnName.append(QChar(column - 1 + 'A'));
|
||||||
|
columnName.append(":");
|
||||||
|
columnName.append(QChar(column - 1 + 'A'));
|
||||||
|
|
||||||
|
QAxObject * col = sheet->querySubObject("Columns(const QString&)", columnName);
|
||||||
|
col->setProperty("ColumnWidth", width);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellTextCenter(int row, int column)
|
||||||
|
{
|
||||||
|
QString cell;
|
||||||
|
cell.append(QChar(column - 1 + 'A'));
|
||||||
|
cell.append(QString::number(row));
|
||||||
|
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->setProperty("HorizontalAlignment", -4108);//xlCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellTextWrap(int row, int column, bool isWrap)
|
||||||
|
{
|
||||||
|
QString cell;
|
||||||
|
cell.append(QChar(column - 1 + 'A'));
|
||||||
|
cell.append(QString::number(row));
|
||||||
|
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->setProperty("WrapText", isWrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setAutoFitRow(int row)
|
||||||
|
{
|
||||||
|
QString rowsName;
|
||||||
|
rowsName.append(QString::number(row));
|
||||||
|
rowsName.append(":");
|
||||||
|
rowsName.append(QString::number(row));
|
||||||
|
|
||||||
|
QAxObject * rows = sheet->querySubObject("Rows(const QString &)", rowsName);
|
||||||
|
rows->dynamicCall("AutoFit()");
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::insertSheet(QString sheetName)
|
||||||
|
{
|
||||||
|
sheets->querySubObject("Add()");
|
||||||
|
QAxObject * a = sheets->querySubObject("Item(int)", 1);
|
||||||
|
a->setProperty("Name", sheetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::mergeSerialSameCellsInAColumn(int column, int topRow)
|
||||||
|
{
|
||||||
|
int a,b,c,rowsCount;
|
||||||
|
getUsedRange(&a, &b, &rowsCount, &c);
|
||||||
|
|
||||||
|
int aMergeStart = topRow, aMergeEnd = topRow + 1;
|
||||||
|
|
||||||
|
QString value;
|
||||||
|
while(aMergeEnd <= rowsCount)
|
||||||
|
{
|
||||||
|
value = getCellValue(aMergeStart, column).toString();
|
||||||
|
while(value == getCellValue(aMergeEnd, column).toString())
|
||||||
|
{
|
||||||
|
clearCell(aMergeEnd, column);
|
||||||
|
aMergeEnd++;
|
||||||
|
}
|
||||||
|
aMergeEnd--;
|
||||||
|
mergeCells(aMergeStart, column, aMergeEnd, column);
|
||||||
|
|
||||||
|
aMergeStart = aMergeEnd + 1;
|
||||||
|
aMergeEnd = aMergeStart + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::clearCell(int row, int column)
|
||||||
|
{
|
||||||
|
QString cell;
|
||||||
|
cell.append(QChar(column - 1 + 'A'));
|
||||||
|
cell.append(QString::number(row));
|
||||||
|
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->dynamicCall("ClearContents()");
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::clearCell(const QString& cell)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->dynamicCall("ClearContents()");
|
||||||
|
}
|
||||||
|
|
||||||
|
int QExcel::getUsedRowsCount()
|
||||||
|
{
|
||||||
|
QAxObject *usedRange = sheet->querySubObject("UsedRange");
|
||||||
|
int topRow = usedRange->property("Row").toInt();
|
||||||
|
QAxObject *rows = usedRange->querySubObject("Rows");
|
||||||
|
int bottomRow = topRow + rows->property("Count").toInt() - 1;
|
||||||
|
return bottomRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellString(const QString& cell, const QString& value)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->dynamicCall("SetValue(const QString&)", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellFontSize(const QString &cell, int size)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range = range->querySubObject("Font");
|
||||||
|
range->setProperty("Size", size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellTextCenter(const QString &cell)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->setProperty("HorizontalAlignment", -4108);//xlCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellFontBold(const QString &cell, bool isBold)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range = range->querySubObject("Font");
|
||||||
|
range->setProperty("Bold", isBold);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setCellTextWrap(const QString &cell, bool isWrap)
|
||||||
|
{
|
||||||
|
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
|
||||||
|
range->setProperty("WrapText", isWrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QExcel::setRowHeight(int row, int height)
|
||||||
|
{
|
||||||
|
QString rowsName;
|
||||||
|
rowsName.append(QString::number(row));
|
||||||
|
rowsName.append(":");
|
||||||
|
rowsName.append(QString::number(row));
|
||||||
|
|
||||||
|
QAxObject * r = sheet->querySubObject("Rows(const QString &)", rowsName);
|
||||||
|
r->setProperty("RowHeight", height);
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
#ifndef QEXCEL_H
|
||||||
|
#define QEXCEL_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
class QAxObject;
|
||||||
|
|
||||||
|
class QExcel : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QExcel(QString xlsFilePath, QObject *parent = 0);
|
||||||
|
~QExcel();
|
||||||
|
|
||||||
|
public:
|
||||||
|
QAxObject * getWorkBooks();
|
||||||
|
QAxObject * getWorkBook();
|
||||||
|
QAxObject * getWorkSheets();
|
||||||
|
QAxObject * getWorkSheet();
|
||||||
|
int m_bSupportExcel=false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**************************************************************************/
|
||||||
|
/* 工作表 */
|
||||||
|
/**************************************************************************/
|
||||||
|
void selectSheet(const QString& sheetName);
|
||||||
|
//sheetIndex 起始于 1
|
||||||
|
void selectSheet(int sheetIndex);
|
||||||
|
void deleteSheet(const QString& sheetName);
|
||||||
|
void deleteSheet(int sheetIndex);
|
||||||
|
void insertSheet(QString sheetName);
|
||||||
|
int getSheetsCount();
|
||||||
|
//在 selectSheet() 之后才可调用
|
||||||
|
QString getSheetName();
|
||||||
|
QString getSheetName(int sheetIndex);
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/* 单元格 */
|
||||||
|
/**************************************************************************/
|
||||||
|
void setCellString(int row, int column, const QString& value);
|
||||||
|
//cell 例如 "A7"
|
||||||
|
void setCellString(const QString& cell, const QString& value);
|
||||||
|
//range 例如 "A5:C7"
|
||||||
|
void mergeCells(const QString& range);
|
||||||
|
void mergeCells(int topLeftRow, int topLeftColumn, int bottomRightRow, int bottomRightColumn);
|
||||||
|
QVariant getCellValue(int row, int column);
|
||||||
|
void clearCell(int row, int column);
|
||||||
|
void clearCell(const QString& cell);
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/* 布局格式 */
|
||||||
|
/**************************************************************************/
|
||||||
|
void getUsedRange(int *topLeftRow, int *topLeftColumn, int *bottomRightRow, int *bottomRightColumn);
|
||||||
|
void setColumnWidth(int column, int width);
|
||||||
|
void setRowHeight(int row, int height);
|
||||||
|
void setCellTextCenter(int row, int column);
|
||||||
|
void setCellTextCenter(const QString& cell);
|
||||||
|
void setCellTextWrap(int row, int column, bool isWrap);
|
||||||
|
void setCellTextWrap(const QString& cell, bool isWrap);
|
||||||
|
void setAutoFitRow(int row);
|
||||||
|
void mergeSerialSameCellsInAColumn(int column, int topRow);
|
||||||
|
int getUsedRowsCount();
|
||||||
|
void setCellFontBold(int row, int column, bool isBold);
|
||||||
|
void setCellFontBold(const QString& cell, bool isBold);
|
||||||
|
void setCellFontSize(int row, int column, int size);
|
||||||
|
void setCellFontSize(const QString& cell, int size);
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/* 文件 */
|
||||||
|
/**************************************************************************/
|
||||||
|
void save();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QAxObject * excel;
|
||||||
|
QAxObject * workBooks;
|
||||||
|
QAxObject * workBook;
|
||||||
|
QAxObject * sheets;
|
||||||
|
QAxObject * sheet;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,169 @@
|
||||||
|
#include "readexcel.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
ReadExcel::ReadExcel()
|
||||||
|
:m_row(0), m_col(0), m_filename("")
|
||||||
|
{
|
||||||
|
m_excel = new QAxObject("Excel.Application");
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadExcel::~ReadExcel()
|
||||||
|
{
|
||||||
|
if (!m_mapdata.empty()) {
|
||||||
|
m_mapdata.clear();
|
||||||
|
}
|
||||||
|
delete m_excel;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool ReadExcel::openExcel(const QString &filename)
|
||||||
|
{
|
||||||
|
if (filename.isEmpty()) {
|
||||||
|
m_row = 0;
|
||||||
|
m_col = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QFile file(filename);
|
||||||
|
if (!file.exists()){
|
||||||
|
m_row = 0;
|
||||||
|
m_col = 0;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if (!m_mapdata.empty()) {
|
||||||
|
m_mapdata.clear();
|
||||||
|
}
|
||||||
|
m_filename = filename;
|
||||||
|
try {
|
||||||
|
getALLfromExcel();
|
||||||
|
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void ReadExcel::getALLfromDirNormalExcel(QString strFileName)
|
||||||
|
{
|
||||||
|
openExcelForWrite(strFileName);
|
||||||
|
}
|
||||||
|
bool ReadExcel::openExcelForWrite(const QString &filename)
|
||||||
|
{
|
||||||
|
if (filename.isEmpty()) {
|
||||||
|
m_row = 0;
|
||||||
|
m_col = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QFile file(filename);
|
||||||
|
if (!file.exists()){
|
||||||
|
m_row = 0;
|
||||||
|
m_col = 0;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if (!m_mapdata.empty()) {
|
||||||
|
m_mapdata.clear();
|
||||||
|
}
|
||||||
|
m_filename = filename;
|
||||||
|
try {
|
||||||
|
WriteALLfromExcel();
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadExcel::getInfo(int &row, int &col) const
|
||||||
|
{
|
||||||
|
row = m_row;
|
||||||
|
col = m_col;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ReadExcel::getCellData(const int &row, const int &col)
|
||||||
|
{
|
||||||
|
if (row >= 1 && row <= m_row && col >= 1 && col <= m_col) {
|
||||||
|
p.m_row = row;
|
||||||
|
p.m_col = col;
|
||||||
|
return m_mapdata[p];
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int ReadExcel::WriteCellData(const int &row, const int &col,std::string strValue )
|
||||||
|
{
|
||||||
|
p.m_row = row;
|
||||||
|
p.m_col = col;
|
||||||
|
|
||||||
|
m_mapdata[p]=strValue;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadExcel::getALLfromExcel()
|
||||||
|
{
|
||||||
|
m_excel->setProperty("Visible", 0);
|
||||||
|
QAxObject* workbooks = m_excel->querySubObject("WorkBooks");
|
||||||
|
workbooks->dynamicCall("Open (const QString&)", m_filename);
|
||||||
|
QAxObject* workbook = m_excel->querySubObject("ActiveWorkBook");
|
||||||
|
QAxObject* worksheets = workbook->querySubObject("WorkSheets");
|
||||||
|
Q_UNUSED(worksheets)
|
||||||
|
QAxObject* worksheet = workbook->querySubObject("Worksheets(int)", 1); //worksheet number
|
||||||
|
QAxObject* usedrange = worksheet->querySubObject("UsedRange");
|
||||||
|
QAxObject* rows = usedrange->querySubObject("Rows");
|
||||||
|
QAxObject* columns = usedrange->querySubObject("Columns");
|
||||||
|
int intRowStart = usedrange->property("Row").toInt();
|
||||||
|
int intColStart = usedrange->property("Column").toInt();
|
||||||
|
int intCols = columns->property("Count").toInt();
|
||||||
|
int intRows = rows->property("Count").toInt();
|
||||||
|
m_row = intRows;
|
||||||
|
m_col = intCols;
|
||||||
|
QAxObject * cell;
|
||||||
|
for (int i = intRowStart; i < intRowStart + intRows; i++)
|
||||||
|
{
|
||||||
|
for (int j = intColStart; j < intColStart + intCols; j++)
|
||||||
|
{
|
||||||
|
Position pos(i, j);
|
||||||
|
cell = m_excel->querySubObject("Cells(Int, Int)", i, j );
|
||||||
|
QVariant cellValue = cell->dynamicCall("value");
|
||||||
|
m_mapdata.insert(std::pair<Position, std::string>(pos, cellValue.toString().toStdString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_excel->setProperty("DisplayAlerts", 0);
|
||||||
|
workbook->dynamicCall("Save(void)");
|
||||||
|
workbook->dynamicCall("Close (Boolean)", false);
|
||||||
|
m_excel->setProperty("DisplayAlerts",1);
|
||||||
|
}
|
||||||
|
void ReadExcel::WriteALLfromExcel()
|
||||||
|
{
|
||||||
|
m_excel->setProperty("Visible", 0);
|
||||||
|
QAxObject* workbooks = m_excel->querySubObject("WorkBooks");
|
||||||
|
workbooks->dynamicCall("Open (const QString&)", m_filename);
|
||||||
|
QAxObject* workbook = m_excel->querySubObject("ActiveWorkBook");
|
||||||
|
QAxObject* worksheets = workbook->querySubObject("WorkSheets");
|
||||||
|
Q_UNUSED(worksheets)
|
||||||
|
QAxObject* worksheet = workbook->querySubObject("Worksheets(int)", 1); //worksheet number
|
||||||
|
QAxObject* usedrange = worksheet->querySubObject("UsedRange");
|
||||||
|
QAxObject* rows = usedrange->querySubObject("Rows");
|
||||||
|
QAxObject* columns = usedrange->querySubObject("Columns");
|
||||||
|
int intRowStart = usedrange->property("Row").toInt();
|
||||||
|
int intColStart = usedrange->property("Column").toInt();
|
||||||
|
int intCols = columns->property("Count").toInt();
|
||||||
|
int intRows = rows->property("Count").toInt();
|
||||||
|
m_row = intRows;
|
||||||
|
m_col = intCols;
|
||||||
|
QAxObject * cell;
|
||||||
|
for (int i = intRowStart; i < intRowStart + intRows; i++)
|
||||||
|
{
|
||||||
|
for (int j = intColStart; j < intColStart + intCols; j++)
|
||||||
|
{
|
||||||
|
Position pos(i, j);
|
||||||
|
cell = m_excel->querySubObject("Cells(Int, Int)", i, j );
|
||||||
|
QVariant cellValue = cell->dynamicCall("value");
|
||||||
|
m_mapdata.insert(std::pair<Position, std::string>(pos, cellValue.toString().toStdString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_excel->setProperty("DisplayAlerts", 0);
|
||||||
|
workbook->dynamicCall("Save(void)");
|
||||||
|
workbook->dynamicCall("Close (Boolean)", false);
|
||||||
|
m_excel->setProperty("DisplayAlerts",1);
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
#ifndef READEXCEL_H
|
||||||
|
#define READEXCEL_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
#include <QAxObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
|
||||||
|
class Position
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Position() {
|
||||||
|
m_row = 0;
|
||||||
|
m_col = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Position(int row, int col) {
|
||||||
|
m_row = row;
|
||||||
|
m_col = col;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
int m_row;
|
||||||
|
int m_col;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool operator<(const Position & ct) const // 两个const是必需的。
|
||||||
|
{
|
||||||
|
if (m_row < ct.m_row) {
|
||||||
|
return true;
|
||||||
|
} else if (m_row == ct.m_row) {
|
||||||
|
if ( m_col < ct.m_col ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ReadExcel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ReadExcel();
|
||||||
|
~ReadExcel();
|
||||||
|
|
||||||
|
public:
|
||||||
|
//打开excel文件
|
||||||
|
bool openExcel(const QString& filename);
|
||||||
|
void getALLfromDirNormalExcel(QString strFileName);
|
||||||
|
bool openExcelForWrite(const QString &filename);
|
||||||
|
//获取 指定单元格的数据
|
||||||
|
std::string getCellData(const int& row, const int& col);
|
||||||
|
int WriteCellData(const int& row, const int& col,std::string strValue );
|
||||||
|
//获取 行数,列数
|
||||||
|
void getInfo(int& row, int& col) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void getALLfromExcel();
|
||||||
|
void WriteALLfromExcel();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_row; //行
|
||||||
|
int m_col; //列
|
||||||
|
QString m_filename;
|
||||||
|
QAxObject* m_excel;
|
||||||
|
int m_rowWrite; //行
|
||||||
|
int m_colWrite; //列
|
||||||
|
QAxObject* m_excelWrite;
|
||||||
|
|
||||||
|
std::map<Position, std::string> m_mapdata;
|
||||||
|
std::map<Position, std::string> m_mapdataWrite;
|
||||||
|
Position p;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // READEXCEL_H
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "aboutdlg.h"
|
||||||
|
#include "ui_aboutdlg.h"
|
||||||
|
#include "globaldefine.h"
|
||||||
|
AboutDlg::AboutDlg(QWidget *parent) :
|
||||||
|
LoQDialog(parent),
|
||||||
|
ui(new Ui::AboutDlg)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->label_2->setText(APP_VERSION);
|
||||||
|
#ifdef MACRO_YUANHENG_VERSION
|
||||||
|
ui->label_3->setVisible(false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
AboutDlg::~AboutDlg()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef ABOUTDLG_H
|
||||||
|
#define ABOUTDLG_H
|
||||||
|
|
||||||
|
#include <LoQClass/loqdialog.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AboutDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AboutDlg : public LoQDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AboutDlg(QWidget *parent = nullptr);
|
||||||
|
~AboutDlg();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AboutDlg *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ABOUTDLG_H
|
|
@ -0,0 +1,202 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AboutDlg</class>
|
||||||
|
<widget class="QDialog" name="AboutDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>410</width>
|
||||||
|
<height>192</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>About</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>30</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">border-top: 2px solid gray; </string>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">image: url(:/res/Logo.png);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
<pointsize>24</pointsize>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">font: 24pt "Arial";
|
||||||
|
color: rgb(255, 255, 255);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>LedOK Express</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::AutoText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>14</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>V20200429</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>15</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><a href="https://www.ledok.cn/">www.ledok.cn</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>pushButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>AboutDlg</receiver>
|
||||||
|
<slot>close()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>361</x>
|
||||||
|
<y>19</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>193</x>
|
||||||
|
<y>89</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -0,0 +1,144 @@
|
||||||
|
#include "changepasswordform.h"
|
||||||
|
#include "ui_changepasswordform.h"
|
||||||
|
#include <QSettings>
|
||||||
|
#include "loappconfig.h"
|
||||||
|
#include "x_uimsgboxok.h"
|
||||||
|
#include "LoUIClass/taesclass.h"
|
||||||
|
#include "QTextCodec"
|
||||||
|
ChangePasswordForm::ChangePasswordForm(QWidget *parent) :
|
||||||
|
LoQDialog(parent),
|
||||||
|
ui(new Ui::ChangePasswordForm)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
||||||
|
ui->lineEdit_2->setEchoMode(QLineEdit::Password);
|
||||||
|
ui->lineEdit_3->setEchoMode(QLineEdit::Password);
|
||||||
|
ui->pushButton_2->setProperty("ssType", "progManageTool");
|
||||||
|
ui->pushButton_2->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
|
||||||
|
ui->pushButton->setProperty("ssType", "progManageTool");
|
||||||
|
ui->pushButton->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
|
||||||
|
setStyleSheet("background-color: #D8D8D8;");
|
||||||
|
ui->lineEdit->setStyleSheet("background-color: #FFFFFF;");
|
||||||
|
ui->lineEdit_2->setStyleSheet("background-color: #FFFFFF;");
|
||||||
|
ui->lineEdit_3->setStyleSheet("background-color: #FFFFFF;");
|
||||||
|
connect(this, SIGNAL(accepted()), this, SLOT(onAccepted()));
|
||||||
|
connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(onOkButton()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ChangePasswordForm::~ChangePasswordForm()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
void ChangePasswordForm::onAccepted()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void ChangePasswordForm::onOkButton()
|
||||||
|
{
|
||||||
|
//如果旧密码错误
|
||||||
|
LoAppConfig *cfg = LoAppConfig::getInstance();
|
||||||
|
QSettings *settings = new QSettings(cfg->OrganizationName(), cfg->ApplicationName());
|
||||||
|
#ifndef MACRO_YUANHENG_VERSION
|
||||||
|
|
||||||
|
QString strMiWenPs=settings->value("advUiPs").toString();
|
||||||
|
#else
|
||||||
|
QString strMiWenPs=settings->value("advUiPs_YuanHeng").toString();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
QString result = QTextCodec::codecForName("GBK")->toUnicode(QByteArray::fromBase64(strMiWenPs.toLocal8Bit()));
|
||||||
|
// QByteArray miwen = strMiWenPs.toLatin1();
|
||||||
|
// if(miwen.size()>=3)
|
||||||
|
// {
|
||||||
|
// miwen[0]=miwen[0]-'1';
|
||||||
|
// miwen[1]=miwen[1]-'7';
|
||||||
|
// miwen[2]=miwen[2]-'5';
|
||||||
|
// miwen[3]=miwen[3]-'8';
|
||||||
|
// miwen[4]=miwen[4]-'0';
|
||||||
|
// miwen[5]=miwen[5]-'1';
|
||||||
|
// }
|
||||||
|
QString strPs=result;
|
||||||
|
|
||||||
|
|
||||||
|
if(strPs.isEmpty())
|
||||||
|
{
|
||||||
|
#ifndef MACRO_YUANHENG_VERSION
|
||||||
|
strPs = "888";
|
||||||
|
#else
|
||||||
|
strPs = "Cargo10065!@#";
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QString strOldPs=ui->lineEdit->text();
|
||||||
|
if(strOldPs.isEmpty())
|
||||||
|
{
|
||||||
|
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("Please input old password"),this,1);
|
||||||
|
pDlg->exec();
|
||||||
|
ui->lineEdit->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ui->lineEdit->text()!=strPs)
|
||||||
|
{
|
||||||
|
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("Old password is wrong"),this,1);
|
||||||
|
pDlg->exec();
|
||||||
|
ui->lineEdit->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ui->lineEdit_2->text().length()<6)
|
||||||
|
{
|
||||||
|
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("Please enter a password with more than 6 characters"),this,1);
|
||||||
|
pDlg->exec();
|
||||||
|
ui->lineEdit_2->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ui->lineEdit_3->text().length()<6)
|
||||||
|
{
|
||||||
|
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("Please enter a password with more than 6 characters"),this,1);
|
||||||
|
pDlg->exec();
|
||||||
|
ui->lineEdit_3->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ui->lineEdit_2->text()!=ui->lineEdit_3->text())//两次输入新密码不一致
|
||||||
|
{
|
||||||
|
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("The new password is not consistent in two times"),this,1);
|
||||||
|
pDlg->exec();
|
||||||
|
ui->lineEdit_2->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString strNewPs=ui->lineEdit_2->text();
|
||||||
|
if(strNewPs.isEmpty())
|
||||||
|
{
|
||||||
|
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("Please enter a new password"),this,1);
|
||||||
|
pDlg->exec();
|
||||||
|
ui->lineEdit_2->setFocus();
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
QString str=ui->lineEdit_2->text();
|
||||||
|
QByteArray a = str.toLocal8Bit().toBase64();
|
||||||
|
|
||||||
|
QString newStr(a);
|
||||||
|
// QByteArray New_mingwen = str.toLatin1();
|
||||||
|
// New_mingwen[0]=New_mingwen[0]+'1';
|
||||||
|
// New_mingwen[1]=New_mingwen[1]+'7';
|
||||||
|
// New_mingwen[2]=New_mingwen[2]+'5';
|
||||||
|
// New_mingwen[3]=New_mingwen[3]+'8';
|
||||||
|
// New_mingwen[4]=New_mingwen[4]+'0';
|
||||||
|
// New_mingwen[5]=New_mingwen[5]+'1';
|
||||||
|
// QString strtemp=New_mingwen;
|
||||||
|
#ifndef MACRO_YUANHENG_VERSION
|
||||||
|
|
||||||
|
settings->setValue("advUiPs",newStr);
|
||||||
|
#else
|
||||||
|
settings->setValue("advUiPs_YuanHeng",newStr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
X_UIMsgBoxOk *pDlg=new X_UIMsgBoxOk(tr("Tip"),tr("Password changed successfully"),this,1);
|
||||||
|
pDlg->exec();
|
||||||
|
this->accept();
|
||||||
|
// emit sigAcceptData(ui->lineEdit_2->text());
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef CHANGEPASSWORDFORM_H
|
||||||
|
#define CHANGEPASSWORDFORM_H
|
||||||
|
|
||||||
|
#include <LoQClass/loqdialog.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ChangePasswordForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChangePasswordForm : public LoQDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ChangePasswordForm(QWidget *parent = nullptr);
|
||||||
|
~ChangePasswordForm();
|
||||||
|
signals:
|
||||||
|
void sigAcceptData(QString strIP);
|
||||||
|
private:
|
||||||
|
Ui::ChangePasswordForm *ui;
|
||||||
|
protected slots:
|
||||||
|
void onAccepted();
|
||||||
|
void onOkButton();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CHANGEPASSWORDFORM_H
|
|
@ -0,0 +1,135 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ChangePasswordForm</class>
|
||||||
|
<widget class="QWidget" name="ChangePasswordForm">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>236</width>
|
||||||
|
<height>159</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Old password</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit">
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>New password</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_2">
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Repeat again</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_3">
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>OK</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>pushButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>ChangePasswordForm</receiver>
|
||||||
|
<slot>close()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>167</x>
|
||||||
|
<y>126</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>117</x>
|
||||||
|
<y>79</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -0,0 +1,186 @@
|
||||||
|
#include "customprogressindicator.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
|
CustomProgressIndicator::CustomProgressIndicator(QWidget* parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
angle_(0),
|
||||||
|
timerId_(-1),
|
||||||
|
delay_(20),
|
||||||
|
displayedWhenStopped_(false),
|
||||||
|
color_(Qt::green) {
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
setWindowFlags(Qt::FramelessWindowHint);//无窗体
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground);//背景透明
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CustomProgressIndicator::isAnimated () const {
|
||||||
|
return (timerId_ != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomProgressIndicator::setDisplayedWhenStopped(bool state) {
|
||||||
|
displayedWhenStopped_ = state;
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CustomProgressIndicator::isDisplayedWhenStopped() const {
|
||||||
|
return displayedWhenStopped_;
|
||||||
|
}
|
||||||
|
void CustomProgressIndicator::setDisplayModel(int iFlag)
|
||||||
|
{
|
||||||
|
m_iLoopBackFlag=iFlag;
|
||||||
|
}
|
||||||
|
void CustomProgressIndicator::startAnimation() {
|
||||||
|
angle_ = 0;
|
||||||
|
|
||||||
|
if (timerId_ == -1) {
|
||||||
|
timerId_ = startTimer(delay_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CustomProgressIndicator::setDisplayStringInfo(QString strTip,QString strTiping) {
|
||||||
|
m_strTip=strTip;
|
||||||
|
m_strTiping=strTiping;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
void CustomProgressIndicator::stopAnimation() {
|
||||||
|
if (timerId_ != -1) {
|
||||||
|
killTimer(timerId_);
|
||||||
|
}
|
||||||
|
|
||||||
|
timerId_ = -1;
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomProgressIndicator::setAnimationDelay(int delay) {
|
||||||
|
if (timerId_ != -1){
|
||||||
|
killTimer(timerId_);
|
||||||
|
}
|
||||||
|
|
||||||
|
delay_ = delay;
|
||||||
|
|
||||||
|
if (timerId_ != -1){
|
||||||
|
timerId_ = startTimer(delay_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomProgressIndicator::setColor(const QColor & color) {
|
||||||
|
color_ = color;
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize CustomProgressIndicator::sizeHint() const {
|
||||||
|
return QSize(80,80);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CustomProgressIndicator::timerEvent(QTimerEvent * /*event*/) {
|
||||||
|
angle_ = (angle_+30)%360;
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomProgressIndicator::paintEvent(QPaintEvent * /*event*/) {
|
||||||
|
QPainter p(this);
|
||||||
|
|
||||||
|
// if(m_iFlagFinishedSuccess==1)
|
||||||
|
// {
|
||||||
|
// drawUnderCircle(&p);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
drawJuHua(&p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void CustomProgressIndicator::drawJuHua(QPainter *painter)
|
||||||
|
{
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
if (displayedWhenStopped_ && !isAnimated()) //如果displayedWhenStopped_==flash并且动画已经停止则不绘制
|
||||||
|
{
|
||||||
|
painter->setPen(color_);
|
||||||
|
painter->drawPixmap(rect(),currentPix_);
|
||||||
|
painter->drawText(rect(), Qt::AlignCenter, m_strTip);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = qMin(this->width(), this->height());
|
||||||
|
|
||||||
|
|
||||||
|
int outerRadius = (width-1) >> 1;
|
||||||
|
int innerRadius = int(((width-1) >> 1)*0.38);
|
||||||
|
|
||||||
|
int capsuleHeight = outerRadius - innerRadius;
|
||||||
|
int capsuleWidth = (width > 32 ) ? (int)(capsuleHeight *0.23) : (int)(capsuleHeight *0.35);
|
||||||
|
int capsuleRadius = capsuleWidth >> 1;
|
||||||
|
if(m_iLoopBackFlag==1)
|
||||||
|
{
|
||||||
|
painter->setPen(color_);
|
||||||
|
painter->drawText(rect(), Qt::AlignCenter, m_strTiping);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* 撰写进度 */
|
||||||
|
if (progress_ > 0 && progress_ < 100) {
|
||||||
|
painter->setPen(color_);
|
||||||
|
painter->drawText(rect(), Qt::AlignCenter, QString("%1%").arg(progress_));
|
||||||
|
}
|
||||||
|
else if (progress_ == 100) {
|
||||||
|
stopAnimation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<12; ++i) {
|
||||||
|
QColor color = color_;
|
||||||
|
color.setAlphaF(1.0f - (i/12.0f));
|
||||||
|
painter->setPen(Qt::NoPen);
|
||||||
|
painter->setBrush(color);
|
||||||
|
painter->save();
|
||||||
|
painter->translate(rect().center());
|
||||||
|
painter->rotate(angle_ - i*30.0f);
|
||||||
|
painter->drawRoundedRect(((-capsuleWidth) >> 1), -(innerRadius+capsuleHeight), capsuleWidth, capsuleHeight, capsuleRadius, capsuleRadius);
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//没有使用的画圆环函数
|
||||||
|
void CustomProgressIndicator::drawUnderCircle(QPainter *painter)
|
||||||
|
{
|
||||||
|
int bigradius = 50;
|
||||||
|
painter->save();
|
||||||
|
painter->setPen(color_);
|
||||||
|
painter->setBrush(color_);
|
||||||
|
|
||||||
|
QPainterPath bigCircle;
|
||||||
|
bigCircle.addEllipse(-width()/2, -height()/2, bigradius*2, bigradius*2);
|
||||||
|
|
||||||
|
int smallradius = 40;
|
||||||
|
QPainterPath smallCircle;
|
||||||
|
smallCircle.addEllipse(-width()/2, -height()/2, smallradius*2, smallradius*2);
|
||||||
|
|
||||||
|
QPainterPath path = bigCircle - smallCircle;
|
||||||
|
painter->drawPath(path);
|
||||||
|
painter->setPen(color_);
|
||||||
|
painter->drawText(rect(), Qt::AlignCenter, m_strTip);
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
/* painter->save();
|
||||||
|
painter->setPen(color_);
|
||||||
|
painter->setBrush(color_);
|
||||||
|
int m_outerRadius=width()>height()?(qreal)height()/2-4:(qreal)width()/2-4;//求最小的那个值。自己可以测试一下减4个像素与不减的区别
|
||||||
|
QPointF TopLeft(rect().center().x() - m_outerRadius,rect().center().y() - m_outerRadius);
|
||||||
|
QPointF BottomRight(rect().center().x() + m_outerRadius,rect().center().y() + m_outerRadius);
|
||||||
|
QRectF CircleRect(TopLeft,BottomRight);//大圆矩形
|
||||||
|
|
||||||
|
//painter->setPen(Qt::NoPen);//大家可以注释掉这行看一下,有什么差别?
|
||||||
|
painter->drawEllipse(CircleRect);//画椭圆,其实就是画圆。特殊椭圆而已
|
||||||
|
painter->setPen(Qt::white);
|
||||||
|
painter->drawText(rect(), Qt::AlignCenter, m_strTip);
|
||||||
|
painter->restore();*/
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
#ifndef CUSTOMPROGRESSINDICATOR_H
|
||||||
|
#define CUSTOMPROGRESSINDICATOR_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QTimer>
|
||||||
|
/*
|
||||||
|
* 菊花转 进度类,基于代码无需图片资源
|
||||||
|
* 作者:陈鲁勇
|
||||||
|
* 邮箱:727057301@qq.com
|
||||||
|
* 创建时间:2017年2月10日16:26:48
|
||||||
|
* QT版本:5.0.2
|
||||||
|
* CSDN:http://blog.csdn.net/csnd_ayo
|
||||||
|
* **************************************
|
||||||
|
* 说明:
|
||||||
|
* 使用前请确保在QT.pro中加入 C++11 的支持
|
||||||
|
*
|
||||||
|
* 示例代码:
|
||||||
|
|
||||||
|
pIndicator = new CustomProgressIndicator(this);
|
||||||
|
pIndicator->setColor(Qt::red);
|
||||||
|
pIndicator->startAnimation();
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CustomProgressIndicator : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int delay READ animationDelay WRITE setAnimationDelay)
|
||||||
|
Q_PROPERTY(bool displayedWhenStopped READ isDisplayedWhenStopped WRITE setDisplayedWhenStopped)
|
||||||
|
Q_PROPERTY(QColor color READ color WRITE setColor)
|
||||||
|
public:
|
||||||
|
CustomProgressIndicator(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
int animationDelay() const { return delay_; }
|
||||||
|
|
||||||
|
/* 动画是否正在进行中 */
|
||||||
|
bool isAnimated () const;
|
||||||
|
|
||||||
|
/* 动画完毕后,是否隐藏菊花转 */
|
||||||
|
bool isDisplayedWhenStopped() const;
|
||||||
|
|
||||||
|
/* 当前菊花转的颜色 */
|
||||||
|
const QColor & color() const { return color_; }
|
||||||
|
|
||||||
|
/* 虚函数:当前大小 */
|
||||||
|
virtual QSize sizeHint() const;
|
||||||
|
|
||||||
|
void setBackground(const QString& _icon) {
|
||||||
|
currentPix_ = QPixmap(_icon);
|
||||||
|
}
|
||||||
|
signals:
|
||||||
|
void Finished(void);
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
/* 开始动画 */
|
||||||
|
void startAnimation();
|
||||||
|
|
||||||
|
/* 停止动画 */
|
||||||
|
void stopAnimation();
|
||||||
|
/* 设置停止菊花,显示圆圈加对号*/
|
||||||
|
void setDisplayStringInfo(QString strTip,QString strTiping);
|
||||||
|
void setDisplayModel(int iFlag);//iFlag 0:表示进度统计,1:表示strTiping提示,结束后显示strTip
|
||||||
|
|
||||||
|
/* 设置菊花转的转速 */
|
||||||
|
void setAnimationDelay(int delay);
|
||||||
|
|
||||||
|
/* 动画完毕后,是否隐藏菊花转 */
|
||||||
|
void setDisplayedWhenStopped(bool state);
|
||||||
|
|
||||||
|
/* 设置菊花转颜色 */
|
||||||
|
void setColor(const QColor & color);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 进度
|
||||||
|
* 参数 _progress:当前进度 0 < _progress < 100
|
||||||
|
*/
|
||||||
|
void onProgress(QString msg, int _progress, bool done)
|
||||||
|
{
|
||||||
|
Q_UNUSED(msg)
|
||||||
|
progress_ = _progress;
|
||||||
|
if(done)
|
||||||
|
{
|
||||||
|
progress_=100;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
/* 系统基类函数 */
|
||||||
|
virtual void timerEvent(QTimerEvent * event);
|
||||||
|
virtual void paintEvent(QPaintEvent * event);
|
||||||
|
|
||||||
|
void drawUnderCircle(QPainter *painter);
|
||||||
|
void drawJuHua(QPainter *painter);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/* 角度 */
|
||||||
|
unsigned int angle_;
|
||||||
|
/* 定时器ID */
|
||||||
|
int timerId_;
|
||||||
|
/* 转速 */
|
||||||
|
int delay_;
|
||||||
|
/* 是否隐藏 */
|
||||||
|
bool displayedWhenStopped_;
|
||||||
|
/* 菊花转颜色 */
|
||||||
|
QColor color_;
|
||||||
|
/* 进度 */
|
||||||
|
int progress_;
|
||||||
|
/* 背景图 */
|
||||||
|
QPixmap currentPix_;
|
||||||
|
/*显示圆圈中的字符串内容*/
|
||||||
|
QString m_strTip = "";
|
||||||
|
QString m_strTiping = "";
|
||||||
|
int m_iLoopBackFlag = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CUSTOMPROGRESSINDICATOR_H
|