コード例 #1
0
ファイル: panel.cpp プロジェクト: ghl800/touch_16
QImage *DemoPanel::createImage(const QMatrix &matrix) const
{
    qWarning() << "panel createImage bgcolor " << this->bgColor << " logicalSize " << this->logicalSize;
    QRect scaledRect;
    scaledRect = matrix.mapRect(QRect(0, 0, this->logicalSize.width(), this->logicalSize.height()));

    QImage *image = new QImage(int(scaledRect.width()), int(scaledRect.height()), QImage::Format_ARGB32_Premultiplied);
    image->fill(QColor(0, 0, 0, 0).rgba());
    QPainter painter(image);
    painter.setRenderHint(QPainter::SmoothPixmapTransform);
    painter.setRenderHint(QPainter::Antialiasing);

    QImage bgImage(this->bgImageFilename);
    if (!bgImage.isNull())
    {
        bgImage.scaled(this->logicalSize);
        painter.drawImage(0,0,bgImage);
    }
    else
    {
        QPen pen;
        pen.setColor(this->borderColor);
        pen.setWidth(this->borderWidth);
        pen.setStyle(this->borderStyle);
        painter.setPen(pen);
        painter.setBrush(this->bgColor);
        painter.drawRoundedRect(0,0,scaledRect.width(),scaledRect.height(),this->borderRadius,this->borderRadius);
    }
    return image;
}
コード例 #2
0
ファイル: reportwindow.cpp プロジェクト: Wushaowei001/xtuple
void ReportWindow::docInfoEditor() {
qDebug("docInfoEditor()");
    ReportProperties * diag = new ReportProperties(this);
    if(diag) {
        // Info
        diag->setReportTitle(reportTitle());
        diag->setReportName(reportName());
        diag->setReportDescription(reportDescription());
        // Background
        diag->setBgEnabled(bgEnabled());
        diag->setBgStatic(bgStatic());
        diag->setBgImageData(bgImage());
        diag->setBgQuery(qsList, bgQuery());
        diag->setBgColumn(bgColumn());
        diag->setBgResizeMode(bgResizeMode());
        diag->setBgAlign(bgAlign());
        diag->setBgBoundsX(bgBoundsX());
        diag->setBgBoundsY(bgBoundsY());
        diag->setBgBoundsWidth(bgBoundsWidth());
        diag->setBgBoundsHeight(bgBoundsHeight());
        diag->setBgOpacity(bgOpacity());
        // Watermark
        diag->setWatermarkOpacity(watermarkOpacity());
        diag->setWmFont(watermarkFont());
        diag->SetUseBestWMFont(watermarkUseDefaultFont());
        diag->setWmTextStatic(watermarkUseStaticText());
        diag->setWmText(watermarkText());
        diag->setWmColumn(watermarkColumn());
        diag->setWmQuery(qsList, watermarkQuery());
        if(diag->exec() == QDialog::Accepted) {
            // Info
            setReportTitle(diag->getReportTitle());
            setReportName(diag->getReportName());
            setReportDescription(diag->getReportDescription());
            // Background
            setBgEnabled(diag->isBgEnabled());
            setBgStatic(diag->isBgStatic());
            setBgImage(diag->getBgImageData());
            setBgQuery(diag->getBgQuery());
            setBgColumn(diag->getBgColumn());
            setBgResizeMode(diag->getBgResizeMode());
            setBgAlign(diag->getBgAlign());
            setBgBoundsX(diag->getBgBoundsX());
            setBgBoundsY(diag->getBgBoundsY());
            setBgBoundsWidth(diag->getBgBoundsWidth());
            setBgBoundsHeight(diag->getBgBoundsHeight());
            setBgOpacity(diag->getBgOpacity());
            // Watermark
            setWatermarkOpacity(diag->getWatermarkOpacity());
            setWatermarkFont(diag->getWmFont());
            setWatermarkUseDefaultFont(diag->getUseBestWmFont());
            setWatermarkUseStaticText(diag->isWmTextStatic());
            setWatermarkText(diag->getWmText());
            setWatermarkColumn(diag->getWmColumn());
            setWatermarkQuery(diag->getWmQuery());
        }
        delete diag;
    }
}
コード例 #3
0
ファイル: LDesktopBackground.cpp プロジェクト: trueos/lumina
QPixmap LDesktopBackground::setBackground(const QString& bgFile, const QString& format, QRect geom) {
    //if (bgPixmap != NULL) delete bgPixmap;
    QPixmap bgPixmap(geom.size());// = new QPixmap(size());

    if (bgFile.startsWith("rgb(")) {
        QStringList colors = bgFile.section(")",0,0).section("(",1,1).split(",");
        QColor color = QColor(colors[0].toInt(), colors[1].toInt(), colors[2].toInt());
        bgPixmap.fill(color);
    } else {
        bgPixmap.fill(Qt::black);

        // Load the background file and scale
        QPixmap bgImage(bgFile);
        if (format == "stretch" || format == "full" || format == "fit") {
            Qt::AspectRatioMode mode;
            if (format == "stretch") {
                mode = Qt::IgnoreAspectRatio;
            } else if (format == "full") {
                mode = Qt::KeepAspectRatioByExpanding;
            } else {
                mode = Qt::KeepAspectRatio;
            }
            if(bgImage.height() != geom.height() && bgImage.width() != geom.width() ){ bgImage = bgImage.scaled(geom.size(), mode, Qt::SmoothTransformation);  }
            //bgImage = bgImage.scaled(size(), mode);
        }

        // Calculate the offset
        int dx = 0, dy = 0;
        int drawWidth = bgImage.width(), drawHeight = bgImage.height();
        if (format == "fit" || format == "center" || format == "full") {
            dx = (geom.width() - bgImage.width()) / 2;
            dy = (geom.height() - bgImage.height()) / 2;
        } else if (format == "tile") {
            drawWidth = geom.width();
            drawHeight = geom.height();
        } else {
            if (format.endsWith("right")) {
                dx = geom.width() - bgImage.width();
            }
            if (format.startsWith("bottom")) {
                dy = geom.height() - bgImage.height();
            }
        }

        // Draw the background image
        QPainter painter(&bgPixmap);
        painter.setBrush(bgImage);
        painter.setBrushOrigin(dx, dy);
        painter.drawRect(dx, dy, drawWidth, drawHeight);
    }
    //this->repaint(); //make sure the entire thing gets repainted right away
   //LSession::handle()->XCB->paintRoot(geom, &bgPixmap);
    return bgPixmap;
    //show();
}
コード例 #4
0
ファイル: videoview.cpp プロジェクト: nosempre/CVMob
VideoView::VideoView(QWidget *parent) :
    QAbstractItemView(parent),
    _view(new VideoGraphicsView),
    _noVideoVideo(Video(new QGraphicsScene(_view), 0)),
    _playBar(new PlayBar(this)),
    _status(new VideoStatus(this))
{
    new QVBoxLayout(viewport());
    viewport()->layout()->addWidget(_status);
    _status->hide();
    viewport()->layout()->addWidget(_view);
    viewport()->layout()->setMargin(0);
    viewport()->layout()->setSpacing(0);
    _view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    _view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    _view->setRenderHint(QPainter::Antialiasing);
    viewport()->layout()->addWidget(_playBar);

    QImage bgImage(":/images/translucent-logo.png");
    _view->setScene(_noVideoVideo.scene);
    _noVideoVideo.bgRect = new QGraphicsRectItem(0);
    _noVideoVideo.bgRect->setRect(QRectF(QPointF(0, 0), bgImage.size()));
    _noVideoVideo.bgRect->setBrush(bgImage);
    _noVideoVideo.bgRect->setPen(Qt::NoPen);
    _noVideoVideo.scene->addItem(_noVideoVideo.bgRect);
    _noVideoVideo.scene->setSceneRect(QRectF(QPointF(0, 0), bgImage.size()));
    QGraphicsItem *noVideoText = _noVideoVideo.scene->addText(tr("No video"));
    noVideoText->moveBy(100, 50);

    connect(_playBar, SIGNAL(newDistanceRequested()), SLOT(beginDistanceCreation()));
    connect(_playBar, SIGNAL(newAngleRequested()), SLOT(beginAngleCreation()));

    connect(_playBar, &PlayBar::frameChanged, [=](int frame)
    {
        QModelIndex currentFrameIndex = model()
                ->index(_currentVideoRow, VideoModel::CurrentFrameColumn);

        if (frame == currentFrameIndex.data().toInt()) {
            return;
        }

        model()->setData(currentFrameIndex, frame);
    });

    connect(_playBar, &PlayBar::newTrajectoryRequested, [=]()
    {
        auto status = new Status::Persistent(_status, tr("Click a point to track"));

        connect(_view, SIGNAL(mouseReleased(QPointF)), SLOT(calculateTrajectory(QPointF)));
        connect(_view, SIGNAL(mouseReleased(QPointF)), status, SLOT(deleteLater()));
    });
}
コード例 #5
0
ファイル: selecteditem.cpp プロジェクト: muromec/qtopia-ezx
/*!
  \internal
  \fn void SelectedItem::drawBackground(QPainter *painter)
  The background image is created on demand, within this method.
*/
void SelectedItem::drawBackground(QPainter *painter)
{
    QRect rectangle = rect().toRect();

    if ( !background ) {
        // Create on demand.
        QImage bgImage(backgroundFileName);

        blendColor(bgImage,QApplication::palette().color(QPalette::Highlight));
        background = new QPixmap(QPixmap::fromImage(
                    bgImage.scaled(rectangle.width(),rectangle.height(),
                        Qt::IgnoreAspectRatio, Qt::SmoothTransformation)));
    }

    painter->drawPixmap(rectangle.x(),rectangle.y(),*background);
}
コード例 #6
0
ファイル: reportwindow.cpp プロジェクト: Wushaowei001/xtuple
QDomDocument ReportWindow::document() {
    QDomDocument doc = QDomDocument("openRPTDef");
    QDomElement root = doc.createElement("report");
    doc.appendChild(root);

    //title
    QDomElement title = doc.createElement("title");
    title.appendChild(doc.createTextNode(reportTitle()));
    root.appendChild(title);

    QDomElement rname = doc.createElement("name");
    rname.appendChild(doc.createTextNode(reportName()));
    root.appendChild(rname);

    QDomElement rdesc = doc.createElement("description");
    rdesc.appendChild(doc.createTextNode(reportDescription()));
    root.appendChild(rdesc);

    for(QMap<QString,QString>::iterator it = _definedParams.begin();
            it != _definedParams.end(); it++) {
        QDomElement param = doc.createElement("parameter");
        param.setAttribute("name", it.key());
        param.appendChild(doc.createTextNode(it.data()));
        root.appendChild(param);
    }

    if((watermarkUseStaticText() && !watermarkText().isEmpty()) || 
        (!watermarkUseStaticText() && !watermarkQuery().isEmpty() && !watermarkColumn().isEmpty())) {
        QDomElement wm = doc.createElement("watermark");
        if(watermarkUseStaticText()) {
            QDomElement wmtext = doc.createElement("text");
            wmtext.appendChild(doc.createTextNode(watermarkText()));
            wm.appendChild(wmtext);
        } else {
            QDomElement wmdata = doc.createElement("data");
            QDomElement wmdq = doc.createElement("query");
            wmdq.appendChild(doc.createTextNode(watermarkQuery()));
            wmdata.appendChild(wmdq);
            QDomElement wmdc = doc.createElement("column");
            wmdc.appendChild(doc.createTextNode(watermarkColumn()));
            wmdata.appendChild(wmdc);
            wm.appendChild(wmdata);
        }
        if(!watermarkUseDefaultFont()) {
            ReportEntity::buildXMLFont(doc,wm,watermarkFont());
        }
        QDomElement wmopac = doc.createElement("opacity");
        wmopac.appendChild(doc.createTextNode(QString::number(watermarkOpacity())));
        wm.appendChild(wmopac);
        root.appendChild(wm);
    }

    if(bgEnabled()) {
        QDomElement bg = doc.createElement("background");
        if(bgStatic()) {
            QDomElement bgimg = doc.createElement("image");
            bgimg.appendChild(doc.createTextNode(bgImage()));
            bg.appendChild(bgimg);
        } else {
            QDomElement bgdata = doc.createElement("data");
            QDomElement bgdq = doc.createElement("query");
            bgdq.appendChild(doc.createTextNode(bgQuery()));
            bgdata.appendChild(bgdq);
            QDomElement bgdc = doc.createElement("column");
            bgdc.appendChild(doc.createTextNode(bgColumn()));
            bgdata.appendChild(bgdc);
            bg.appendChild(bgdata);
        }
        QDomElement bgmode = doc.createElement("mode");
        bgmode.appendChild(doc.createTextNode(bgResizeMode()));
        bg.appendChild(bgmode);
        QDomElement bgopac = doc.createElement("opacity");
        bgopac.appendChild(doc.createTextNode(QString::number(bgOpacity())));
        bg.appendChild(bgopac);

        QDomElement bgrect = doc.createElement("rect");
        QDomElement bgrectx = doc.createElement("x");
        bgrectx.appendChild(doc.createTextNode(QString::number(bgBoundsX())));
        bgrect.appendChild(bgrectx);
        QDomElement bgrecty = doc.createElement("y");
        bgrecty.appendChild(doc.createTextNode(QString::number(bgBoundsY())));
        bgrect.appendChild(bgrecty);
        QDomElement bgrectw = doc.createElement("width");
        bgrectw.appendChild(doc.createTextNode(QString::number(bgBoundsWidth())));
        bgrect.appendChild(bgrectw);
        QDomElement bgrecth = doc.createElement("height");
        bgrecth.appendChild(doc.createTextNode(QString::number(bgBoundsHeight())));
        bgrect.appendChild(bgrecth);
        bg.appendChild(bgrect);

        int align = bgAlign();
        // horizontal
        if((align & Qt::AlignRight) == Qt::AlignRight)
            bg.appendChild(doc.createElement("right"));
        else if((align & Qt::AlignHCenter) == Qt::AlignHCenter)
            bg.appendChild(doc.createElement("hcenter"));
        else // Qt::AlignLeft
            bg.appendChild(doc.createElement("left"));
        // vertical
        if((align & Qt::AlignBottom) == Qt::AlignBottom)
            bg.appendChild(doc.createElement("bottom"));
        else if((align & Qt::AlignVCenter) == Qt::AlignVCenter)
            bg.appendChild(doc.createElement("vcenter"));
        else // Qt::AlignTop
            bg.appendChild(doc.createElement("top"));

        root.appendChild(bg);
    }

    // pageOptions
    // -- size
    QDomElement size = doc.createElement("size");
    if(pageOptions->getPageSize() == "Custom") {
        QDomElement page_width = doc.createElement("width");
        page_width.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getCustomWidth()*100))));
        size.appendChild(page_width);
        QDomElement page_height = doc.createElement("height");
        page_height.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getCustomHeight()*100))));
        size.appendChild(page_height);
    } else if(pageOptions->getPageSize() == "Labels") {
        size.appendChild(doc.createTextNode("Labels"));
        QDomElement labeltype = doc.createElement("labeltype");
        labeltype.appendChild(doc.createTextNode(pageOptions->getLabelType()));
        root.appendChild(labeltype);
    } else {
        size.appendChild(doc.createTextNode(pageOptions->getPageSize()));
    }
    root.appendChild(size);
    // -- orientation
    QString str_orientation;
    if(pageOptions->isPortrait()) {
        str_orientation = "portrait";
    } else {
        str_orientation = "landscape";
    }
    root.appendChild(doc.createElement(str_orientation));
    // -- margins
    QDomElement margin;
    margin = doc.createElement("topmargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginTop()*100))));
    root.appendChild(margin);
    margin = doc.createElement("bottommargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginBottom()*100))));
    root.appendChild(margin);
    margin = doc.createElement("rightmargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginRight()*100))));
    root.appendChild(margin);
    margin = doc.createElement("leftmargin");
    margin.appendChild(doc.createTextNode(QString::number((int)(pageOptions->getMarginLeft()*100))));
    root.appendChild(margin);

    // write out are Query Sources
    QDomElement qsource;
    QDomElement qname;
    QDomElement qsql;
    QuerySource * qs = NULL;
    for(unsigned int i = 0; i < qsList->size(); i++) {
        qs = qsList->get(i);
        qsource = doc.createElement("querysource");
        qname = doc.createElement("name");
        qname.appendChild(doc.createTextNode(qs->name()));
        qsource.appendChild(qname);
        qsql = doc.createElement("sql");
        qsql.appendChild(doc.createTextNode(qs->query()));
        qsource.appendChild(qsql);
        root.appendChild(qsource);
    }
    qs = NULL;

    QDomElement cdef;
    QDomElement cname;
    QDomElement ccomponent;
    QMapIterator<QString, QColor> cit;
    for(cit = _colorMap.begin(); cit != _colorMap.end(); ++cit) {
        cdef = doc.createElement("colordef");
        cname = doc.createElement("name");
        cname.appendChild(doc.createTextNode(cit.key()));
        cdef.appendChild(cname);
        ccomponent = doc.createElement("red");
        ccomponent.appendChild(doc.createTextNode(QString::number(cit.data().red())));
        cdef.appendChild(ccomponent);
        ccomponent = doc.createElement("green");
        ccomponent.appendChild(doc.createTextNode(QString::number(cit.data().green())));
        cdef.appendChild(ccomponent);
        ccomponent = doc.createElement("blue");
        ccomponent.appendChild(doc.createTextNode(QString::number(cit.data().blue())));
        cdef.appendChild(ccomponent);
        root.appendChild(cdef);
    }

    QDomElement section;

    // report head
    if(rptHead) {
        section = doc.createElement("rpthead");
        rptHead->buildXML(doc, section);
        root.appendChild(section);
    }

    // page head first
    if(pageHeadFirst) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("firstpage"));
        pageHeadFirst->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head odd
    if(pageHeadOdd) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("odd"));
        pageHeadOdd->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head even
    if(pageHeadEven) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("even"));
        pageHeadEven->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head last
    if(pageHeadLast) {
        section = doc.createElement("pghead");
        section.appendChild(doc.createElement("lastpage"));
        pageHeadLast->buildXML(doc, section);
        root.appendChild(section);
    }
    // page head any
    if(pageHeadAny) {
        section = doc.createElement("pghead");
        pageHeadAny->buildXML(doc, section);
        root.appendChild(section);
    }

    // detail sections
    for(int ii = 0; ii < detailSectionCount(); ii++) {
        section = doc.createElement("section");
        getSection(ii)->buildXML(doc,section);
        root.appendChild(section);
    }

    // page foot first
    if(pageFootFirst) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("firstpage"));
        pageFootFirst->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot odd
    if(pageFootOdd) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("odd"));
        pageFootOdd->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot even
    if(pageFootEven) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("even"));
        pageFootEven->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot last
    if(pageFootLast) {
        section = doc.createElement("pgfoot");
        section.appendChild(doc.createElement("lastpage"));
        pageFootLast->buildXML(doc, section);
        root.appendChild(section);
    }
    // page foot any
    if(pageFootAny) {
        section = doc.createElement("pgfoot");
        pageFootAny->buildXML(doc, section);
        root.appendChild(section);
    }

    // report foot
    if(rptFoot) {
        section = doc.createElement("rptfoot");
        rptFoot->buildXML(doc, section);
        root.appendChild(section);
    }

    return doc;
}