void WizScreenShotWidget::paintEvent(QPaintEvent *event)
{
    QColor shadowColor;
    shadowColor= QColor(0, 0, 0, 100);
    painter.begin(this);

    painter.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap));
    painter.drawPixmap(screenx, screeny, loadPixmap);
    painter.fillRect(screenx, screeny, screenwidth, screenheight, shadowColor);

    switch (currentShotState)
    {
    case initShot:
        drawTipsText();
        break;
    case beginShot:
    case finishShot:
        selectedRect = getRect(beginPoint,endPoint); // get selected range
        drawSelectedPixmap();
        break;
    case beginMoveShot:
    case finishMoveShot:
        selectedRect = getMoveAllSelectedRect();  // get selected range
        drawSelectedPixmap();
        break;
    case beginControl:
    case finishControl:
        selectedRect = getMoveControlSelectedRect();
        drawSelectedPixmap();
        break;
    default:
        break;
    }
    drawXYWHInfo(); //draw point info
    painter.end();

    if (currentShotState == finishMoveShot || currentShotState == finishControl)
    {
        updateBeginEndPointValue(selectedRect); //prepare for next move
    }

}
Exemplo n.º 2
0
void ScreenshotsWidget::paintEvent(QPaintEvent *event)
{
    QColor shadowColor;
    shadowColor= QColor(0,0,0,100); //阴影颜色设置
    painter.begin(this); //进行重绘

    painter.setPen(QPen(Qt::blue,2,Qt::SolidLine,Qt::FlatCap));//设置画笔
    painter.drawPixmap(screenx,screeny,loadPixmap); //将背景图片画到窗体上
    painter.fillRect(screenx,screeny,screenwidth,screenheight,shadowColor); //画影罩效果

    switch(currentShotState){
    case initShot:
        drawTipsText();
        break;
    case beginShot:
    case finishShot:
        selectedRect = getRect(beginPoint,endPoint); //获取选区
        drawSelectedPixmap();
        break;
    case beginMoveShot:
    case finishMoveShot:
        selectedRect = getMoveAllSelectedRect(); //获取选区
        drawSelectedPixmap();
        break;
    case beginControl:
    case finishControl:
        selectedRect = getMoveControlSelectedRect();
        drawSelectedPixmap();
        break;
    default:
        break;
    }
    drawXYWHInfo(); //打印坐标信息
    painter.end();  //重绘结束

    if(currentShotState == finishMoveShot || currentShotState == finishControl){
        updateBeginEndPointValue(selectedRect); //当移动完选区后,更新beginPoint,endPoint;为下一次移动做准备工作
    }

}