Example #1
0
void StatusIcon::update(bool isReachable, bool isOn, double brightness) {
    mIcon->setFixedSize(this->width(), this->height());
    QPixmap buttonIcon;
    if (!isReachable) {
        buttonIcon = QPixmap(":/images/redButton.png");
    } else if (!isOn) {
        buttonIcon = QPixmap(":/images/blackButton.png");
    } else {
        buttonIcon = QPixmap(":/images/whiteButton.png");

        QPixmap blackPixmap(":/images/blackButton.png");
        blackPixmap = blackPixmap.scaled(int(mIcon->height() * 0.5f),
                                       int(mIcon->height() * 0.5f),
                                       Qt::KeepAspectRatio,
                                       Qt::SmoothTransformation);
        mBlackIcon->setPixmap(blackPixmap);

        mBlackIcon->setGeometry(mIcon->geometry());

        // make black icon inverse of brightness
        double blackBrightness = 1.0 - (brightness / 100.0);
        auto effect = new QGraphicsOpacityEffect(mBlackIcon);
        effect->setOpacity(blackBrightness);
        mBlackIcon->setGraphicsEffect(effect);
    }
    buttonIcon = buttonIcon.scaled(int(mIcon->height() * 0.5f),
                                   int(mIcon->height() * 0.5f),
                                   Qt::KeepAspectRatio,
                                   Qt::SmoothTransformation);
    mIcon->setPixmap(buttonIcon);
}
Example #2
0
Field::Field(QColor color, int row, int column) :
    QLabel()
{
    this->setFixedSize(Data::WIDTH_FIELD, Data::HEIGTH_FIELD);
    internColor = color;
    this->row = row;
    this->column = column;
    isFree = true;
    isClicked = false;
    tile = 0;
    if (internColor == Qt::black){
        QPixmap blackPixmap(":/images/black.bmp");
        this->setPixmap(blackPixmap);
    } else if (internColor == Qt::white){
        QPixmap whitePixmap(":/images/white.bmp");
        this->setPixmap(whitePixmap);
    }

    //connect(this, SIGNAL(clicked()), this , SLOT(changePixmap()));

}
Example #3
0
void Field::renewBlackColor(){
    QPixmap blackPixmap(":/images/black.bmp");
    this->setPixmap(blackPixmap);
}