Ejemplo n.º 1
0
Window::Window(const QString &title, const QSizeF &size,
               const QString &path/* = QString()*/, bool isModal/* = false*/, bool isShowTitle/* = true*/)
    : size(size), keep_when_disappear(false), m_isModal(isModal)
{
    setFlags(ItemIsMovable);

    setAcceptedMouseButtons(Qt::LeftButton);
    setData(0, title);

    if (!path.isEmpty()) {
        outimg = new QImage(path);
    }
    else {
        outimg = size.width() > size.height()
                 ? new QImage("image/system/tip.png")
                 : new QImage("image/system/about.png");
    }

    scaleTransform = new QGraphicsScale(this);
    scaleTransform->setXScale(1.05);
    scaleTransform->setYScale(0.95);
    scaleTransform->setOrigin(QVector3D(boundingRect().width() / 2, boundingRect().height() / 2, 0));

    QList<QGraphicsTransform *> transforms;
    transforms << scaleTransform;
    setTransformations(transforms);

    setOpacity(0.0);

    if (isShowTitle) {
        titleItem = new QGraphicsTextItem(this);
        setTitle(title);
    }
}
Ejemplo n.º 2
0
Window::Window(const QString &title, const QSizeF &size, const QString &path)
    : size(size), keep_when_disappear(false)
{
    setFlags(ItemIsMovable);

    QPixmap *bg;
    if (!path.isEmpty())
        bg = new QPixmap(path);
    else
        bg = size.width() > size.height() ? new QPixmap("image/system/tip.png") : new QPixmap("image/system/about.png");
    QImage bgimg = bg->toImage();
    outimg = new QImage(size.toSize(), QImage::Format_ARGB32);

    qreal pad = 10;

    int w = bgimg.width(), h = bgimg.height();
    int tw = outimg->width(), th = outimg->height();

    qreal xc = (w - 2 * pad) / (tw - 2 * pad), yc = (h - 2 * pad) / (th - 2 * pad);

    for (int i = 0; i < tw; i++) {
        for (int j = 0; j < th; j++) {
            int x = i, y = j;

            if (x >= pad && x <= (tw - pad))
                x = pad + (x - pad) * xc;
            else if (x >= (tw - pad))
                x = w - (tw - x);

            if (y >= pad && y <= (th - pad))
                y = pad + (y - pad) * yc;
            else if (y >= (th - pad))
                y = h - (th - y);

            QRgb rgb = bgimg.pixel(x, y);
            outimg->setPixel(i, j, rgb);
        }
    }

    scaleTransform = new QGraphicsScale(this);
    scaleTransform->setXScale(1.05);
    scaleTransform->setYScale(0.95);
    scaleTransform->setOrigin(QVector3D(boundingRect().width() / 2, boundingRect().height() / 2, 0));

    QList<QGraphicsTransform *> transforms;
    transforms << scaleTransform;
    setTransformations(transforms);

    setOpacity(0.0);

    titleItem = new QGraphicsTextItem(this);
    setTitle(title);
}
Ejemplo n.º 3
0
Window::Window(const QString &title, const QSizeF &size)
    :title(title), size(size), keep_when_disappear(false)
{
    setFlags(ItemIsMovable);

    QPixmap *bg;
    bg = size.width()>size.height() ?
                new QPixmap("image/system/tip.png")
              : new QPixmap("image/system/about.png");
    QImage bgimg = bg->toImage();
    outimg = new QImage(size.toSize(),QImage::Format_ARGB32);

    qreal pad = 10;

    int w = bgimg.width();
    int h = bgimg.height();

    int tw = outimg->width();
    int th  =outimg->height();

    qreal xc = (w - 2*pad)/(tw - 2*pad);
    qreal yc = (h - 2*pad)/(th - 2*pad);

    for(int i=0;i<tw;i++)
        for(int j=0;j<th;j++)
        {
            int x = i;
            int y = j;

            if( x>=pad && x<=(tw - pad) ) x = pad + (x - pad)*xc;
            else if(x>=(tw-pad))x = w - (tw - x);

            if( y>=pad && y<=(th - pad) ) y = pad + (y - pad)*yc;
            else if(y>=(th-pad))y = h - (th - y);


            QRgb rgb = bgimg.pixel(x,y);
            outimg->setPixel(i,j,rgb);
        }


    scaleTransform = new QGraphicsScale(this);
    scaleTransform->setXScale(1.05);
    scaleTransform->setYScale(0.95);
    scaleTransform->setOrigin(QVector3D(
                                  this->boundingRect().width()/2,
                                  this->boundingRect().height()/2,
                                  0
                                  ));

    QList<QGraphicsTransform *> transforms;
    transforms << scaleTransform;
    setTransformations(transforms);

    this->setOpacity(0.0);

    QGraphicsTextItem * titleItem = new QGraphicsTextItem(this);

    QString style;
    style.append("font-size:18pt; ");
    style.append("color:#77c379; ");
    style.append(QString("font-family: %1").arg(Config.SmallFont.family()));

    QString content;
    content.append(QString("<h style=\"%1\">%2</h>")
                   .arg(style).arg(title));

    titleItem->setHtml(content);
    titleItem->moveBy(size.width()/2 - titleItem->boundingRect().width()/2,10);
}