Exemplo n.º 1
0
void CScreenShotView::keyPressEvent(QKeyEvent *event)
{
    if(event->key() == Qt::Key_Escape)
    {
        setShotStatus(CSCREEN_SHOT_STATE_CANCEL);
        event->accept();
        return;
    }
    else if(event->key() == Qt::Key_Enter
            || event->key() == Qt::Key_Return)
    {
        if(m_shotStatus == CSCREEN_SHOT_STATE_EDITED
                || m_shotStatus == CSCREEN_SHOT_STATE_SELECTED)
        {
            doFinished();
            event->accept();
            return;
        }
    }
    if(m_isLocked)
    {
        event->accept();
        return;
    }
    return QGraphicsView::keyPressEvent(event);
}
Exemplo n.º 2
0
void CScreenShotView::onButtonClicked(CScreenButtonType type)
{
    C_SCREENSHOT_LOG_INFO(QString("onButtonClicked type %1").arg(type));
    m_screenButtonType = type;
    if(CScreenshotUtil::isEditType(m_screenButtonType))
    {
        if(m_shotStatus == CSCREEN_SHOT_STATE_SELECTED)
        {
            setShotStatus(CSCREEN_SHOT_STATE_EDITED);
            m_selectRectItem->setMovePointHidden(true);
        }
        return;
    }
    switch (type)
    {
    case CSCREEN_BUTTON_TYPE_OK:
        doFinished();
        C_SCREENSHOT_LOG_INFO(QString("CSCREEN_SHOT_STATE_FINISHED type %1").arg(CSCREEN_SHOT_STATE_FINISHED));
        break;
    case CSCREEN_BUTTON_TYPE_CANCLE:
        setShotStatus(CSCREEN_SHOT_STATE_CANCEL);
        break;
    default:
        break;
    }
}
Exemplo n.º 3
0
void CWizAutoTimeOutEventLoop::on_replyFinished()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply *>(sender());
    //
    doFinished(reply);

    reply->deleteLater();
    //
    quit();
}
Exemplo n.º 4
0
/*!
  \brief Connects the \p reply object with it's slots here.

  \param reply The \c QNetworkReply object to connect to everything.
*/
void
Steam::connectReply( QNetworkReply *reply )
{
  if( ! reply )
    return;

  connect( reply, SIGNAL( downloadProgress( qint64, qint64 ) ), this,
    SLOT( doDownloadProgress( qint64, qint64 ) ) );
  connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this,
    SLOT( doError() ) );
  connect( reply, SIGNAL( finished() ), this, SLOT( doFinished() ) );
}
Exemplo n.º 5
0
void CScreenShotView::mouseReleaseEvent(QMouseEvent *event)
{
    if(m_isLocked)
    {
        event->accept();
        return;
    }
    QRectF selectRect = m_selectRectItem->getSelectRect();
    if(m_isPressed && (selectRect.width() >= 1 && selectRect.height() >= 1))
    {
        if(m_shotStatus == CSCREEN_SHOT_STATE_INITIALIZED)
        {
            updateToolbarPosition();
            m_selectRect = selectRect;
            setShotStatus(CSCREEN_SHOT_STATE_SELECTED);
            m_previewItem->setVisible(false);
            m_selectRectItem->setVisible(true);
            m_selectRectItem->setMovePointHidden(false);
            m_toolbarItem->setVisible(true);
            if(m_onlySelect)
            {
                doFinished();
            }
        }
        else if(m_shotStatus == CSCREEN_SHOT_STATE_SELECTED)
        {
            updateToolbarPosition();
            m_toolbarItem->setVisible(true);
        }
        else if(m_shotStatus == CSCREEN_SHOT_STATE_EDITED)
        {
            m_currentRectItem = NULL;
        }
    }
    else if(m_isPressed)
    {
        m_selectRectItem->setVisible(false);
        m_tooltipSizeItem->setVisible(false);
    }
    m_isPressed = false;
    QGraphicsView::mouseReleaseEvent(event);
}
Exemplo n.º 6
0
void avrOutputDialog::doCopy() 
{
  char buf[BLKSIZE];

  QFile source(sourceFile);
  int blocks = (source.size() + BLKSIZE - 1) / BLKSIZE;
  ui->progressBar->setMaximum(blocks-1);

  if (source.open(QIODevice::ReadOnly)) {
    QFile dest(destFile);
    if (dest.open(QIODevice::WriteOnly)) {
      addText(tr("Writing file: "));
      for (int i=0; i<blocks; i++) {
        int read = source.read(buf, BLKSIZE);
        if (dest.write(buf, read) == read) {
          dest.flush();
          ui->progressBar->setValue(i);
          if ((i%2) != 0)
            addText("#");
        }
        else {
          QMessageBox::warning(this, tr("Error"), tr("Write error"));
          break;
        }
      }
      dest.close();
    }
    else {
      QMessageBox::warning(this, tr("Error"),tr("Cannot write destination") + ": " + dest.fileName() + ", " + tr("reason") + ": " + dest.errorString());
    }
  }
  else {
    QMessageBox::warning(this, tr("Error"),tr("Cannot open source file") + ": " + source.fileName() + ", " + tr("reason") + ": " + source.errorString());
  }

  source.close();
  doFinished(0);
}
Exemplo n.º 7
0
void CScreenShotView::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(m_isLocked)
    {
        event->accept();
        return;
    }
    if(m_shotStatus == CSCREEN_SHOT_STATE_SELECTED || m_shotStatus == CSCREEN_SHOT_STATE_EDITED)
    {
        bool isContains = m_selectRect.contains(getPointToSelectedItem(event->pos()));
        QRect toolbarRect(m_toolbarItem->pos().x(),
                          m_toolbarItem->pos().y(),
                          m_toolbarItem->boundingRect().width(),
                          m_toolbarItem->boundingRect().height());
        if(isContains && !toolbarRect.contains(event->pos()) && m_toolbarItem->isVisible())
        {
            event->accept();
            doFinished();
            return;
        }
    }
    return QGraphicsView::mouseDoubleClickEvent(event);
}
Exemplo n.º 8
0
bool CScreenShotView::eventFilter(QObject *obj, QEvent *event)
{
#ifdef Q_OS_MAC
    if(/*obj == qApp && */event->type() == QEvent::KeyPress || this->isVisible())
    {
        QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
        if(keyEvent)
        {
            if(keyEvent->key() == Qt::Key_Escape)
            {
                setShotStatus(CSCREEN_SHOT_STATE_CANCEL);
                event->accept();
                return true;
            }
            else if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return)
            {
                if(m_shotStatus == CSCREEN_SHOT_STATE_EDITED
                        || m_shotStatus == CSCREEN_SHOT_STATE_SELECTED)
                {
                    doFinished();
                    event->accept();
                    return true;
                }
            }
        }
    }
    if(this->isVisible())
    {
        //弥补界面最下面、最右边差1px的事件范围
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        if(mouseEvent && m_desktopScreen)
        {
            QPoint globalPos = mouseEvent->globalPos();
            QRect geometry = m_desktopScreen->geometry();
            bool isContains = globalPos.x() >= geometry.x()
                    && globalPos.x() <= (geometry.x() + geometry.width())
                    && globalPos.y() >= geometry.y()
                    && globalPos.y() <= (geometry.y() + geometry.height());
            bool onBoundary = (globalPos.x() == (geometry.x() + geometry.width()) || globalPos.y() == (geometry.y() + geometry.height()));
            if(isContains && onBoundary)
            {
                switch (event->type())
                {
                case QEvent::MouseButtonPress:
                    mousePressEvent(mouseEvent);
                    break;
                case QEvent::MouseMove:
                    mouseMoveEvent(mouseEvent);
                    break;
                case QEvent::MouseButtonDblClick:
                    mouseDoubleClickEvent(mouseEvent);
                    break;
                default:
                    break;
                }
            }
        }
    }
#endif
    return QGraphicsView::eventFilter(obj,event);
}