コード例 #1
0
ファイル: cell.cpp プロジェクト: DoubleYouEl/CrochetCharts
void Cell::setColor(QColor c)
{

    if(mColor != c) {
        QString old = "";
        if(mColor.isValid())
            old = mColor.name();
        mColor = c;

        QSvgRenderer *r = stitch()->renderSvg(c);
        if(r)
            setSharedRenderer(r);

        emit colorChanged(old, c.name());
        update();
    }

}
コード例 #2
0
Piece::Piece(const QPointF & top_left, const unsigned int square, const piece_t type, QGraphicsItem * parent)
	: QGraphicsSvgItem(parent),
	  square_(square),
	  type_(type),
	  moves_() {
	setAcceptedMouseButtons(0);

	setSharedRenderer(&
		(type_ == WHITE_MAN ? white_man_renderer :
			(type_ == WHITE_KING ? white_king_renderer:
				(type_ == BLACK_MAN ? black_man_renderer : black_king_renderer))));

	// TODO scale and center properly
	qreal size = 38;
	qreal new_size = SQUARE_SIZE - 10; // leave 5 pixels for each margin
	qreal factor = new_size / size;
	setScale(factor);
	setPos(top_left.x() + 1, top_left.y() + 1);
}
コード例 #3
0
ファイル: cell.cpp プロジェクト: DoubleYouEl/CrochetCharts
void Cell::useAlternateRenderer(bool useAlt)
{
    if(mStitch->isSvg() && mStitch->renderSvg()->isValid()) {
        QString primary = Settings::inst()->value("stitchPrimaryColor").toString();
        QString secondary = Settings::inst()->value("stitchAlternateColor").toString();
        QString color;

        //only use the primary and secondary colors if the stitch is using the default colors.
        if(useAlt && mColor == primary) {
            color = secondary;
        } else if(!useAlt && mColor == secondary) {
            color = primary;
        } else {
            color = mColor.name();
        }

        mColor = QColor(color);
        setSharedRenderer(mStitch->renderSvg(mColor.name()));
    }
}
コード例 #4
0
ファイル: cell.cpp プロジェクト: DoubleYouEl/CrochetCharts
void Cell::setStitch(Stitch *s)
{

    if (mStitch != s) {
        QString old;
        bool doUpdate = false;
        
        if (mStitch) {
            old = mStitch->name();
            doUpdate = (mStitch->isSvg() != s->isSvg());
        }
        mStitch = s;
        if(s->isSvg()) {
            setSharedRenderer(s->renderSvg(mColor));
        }

        if(doUpdate)
            update();
        
        emit stitchChanged(old, s->name());
    }
    
    setTransformOriginPoint(s->width()/2, s->height());
}
コード例 #5
0
bool GraphicsIniItem::loadFrame(int frame)
{
    if (frame >= currentState.frames.size())
        return false;

    // stores current frame
    currentFrame = frame;

    // updates the image to be rendered
    if (currentRenderer)
        delete currentRenderer;

    currentRenderer = new QSvgRenderer(prefix
                                       + currentState.frames[currentFrame],
                                       this);

    setSharedRenderer(currentRenderer);

    // starts the timer
    if (currentState.period)
        timer.start(currentState.period);

    return true;
}