923 lines
26 KiB
C++
923 lines
26 KiB
C++
|
|
#include "controlactionwidget.h"
|
|||
|
|
#include "ui_controlactionwidget.h"
|
|||
|
|
|
|||
|
|
ControlActionWidget::ControlActionWidget(QWidget *parent) :
|
|||
|
|
QWidget(parent),
|
|||
|
|
ui(new Ui::ControlActionWidget),
|
|||
|
|
m_itemPerPage(8),
|
|||
|
|
m_btnPerRow(5)
|
|||
|
|
{
|
|||
|
|
ui->setupUi(this);
|
|||
|
|
|
|||
|
|
setWindowFlags (Qt::Window | Qt::FramelessWindowHint);
|
|||
|
|
setWindowModality(Qt::ApplicationModal);
|
|||
|
|
|
|||
|
|
m_mousePressX = 0;
|
|||
|
|
m_mousePressY = 0;
|
|||
|
|
m_mouseReleaseX = 0;
|
|||
|
|
m_mouseReleaseY = 0;
|
|||
|
|
|
|||
|
|
m_speed = 0;
|
|||
|
|
|
|||
|
|
this->move(0+g_mainWidgetPos.x(),0+g_mainWidgetPos.y());
|
|||
|
|
|
|||
|
|
m_curPage = 0;
|
|||
|
|
m_itemList.clear();
|
|||
|
|
m_allItemList.clear();
|
|||
|
|
initControl();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ControlActionWidget::~ControlActionWidget()
|
|||
|
|
{
|
|||
|
|
delete ui;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//初始化窗体控件,包括位置、尺寸、样式
|
|||
|
|
void ControlActionWidget::initControl()
|
|||
|
|
{
|
|||
|
|
m_itemFrameList.clear();
|
|||
|
|
m_itemFrameList.append(ui->frame1);
|
|||
|
|
m_itemFrameList.append(ui->frame2);
|
|||
|
|
m_itemFrameList.append(ui->frame3);
|
|||
|
|
m_itemFrameList.append(ui->frame4);
|
|||
|
|
m_itemFrameList.append(ui->frame5);
|
|||
|
|
ui->frame6->setVisible(false);
|
|||
|
|
ui->frame7->setVisible(false);
|
|||
|
|
ui->frame8->setVisible(false);
|
|||
|
|
ui->frame9->setVisible(false);
|
|||
|
|
ui->frame10->setVisible(false);
|
|||
|
|
ui->frame11->setVisible(false);
|
|||
|
|
ui->frame12->setVisible(false);
|
|||
|
|
ui->frame6->setVisible(true);//显示
|
|||
|
|
ui->frame7->setVisible(true);
|
|||
|
|
ui->frame8->setVisible(true);
|
|||
|
|
m_itemFrameList.append(ui->frame6);
|
|||
|
|
m_itemFrameList.append(ui->frame7);
|
|||
|
|
m_itemFrameList.append(ui->frame8);
|
|||
|
|
|
|||
|
|
m_itemLabelList.clear();
|
|||
|
|
m_itemLabelList.append(ui->label1);
|
|||
|
|
m_itemLabelList.append(ui->label2);
|
|||
|
|
m_itemLabelList.append(ui->label3);
|
|||
|
|
m_itemLabelList.append(ui->label4);
|
|||
|
|
m_itemLabelList.append(ui->label5);
|
|||
|
|
m_itemLabelList.append(ui->label6);
|
|||
|
|
m_itemLabelList.append(ui->label7);
|
|||
|
|
m_itemLabelList.append(ui->label8);
|
|||
|
|
m_itemLabelList.append(ui->label9);
|
|||
|
|
m_itemLabelList.append(ui->label10);
|
|||
|
|
m_itemLabelList.append(ui->label11);
|
|||
|
|
m_itemLabelList.append(ui->label12);
|
|||
|
|
|
|||
|
|
m_itemBtnList.clear();
|
|||
|
|
m_itemBtnList.append(ui->button1_1);
|
|||
|
|
m_itemBtnList.append(ui->button1_2);
|
|||
|
|
m_itemBtnList.append(ui->button1_3);
|
|||
|
|
m_itemBtnList.append(ui->button1_4);
|
|||
|
|
m_itemBtnList.append(ui->button1_5);
|
|||
|
|
m_itemBtnList.append(ui->button2_1);
|
|||
|
|
m_itemBtnList.append(ui->button2_2);
|
|||
|
|
m_itemBtnList.append(ui->button2_3);
|
|||
|
|
m_itemBtnList.append(ui->button2_4);
|
|||
|
|
m_itemBtnList.append(ui->button2_5);
|
|||
|
|
m_itemBtnList.append(ui->button3_1);
|
|||
|
|
m_itemBtnList.append(ui->button3_2);
|
|||
|
|
m_itemBtnList.append(ui->button3_3);
|
|||
|
|
m_itemBtnList.append(ui->button3_4);
|
|||
|
|
m_itemBtnList.append(ui->button3_5);
|
|||
|
|
m_itemBtnList.append(ui->button4_1);
|
|||
|
|
m_itemBtnList.append(ui->button4_2);
|
|||
|
|
m_itemBtnList.append(ui->button4_3);
|
|||
|
|
m_itemBtnList.append(ui->button4_4);
|
|||
|
|
m_itemBtnList.append(ui->button4_5);
|
|||
|
|
m_itemBtnList.append(ui->button5_1);
|
|||
|
|
m_itemBtnList.append(ui->button5_2);
|
|||
|
|
m_itemBtnList.append(ui->button5_3);
|
|||
|
|
m_itemBtnList.append(ui->button5_4);
|
|||
|
|
m_itemBtnList.append(ui->button5_5);
|
|||
|
|
m_itemBtnList.append(ui->button6_1);
|
|||
|
|
m_itemBtnList.append(ui->button6_2);
|
|||
|
|
m_itemBtnList.append(ui->button6_3);
|
|||
|
|
m_itemBtnList.append(ui->button6_4);
|
|||
|
|
m_itemBtnList.append(ui->button6_5);
|
|||
|
|
m_itemBtnList.append(ui->button7_1);
|
|||
|
|
m_itemBtnList.append(ui->button7_2);
|
|||
|
|
m_itemBtnList.append(ui->button7_3);
|
|||
|
|
m_itemBtnList.append(ui->button7_4);
|
|||
|
|
m_itemBtnList.append(ui->button7_5);
|
|||
|
|
m_itemBtnList.append(ui->button8_1);
|
|||
|
|
m_itemBtnList.append(ui->button8_2);
|
|||
|
|
m_itemBtnList.append(ui->button8_3);
|
|||
|
|
m_itemBtnList.append(ui->button8_4);
|
|||
|
|
m_itemBtnList.append(ui->button8_5);
|
|||
|
|
m_itemBtnList.append(ui->button9_1);
|
|||
|
|
m_itemBtnList.append(ui->button9_2);
|
|||
|
|
m_itemBtnList.append(ui->button9_3);
|
|||
|
|
m_itemBtnList.append(ui->button9_4);
|
|||
|
|
m_itemBtnList.append(ui->button9_5);
|
|||
|
|
m_itemBtnList.append(ui->button10_1);
|
|||
|
|
m_itemBtnList.append(ui->button10_2);
|
|||
|
|
m_itemBtnList.append(ui->button10_3);
|
|||
|
|
m_itemBtnList.append(ui->button10_4);
|
|||
|
|
m_itemBtnList.append(ui->button10_5);
|
|||
|
|
m_itemBtnList.append(ui->button11_1);
|
|||
|
|
m_itemBtnList.append(ui->button11_2);
|
|||
|
|
m_itemBtnList.append(ui->button11_3);
|
|||
|
|
m_itemBtnList.append(ui->button11_4);
|
|||
|
|
m_itemBtnList.append(ui->button11_5);
|
|||
|
|
m_itemBtnList.append(ui->button12_1);
|
|||
|
|
m_itemBtnList.append(ui->button12_2);
|
|||
|
|
m_itemBtnList.append(ui->button12_3);
|
|||
|
|
m_itemBtnList.append(ui->button12_4);
|
|||
|
|
m_itemBtnList.append(ui->button12_5);
|
|||
|
|
for(int var = 0; var < m_itemBtnList.size(); var++)
|
|||
|
|
{
|
|||
|
|
connect(m_itemBtnList.at(var),
|
|||
|
|
SIGNAL(clicked(bool)),
|
|||
|
|
this,
|
|||
|
|
SLOT(slotItemBtnClicked())
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
connect(m_itemBtnList.at(var),
|
|||
|
|
SIGNAL(pressed()),
|
|||
|
|
this,
|
|||
|
|
SLOT(slotItemBtnPressed())
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
connect(m_itemBtnList.at(var),
|
|||
|
|
SIGNAL(released()),
|
|||
|
|
this,
|
|||
|
|
SLOT(slotItemBtnReleased())
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//根据不同分辨率设置控件的位置和尺寸
|
|||
|
|
if(g_emTheme == theme2)
|
|||
|
|
{
|
|||
|
|
initResolution_BlueVer();
|
|||
|
|
}else
|
|||
|
|
{
|
|||
|
|
initResolution();
|
|||
|
|
}
|
|||
|
|
initControlStyle();//初始化窗体控件样式
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//初始化窗体控件为任意分辨率
|
|||
|
|
void ControlActionWidget::initResolution()
|
|||
|
|
{
|
|||
|
|
double factoryX = getFactoryX();
|
|||
|
|
double factoryY = getFactoryY();
|
|||
|
|
|
|||
|
|
this->resize(GLB_SCR_WIGHT*factoryX,GLB_SCR_HEIGHT*factoryY);
|
|||
|
|
ui->frameBack->setGeometry(0*factoryX,0*factoryY,GLB_SCR_WIGHT*factoryX,GLB_SCR_HEIGHT*factoryY);
|
|||
|
|
ui->buttonTypeLogo->setGeometry(GLB_EDGE_WIGHT*factoryX,GLB_EDGE_HEIGHT*factoryY,GLB_LICON_SIZE*factoryX,GLB_LICON_SIZE*factoryY);
|
|||
|
|
ui->labelMainTitle->setGeometry((GLB_EDGE_WIGHT+GLB_LICON_SIZE+GLB_EDGE_WIGHT)*factoryX,GLB_EDGE_HEIGHT*factoryY,
|
|||
|
|
(GLB_SCR_WIGHT-(GLB_EDGE_WIGHT+GLB_LICON_SIZE+GLB_EDGE_WIGHT*2))*factoryX,GLB_TEXT_L_HEIGHT*factoryY);
|
|||
|
|
ui->labelSubTitle->setGeometry((GLB_EDGE_WIGHT+GLB_LICON_SIZE+GLB_EDGE_WIGHT+GLB_TAB_WIGHT)*factoryX,(GLB_EDGE_HEIGHT+GLB_LICON_SIZE-GLB_TEXT_HEIGHT)*factoryY,
|
|||
|
|
(GLB_SCR_WIGHT-(GLB_EDGE_WIGHT+GLB_LICON_SIZE+GLB_EDGE_WIGHT+GLB_TAB_WIGHT*2))*factoryX,GLB_TEXT_HEIGHT*factoryY);
|
|||
|
|
|
|||
|
|
for(int i = 0; i < m_itemPerPage; i++)
|
|||
|
|
{
|
|||
|
|
m_itemFrameList[i]->setGeometry(GLB_PARA_LEFT*factoryX,(GLB_PARA_TOP + i * GLB_PARA_HEIGHT +3)*factoryY,GLB_PARA_WIGHT*factoryX,(GLB_PARA_HEIGHT-3)*factoryY);
|
|||
|
|
m_itemLabelList[i]->setGeometry(GLB_TAB_WIGHT*factoryX,GLB_ICON_TEXT*factoryY,(GLB_PARA_WIGHT-GLB_TAB_WIGHT*2)*factoryX,GLB_LBUT_HEIGHT*factoryY);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int bgX = GLB_PARA_WIGHT - GLB_BAS_WIGHT * (m_btnPerRow-1) - GLB_SBUT_WIGHT * m_btnPerRow - GLB_TAB_WIGHT;
|
|||
|
|
for(int i = 0; i < m_btnPerRow; i++)
|
|||
|
|
{
|
|||
|
|
for(int j = 0; j < m_itemPerPage; j++)
|
|||
|
|
{
|
|||
|
|
m_itemBtnList[m_btnPerRow*j+i]->setGeometry((bgX+i*(GLB_SBUT_WIGHT + GLB_BAS_WIGHT))*factoryX,GLB_BAS_WIGHT*factoryY,GLB_SBUT_WIGHT*factoryX,GLB_SBUT_HEIGHT*factoryY);//蓝色按钮大小位置
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ui->labelPage->setGeometry(GLB_EDGE_WIGHT*factoryX,(GLB_SCR_HEIGHT-GLB_TEXT_HEIGHT-GLB_EDGE_WIGHT)*factoryY,(GLB_SCR_WIGHT/3)*factoryX,GLB_TEXT_HEIGHT*factoryY);
|
|||
|
|
|
|||
|
|
ui->framePageBtn->setGeometry(0*factoryX,(GLB_SCR_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_WIGHT)*factoryY,GLB_SCR_WIGHT*factoryX,GLB_LBUT_HEIGHT*factoryY);
|
|||
|
|
ui->buttonPgUp->setGeometry((GLB_SCR_WIGHT-(GLB_EDGE_WIGHT+GLB_BAS_WIGHT*2+GLB_LBUT_WIGHT*3))*factoryX,0*factoryY,GLB_LBUT_WIGHT*factoryX,GLB_LBUT_HEIGHT*factoryY);
|
|||
|
|
ui->buttonPgDn->setGeometry((GLB_SCR_WIGHT-(GLB_EDGE_WIGHT+GLB_BAS_WIGHT*1+GLB_LBUT_WIGHT*2))*factoryX,0*factoryY,GLB_LBUT_WIGHT*factoryX,GLB_LBUT_HEIGHT*factoryY);
|
|||
|
|
ui->buttonBack->setGeometry((GLB_SCR_WIGHT-(GLB_EDGE_WIGHT+GLB_BAS_WIGHT*0+GLB_LBUT_WIGHT*1))*factoryX,0*factoryY,GLB_LBUT_WIGHT*factoryX,GLB_LBUT_HEIGHT*factoryY);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//初始化窗体控件分辨率
|
|||
|
|
void ControlActionWidget::initResolution_BlueVer()
|
|||
|
|
{
|
|||
|
|
double scaleX,scaleY;
|
|||
|
|
scaleX = getFactoryX();
|
|||
|
|
scaleY = getFactoryY();
|
|||
|
|
this->resize(1024*scaleX,600*scaleY);
|
|||
|
|
ui->frameBack->setGeometry(0,0,1024*scaleX,600*scaleY);
|
|||
|
|
|
|||
|
|
ui->buttonTypeLogo->setGeometry(14*scaleX,10*scaleY,42*scaleX,42*scaleY);
|
|||
|
|
ui->labelMainTitle->setGeometry(64*scaleX,4*scaleY,213*scaleX,30*scaleY);
|
|||
|
|
ui->labelSubTitle->setGeometry(64*scaleX,35*scaleY,533*scaleX,24*scaleY);
|
|||
|
|
|
|||
|
|
for(int i = 0; i < m_itemPerPage; i++)
|
|||
|
|
{
|
|||
|
|
m_itemFrameList[i]->setGeometry(148*scaleX,99*scaleY + i * 48*scaleY,718*scaleX,48*scaleY);
|
|||
|
|
m_itemLabelList[i]->setGeometry(10*scaleX,0*scaleY,340*scaleX,48*scaleY);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for(int i = 0; i < m_btnPerRow; i++)
|
|||
|
|
{
|
|||
|
|
for(int j = 0; j < m_itemPerPage; j++)
|
|||
|
|
{
|
|||
|
|
m_itemBtnList[m_btnPerRow*j+i]->setGeometry(283*scaleX+i*86*scaleX,4*scaleY,80*scaleX,40*scaleY);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ui->framePageBtn->setGeometry(584*scaleX,530*scaleY,427*scaleX,40*scaleY);
|
|||
|
|
ui->labelPage->setGeometry(26*scaleX,540*scaleY,213*scaleX,40*scaleY);
|
|||
|
|
ui->buttonPgUp->setGeometry(107*scaleX,0,90*scaleX,40*scaleY);
|
|||
|
|
ui->buttonPgDn->setGeometry(213*scaleX,0,90*scaleX,40*scaleY);
|
|||
|
|
ui->buttonBack->setGeometry(320*scaleX,0,90*scaleX,40*scaleY);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//初始化窗体控件样式
|
|||
|
|
void ControlActionWidget::initControlStyle()
|
|||
|
|
{
|
|||
|
|
SetStyle setControlStyle;
|
|||
|
|
setControlStyle.setUiName(this->objectName());
|
|||
|
|
|
|||
|
|
//背景图
|
|||
|
|
QString frameBackImgPath = setControlStyle.getSharedStyleSheet();
|
|||
|
|
ui->frameBack->setStyleSheet(frameBackImgPath);
|
|||
|
|
ui->labelMainTitle->setFont(fontSize_L());
|
|||
|
|
ui->labelMainTitle->setStyleSheet(titleTextColour());
|
|||
|
|
ui->labelSubTitle->setFont(fontSize_M());
|
|||
|
|
ui->labelSubTitle->setStyleSheet(noteTextColour());
|
|||
|
|
ui->labelPage->setFont(fontSize_M());
|
|||
|
|
ui->labelPage->setStyleSheet(commonTextColour());
|
|||
|
|
|
|||
|
|
//条目frame
|
|||
|
|
for(int i = 0; i < m_itemPerPage; i++)
|
|||
|
|
{
|
|||
|
|
m_itemFrameList[i]->setStyleSheet(transparentStyle());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//条目label
|
|||
|
|
for(int i = 0; i < m_itemPerPage; i++)
|
|||
|
|
{
|
|||
|
|
m_itemLabelList[i]->setFont(fontSize_M());
|
|||
|
|
m_itemLabelList[i]->setStyleSheet(commonTextColour());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//条目按钮
|
|||
|
|
for(int i = 0; i < m_itemBtnList.size(); i++)
|
|||
|
|
{
|
|||
|
|
m_itemBtnList[i]->setStyleSheet(textButtonStyle());
|
|||
|
|
m_itemBtnList[i]->setFont(fontSize_M());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//四个按钮样式表一样
|
|||
|
|
ui->buttonPgUp->setStyleSheet(confirmIconStyle());
|
|||
|
|
ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()));
|
|||
|
|
|
|||
|
|
ui->buttonPgDn->setStyleSheet(confirmIconStyle());
|
|||
|
|
ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()));
|
|||
|
|
|
|||
|
|
ui->buttonBack->setStyleSheet(confirmIconStyle());
|
|||
|
|
if(g_emTheme == theme2)
|
|||
|
|
{
|
|||
|
|
ui->buttonBack->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonBack->objectName()+"_1"));
|
|||
|
|
}else
|
|||
|
|
{
|
|||
|
|
ui->buttonBack->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonBack->objectName()));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::refreshUi(int idx)
|
|||
|
|
{
|
|||
|
|
// m_itemList 所有的控制动作
|
|||
|
|
if(idx != 0)
|
|||
|
|
{
|
|||
|
|
m_itemList.clear();
|
|||
|
|
|
|||
|
|
for( int i= 0; i < m_allItemList.size();i++)
|
|||
|
|
{
|
|||
|
|
m_itemList.append(m_allItemList[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int itemNum,pageNums;
|
|||
|
|
if (m_itemList.size() == 0)
|
|||
|
|
{
|
|||
|
|
itemNum = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
itemNum = m_itemList.size();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pageNums = (itemNum+m_itemPerPage-1) / m_itemPerPage; // 计算页数
|
|||
|
|
|
|||
|
|
if (m_curPage > pageNums) // 当前页
|
|||
|
|
{
|
|||
|
|
m_curPage = pageNums;
|
|||
|
|
}
|
|||
|
|
if (m_curPage <= 1)
|
|||
|
|
{
|
|||
|
|
m_curPage = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int itemidx = (m_curPage-1) * m_itemPerPage;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < m_itemPerPage; i++)
|
|||
|
|
{
|
|||
|
|
if (itemidx < itemNum)
|
|||
|
|
{
|
|||
|
|
m_itemFrameList.at(i)->show();
|
|||
|
|
OutCtrlItem item = m_itemList.at(itemidx);
|
|||
|
|
m_itemLabelList[i]->setText(item.m_name);
|
|||
|
|
|
|||
|
|
m_itemBtnList[i*m_btnPerRow]->setText(item.m_btn1Str);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+1]->setText(item.m_btn2Str);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+2]->setText(item.m_btn3Str);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+3]->setText(item.m_btn4Str);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+4]->setText(item.m_btn5Str);
|
|||
|
|
|
|||
|
|
m_itemBtnList[i*m_btnPerRow]->setVisible(item.m_btn1Visible);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+1]->setVisible(item.m_btn2Visible);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+2]->setVisible(item.m_btn3Visible);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+3]->setVisible(item.m_btn4Visible);
|
|||
|
|
m_itemBtnList[i*m_btnPerRow+4]->setVisible(item.m_btn5Visible);
|
|||
|
|
|
|||
|
|
itemidx++;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_itemFrameList.at(i)->hide();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 翻页按钮
|
|||
|
|
if (m_curPage <= 1)
|
|||
|
|
{
|
|||
|
|
ui->buttonPgUp->setEnabled(false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ui->buttonPgUp->setEnabled(true);
|
|||
|
|
}
|
|||
|
|
if (m_curPage >= pageNums)
|
|||
|
|
{
|
|||
|
|
ui->buttonPgDn->setEnabled(false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ui->buttonPgDn->setEnabled(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(pageNums == 0)
|
|||
|
|
{
|
|||
|
|
m_curPage = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 页信息
|
|||
|
|
QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPage).arg(pageNums);//页数:
|
|||
|
|
ui->labelPage->setText(str);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//按钮动作
|
|||
|
|
void ControlActionWidget::btnAction(int rowidx, int btnidx, int event)
|
|||
|
|
{
|
|||
|
|
int nidx = (rowidx - 1) + (m_curPage - 1) * m_itemPerPage;
|
|||
|
|
int size = m_itemList.size();
|
|||
|
|
if(size <= 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(nidx >= size)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
OutCtrlItem item = m_itemList[nidx];
|
|||
|
|
int def = item.m_def;
|
|||
|
|
int fun = -1;
|
|||
|
|
|
|||
|
|
switch(btnidx)
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
switch(event)
|
|||
|
|
{
|
|||
|
|
case BTNCLICK:
|
|||
|
|
fun = item.m_btn1ClickFun;
|
|||
|
|
break;
|
|||
|
|
case BTNPRE:
|
|||
|
|
fun = item.m_btn1PreFun;
|
|||
|
|
break;
|
|||
|
|
case BTNREL:
|
|||
|
|
fun = item.m_btn1RelFun;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
switch(event)
|
|||
|
|
{
|
|||
|
|
case BTNCLICK:
|
|||
|
|
fun = item.m_btn2ClickFun;
|
|||
|
|
break;
|
|||
|
|
case BTNPRE:
|
|||
|
|
fun = item.m_btn2PreFun;
|
|||
|
|
break;
|
|||
|
|
case BTNREL:
|
|||
|
|
fun = item.m_btn2RelFun;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
switch(event)
|
|||
|
|
{
|
|||
|
|
case BTNCLICK:
|
|||
|
|
fun = item.m_btn3ClickFun;
|
|||
|
|
break;
|
|||
|
|
case BTNPRE:
|
|||
|
|
fun = item.m_btn3PreFun;
|
|||
|
|
break;
|
|||
|
|
case BTNREL:
|
|||
|
|
fun = item.m_btn3RelFun;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 4:
|
|||
|
|
switch(event)
|
|||
|
|
{
|
|||
|
|
case BTNCLICK:
|
|||
|
|
fun = item.m_btn4ClickFun;
|
|||
|
|
break;
|
|||
|
|
case BTNPRE:
|
|||
|
|
fun = item.m_btn4PreFun;
|
|||
|
|
break;
|
|||
|
|
case BTNREL:
|
|||
|
|
fun = item.m_btn4RelFun;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 5:
|
|||
|
|
switch(event)
|
|||
|
|
{
|
|||
|
|
case BTNCLICK:
|
|||
|
|
fun = item.m_btn5ClickFun;
|
|||
|
|
break;
|
|||
|
|
case BTNPRE:
|
|||
|
|
fun = item.m_btn5PreFun;
|
|||
|
|
break;
|
|||
|
|
case BTNREL:
|
|||
|
|
fun = item.m_btn5RelFun;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
fun = -1;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
excuteOrder(def,fun);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::slotSpeed(int speed) // 手动换挡
|
|||
|
|
{
|
|||
|
|
m_speed = speed;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//执行按钮动作
|
|||
|
|
void ControlActionWidget::excuteOrder(int def, int fun)
|
|||
|
|
{
|
|||
|
|
if(def < 0 || fun < 0)
|
|||
|
|
return;
|
|||
|
|
PromptDialog promptDlg(this);
|
|||
|
|
QString str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全!
|
|||
|
|
switch(fun)
|
|||
|
|
{
|
|||
|
|
case OUTCONTROL_ENABLE:
|
|||
|
|
g_pMachine->motoServoCtrl(def, UP_OPEN_ON);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_DISABLE:
|
|||
|
|
g_pMachine->motoServoCtrl(def, DOWN_CLOSE_OFF);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_MS_ENABLE://主轴
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_MS_DISABLE:
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_JOGP://电机点动正转
|
|||
|
|
{
|
|||
|
|
if(m_speed == 1) // 手动换挡
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_RIGHTMOVE://右移
|
|||
|
|
{
|
|||
|
|
if(m_speed == 1) // 手动换挡
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_FORWARD://前进
|
|||
|
|
if(m_speed == 1) // 手动换挡
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 0);
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_JOGN://电机点动反转
|
|||
|
|
if(m_speed == 1)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 0);
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_LEFTMOVE://左移
|
|||
|
|
if(m_speed == 1)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 0);
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_REVERSE://后退
|
|||
|
|
{
|
|||
|
|
if(m_speed == 1)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_STOP://电机点动停止
|
|||
|
|
{
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_STOP, 0);
|
|||
|
|
|
|||
|
|
//QTime dieTime = QTime::currentTime().addSecs(sec);//延时sec秒
|
|||
|
|
QTime dieTime = QTime::currentTime().addMSecs(500);//延时msec毫秒
|
|||
|
|
while( QTime::currentTime() < dieTime )
|
|||
|
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
|||
|
|
|
|||
|
|
//延时500毫秒再发一次,因为有时按钮抬起电机不会停
|
|||
|
|
g_pMachine->motoMove(def, MT_MOVE_DIR_STOP, 0);
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_ZERO://电机归零
|
|||
|
|
g_pMachine->motoToZero(def);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_LEFT://电机位置前
|
|||
|
|
g_pMachine->outputCtrl(def, UP_OPEN_ON, 0);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_MIDDLE://电机位置中
|
|||
|
|
g_pMachine->outputCtrl(def, DOWN_CLOSE_OFF, 0);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_RIGHT://电机位置后
|
|||
|
|
g_pMachine->outputCtrl(def, OT_ACTION, 0);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_UP://气缸上升,输出控制方式的电机正转
|
|||
|
|
g_pMachine->outputCtrl(def, UP_OPEN_ON, 0);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_DOWN://气缸下降,输出控制方式的电机反转
|
|||
|
|
g_pMachine->outputCtrl(def, DOWN_CLOSE_OFF, 0);
|
|||
|
|
break;
|
|||
|
|
case MANUALACTION_RUN://手动动作执行
|
|||
|
|
g_pMachine->manualAction(def);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_OPEN://电磁阀开
|
|||
|
|
g_pMachine->outputCtrl(def, UP_OPEN_ON, 0);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_CLOSE://电磁阀合
|
|||
|
|
g_pMachine->outputCtrl(def, DOWN_CLOSE_OFF, 0);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_COCOSTOP://电磁阀停止
|
|||
|
|
g_pMachine->outputCtrl(def, OT_STOP, 0);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_STARTOIL://开始(如手动加油)
|
|||
|
|
g_pMachine->manualOil(1);
|
|||
|
|
break;
|
|||
|
|
case OUTCONTROL_STOPOIL://停止(如手动加油)
|
|||
|
|
g_pMachine->manualOil(0);
|
|||
|
|
break;
|
|||
|
|
case ALLTO_ZERO: // 全部归零
|
|||
|
|
promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL);
|
|||
|
|
promptDlg.setTitleStr(tr("All to zero"));//全部归零
|
|||
|
|
promptDlg.setContentStr(str);
|
|||
|
|
if(promptDlg.exec() == 1)
|
|||
|
|
g_pMachine->allToZero();
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_PULL://拉料
|
|||
|
|
{
|
|||
|
|
if(m_speed == 1) // 手动换挡
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_POSI, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_POSI, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_POSI, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_POSI, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_PULLBACK://退料
|
|||
|
|
{
|
|||
|
|
if(m_speed == 1)
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_NEGA, 1);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 2)
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_NEGA, 2);
|
|||
|
|
}
|
|||
|
|
else if(m_speed == 3)
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_NEGA, 3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_NEGA, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case OUTCONTROL_PULLSTOP://电机点动停止
|
|||
|
|
g_pMachine->pullMove(def, MT_MOVE_DIR_STOP, 0);
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设置类型图标
|
|||
|
|
void ControlActionWidget::setTypeLogo(QString tStyle)
|
|||
|
|
{
|
|||
|
|
ui->buttonTypeLogo->setUnPreBtnLogo(tStyle);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设置主title
|
|||
|
|
void ControlActionWidget::setMainTitle(QString str)
|
|||
|
|
{
|
|||
|
|
ui->labelMainTitle->setText(str);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设置副title
|
|||
|
|
void ControlActionWidget::setSubTitle(QString str)
|
|||
|
|
{
|
|||
|
|
ui->labelSubTitle->setText(str);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 设置控制动作后面的反馈数据
|
|||
|
|
* @param def
|
|||
|
|
* @param value
|
|||
|
|
*/
|
|||
|
|
void ControlActionWidget::setdefName(int showPriority, int value)
|
|||
|
|
{
|
|||
|
|
for(int i = 0; i < m_itemList.size(); i++)
|
|||
|
|
{
|
|||
|
|
if(showPriority == m_itemList[i].m_showPriority){
|
|||
|
|
int pageOfDef = i/m_itemPerPage;
|
|||
|
|
int indexOfDef = i%m_itemPerPage;
|
|||
|
|
|
|||
|
|
if(pageOfDef + 1 == m_curPage){
|
|||
|
|
QString text = m_itemLabelList[indexOfDef]->text();
|
|||
|
|
double doubleVal = value*0.01;
|
|||
|
|
QString resStr = text.left(text.indexOf(":")) + QString(":%1").arg(QString::number(doubleVal));
|
|||
|
|
m_itemLabelList[indexOfDef]->setText(resStr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::addItemList(QList<OutCtrlItem> itemList)
|
|||
|
|
{
|
|||
|
|
m_itemList.append(itemList);
|
|||
|
|
m_allItemList.append(itemList);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//控制按钮被点击
|
|||
|
|
void ControlActionWidget::slotItemBtnClicked()
|
|||
|
|
{
|
|||
|
|
MyButton *button = (MyButton*) this->sender() ;
|
|||
|
|
|
|||
|
|
if(button == NULL)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取所触发按钮的行和按钮索引
|
|||
|
|
int rowIdx,btnIdx;
|
|||
|
|
rowIdx = btnIdx = 1;
|
|||
|
|
for(int i = 0; i < m_itemBtnList.size(); i++)
|
|||
|
|
{
|
|||
|
|
if(button == m_itemBtnList[i])
|
|||
|
|
{
|
|||
|
|
rowIdx = i / m_btnPerRow + 1;
|
|||
|
|
btnIdx = i % m_btnPerRow + 1;
|
|||
|
|
btnAction(rowIdx,btnIdx,BTNCLICK);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//控制按钮按下
|
|||
|
|
void ControlActionWidget::slotItemBtnPressed()
|
|||
|
|
{
|
|||
|
|
MyButton *button = (MyButton*) this->sender() ;
|
|||
|
|
|
|||
|
|
if(button == NULL)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取所触发按钮的行和按钮索引
|
|||
|
|
int rowIdx,btnIdx;
|
|||
|
|
rowIdx = btnIdx = 1;
|
|||
|
|
for(int i = 0; i < m_itemBtnList.size(); i++)
|
|||
|
|
{
|
|||
|
|
if(button == m_itemBtnList[i])
|
|||
|
|
{
|
|||
|
|
rowIdx = i / m_btnPerRow + 1;
|
|||
|
|
btnIdx = i % m_btnPerRow + 1;
|
|||
|
|
btnAction(rowIdx,btnIdx,BTNPRE);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//控制按钮抬起
|
|||
|
|
void ControlActionWidget::slotItemBtnReleased()
|
|||
|
|
{
|
|||
|
|
MyButton *button = (MyButton*) this->sender() ;
|
|||
|
|
|
|||
|
|
if(button == NULL)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取所触发按钮的行和按钮索引
|
|||
|
|
int rowIdx,btnIdx;
|
|||
|
|
rowIdx = btnIdx = 1;
|
|||
|
|
for(int i = 0; i < m_itemBtnList.size(); i++)
|
|||
|
|
{
|
|||
|
|
if(button == m_itemBtnList[i])
|
|||
|
|
{
|
|||
|
|
rowIdx = i / m_btnPerRow + 1;
|
|||
|
|
btnIdx = i % m_btnPerRow + 1;
|
|||
|
|
btnAction(rowIdx,btnIdx,BTNREL);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::on_buttonPgUp_clicked()
|
|||
|
|
{
|
|||
|
|
m_curPage--;
|
|||
|
|
refreshUi();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::on_buttonPgDn_clicked()
|
|||
|
|
{
|
|||
|
|
m_curPage++;
|
|||
|
|
refreshUi();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::on_buttonBack_clicked()
|
|||
|
|
{
|
|||
|
|
this->hide();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::mousePressEvent(QMouseEvent *e)
|
|||
|
|
{
|
|||
|
|
if ( e->button() == Qt::LeftButton)
|
|||
|
|
{
|
|||
|
|
m_mousePressX = e->x();
|
|||
|
|
m_mousePressY = e->y();
|
|||
|
|
m_mouseReleaseX = 0;
|
|||
|
|
m_mouseReleaseY = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ControlActionWidget::mouseReleaseEvent(QMouseEvent *e)
|
|||
|
|
{
|
|||
|
|
if ( e->button() == Qt::LeftButton)
|
|||
|
|
{
|
|||
|
|
m_mouseReleaseX = e->x();
|
|||
|
|
m_mouseReleaseY = e->y();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int width = this->width();
|
|||
|
|
int height = this->height();
|
|||
|
|
if ((m_mousePressX >= 0 && m_mousePressX <= 100) &&
|
|||
|
|
((m_mousePressY >= (height - 100)) && m_mousePressY <= height) &&
|
|||
|
|
((m_mouseReleaseX >= (width - 100)) && m_mouseReleaseX <= width) &&
|
|||
|
|
((m_mouseReleaseY >= (height - 100)) && m_mouseReleaseY <= height))
|
|||
|
|
{
|
|||
|
|
MainWidgetFunction mainFunction;
|
|||
|
|
QString usbPath;//优盘路径
|
|||
|
|
usbPath = mainFunction.detectUsb();//优盘检测
|
|||
|
|
if(usbPath.length() <= 0)
|
|||
|
|
{
|
|||
|
|
//优盘不存在
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
QPixmap pixmap=QPixmap::grabWindow(this->winId(),0,0,this->width(),this->height());//截屏存放在pixmap
|
|||
|
|
QString name_pc = usbPath + "EMB" + //
|
|||
|
|
QDateTime::currentDateTime().toString("yyyyMMdd") +//获取时期时间
|
|||
|
|
+"_"+
|
|||
|
|
QDateTime::currentDateTime().toString("hhmmss") + ".png";
|
|||
|
|
|
|||
|
|
pixmap.save(name_pc,"png"); // 路径
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_mousePressX = 0;
|
|||
|
|
m_mousePressY = 0;
|
|||
|
|
m_mouseReleaseX = 0;
|
|||
|
|
m_mouseReleaseY = 0;
|
|||
|
|
}
|