Exemplo n.º 1
0
void ResourceView::colorItemSelected(int index)
{
    QString rgbValue("#");
    rgbValue += QString::number(HbColorScheme::color(mResourcesList->items()[index]).red(), 16);
    rgbValue += QString::number(HbColorScheme::color(mResourcesList->items()[index]).green(), 16);
    rgbValue += QString::number(HbColorScheme::color(mResourcesList->items()[index]).blue(), 16);
    mResourceItem->setPlainText(rgbValue.toUpper());
}
Exemplo n.º 2
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();
    }

}
Exemplo n.º 3
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;
        }
    }
}