2012-09-13 18:58:42 -04:00
|
|
|
#include <QBuffer>
|
|
|
|
|
2012-09-12 17:43:41 -04:00
|
|
|
#include "AlbumCreateDialog.h"
|
|
|
|
#include "ui_AlbumCreateDialog.h"
|
|
|
|
|
|
|
|
#include "util/misc.h"
|
2012-11-10 18:42:38 -05:00
|
|
|
#include "gxs/rsgxsflags.h"
|
2012-09-12 17:43:41 -04:00
|
|
|
|
2012-10-21 15:45:35 -04:00
|
|
|
AlbumCreateDialog::AlbumCreateDialog(TokenQueue *photoQueue, RsPhotoV2 *rs_photo, QWidget *parent):
|
2012-09-12 17:43:41 -04:00
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::AlbumCreateDialog), mPhotoQueue(photoQueue), mRsPhoto(rs_photo)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
connect(ui->publishButton, SIGNAL(clicked()), this, SLOT(publishAlbum()));
|
2012-09-13 18:58:42 -04:00
|
|
|
connect(ui->AlbumThumbNail, SIGNAL(clicked()), this, SLOT(addAlbumThumbnail()));
|
2012-09-12 17:43:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
AlbumCreateDialog::~AlbumCreateDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2012-11-10 18:42:38 -05:00
|
|
|
#define PUBLIC_INDEX 0
|
|
|
|
#define RESTRICTED_INDEX 1
|
|
|
|
#define PRIVATE_INDEX 2
|
|
|
|
|
2012-09-12 17:43:41 -04:00
|
|
|
void AlbumCreateDialog::publishAlbum()
|
|
|
|
{
|
|
|
|
// get fields for album to publish, publish and then exit dialog
|
|
|
|
RsPhotoAlbum album;
|
|
|
|
|
|
|
|
album.mCaption = ui->lineEdit_Caption_2->text().toStdString();
|
|
|
|
album.mPhotographer = ui->lineEdit_Photographer->text().toStdString();
|
|
|
|
album.mMeta.mGroupName = ui->lineEdit_Title_2->text().toStdString();
|
|
|
|
album.mDescription = ui->textEdit_Description->toPlainText().toStdString();
|
|
|
|
album.mWhere = ui->lineEdit_Where->text().toStdString();
|
2012-09-13 18:58:42 -04:00
|
|
|
album.mPhotographer = ui->lineEdit_Photographer->text().toStdString();
|
|
|
|
getAlbumThumbnail(album.mThumbnail);
|
2012-09-12 17:43:41 -04:00
|
|
|
|
2012-11-10 18:42:38 -05:00
|
|
|
|
|
|
|
int currIndex = ui->privacyComboBox->currentIndex();
|
|
|
|
|
|
|
|
switch(currIndex)
|
|
|
|
{
|
|
|
|
case PUBLIC_INDEX:
|
|
|
|
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
|
|
|
break;
|
|
|
|
case RESTRICTED_INDEX:
|
|
|
|
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_RESTRICTED;
|
|
|
|
break;
|
|
|
|
case PRIVATE_INDEX:
|
|
|
|
album.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PRIVATE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-09-12 17:43:41 -04:00
|
|
|
uint32_t token;
|
|
|
|
mRsPhoto->submitAlbumDetails(token, album);
|
|
|
|
mPhotoQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2012-09-13 18:58:42 -04:00
|
|
|
bool AlbumCreateDialog::getAlbumThumbnail(RsPhotoThumbnail &nail)
|
|
|
|
{
|
|
|
|
const QPixmap *tmppix = &mThumbNail;
|
|
|
|
|
|
|
|
QByteArray ba;
|
|
|
|
QBuffer buffer(&ba);
|
|
|
|
|
|
|
|
if(!tmppix->isNull())
|
|
|
|
{
|
|
|
|
// send chan image
|
|
|
|
|
|
|
|
buffer.open(QIODevice::WriteOnly);
|
|
|
|
tmppix->save(&buffer, "PNG"); // writes image into ba in PNG format
|
|
|
|
|
|
|
|
RsPhotoThumbnail tmpnail;
|
|
|
|
tmpnail.data = (uint8_t *) ba.data();
|
|
|
|
tmpnail.size = ba.size();
|
|
|
|
|
|
|
|
nail.copyFrom(tmpnail);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nail.data = NULL;
|
|
|
|
nail.size = 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-12 17:43:41 -04:00
|
|
|
void AlbumCreateDialog::addAlbumThumbnail()
|
|
|
|
{
|
2012-09-25 17:04:04 -04:00
|
|
|
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Album Thumbnail"), 128, 128);
|
2012-09-12 17:43:41 -04:00
|
|
|
|
|
|
|
if (img.isNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
mThumbNail = img;
|
|
|
|
|
|
|
|
// to show the selected
|
|
|
|
ui->AlbumThumbNail->setIcon(mThumbNail);
|
|
|
|
}
|