draw instrument
This commit is contained in:
+2
-2
@@ -46,8 +46,8 @@ QSize GetDesktopSize() {
|
|||||||
|
|
||||||
return QSize(lcd_width, lcd_height);
|
return QSize(lcd_width, lcd_height);
|
||||||
#endif
|
#endif
|
||||||
|
//return QSize(800, 480);
|
||||||
return QSize(800, 480);
|
return QSize(1600, 800);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckDir(const QString &path) {
|
void CheckDir(const QString &path) {
|
||||||
|
|||||||
+5
-5
@@ -20,12 +20,12 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
nav = new QNavigationWidget(this);
|
nav = new QNavigationWidget(this);
|
||||||
|
|
||||||
copk = new Cockpit(this);
|
copk = new Cockpit(this);
|
||||||
|
|
||||||
copk->setGeometry(this->width() - copk->width(),0,copk->width(),copk->height());
|
copk->setGeometry(this->width() - copk->width(),0,700,this->height());
|
||||||
|
|
||||||
|
|
||||||
nav->setGeometry(0,0,50,this->height());
|
nav->setGeometry(0,0,50,this->height());
|
||||||
|
|
||||||
|
|
||||||
nav->setRowHeight(50);
|
nav->setRowHeight(50);
|
||||||
@@ -71,7 +71,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
map->SetMapType(mapcontrol::Helper::MapTypeFromString("BingSatellite"));
|
map->SetMapType(mapcontrol::Helper::MapTypeFromString("BingSatellite"));
|
||||||
map->setGeometry(nav->width(),
|
map->setGeometry(nav->width(),
|
||||||
0,
|
0,
|
||||||
this->width() - nav->width(),
|
this->width() - nav->width() - copk->width(),
|
||||||
this->height());
|
this->height());
|
||||||
|
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ void MainWindow::resizeEvent(QResizeEvent *e)
|
|||||||
|
|
||||||
map->setGeometry(nav->width(),
|
map->setGeometry(nav->width(),
|
||||||
0,
|
0,
|
||||||
this->width() - nav->width(),
|
this->width() - nav->width() - copk->width(),
|
||||||
this->height());
|
this->height());
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|||||||
+214
-51
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
||||||
{
|
{
|
||||||
setMouseTracking(true);
|
// setMouseTracking(true);
|
||||||
//GPS初始化
|
//GPS初始化
|
||||||
m_GPS.fixtype = 0;
|
m_GPS.fixtype = 0;
|
||||||
m_GPS.svn = 0;
|
m_GPS.svn = 0;
|
||||||
@@ -37,48 +37,11 @@ Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
|||||||
m_Attitude.horizontalspeed = 0;//侧滑速度
|
m_Attitude.horizontalspeed = 0;//侧滑速度
|
||||||
m_Attitude.verticalspeed = 0;//爬升速度
|
m_Attitude.verticalspeed = 0;//爬升速度
|
||||||
|
|
||||||
m_Battery.current = 0;
|
m_Battery.current[0] = 0;
|
||||||
m_Battery.voltage = 0;
|
m_Battery.voltage[0] = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
m_GroundColor = QColor("#8B5A2B");
|
||||||
m_PitchValue = 0;
|
|
||||||
m_RollValue = 0;
|
|
||||||
m_YawValue = 0;
|
|
||||||
m_CourseValue = 0;
|
|
||||||
|
|
||||||
m_GPSAltitudeValue = 0;
|
|
||||||
m_PressureAltitudeValue = 0;
|
|
||||||
|
|
||||||
m_gps_altitude = 21.6;
|
|
||||||
m_pre_altitude = 0;
|
|
||||||
|
|
||||||
m_gps_speed = 0;
|
|
||||||
m_air_speed = 0;
|
|
||||||
|
|
||||||
m_CtrlModeValue = "自动";
|
|
||||||
m_AirplaneModeValue = "固定翼";
|
|
||||||
m_CurrentStatusValue = "起飞";
|
|
||||||
m_LockStatusValue = "未解锁";
|
|
||||||
m_TurningStatusValue = "直飞";
|
|
||||||
|
|
||||||
m_GPSStatusValue = 0;//GPS无效
|
|
||||||
m_GPSStarValue = 0;//卫星数0
|
|
||||||
|
|
||||||
m_Protect = 0;
|
|
||||||
|
|
||||||
//m_Pitch_Roll_MinValue = -90;
|
|
||||||
//m_Pitch_Roll_MaxValue = +90;
|
|
||||||
m_Yaw_MinValue = -180;
|
|
||||||
m_Yaw_MaxValue = 360;
|
|
||||||
m_CourseMinValue = 0;
|
|
||||||
m_CourseMaxValue = 360;
|
|
||||||
|
|
||||||
m_BatteryMinValue = 21.2;//6s
|
|
||||||
m_BatteryMaxValue = 25.2;
|
|
||||||
m_BatteryValue = 25.8;
|
|
||||||
*/
|
|
||||||
m_GroundColor = QColor("#B8860B");
|
|
||||||
m_SkyColor = QColor("#5CACEE");
|
m_SkyColor = QColor("#5CACEE");
|
||||||
|
|
||||||
m_ForeColor = Qt::darkGray;
|
m_ForeColor = Qt::darkGray;
|
||||||
@@ -86,8 +49,17 @@ Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
|||||||
|
|
||||||
m_LedColor = Qt::green;
|
m_LedColor = Qt::green;
|
||||||
|
|
||||||
setMinimumSize(QSize(10, 10));
|
m_TargetColor = QColor("#B23AEE");
|
||||||
resize(600, 200);
|
m_CurrentColor = QColor("#FFFFFF");
|
||||||
|
|
||||||
|
m_WColor = QColor("#458B00");
|
||||||
|
|
||||||
|
|
||||||
|
//setMinimumSize(QSize(10, 10));
|
||||||
|
//resize(600, 200);
|
||||||
|
|
||||||
|
//qDebug() << "here";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +75,10 @@ void Cockpit::mousePressEvent(QMouseEvent *e)
|
|||||||
m_LedColor = Qt::blue;
|
m_LedColor = Qt::blue;
|
||||||
|
|
||||||
m_c = this->pos();
|
m_c = this->pos();
|
||||||
|
|
||||||
|
setPitch(m_Attitude.pitch + e->x());
|
||||||
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +90,12 @@ void Cockpit::mouseDoubleClickEvent(QMouseEvent *e)
|
|||||||
void Cockpit::wheelEvent(QWheelEvent *e)
|
void Cockpit::wheelEvent(QWheelEvent *e)
|
||||||
{
|
{
|
||||||
qDebug() << "wheel event" << e;
|
qDebug() << "wheel event" << e;
|
||||||
|
|
||||||
|
setRoll(m_Attitude.roll + e->angleDelta().y()/120.0f);
|
||||||
|
setPitch(m_Attitude.pitch + e->angleDelta().y()/120.0f);
|
||||||
|
|
||||||
|
qDebug() << "wheel event" << m_Attitude.roll << m_Attitude.pitch;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +191,7 @@ void Cockpit::setAirSpeed(double speed)
|
|||||||
|
|
||||||
void Cockpit::setVoltage(double Voltage)
|
void Cockpit::setVoltage(double Voltage)
|
||||||
{
|
{
|
||||||
m_Battery.voltage = Voltage;
|
m_Battery.voltage[0] = Voltage;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +212,9 @@ void Cockpit::paintEvent(QPaintEvent *)
|
|||||||
painter.scale(side / 2000.0, side / 2000.0); /* 比例缩放 */
|
painter.scale(side / 2000.0, side / 2000.0); /* 比例缩放 */
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
|
|
||||||
//drawAttitude(&painter);
|
drawPitch(&painter);
|
||||||
|
drawRoll(&painter);
|
||||||
|
drawRollScale(&painter);
|
||||||
//drawYawScale(&painter);
|
//drawYawScale(&painter);
|
||||||
//drawScale(&painter);
|
//drawScale(&painter);
|
||||||
//drawCenterLine(&painter);
|
//drawCenterLine(&painter);
|
||||||
@@ -244,6 +228,16 @@ void Cockpit::paintEvent(QPaintEvent *)
|
|||||||
|
|
||||||
|
|
||||||
//drawLowPanel(&painter);
|
//drawLowPanel(&painter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,22 +252,191 @@ void Cockpit::drawLed(QPainter *painter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//使用translate对一幅大图进行平移/旋转变换
|
//使用translate对一幅大图进行平移/旋转变换
|
||||||
//画姿态roll pitch yaw gx gy gz
|
//画姿态roll pitch
|
||||||
void Cockpit::drawAttitude(QPainter *painter)
|
void Cockpit::drawPitch(QPainter *painter)
|
||||||
{
|
{
|
||||||
//画俯仰和滚转
|
//画俯仰
|
||||||
QRectF bluerect(-4000,-4000,8000,4000);
|
QRectF bluerect(-4000,-4000,8000,4000);
|
||||||
QRectF yellowrect(-4000,0,8000,4000);
|
QRectF yellowrect(-4000,0,8000,4000);
|
||||||
|
//QRectF whiterect(-4000,-8,8000,16);
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->translate(0,m_Attitude.pitch/90.0f * 1000);
|
painter->translate(0,m_Attitude.pitch/45.0f * 1000);
|
||||||
painter->rotate(-m_Attitude.roll);
|
|
||||||
painter->setBrush(m_SkyColor);
|
painter->setBrush(m_SkyColor);
|
||||||
painter->drawRect(bluerect);
|
painter->drawRect(bluerect);
|
||||||
painter->setBrush(m_GroundColor);
|
painter->setBrush(m_GroundColor);
|
||||||
painter->drawRect(yellowrect);
|
painter->drawRect(yellowrect);
|
||||||
|
//painter->setBrush(QColor("#FFFFFF"));
|
||||||
|
//painter->drawRect(whiterect);
|
||||||
|
|
||||||
|
//俯仰刻度线
|
||||||
|
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
//画航向
|
void Cockpit::drawRoll(QPainter *painter)
|
||||||
|
{
|
||||||
|
//画俯仰和滚转
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
painter->rotate(m_Attitude.roll);
|
||||||
|
|
||||||
|
//画绿色W和顶部滚转
|
||||||
|
|
||||||
|
|
||||||
|
static const QPointF W_Line[7] = {
|
||||||
|
QPointF(-350, 0),
|
||||||
|
QPointF(-100, 0),
|
||||||
|
QPointF(-50, 100),
|
||||||
|
QPointF( 0,-100),
|
||||||
|
QPointF( 50, 100),
|
||||||
|
QPointF( 100, 0),
|
||||||
|
QPointF( 300, 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
QPen pen;
|
||||||
|
pen.setWidth(10);
|
||||||
|
pen.setColor(m_WColor);
|
||||||
|
painter->setPen(pen);
|
||||||
|
painter->drawPolyline(W_Line,7);
|
||||||
|
|
||||||
|
|
||||||
|
if((m_Attitude.roll >= -60)&&(m_Attitude.roll <= 60))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
//画紫色小三角形
|
||||||
|
static const QPointF points1[3] = {
|
||||||
|
QPointF(-50,-620),
|
||||||
|
QPointF(0,-690),
|
||||||
|
QPointF(50,-620)
|
||||||
|
};
|
||||||
|
|
||||||
|
pen.setWidth(1);
|
||||||
|
pen.setColor(m_TargetColor);
|
||||||
|
painter->setPen(pen);
|
||||||
|
painter->setBrush(m_TargetColor);
|
||||||
|
painter->drawPolygon(points1,3);
|
||||||
|
|
||||||
|
|
||||||
|
//画白色小三角形
|
||||||
|
static const QPointF points2[3] = {
|
||||||
|
QPointF(-50,-800),
|
||||||
|
QPointF(0,-710),
|
||||||
|
QPointF(50,-800)
|
||||||
|
};
|
||||||
|
|
||||||
|
pen.setWidth(1);
|
||||||
|
pen.setColor(m_CurrentColor);
|
||||||
|
painter->setPen(pen);
|
||||||
|
painter->setBrush(m_CurrentColor);
|
||||||
|
painter->drawPolygon(points2,3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cockpit::drawRollScale(QPainter *painter)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
QPen ePen;
|
||||||
|
ePen.setColor(m_CentreLineColor);
|
||||||
|
ePen.setWidth(10);
|
||||||
|
QFont font;
|
||||||
|
font.setPointSize(60);
|
||||||
|
|
||||||
|
painter->setPen(ePen);
|
||||||
|
painter->setFont(font);
|
||||||
|
painter->drawArc(-700,-700,1400,1400,30*16,120*16);
|
||||||
|
|
||||||
|
//中间 两块黑块
|
||||||
|
|
||||||
|
static const QPointF points1[6] = {
|
||||||
|
QPointF(-700, 0),
|
||||||
|
QPointF(-400, 0),
|
||||||
|
QPointF(-400, 100),
|
||||||
|
QPointF(-450, 100),
|
||||||
|
QPointF(-450, 50),
|
||||||
|
QPointF(-700, 50)
|
||||||
|
};
|
||||||
|
static const QPointF points2[6] = {
|
||||||
|
QPointF(700, 0),
|
||||||
|
QPointF(400, 0),
|
||||||
|
QPointF(400, 100),
|
||||||
|
QPointF(450, 100),
|
||||||
|
QPointF(450, 50),
|
||||||
|
QPointF(700, 50)
|
||||||
|
};
|
||||||
|
|
||||||
|
painter->setBrush(QColor("#000000"));
|
||||||
|
painter->drawPolygon(points1, 6);
|
||||||
|
painter->drawPolygon(points2, 6);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//大刻度盘
|
||||||
|
for(int i = -60;i<=60;i+=10)
|
||||||
|
{
|
||||||
|
//QString strText = QString::number(i); //设置当前字体
|
||||||
|
painter->save();
|
||||||
|
painter->translate(0,0);
|
||||||
|
painter->rotate(-i);
|
||||||
|
if((i%20) == 0)
|
||||||
|
painter->drawLine(0,-700,0,-740);
|
||||||
|
else
|
||||||
|
painter->drawLine(0,-700,0,-720);
|
||||||
|
//painter->drawText(-30,-750, strText);
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
m_Max_Roll = m_RollValue + 60;
|
||||||
|
m_Min_Roll = m_RollValue - 60;
|
||||||
|
|
||||||
|
|
||||||
|
//俯仰刻度表
|
||||||
|
float h = 1000.0f/45.0f;//单位高度
|
||||||
|
|
||||||
|
|
||||||
|
for(int i = -20;i<=20;i+=1)
|
||||||
|
{
|
||||||
|
|
||||||
|
QString strText = QString::number(qAbs(i)); //设置当前字体
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
if((i%10) == 0)
|
||||||
|
{
|
||||||
|
if(i!=0){
|
||||||
|
painter->drawLine(-290,i * h,290,i * h);
|
||||||
|
painter->drawText(-380,i * h + 30, strText);//减去字体的一半
|
||||||
|
painter->drawText( 300,i * h + 30, strText);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if((i%5) == 0)
|
||||||
|
{
|
||||||
|
painter->drawLine(-100,i * h,100,i * h);
|
||||||
|
painter->drawText(-180,i * h+ 30, strText);
|
||||||
|
painter->drawText( 110,i * h+ 30, strText);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
}
|
||||||
|
//画航向(位于底部的一个圈)
|
||||||
void Cockpit::drawYawScale(QPainter *painter)
|
void Cockpit::drawYawScale(QPainter *painter)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
+16
-3
@@ -48,11 +48,13 @@ typedef struct {
|
|||||||
float verticalspeed;
|
float verticalspeed;
|
||||||
float horizontalspeed;
|
float horizontalspeed;
|
||||||
|
|
||||||
|
float distofly;
|
||||||
|
|
||||||
}_attitude;
|
}_attitude;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float voltage;
|
float voltage[10];
|
||||||
float current;
|
float current[10];
|
||||||
}_battery;
|
}_battery;
|
||||||
|
|
||||||
_gps m_GPS;
|
_gps m_GPS;
|
||||||
@@ -93,7 +95,11 @@ protected:
|
|||||||
|
|
||||||
void drawLed(QPainter *painter);
|
void drawLed(QPainter *painter);
|
||||||
|
|
||||||
void drawAttitude(QPainter *painter);
|
void drawPitch(QPainter *painter);
|
||||||
|
void drawRoll(QPainter *painter);
|
||||||
|
void drawRollScale(QPainter *painter);
|
||||||
|
|
||||||
|
|
||||||
void drawYawScale(QPainter *painter);
|
void drawYawScale(QPainter *painter);
|
||||||
void drawScale(QPainter *painter);
|
void drawScale(QPainter *painter);
|
||||||
void drawCenterLine(QPainter *painter);
|
void drawCenterLine(QPainter *painter);
|
||||||
@@ -109,6 +115,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
QString m_mode;//显示模式
|
||||||
|
|
||||||
|
|
||||||
double m_PitchValue;
|
double m_PitchValue;
|
||||||
double m_RollValue;
|
double m_RollValue;
|
||||||
@@ -172,6 +180,11 @@ private:
|
|||||||
|
|
||||||
QColor m_LedColor;
|
QColor m_LedColor;
|
||||||
|
|
||||||
|
QColor m_CurrentColor;
|
||||||
|
QColor m_TargetColor;
|
||||||
|
|
||||||
|
QColor m_WColor;
|
||||||
|
|
||||||
QPoint m_c;
|
QPoint m_c;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
@@ -12,7 +12,9 @@ QNavigationWidget::QNavigationWidget(QWidget *parent) : QWidget(parent)
|
|||||||
MouseIndex = -1;
|
MouseIndex = -1;
|
||||||
|
|
||||||
|
|
||||||
controlBarColor = "#87CEFF";
|
controlBarColor = "#CAE1FF";
|
||||||
|
controlSlideColor = "#1E90FF";
|
||||||
|
|
||||||
|
|
||||||
controlBarWidth = 10;
|
controlBarWidth = 10;
|
||||||
|
|
||||||
@@ -86,21 +88,51 @@ void QNavigationWidget::paintEvent(QPaintEvent *)
|
|||||||
painter.drawRect(rect());
|
painter.drawRect(rect());
|
||||||
|
|
||||||
|
|
||||||
painter.setBrush(QColor(backgroundColor));
|
|
||||||
painter.drawRect(width() - controlBarWidth, 0, controlBarWidth,height());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//QPainterPath MenuPath;
|
|
||||||
//MenuPath.addRect(QRect(width() - controlBarWidth,0,controlBarWidth, height()));
|
|
||||||
//painter.setPen("#202020");
|
|
||||||
//painter.fillPath(MenuPath, QColor("#202020"));
|
|
||||||
|
|
||||||
if(!isHidden)
|
if(!isHidden)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QPainterPath MenuPath;
|
||||||
|
MenuPath.addRect(QRect(width() - controlBarWidth,0,controlBarWidth, height()));
|
||||||
|
painter.setPen("#202020");
|
||||||
|
painter.fillPath(MenuPath, QColor(controlBarColor));
|
||||||
|
|
||||||
|
|
||||||
|
int h = height()/2;
|
||||||
|
|
||||||
|
QPolygon polygon1,polygon2,polygon3,polygon4;
|
||||||
|
|
||||||
|
polygon1.setPoints(4,
|
||||||
|
width() - controlBarWidth,h ,
|
||||||
|
width(), h - controlBarWidth,
|
||||||
|
width(), h - 3 * controlBarWidth / 2,
|
||||||
|
width() - controlBarWidth,h - controlBarWidth / 2);
|
||||||
|
|
||||||
|
polygon2.setPoints(4,
|
||||||
|
width() - controlBarWidth,h ,
|
||||||
|
width(), h + controlBarWidth,
|
||||||
|
width(), h + 3 * controlBarWidth / 2,
|
||||||
|
width() - controlBarWidth,h + controlBarWidth / 2);
|
||||||
|
|
||||||
|
polygon3.setPoints(4,
|
||||||
|
width() - controlBarWidth,h - controlBarWidth ,
|
||||||
|
width(), h - 2 * controlBarWidth,
|
||||||
|
width(), h - 5 * controlBarWidth /2,
|
||||||
|
width() - controlBarWidth,h - 3 * controlBarWidth /2);
|
||||||
|
|
||||||
|
polygon4.setPoints(4,
|
||||||
|
width() - controlBarWidth,h + controlBarWidth ,
|
||||||
|
width(), h + 2 * controlBarWidth,
|
||||||
|
width(), h + 5 * controlBarWidth /2,
|
||||||
|
width() - controlBarWidth,h + 3 * controlBarWidth /2);
|
||||||
|
|
||||||
|
QPainterPath SlidePath;
|
||||||
|
|
||||||
|
SlidePath.addRegion(polygon1);
|
||||||
|
SlidePath.addRegion(polygon2);
|
||||||
|
SlidePath.addRegion(polygon3);
|
||||||
|
SlidePath.addRegion(polygon4);
|
||||||
|
|
||||||
|
painter.fillPath(SlidePath, QColor(controlSlideColor));
|
||||||
|
|
||||||
|
|
||||||
// Draw Items
|
// Draw Items
|
||||||
@@ -141,7 +173,47 @@ void QNavigationWidget::paintEvent(QPaintEvent *)
|
|||||||
QPainterPath MenuPath;
|
QPainterPath MenuPath;
|
||||||
MenuPath.addRect(QRect(0,0,controlBarWidth, height()));
|
MenuPath.addRect(QRect(0,0,controlBarWidth, height()));
|
||||||
painter.setPen("#202020");
|
painter.setPen("#202020");
|
||||||
painter.fillPath(MenuPath, QColor(backgroundColor));
|
painter.fillPath(MenuPath, QColor(controlBarColor));
|
||||||
|
|
||||||
|
|
||||||
|
int h = height()/2;
|
||||||
|
|
||||||
|
QPolygon polygon1,polygon2,polygon3,polygon4;
|
||||||
|
|
||||||
|
polygon1.setPoints(4,
|
||||||
|
controlBarWidth,h ,
|
||||||
|
0, h - controlBarWidth,
|
||||||
|
0, h - 3 * controlBarWidth / 2,
|
||||||
|
controlBarWidth,h - controlBarWidth / 2);
|
||||||
|
|
||||||
|
polygon2.setPoints(4,
|
||||||
|
controlBarWidth,h ,
|
||||||
|
0, h + controlBarWidth,
|
||||||
|
0, h + 3 * controlBarWidth / 2,
|
||||||
|
controlBarWidth,h + controlBarWidth / 2);
|
||||||
|
|
||||||
|
polygon3.setPoints(4,
|
||||||
|
controlBarWidth,h - controlBarWidth ,
|
||||||
|
0, h - 2 * controlBarWidth,
|
||||||
|
0, h - 5 * controlBarWidth /2,
|
||||||
|
controlBarWidth,h - 3 * controlBarWidth /2);
|
||||||
|
|
||||||
|
polygon4.setPoints(4,
|
||||||
|
controlBarWidth,h + controlBarWidth ,
|
||||||
|
0, h + 2 * controlBarWidth,
|
||||||
|
0, h + 5 * controlBarWidth /2,
|
||||||
|
controlBarWidth,h + 3 * controlBarWidth /2);
|
||||||
|
|
||||||
|
QPainterPath SlidePath;
|
||||||
|
|
||||||
|
SlidePath.addRegion(polygon1);
|
||||||
|
SlidePath.addRegion(polygon2);
|
||||||
|
SlidePath.addRegion(polygon3);
|
||||||
|
SlidePath.addRegion(polygon4);
|
||||||
|
|
||||||
|
painter.fillPath(SlidePath, QColor(controlSlideColor));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +270,7 @@ void QNavigationWidget::mousePressEvent(QMouseEvent *e)
|
|||||||
if(isHidden){
|
if(isHidden){
|
||||||
|
|
||||||
setWidth(controlBarWidth);
|
setWidth(controlBarWidth);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setWidth(150);
|
setWidth(150);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ private:
|
|||||||
QString MouseColor;
|
QString MouseColor;
|
||||||
|
|
||||||
QString controlBarColor;
|
QString controlBarColor;
|
||||||
|
QString controlSlideColor;
|
||||||
|
|
||||||
int controlBarWidth = 10;
|
int controlBarWidth = 10;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user