Clean code

This commit is contained in:
Angela Mazzurco 2017-09-11 16:42:29 +02:00
parent cd2e18f27b
commit 4642f2ab2a
2 changed files with 12 additions and 63 deletions

View File

@ -79,18 +79,7 @@ public slots:
reader.setFileName(path);
QImage image = reader.read();
painter.drawImage(0, 0, image); // xi, yi is the position for imagei
// if (counter == 0)
// {
// base = QImage(bg.size(), QImage::Format_ARGB32_Premultiplied);
// qDebug() << "FIIIRST ";
// }
// else
// {
// }
qDebug() << "iterating through QVariantList ";
qDebug() << (*j).toString(); // Print QVariant
qDebug() << "Generating face Avatar from: " << (*j).toString(); // Print QVariant
counter++;
}
painter.end();
@ -104,23 +93,9 @@ public slots:
// Get Based 64 image string
QString encoded = QString(ba.toBase64());
qDebug() << "@@@@@ encoded avatar " << encoded ;
return encoded;
}
QImage getImageFromPath (QString localPath)
{
qDebug() << "getImageFromPath() local path:" << localPath ;
// Read the image
QImageReader reader;
reader.setFileName(localPath);
QImage image = reader.read();
return image;
}
};

View File

@ -16,7 +16,6 @@ Item
id: imageAvatar
width: height
height: iconSize
visible: true
}
// Canvas
@ -134,13 +133,9 @@ Item
{
var url = src(gender, i, data[i+1])
onloads.push(url)
// canvasAvatar.loadImage(url)
}
// canvasAvatar.images = onloads
// canvasAvatar.callback = callback
var base64Image = androidImagePicker.faceImage(onloads, canvasSizes)
callback("data:image/png;base64,"+base64Image)
// canvasAvatar.requestPaint()
}
// Create the identicon
@ -148,32 +143,11 @@ Item
{
var iconId = [dataHex, iconSize];
var update = function(data)
{
// This conditions are for solve a bug on an Lg S3.
// On this device the toDataURL() is incompleted.
// So for see the complete avatar at least at first execution we'll show the canvas,
// instead of the image component.
// See issue: https://gitlab.com/angesoc/RetroShare/issues/37
if (facesCache.iconCache[iconId])
{
imageAvatar.source = data
imageAvatar.visible = true
// canvasAvatar.visible = false
// canvasAvatar.height = 0
imageAvatar.height = iconSize
}
else
{
// canvasAvatar.visible = true
imageAvatar.visible = false
// canvasAvatar.height = iconSize
imageAvatar.height = 0
}
facesCache.iconCache[iconId] = data;
}
{
imageAvatar.source = data
imageAvatar.height = iconSize
facesCache.iconCache[iconId] = data;
}
if (facesCache.iconCache.hasOwnProperty(iconId))
{
@ -186,13 +160,13 @@ Item
else
{
var onImageGenerated = function(data)
{
{
facesCache.callbackCache[iconId].forEach(function(callback)
{
callback(data);
})
}
facesCache.callbackCache[iconId].forEach(function(callback)
{
callback(data);
})
}
facesCache.callbackCache[iconId] = [update];
if (dataHex)