Example #1
0
void RecSkinWidget::addItem(const QString &fileName,const QPixmap &pix,
                            const QColor &averageColor,bool isColor,bool isSkin)
{
    if(isSkin)
        emit currentPixmap(fileName,pix,averageColor);

    RecSkinPushButton *SkinPushButton = new RecSkinPushButton(this);
    connect(SkinPushButton,SIGNAL(currentPixmap(QString,QPixmap,QColor)),
            this,SIGNAL(currentPixmap(QString,QPixmap,QColor)));

    connect(SkinPushButton,SIGNAL(clickNum(int)),
            this,SLOT(onClickNum(int)));

    SkinPushButton->setPixmap(fileName,pix,averageColor,60,isColor);
    SkinPushButton->setSkin(isSkin);
    if(isSkin)
    {
        SkinPushButton->setCanDelete(true);

        nowPixNum = 0;
    }

    connect(SkinPushButton,SIGNAL(closeNum(int,QString)),
            this,SLOT(onCloseNum(int,QString)));

    ui->horizontalLayoutHistory->insertWidget(0,SkinPushButton);
    buttons.insert(0,SkinPushButton);
    int buttonNum = m_rowMaxPix/2 + 1;
    if(buttons.size() > buttonNum)
    {
        RecSkinPushButton *SkinPushButtonBotton = buttons.value(buttonNum);
        ui->horizontalLayoutHistory->removeWidget(SkinPushButtonBotton);
        ui->horizontalLayoutHistoryBotton->insertWidget(0,SkinPushButtonBotton);

        if(buttons.size() == m_rowMaxPix + 1)
        {
            int buttonbottonNum = m_rowMaxPix;
            ui->horizontalLayoutHistoryBotton->removeWidget(buttons.value(buttonbottonNum));
            RecSkinPushButton *delButton = buttons.takeAt(buttonbottonNum);
            QString fileName = delButton->getFileName();
            if(!fileName.isEmpty())
                QFile::remove(fileName);
            delButton->deleteLater();
        }
    }
    for(int i = 0; i < buttons.size(); ++i)
        buttons.value(i)->setNum(i);
}
Example #2
0
bool GroupButton::handleSelectAllButton(uint32_t checkedDevicesCount, uint32_t reachableDevicesCount) {
    bool renderFlag = false;
    EGroupButtonState state;
    if (reachableDevicesCount == 0) {
        state = EGroupButtonState::disabled;
    } else if (mCheckedCount > 0) {
        state = EGroupButtonState::clearAll;
    } else {
        state = EGroupButtonState::selectAll;
    }

    if (mButtonState != state) {
        mButtonState = state;
        mButton->setPixmap(currentPixmap());
        renderFlag = true;
    }

   if (mCheckedCount != checkedDevicesCount
           || mReachableCount != reachableDevicesCount) {
        mCheckedCount = checkedDevicesCount;
        mReachableCount = reachableDevicesCount;
        renderFlag = true;
   }
   return renderFlag;
}
Example #3
0
void RecSkinWidget::onCloseNum(int num,const QString &fileName)
{
    int type = QjtMessageBox::warning(0,tr("warning"),tr("sure to delete ?"),QMessageBox::Ok|QMessageBox::No);
    if(type == QMessageBox::No || type == QMessageBox::NoButton)
    {
        return;
    }
    RecSkinPushButton *tmpButton = NULL;
    if(nowPixNum == num)
        emit currentPixmap(oneFileName,onePix,oneColor);
    else
        tmpButton = buttons.value(nowPixNum);
    if(num <= 7)
    {
        ui->horizontalLayoutHistory->removeWidget(buttons.value(num));
        buttons.takeAt(num)->deleteLater();
        int buttonNum = m_rowMaxPix/2;
        RecSkinPushButton *SkinPushButtonBotton = buttons.value(buttonNum);
        ui->horizontalLayoutHistoryBotton->removeWidget(SkinPushButtonBotton);
        ui->horizontalLayoutHistory->insertWidget(buttonNum,SkinPushButtonBotton);
    }
    else
    {
        ui->horizontalLayoutHistoryBotton->removeWidget(buttons.value(num));
        buttons.takeAt(num)->deleteLater();
    }
    QPixmap historyPix(":/skinHistoryImage.png");
    RecSkinPushButton *SkinPushButton = new RecSkinPushButton(this);
    connect(SkinPushButton,SIGNAL(currentPixmap(QString,QPixmap,QColor)),
            this,SIGNAL(currentPixmap(QString,QPixmap,QColor)));
    SkinPushButton->setPixmap("",historyPix,QColor(255,255,255,255),60,false);
    buttons << SkinPushButton;
    ui->horizontalLayoutHistoryBotton->insertWidget(6,SkinPushButton);

    for(int i = 0; i < buttons.size(); ++i)
    {
        buttons.value(i)->setNum(i);
        if(tmpButton == buttons.value(i))
            nowPixNum = i;
    }

    QFile::remove(fileName);
}
Example #4
0
void GroupButton::buttonPressed(bool) {
    if (mButtonState != EGroupButtonState::disabled) {
        if (mCheckedCount > 0) {
            mButtonState = EGroupButtonState::selectAll;
            mCheckedCount = 0;
        } else {
            mCheckedCount = mReachableCount;
            mButtonState = EGroupButtonState::clearAll;
        }

        mButton->setPixmap(currentPixmap());

        emit groupSelectAllToggled(mTitle->text(), EGroupButtonState::clearAll == mButtonState);
        update();
    }
}
Example #5
0
void RecSkinPushButton::mousePressEvent(QMouseEvent */*e*/)
{
    if(isSkin)
    {
        if(!isColorTrue)
        {
            QImage skinImage(originalPixmap.toImage());
            int num = 0;
            int red = 0;
            int green = 0;
            int blue = 0;
            for(int ii = 0; ii < skinImage.width(); ++ii)
            {
                for(int j = 0; j < skinImage.height(); ++j)
                {
                    ++num;
                    QRgb rgbValue(skinImage.pixel(ii, j));
                    red += qRed(rgbValue);
                    green += qGreen(rgbValue);
                    blue += qBlue(rgbValue);
                }
            }
            if(num != 0)
            {
                red = red/num;
                green = green/num;
                blue = blue/num;
            }
            averageColor = QColor(red,green,blue,255);
        }

        emit currentPixmap(fileName,originalPixmap,averageColor);
        emit clickNum(m_num);
    }
    else
    {
        emit clickResult();
    }

}
Example #6
0
RecSkinWidget::RecSkinWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::RecSkinWidget)
    , nowPixNum(-1)
    , m_rowMaxPix(15)
{
    ui->setupUi(this);
    setFixedSize(490,255);

    QStringList l = MOption::instance()->option(OPTION_Recommand, OPTION_GROUP_Theme).toStringList();
    QString appPath = QCoreApplication::applicationDirPath() + "/";

    for(int i = 0; i < 4; ++i)
    {
        RecSkinPushButton *SkinPushButton = new RecSkinPushButton(this);
        connect(SkinPushButton,SIGNAL(currentPixmap(QString,QPixmap,QColor)),
                this,SIGNAL(currentPixmap(QString,QPixmap,QColor)));

        connect(SkinPushButton,SIGNAL(clickNum(int)),
                this,SLOT(onClickNum(int)));
        if(i <= l.size() - 1)
        {
            QString path = appPath + l.at(i);
            qDebug() << path;
            QPixmap pix(path);
            SkinPushButton->setToolTip("");
            if(i == 0)
            {
                QString themeType = MOption::instance()->option("WindowBGPixmapType", "theme").toString();


                QImage skinImage(pix.toImage());
                int num = 0;
                int red = 0;
                int green = 0;
                int blue = 0;
                for(int ii = 0; ii < skinImage.width(); ++ii)
                {
                    for(int j = 0; j < skinImage.height(); ++j)
                    {
                        ++num;
                        QRgb rgbValue(skinImage.pixel(ii, j));
                        red += qRed(rgbValue);
                        green += qGreen(rgbValue);
                        blue += qBlue(rgbValue);
                    }
                }
                if(num != 0)
                {
                    red = red/num;
                    green = green/num;
                    blue = blue/num;
                }

                oneFileName = path;
                onePix = pix;
                oneColor = QColor(red,green,blue,255);
                if(themeType.isEmpty())
                {
                    SkinPushButton->setPixmap(path,pix,oneColor,120,true);

                    QTimer::singleShot(1000, this, SLOT(getRgb()));
                }
                else
                {
                    SkinPushButton->setPixmap(path,pix,QColor(255,255,255,255),120);
                }
            }
            else
            {
                SkinPushButton->setPixmap(path,pix,QColor(255,255,255,255),120);
            }
            SkinPushButton->setSkin(true);
        }


        ui->horizontalLayoutDefault->addWidget(SkinPushButton);
    }

    QPixmap addPix(":/add.png");
    QPixmap historyPix(":/skinHistoryImage.png");
    RecSkinPushButton *button = new RecSkinPushButton(this);
    button->setPixmap("",addPix, QColor(255,255,255,255),60,false);
    connect(button,SIGNAL(clickResult()),
            this,SIGNAL(definePixmapResult()));
    ui->horizontalLayoutHistoryBotton->insertWidget(0,button);


    QString historyPath = QCoreApplication::applicationDirPath() + "/theme/saved";

    // TODO MEM leak
    QDir *dir = new QDir(historyPath);
    QStringList filter;

    QList<QFileInfo> *fileInfo=new QList<QFileInfo>(dir->entryInfoList(filter));

    QStringList fileNames;

    for(int i = 0; i < fileInfo->count(); ++ i)
    {
        if(fileInfo->at(i).isDir())
            continue;
        fileNames << fileInfo->at(i).fileName();
    }
    fileNames.sort();
    int fileSize = fileNames.size();
    if(fileSize > m_rowMaxPix)
        fileSize = m_rowMaxPix;

    for(int i = 0; i < m_rowMaxPix - fileSize; ++i)
    {
        addItem("",historyPix, QColor(255,255,255,255),false,false);
    }

    for(int i = 0; i < fileSize; ++i)
    {
        QString imagePathName = historyPath + "/" + fileNames.value(i);
        QPixmap pxi(imagePathName);
        addItem(imagePathName,pxi, QColor(255,255,255,255),false,true);
    }

    QString themeType = MOption::instance()->option("WindowBGPixmapType", "theme").toString();
    if(themeType == "bitmap")
    {
        QString fileName = MOption::instance()->option("WindowBGPixmap", "theme").toString();

        for(int i = 0; i < buttons.size(); ++i)
        {
            if(buttons.value(i)->getFileName() == fileName)
                nowPixNum = i;
        }
    }
}
Example #7
0
void RecSkinWidget::getRgb()
{
    emit currentPixmap(oneFileName,onePix,oneColor);
}
Example #8
0
void GroupButton::resizeEvent(QResizeEvent *) {
    resize();
    mButton->setPixmap(currentPixmap());
}
Example #9
0
QSize Animation::size()
{
	//qDebug() << "Animation::size, currentFrameNumber = " << currentFrameNumber();
	return currentPixmap().size();
}