From 03e2ee72e07243f19c53aebd0c79e6ca6a64bf6b Mon Sep 17 00:00:00 2001 From: drbob Date: Thu, 21 Jun 2012 15:52:49 +0000 Subject: [PATCH] Major improvements to the PhotoSharing Application. - Editing of Photo Descriptions & Album descriptions. - Photo versions. - Default to Album description, if Photo not filled in. - Album Cover images. - SlideShow. Todo: - Deletion of Photos & Albums. - Handle Photo Files (only thumbnails at the moment). - Searching. - Sharing options. - Image processing. - +lots more. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5239 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 9 +- .../src/gui/PhotoShare/PhotoAddDialog.cpp | 436 ++++++++++++++++- .../src/gui/PhotoShare/PhotoAddDialog.h | 29 +- .../src/gui/PhotoShare/PhotoAddDialog.ui | 55 ++- .../src/gui/PhotoShare/PhotoDetailsDialog.cpp | 460 ++++++++++++++++-- .../src/gui/PhotoShare/PhotoDetailsDialog.h | 3 + .../src/gui/PhotoShare/PhotoDialog.cpp | 99 +++- .../src/gui/PhotoShare/PhotoDialog.h | 5 +- .../src/gui/PhotoShare/PhotoDialog.ui | 22 +- .../src/gui/PhotoShare/PhotoDrop.cpp | 37 +- retroshare-gui/src/gui/PhotoShare/PhotoDrop.h | 5 + .../src/gui/PhotoShare/PhotoItem.cpp | 135 +++-- retroshare-gui/src/gui/PhotoShare/PhotoItem.h | 10 +- .../src/gui/PhotoShare/PhotoSlideDetails.ui | 129 +++++ .../src/gui/PhotoShare/PhotoSlideShow.cpp | 349 +++++++++++++ .../src/gui/PhotoShare/PhotoSlideShow.h | 92 ++++ .../src/gui/PhotoShare/PhotoSlideShow.ui | 144 ++++++ 17 files changed, 1860 insertions(+), 159 deletions(-) create mode 100644 retroshare-gui/src/gui/PhotoShare/PhotoSlideDetails.ui create mode 100644 retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp create mode 100644 retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.h create mode 100644 retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 8afc16798..e23df4862 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -18,9 +18,13 @@ RCC_DIR = temp/qrc UI_DIR = temp/ui MOC_DIR = temp/moc -#CONFIG += debug +CONFIG += debug debug { QMAKE_CFLAGS += -g + QMAKE_CXXFLAGS -= -O2 + QMAKE_CXXFLAGS += -O0 + QMAKE_CFLAGS -= -O2 + QMAKE_CFLAGS += -O0 } minimal { @@ -863,17 +867,20 @@ photoshare { gui/PhotoShare/PhotoAddDialog.h \ gui/PhotoShare/PhotoDetailsDialog.h \ gui/PhotoShare/PhotoDrop.h \ + gui/PhotoShare/PhotoSlideShow.h \ FORMS += gui/PhotoShare/PhotoItem.ui \ gui/PhotoShare/PhotoDialog.ui \ gui/PhotoShare/PhotoAddDialog.ui \ gui/PhotoShare/PhotoDetailsDialog.ui \ + gui/PhotoShare/PhotoSlideShow.ui \ SOURCES += gui/PhotoShare/PhotoItem.cpp \ gui/PhotoShare/PhotoDialog.cpp \ gui/PhotoShare/PhotoAddDialog.cpp \ gui/PhotoShare/PhotoDetailsDialog.cpp \ gui/PhotoShare/PhotoDrop.cpp \ + gui/PhotoShare/PhotoSlideShow.cpp \ } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.cpp index 49e2a00a5..f1d1a5309 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.cpp @@ -37,11 +37,20 @@ PhotoAddDialog::PhotoAddDialog(QWidget *parent) connect(ui.pushButton_ShiftLeft, SIGNAL( clicked( void ) ), ui.scrollAreaWidgetContents, SLOT( moveLeft( void ) ) ); connect(ui.pushButton_ShiftRight, SIGNAL( clicked( void ) ), ui.scrollAreaWidgetContents, SLOT( moveRight( void ) ) ); connect(ui.pushButton_EditPhotoDetails, SIGNAL( clicked( void ) ), this, SLOT( showPhotoDetails( void ) ) ); + connect(ui.pushButton_EditAlbumDetails, SIGNAL( clicked( void ) ), this, SLOT( showAlbumDetails( void ) ) ); + connect(ui.pushButton_DeleteAlbum, SIGNAL( clicked( void ) ), this, SLOT( deleteAlbum( void ) ) ); + connect(ui.pushButton_DeletePhoto, SIGNAL( clicked( void ) ), this, SLOT( deletePhoto( void ) ) ); connect(ui.pushButton_Publish, SIGNAL( clicked( void ) ), this, SLOT( publishAlbum( void ) ) ); mPhotoDetails = NULL; + mPhotoQueue = new TokenQueue(rsPhoto, this); + + ui.AlbumDrop->setSingleImage(); + connect(ui.AlbumDrop, SIGNAL( photosChanged( void ) ), this, SLOT( albumImageChanged( void ) ) ); + connect(ui.scrollAreaWidgetContents, SIGNAL( photosChanged( void ) ), this, SLOT( photoImageChanged( void ) ) ); + } @@ -72,23 +81,212 @@ void PhotoAddDialog::updateMoveButtons(uint32_t status) } +bool PhotoAddDialog::updateAlbumDetails(const RsPhotoAlbum &album) +{ + std::cerr << "PhotoAddDialog::updateAlbumDetails()"; + std::cerr << " (Copy data to mAlbumData + Add PhotoItem)"; + std::cerr << std::endl; + // cleanup old image first. + mAlbumData.mThumbnail.deleteImage(); + mAlbumData = album; + + // copy photo too. + mAlbumData.mThumbnail.data = 0; + mAlbumData.mThumbnail.copyFrom(album.mThumbnail); + + /* show iterate through all the photos and update them too - except normally they haven't arrived yet */ + + ui.lineEdit_Title->setText(QString::fromUtf8(album.mMeta.mGroupName.c_str())); + ui.lineEdit_Caption->setText(QString::fromUtf8(album.mCaption.c_str())); + ui.lineEdit_Where->setText(QString::fromUtf8(album.mWhere.c_str())); + ui.lineEdit_When->setText(QString::fromUtf8(album.mWhen.c_str())); + + PhotoItem *item = new PhotoItem(NULL, mAlbumData); + ui.AlbumDrop->addPhotoItem(item); + + // called via callback AlbumChanged. + //setAlbumDataToPhotos(); + return true; +} + + +bool PhotoAddDialog::setAlbumDataToPhotos() +{ + std::cerr << "PhotoAddDialog::setAlbumDataToPhotos()"; + std::cerr << std::endl; + + int photoCount = ui.scrollAreaWidgetContents->getPhotoCount(); + + for(int i = 0; i < photoCount; i++) + { + PhotoItem *item = ui.scrollAreaWidgetContents->getPhotoIdx(i); + item->updateAlbumText(mAlbumData); + } + return true; +} + + void PhotoAddDialog::showPhotoDetails() { std::cerr << "PhotoAddDialog::showPhotoDetails()"; std::cerr << std::endl; - if (!mPhotoDetails) - { - mPhotoDetails = new PhotoDetailsDialog(NULL); - } - PhotoItem *item = ui.scrollAreaWidgetContents->getSelectedPhotoItem(); - - mPhotoDetails->setPhotoItem(item); - mPhotoDetails->show(); + if (item) + { + if (!mPhotoDetails) + { + mPhotoDetails = new PhotoDetailsDialog(NULL); + connect(mPhotoDetails, SIGNAL( editingDone( void ) ), this, SLOT( editingStageDone( void ) ) ); + } + mPhotoDetails->setPhotoItem(item); + mPhotoDetails->show(); + mEditingModeAlbum = false; + } } +void PhotoAddDialog::showAlbumDetails() +{ + std::cerr << "PhotoAddDialog::showAlbumDetails()"; + std::cerr << std::endl; + + + /* grab the image from the AlbumDrop */ + PhotoItem *item = NULL; + if (ui.AlbumDrop->getPhotoCount() > 0) + { + item = ui.AlbumDrop->getPhotoIdx(0); + } + + if (item) + { + if (!mPhotoDetails) + { + mPhotoDetails = new PhotoDetailsDialog(NULL); + connect(mPhotoDetails, SIGNAL( editingDone( void ) ), this, SLOT( editingStageDone( void ) ) ); + } + mPhotoDetails->setPhotoItem(item); + mPhotoDetails->show(); + mEditingModeAlbum = true; + } + else + { + std::cerr << "PhotoAddDialog::showAlbumDetails() PhotoItem Invalid"; + std::cerr << std::endl; + } +} + +/* Callback when AlbumDrop gets new image */ +void PhotoAddDialog::albumImageChanged() +{ + std::cerr << "PhotoAddDialog::albumImageChanged()"; + std::cerr << std::endl; + + /* must update the data from the reference stuff */ + PhotoItem *item = NULL; + if (ui.AlbumDrop->getPhotoCount() > 0) + { + item = ui.AlbumDrop->getPhotoIdx(0); + } + + if (!item) + { + std::cerr << "PhotoAddDialog::albumImageChanged() ERROR no Album PhotoItem"; + std::cerr << std::endl; + return; + } + + std::cerr << "PhotoAddDialog::albumImageChanged() PRE: AlbumDrop: " << item->mAlbumDetails; + std::cerr << std::endl; + std::cerr << "PhotoAddDialog::albumImageChanged() PRE: mAlbumData: " << mAlbumData; + std::cerr << std::endl; + + + item->mIsPhoto = false; // Force to Album mode. + + /* now AlbumDrop has the image, but AlbumData has the other stuff */ + + item->getPhotoThumbnail(mAlbumData.mThumbnail); + item->updateAlbumText(mAlbumData); + + + + /* if we are in editing mode -> update it */ + if ((mEditingModeAlbum) && (mPhotoDetails)) + { + std::cerr << "PhotoAddDialog::albumImageChanged() Updating PhotoDetails -> PhotoItem"; + std::cerr << std::endl; + mPhotoDetails->setPhotoItem(item); + } + + std::cerr << "PhotoAddDialog::albumImageChanged() POST: AlbumDrop: " << item->mAlbumDetails; + std::cerr << std::endl; + std::cerr << "PhotoAddDialog::albumImageChanged() POST: mAlbumData: " << mAlbumData; + std::cerr << std::endl; + +} + + +/* This is called back once PhotoDetailsDialog Finishes */ +void PhotoAddDialog::editingStageDone() +{ + std::cerr << "PhotoAddDialog::editingStageDone()"; + std::cerr << std::endl; + + if (mEditingModeAlbum) + { + /* need to resolve Album Data, repopulate entries + */ + + /* grab the image from the AlbumDrop (This is where PhotoDetailsDialog stores the data) */ + PhotoItem *item = NULL; + if (ui.AlbumDrop->getPhotoCount() > 0) + { + item = ui.AlbumDrop->getPhotoIdx(0); + } + + if (!item) + { + std::cerr << "PhotoAddDialog::editingStageDone() ERROR no Album PhotoItem"; + std::cerr << std::endl; + } + + /* Total Hack here Copy from AlbumDrop to Reference Data */ + + // cleanup old image first. + mAlbumData.mThumbnail.deleteImage(); + mAlbumData = item->mAlbumDetails; + item->getPhotoThumbnail(mAlbumData.mThumbnail); + + // Push Back data -> to trigger Text Update. + item->updateAlbumText(mAlbumData); + mEditingModeAlbum = false; + + // Update GUI too. + ui.lineEdit_Title->setText(QString::fromUtf8(mAlbumData.mMeta.mGroupName.c_str())); + ui.lineEdit_Caption->setText(QString::fromUtf8(mAlbumData.mCaption.c_str())); + ui.lineEdit_Where->setText(QString::fromUtf8(mAlbumData.mWhere.c_str())); + ui.lineEdit_When->setText(QString::fromUtf8(mAlbumData.mWhen.c_str())); + + } + else + { + std::cerr << "PhotoAddDialog::editingStageDone() ERROR not EditingModeAlbum"; + std::cerr << std::endl; + } + + // This forces item update -> though the AlbumUpdate is only needed if we edited Album. + setAlbumDataToPhotos(); +} + + +/* Callback when PhotoDrop gets new image */ +void PhotoAddDialog::photoImageChanged() +{ + setAlbumDataToPhotos(); +} + void PhotoAddDialog::publishAlbum() @@ -98,8 +296,8 @@ void PhotoAddDialog::publishAlbum() /* we need to iterate through each photoItem, and extract the details */ - - RsPhotoAlbum album; + RsPhotoAlbum album = mAlbumData; + album.mThumbnail.data = 0; album.mShareOptions.mShareType = 0; album.mShareOptions.mShareGroupId = "unknown"; @@ -107,13 +305,38 @@ void PhotoAddDialog::publishAlbum() album.mShareOptions.mCommentMode = 0; album.mShareOptions.mResizeMode = 0; - album.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString(); - album.mCategory = "Unknown"; - album.mCaption = ui.lineEdit_Caption->text().toStdString(); - album.mWhere = ui.lineEdit_Where->text().toStdString(); - album.mWhen = ui.lineEdit_When->text().toStdString(); + //album.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString(); + //album.mCategory = "Unknown"; + //album.mCaption = ui.lineEdit_Caption->text().toStdString(); + //album.mWhere = ui.lineEdit_Where->text().toStdString(); + //album.mWhen = ui.lineEdit_When->text().toStdString(); - if (rsPhoto->submitAlbumDetails(album)) + /* grab the image from the AlbumDrop */ + if (ui.AlbumDrop->getPhotoCount() > 0) + { + PhotoItem *item = ui.AlbumDrop->getPhotoIdx(0); + item->getPhotoThumbnail(album.mThumbnail); + } + + bool isAlbumOk = false; + + // For the moment, only submit albums Once. + if (mAlbumEdit) + { + std::cerr << "PhotoAddDialog::publishAlbum() AlbumEdit Mode"; + std::cerr << std::endl; + + isAlbumOk = true; + } + else if (rsPhoto->submitAlbumDetails(album, true)) + { + std::cerr << "PhotoAddDialog::publishAlbum() New Album Mode"; + std::cerr << std::endl; + + isAlbumOk = true; + } + + if (isAlbumOk) { /* now have path and album id */ int photoCount = ui.scrollAreaWidgetContents->getPhotoCount(); @@ -130,11 +353,41 @@ void PhotoAddDialog::publishAlbum() } photo = item->mPhotoDetails; + photo.mThumbnail.data = 0; // do proper data copy. item->getPhotoThumbnail(photo.mThumbnail); - - photo.mMeta.mGroupId = album.mMeta.mGroupId; + + bool isNewPhoto = false; + bool isModifiedPhoto = false; + + if (mAlbumEdit) + { + // can have modFlags and be New... so the order is important. + if (photo.mMeta.mGroupId.length() < 1) + { + /* new photo - flag in mods */ + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTO; + photo.mMeta.mGroupId = album.mMeta.mGroupId; + isNewPhoto = true; + } + else if (photo.mModFlags) + { + isModifiedPhoto = true; + } + } + else + { + /* new album - update GroupId, all photos are new */ + photo.mMeta.mGroupId = album.mMeta.mGroupId; + isNewPhoto = true; + } + photo.mOrder = i; + std::cerr << "PhotoAddDialog::publishAlbum() Photo(" << i << ")"; + std::cerr << " mSetFlags: " << photo.mSetFlags; + std::cerr << " mModFlags: " << photo.mModFlags; + std::cerr << std::endl; + /* scale photo if needed */ if (album.mShareOptions.mResizeMode) { @@ -144,7 +397,22 @@ void PhotoAddDialog::publishAlbum() /* save image to album path */ photo.path = "unknown"; - rsPhoto->submitPhoto(photo); + std::cerr << "PhotoAddDialog::publishAlbum() Photo(" << i << ") "; + if (isNewPhoto) + { + std::cerr << "Is a New Photo"; + rsPhoto->submitPhoto(photo, true); + } + else if (isModifiedPhoto) + { + std::cerr << "Is Updated"; + rsPhoto->submitPhoto(photo, false); + } + else + { + std::cerr << "Is Unchanged"; + } + std::cerr << std::endl; } } @@ -154,6 +422,20 @@ void PhotoAddDialog::publishAlbum() } +void PhotoAddDialog::deleteAlbum() +{ + std::cerr << "PhotoAddDialog::deleteAlbum() Not Implemented Yet"; + std::cerr << std::endl; +} + + +void PhotoAddDialog::deletePhoto() +{ + std::cerr << "PhotoAddDialog::deletePhoto() Not Implemented Yet"; + std::cerr << std::endl; +} + + void PhotoAddDialog::clearDialog() { ui.lineEdit_Title->setText(QString("title")); @@ -162,6 +444,122 @@ void PhotoAddDialog::clearDialog() ui.lineEdit_When->setText(QString("When")); ui.scrollAreaWidgetContents->clearPhotos(); + ui.AlbumDrop->clearPhotos(); + + /* clean up album image */ + mAlbumData.mThumbnail.deleteImage(); + + RsPhotoAlbum emptyAlbum; + mAlbumData = emptyAlbum; + + /* add empty image */ + PhotoItem *item = new PhotoItem(NULL, mAlbumData); + ui.AlbumDrop->addPhotoItem(item); + + mAlbumEdit = false; } + +void PhotoAddDialog::loadAlbum(const std::string &albumId) +{ + /* much like main load fns */ + clearDialog(); + mAlbumEdit = true; + + RsTokReqOptions opts; + uint32_t token; + std::list albumIds; + albumIds.push_back(albumId); + + // We need both Album and Photo Data. + + mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0); + +} + + +bool PhotoAddDialog::loadPhotoData(const uint32_t &token) +{ + std::cerr << "PhotoAddDialog::loadPhotoData()"; + std::cerr << std::endl; + bool moreData = true; + while(moreData) + { + RsPhotoPhoto photo; + + if (rsPhoto->getPhoto(token, photo)) + { + std::cerr << "PhotoDialog::addAddPhoto() AlbumId: " << photo.mMeta.mGroupId; + std::cerr << " PhotoId: " << photo.mMeta.mMsgId; + std::cerr << std::endl; + + PhotoItem *item = new PhotoItem(NULL, photo, mAlbumData); + ui.scrollAreaWidgetContents->addPhotoItem(item); + + } + else + { + moreData = false; + } + } + return true; +} + +bool PhotoAddDialog::loadAlbumData(const uint32_t &token) +{ + std::cerr << "PhotoAddDialog::loadAlbumData()"; + std::cerr << std::endl; + + bool moreData = true; + while(moreData) + { + RsPhotoAlbum album; + if (rsPhoto->getAlbum(token, album)) + { + std::cerr << " PhotoAddDialog::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl; + updateAlbumDetails(album); + + RsTokReqOptions opts; + opts.mOptions = RS_TOKREQOPT_MSG_LATEST; + uint32_t token; + std::list albumIds; + albumIds.push_back(album.mMeta.mGroupId); + mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0); + } + else + { + moreData = false; + } + } + return true; +} + + +void PhotoAddDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) +{ + std::cerr << "PhotoDialog::loadRequest()"; + std::cerr << std::endl; + + if (queue == mPhotoQueue) + { + /* now switch on req */ + switch(req.mType) + { + case TOKENREQ_GROUPINFO: + loadAlbumData(req.mToken); + break; + case TOKENREQ_MSGINFO: + loadPhotoData(req.mToken); + break; + default: + std::cerr << "PhotoAddDialog::loadRequest() ERROR: GROUP: INVALID ANS TYPE"; + std::cerr << std::endl; + break; + } + } +} + + + + diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.h b/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.h index 36a8055de..cab5b0bcc 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.h @@ -26,24 +26,49 @@ #include "ui_PhotoAddDialog.h" +#include +#include "util/TokenQueue.h" + class PhotoDetailsDialog; -class PhotoAddDialog : public QWidget +class PhotoAddDialog : public QWidget, public TokenResponse { Q_OBJECT public: PhotoAddDialog(QWidget *parent = 0); + void loadAlbum(const std::string &albumId); +virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + + void clearDialog(); + private slots: void showPhotoDetails(); + void showAlbumDetails(); + void editingStageDone(); + + // From PhotoDrops... + void albumImageChanged(); + void photoImageChanged(); void updateMoveButtons(uint32_t status); void publishAlbum(); - void clearDialog(); + void deleteAlbum(); + void deletePhoto(); +private: + + bool updateAlbumDetails(const RsPhotoAlbum &album); + bool setAlbumDataToPhotos(); + bool loadPhotoData(const uint32_t &token); + bool loadAlbumData(const uint32_t &token); + TokenQueue *mPhotoQueue; protected: + bool mAlbumEdit; // Editing or New. + bool mEditingModeAlbum; // Changing Album or Photo Details. + RsPhotoAlbum mAlbumData; PhotoDetailsDialog *mPhotoDetails; Ui::PhotoAddDialog ui; diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.ui b/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.ui index eff5b7584..bfb09f45e 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.ui +++ b/retroshare-gui/src/gui/PhotoShare/PhotoAddDialog.ui @@ -162,7 +162,7 @@ - + 0 @@ -174,16 +174,8 @@ - - - Album Thumbnail......... -Drag and Drop an Image -from the Picture List -to make it the Album -Image -1 -2 - + + @@ -198,11 +190,14 @@ Image - Basic Details + Summary + + false + 0 @@ -220,6 +215,9 @@ Image + + false + Travel @@ -261,6 +259,9 @@ Image + + false + 0 @@ -278,6 +279,9 @@ Image + + false + 0 @@ -288,6 +292,9 @@ Image + + false + 0 @@ -376,8 +383,8 @@ Image 0 0 - 822 - 76 + 830 + 83 @@ -393,6 +400,26 @@ Image + + + + Delete Photo + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.cpp index d94573f71..87f74184a 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.cpp @@ -24,6 +24,8 @@ #include "gui/PhotoShare/PhotoDetailsDialog.h" #include "gui/PhotoShare/PhotoItem.h" +#include + /** Constructor */ PhotoDetailsDialog::PhotoDetailsDialog(QWidget *parent) : QWidget(parent) @@ -50,10 +52,10 @@ void PhotoDetailsDialog::setPhotoItem(PhotoItem *item) void PhotoDetailsDialog::refreshDetails() { - - if(!mPhotoItem) + blankDetails(); + if (!mPhotoItem) { - blankDetails(); + return; } ui.label_Headline->setText(QString("Photo Description")); @@ -62,25 +64,126 @@ void PhotoDetailsDialog::refreshDetails() if (mPhotoItem->mIsPhoto) { - ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mCaption)); - ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mDescription)); - ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mPhotographer)); - ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mWhere)); - ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mWhen)); - ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mOther)); - ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mMeta.mMsgName)); - ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mHashTags)); + // THIS is tedious! + + RsPhotoPhoto &photo = mPhotoItem->mPhotoDetails; + RsPhotoAlbum &album = mPhotoItem->mAlbumDetails; + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE) + { + ui.lineEdit_Title->setText(QString::fromUtf8(photo.mMeta.mMsgName.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE) + { + ui.lineEdit_Title->setText(QString::fromUtf8(album.mMeta.mGroupName.c_str())); + } + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION) + { + ui.lineEdit_Caption->setText(QString::fromUtf8(photo.mCaption.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION) + { + ui.lineEdit_Caption->setText(QString::fromUtf8(album.mCaption.c_str())); + } + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC) + { + ui.textEdit_Description->setText(QString::fromUtf8(photo.mDescription.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC) + { + ui.textEdit_Description->setText(QString::fromUtf8(album.mDescription.c_str())); + } + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER) + { + ui.lineEdit_Photographer->setText(QString::fromUtf8(photo.mPhotographer.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER) + { + ui.lineEdit_Photographer->setText(QString::fromUtf8(album.mPhotographer.c_str())); + } + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE) + { + ui.lineEdit_Where->setText(QString::fromUtf8(photo.mWhere.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE) + { + ui.lineEdit_Where->setText(QString::fromUtf8(album.mWhere.c_str())); + } + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN) + { + ui.lineEdit_When->setText(QString::fromUtf8(photo.mWhen.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN) + { + ui.lineEdit_When->setText(QString::fromUtf8(album.mWhen.c_str())); + } + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER) + { + ui.lineEdit_Other->setText(QString::fromUtf8(photo.mOther.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER) + { + ui.lineEdit_Other->setText(QString::fromUtf8(album.mOther.c_str())); + } + + if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS) + { + ui.lineEdit_HashTags->setText(QString::fromUtf8(photo.mHashTags.c_str())); + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS) + { + ui.lineEdit_HashTags->setText(QString::fromUtf8(album.mHashTags.c_str())); + } } else { - ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mCaption)); - ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mDescription)); - ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mPhotographer)); - ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mWhere)); - ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mWhen)); - ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mOther)); - ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mMeta.mGroupName)); - ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mHashTags)); + RsPhotoAlbum &album = mPhotoItem->mAlbumDetails; + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE) + { + ui.lineEdit_Title->setText(QString::fromUtf8(album.mMeta.mGroupName.c_str())); + } + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION) + { + ui.lineEdit_Caption->setText(QString::fromUtf8(album.mCaption.c_str())); + } + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC) + { + ui.textEdit_Description->setText(QString::fromUtf8(album.mDescription.c_str())); + } + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER) + { + ui.lineEdit_Photographer->setText(QString::fromUtf8(album.mPhotographer.c_str())); + } + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE) + { + ui.lineEdit_Where->setText(QString::fromUtf8(album.mWhere.c_str())); + } + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN) + { + ui.lineEdit_When->setText(QString::fromUtf8(album.mWhen.c_str())); + } + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER) + { + ui.lineEdit_Other->setText(QString::fromUtf8(album.mOther.c_str())); + } + + if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS) + { + ui.lineEdit_HashTags->setText(QString::fromUtf8(album.mHashTags.c_str())); + } } const QPixmap *qtn = mPhotoItem->getPixmap(); @@ -94,14 +197,14 @@ void PhotoDetailsDialog::blankDetails() //ui.comboBox_Category= mPhotoItem->mDetails.mCaption; - ui.lineEdit_Caption->setText(QString("N/A")); - ui.textEdit_Description->setText(QString("N/A")); - ui.lineEdit_Photographer->setText(QString("N/A")); - ui.lineEdit_Where->setText(QString("N/A")); - ui.lineEdit_When->setText(QString("N/A")); - ui.lineEdit_Other->setText(QString("N/A")); - ui.lineEdit_Title->setText(QString("N/A")); - ui.lineEdit_HashTags->setText(QString("N/A")); + ui.lineEdit_Title->setText(QString("")); + ui.lineEdit_Caption->setText(QString("")); + ui.textEdit_Description->setText(QString("")); + ui.lineEdit_Photographer->setText(QString("")); + ui.lineEdit_Where->setText(QString("")); + ui.lineEdit_When->setText(QString("")); + ui.lineEdit_Other->setText(QString("")); + ui.lineEdit_HashTags->setText(QString("")); //QPixmap qtn = mPhotoItem->getPixmap(); //ui.label_Photo->setPixmap(qtn); @@ -112,6 +215,9 @@ void PhotoDetailsDialog::updateDetails() { saveDetails(); + // Notify Listeners. + editingDone(); + hide(); } @@ -123,30 +229,290 @@ void PhotoDetailsDialog::saveDetails() return; } - //mPhotoItem->mDetails.mCaption = ui.comboBox_Category; + RsPhotoPhoto &photo = mPhotoItem->mPhotoDetails; + RsPhotoAlbum &album = mPhotoItem->mAlbumDetails; + std::string txt = ui.lineEdit_Title->text().toUtf8().constData(); + bool setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE)) + { + if (txt != photo.mMeta.mMsgName) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE) + { + if (txt != album.mMeta.mGroupName) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE; + photo.mMeta.mMsgName = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE; + album.mMeta.mGroupName = txt; + } + } + + + txt = ui.lineEdit_Caption->text().toUtf8().constData(); + setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION)) + { + if (txt != photo.mCaption) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION) + { + if (txt != album.mCaption) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION; + photo.mCaption = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION; + album.mCaption = txt; + } + } + + + txt = ui.textEdit_Description->toPlainText().toUtf8().constData(); + setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC)) + { + if (txt != photo.mDescription) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC) + { + if (txt != album.mDescription) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_DESC; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_DESC; + photo.mDescription = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_DESC; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_DESC; + album.mDescription = txt; + } + } + + + txt = ui.lineEdit_Photographer->text().toUtf8().constData(); + setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER)) + { + if (txt != photo.mPhotographer) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER) + { + if (txt != album.mPhotographer) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER; + photo.mPhotographer = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER; + album.mPhotographer = txt; + } + } + + + txt = ui.lineEdit_Where->text().toUtf8().constData(); + setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)) + { + if (txt != photo.mWhere) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE) + { + if (txt != album.mWhere) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE; + photo.mWhere = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE; + album.mWhere = txt; + } + } + + txt = ui.lineEdit_When->text().toUtf8().constData(); + setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN)) + { + if (txt != photo.mWhen) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN) + { + if (txt != album.mWhen) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN; + photo.mWhen = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN; + album.mWhen = txt; + } + } + + + txt = ui.lineEdit_HashTags->text().toUtf8().constData(); + setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS)) + { + if (txt != photo.mHashTags) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS) + { + if (txt != album.mHashTags) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS; + photo.mHashTags = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS; + album.mHashTags = txt; + } + } + + + txt = ui.lineEdit_Other->text().toUtf8().constData(); + setName = false; + if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER)) + { + if (txt != photo.mOther) + setName = true; + } + else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER) + { + if (txt != album.mOther) + setName = true; + } + else if (txt.length() != 0) + { + setName = true; + } + + if (setName) + { + if (mPhotoItem->mIsPhoto) + { + photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER; + photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER; + photo.mOther = txt; + } + else + { + album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER; + album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER; + album.mOther = txt; + } + } + + + + std::cerr << "PhotoDetailsDialog::saveDetails() "; if (mPhotoItem->mIsPhoto) { - mPhotoItem->mPhotoDetails.mCaption = ui.lineEdit_Caption->text().toStdString(); - mPhotoItem->mPhotoDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString(); - mPhotoItem->mPhotoDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString(); - mPhotoItem->mPhotoDetails.mWhere = ui.lineEdit_Where->text().toStdString(); - mPhotoItem->mPhotoDetails.mWhen = ui.lineEdit_When->text().toStdString(); - mPhotoItem->mPhotoDetails.mOther = ui.lineEdit_Other->text().toStdString(); - mPhotoItem->mPhotoDetails.mMeta.mMsgName = ui.lineEdit_Title->text().toStdString(); - mPhotoItem->mPhotoDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString(); - } - else - { - mPhotoItem->mAlbumDetails.mCaption = ui.lineEdit_Caption->text().toStdString(); - mPhotoItem->mAlbumDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString(); - mPhotoItem->mAlbumDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString(); - mPhotoItem->mAlbumDetails.mWhere = ui.lineEdit_Where->text().toStdString(); - mPhotoItem->mAlbumDetails.mWhen = ui.lineEdit_When->text().toStdString(); - mPhotoItem->mAlbumDetails.mOther = ui.lineEdit_Other->text().toStdString(); - mPhotoItem->mAlbumDetails.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString(); - mPhotoItem->mAlbumDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString(); + std::cerr << " photo.mSetFlags: " << mPhotoItem->mPhotoDetails.mSetFlags; + std::cerr << " photo.mModFlags: " << mPhotoItem->mPhotoDetails.mModFlags; } + std::cerr << " album.mSetFlags: " << mPhotoItem->mAlbumDetails.mSetFlags; + std::cerr << " album.mModFlags: " << mPhotoItem->mAlbumDetails.mModFlags; + std::cerr << std::endl; //QPixmap qtn = mPhotoItem->getPixmap(); //ui.label_Photo->setPixmap(qtn); diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.h b/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.h index 0e3c2746d..dd3ea03df 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDetailsDialog.h @@ -37,6 +37,9 @@ public: void setPhotoItem(PhotoItem *item); +signals: + void editingDone(); + private: void saveDetails(); void refreshDetails(); diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp index d38751a7f..405e7e397 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp @@ -30,6 +30,7 @@ #include #include +#include /****** * #define PHOTO_DEBUG 1 @@ -66,8 +67,11 @@ PhotoDialog::PhotoDialog(QWidget *parent) mAddDialog = NULL; mAlbumSelected = NULL; mPhotoSelected = NULL; + mSlideShow = NULL; connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(OpenOrShowPhotoAddDialog())); + connect( ui.toolButton_EditAlbum, SIGNAL(clicked()), this, SLOT(OpenPhotoEditDialog())); + connect( ui.toolButton_SlideShow, SIGNAL(clicked()), this, SLOT(OpenSlideShow())); QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); @@ -148,6 +152,45 @@ void PhotoDialog::checkUpdate() } +/*************** New Photo Dialog ***************/ + +void PhotoDialog::OpenSlideShow() +{ + + // TODO. + if (!mAlbumSelected) + { + // ALERT. + int ret = QMessageBox::information(this, tr("PhotoShare"), + tr("Please select an album before\n" + "requesting to edit it!"), + QMessageBox::Ok); + return; + } + + if (mAlbumSelected->mIsPhoto) + { + std::cerr << "PhotoDialog::OpenPhotoEditDialog() MAJOR ERROR!"; + std::cerr << std::endl; + return; + } + + std::string albumId = mAlbumSelected->mAlbumDetails.mMeta.mGroupId; + + if (mSlideShow) + { + mSlideShow->show(); + } + else + { + mSlideShow = new PhotoSlideShow(NULL); + mSlideShow->show(); + } + mSlideShow->loadAlbum(albumId); + +} + + /*************** New Photo Dialog ***************/ void PhotoDialog::OpenOrShowPhotoAddDialog() @@ -161,6 +204,50 @@ void PhotoDialog::OpenOrShowPhotoAddDialog() mAddDialog = new PhotoAddDialog(NULL); mAddDialog->show(); } + mAddDialog->clearDialog(); +} + + +/*************** Edit Photo Dialog ***************/ + +void PhotoDialog::OpenPhotoEditDialog() +{ + /* check if we have an album selected */ + // THE TWO MessageBoxes - should be handled by disabling the Button!. + // TODO. + if (!mAlbumSelected) + { + // ALERT. + int ret = QMessageBox::information(this, tr("PhotoShare"), + tr("Please select an album before\n" + "requesting to edit it!"), + QMessageBox::Ok); + return; + } + + if (mAlbumSelected->mIsPhoto) + { + std::cerr << "PhotoDialog::OpenPhotoEditDialog() MAJOR ERROR!"; + std::cerr << std::endl; + } + + std::string albumId = mAlbumSelected->mAlbumDetails.mMeta.mGroupId; +#if 0 + uint32_t flags = mAlbumSelected->mAlbumDetails.mMeta.mGroupFlags; + + if (!(flags & OWN)) + { + // ALERT. + int ret = QMessageBox::information(this, tr("PhotoShare"), + tr("Cannot Edit Someone Else's Album"), + QMessageBox::Ok); + return; + } +#endif + + OpenOrShowPhotoAddDialog(); + mAddDialog->loadAlbum(albumId); + } @@ -320,7 +407,10 @@ void PhotoDialog::addPhoto(const RsPhotoPhoto &photo) std::cerr << " PhotoId: " << photo.mMeta.mMsgId; std::cerr << std::endl; - PhotoItem *item = new PhotoItem(this, photo); + RsPhotoAlbum dummyAlbum; + dummyAlbum.mSetFlags = 0; + + PhotoItem *item = new PhotoItem(this, photo, dummyAlbum); QLayout *alayout = ui.scrollAreaWidgetContents_2->layout(); alayout->addWidget(item); @@ -411,6 +501,7 @@ void PhotoDialog::requestPhotoList(const std::string &albumId) std::list ids; ids.push_back(albumId); RsTokReqOptions opts; + opts.mOptions = RS_TOKREQOPT_MSG_LATEST; uint32_t token; mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0); } @@ -452,13 +543,11 @@ void PhotoDialog::loadPhotoData(const uint32_t &token) if (rsPhoto->getPhoto(token, photo)) { - std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mMeta.mGroupId; + std::cerr << "PhotoDialog::loadPhotoData() AlbumId: " << photo.mMeta.mGroupId; std::cerr << " PhotoId: " << photo.mMeta.mMsgId; std::cerr << std::endl; - PhotoItem *item = new PhotoItem(this, photo); - QLayout *alayout = ui.scrollAreaWidgetContents_2->layout(); - alayout->addWidget(item); + addPhoto(photo); } else { diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.h b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.h index 8c454356f..a37352d90 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.h @@ -33,6 +33,7 @@ #include "gui/PhotoShare/PhotoItem.h" #include "gui/PhotoShare/PhotoAddDialog.h" +#include "gui/PhotoShare/PhotoSlideShow.h" #include "util/TokenQueue.h" class PhotoDialog : public MainPage, public PhotoHolder, public TokenResponse @@ -52,7 +53,8 @@ private slots: void checkUpdate(); void OpenOrShowPhotoAddDialog(); - + void OpenPhotoEditDialog(); + void OpenSlideShow(); private: /* Request Response Functions for loading data */ @@ -94,6 +96,7 @@ private: void clearPhotos(); PhotoAddDialog *mAddDialog; + PhotoSlideShow *mSlideShow; PhotoItem *mAlbumSelected; PhotoItem *mPhotoSelected; diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui index 385336ad0..30217f6c8 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.ui @@ -122,8 +122,8 @@ 0 0 - 746 - 227 + 754 + 234 @@ -165,8 +165,8 @@ 0 0 - 746 - 227 + 754 + 233 @@ -193,13 +193,6 @@ - - - - Remove Picture - - - @@ -214,13 +207,6 @@ - - - - Edit Picture Details - - - diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp index 7ffcfcf27..49a316963 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp @@ -57,6 +57,8 @@ PhotoDrop::PhotoDrop(QWidget *parent) : QWidget(parent) { setAcceptDrops(true); + mIsSingleImageDrop = false; + mSelected = NULL; checkMoveButtons(); reorderPhotos(); @@ -84,6 +86,11 @@ void PhotoDrop::clear() { } +void PhotoDrop::setSingleImage() +{ + mIsSingleImageDrop = true; +} + PhotoItem *PhotoDrop::getSelectedPhotoItem() { @@ -248,6 +255,11 @@ void PhotoDrop::reorderPhotos() } int space = width(); mColumns = space / minWidth; + // incase its too thin! + if (mColumns < 1) + { + mColumns = 1; + } std::cerr << "PhotoDrop::reorderPhotos() minWidth: " << minWidth << " space: " << space; std::cerr << " columns: " << mColumns; @@ -627,11 +639,15 @@ void PhotoDrop::dropEvent(QDropEvent *event) PhotoItem *item = new PhotoItem(this, localpath.toStdString()); + addPhotoItem(item); //mPhotos.push_back(item); - layout()->addWidget(item); + //layout()->addWidget(item); } event->setDropAction(Qt::CopyAction); event->accept(); + + // Notify Listeners. (only happens for drop - not programmatically added). + photosChanged(); } else { @@ -641,6 +657,7 @@ void PhotoDrop::dropEvent(QDropEvent *event) } checkMoveButtons(); + } void PhotoDrop::mousePressEvent(QMouseEvent *event) @@ -655,3 +672,21 @@ void PhotoDrop::mousePressEvent(QMouseEvent *event) } + +void PhotoDrop::addPhotoItem(PhotoItem *item) +{ + std::cerr << "PhotoDrop::addPhotoItem()"; + std::cerr << std::endl; + + if (mIsSingleImageDrop) + { + clearPhotos(); + } + + item->updateParent(this); + layout()->addWidget(item); + + //checkMoveButtons(); + +} + diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h index 55f07ac60..881cf9ccd 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h @@ -50,6 +50,7 @@ class PhotoDrop : public QWidget, public PhotoHolder public: PhotoDrop(QWidget *parent = 0); void clear(); + void setSingleImage(); virtual void deletePhotoItem(PhotoItem *, uint32_t type); virtual void notifySelection(PhotoItem *item, int ptype); @@ -57,6 +58,7 @@ virtual void notifySelection(PhotoItem *item, int ptype); PhotoItem *getSelectedPhotoItem(); int getPhotoCount(); PhotoItem *getPhotoIdx(int idx); +void addPhotoItem(PhotoItem *item); public slots: void moveLeft(); @@ -66,6 +68,7 @@ public slots: signals: void buttonStatus(uint32_t status); + void photosChanged(); protected: @@ -77,11 +80,13 @@ protected: void dragMoveEvent(QDragMoveEvent *event); void dropEvent(QDropEvent *event); + private: void reorderPhotos(); PhotoItem *mSelected; int mColumns; + bool mIsSingleImageDrop; }; #endif diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp index e5475005e..26611d9d0 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp @@ -47,15 +47,15 @@ PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album) setAttribute ( Qt::WA_DeleteOnClose, true ); mIsPhoto = false; - mAlbumDetails = album; - updateAlbumText(album); + setDummyText(); + updateAlbumText(album); // saves: mAlbumDetails = album; updateImage(album.mThumbnail); setSelected(false); } -PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo) +PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo, const RsPhotoAlbum &album) :QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_PHOTO) { setupUi(this); @@ -63,9 +63,11 @@ PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo) setAttribute ( Qt::WA_DeleteOnClose, true ); mIsPhoto = true; - mPhotoDetails = photo; - updatePhotoText(photo); + setDummyText(); + updatePhotoText(photo); // saves: mPhotoDetails = photo; + updateAlbumText(album); // saves: mAlbumDetails = album; + updateImage(photo.mThumbnail); setSelected(false); @@ -79,20 +81,9 @@ PhotoItem::PhotoItem(PhotoHolder *parent, std::string path) // for new photos. setAttribute ( Qt::WA_DeleteOnClose, true ); - QString dummyString("dummytext"); - titleLabel->setText(QString("NEW PHOTO")); - + setDummyText(); mIsPhoto = true; - fromBoldLabel->setText(QString("From:")); - fromLabel->setText(QString("Ourselves")); - - statusBoldLabel->setText(QString("Status:")); - statusLabel->setText(QString("new photo")); - - dateBoldLabel->setText(QString("Date:")); - dateLabel->setText(QString("now")); - int width = 120; int height = 120; @@ -102,46 +93,94 @@ PhotoItem::PhotoItem(PhotoHolder *parent, std::string path) // for new photos. setSelected(false); } +void PhotoItem::updateParent(PhotoHolder *parent) // for external construction. +{ + mParent = parent; +} + + +void PhotoItem::setDummyText() +{ + titleLabel->setText(QString("Unknown")); + fromBoldLabel->setText(QString("By:")); + fromLabel->setText(QString("Unknown")); + statusBoldLabel->setText(QString("Where:")); + statusLabel->setText(QString("Unknown")); + dateBoldLabel->setText(QString("When:")); + dateLabel->setText(QString("Unknown")); +} + + void PhotoItem::updateAlbumText(const RsPhotoAlbum &album) { - QString dummyString("dummytext"); - titleLabel->setText(QString("TITLE")); - - fromBoldLabel->setText(QString("From:")); - fromLabel->setText(QString("Unknown")); - - statusBoldLabel->setText(QString("Status:")); - statusLabel->setText(QString("new photo")); - - dateBoldLabel->setText(QString("Date:")); - dateLabel->setText(QString("now")); - - //QDateTime qtime; - //qtime.setTime_t(msg.ts); - //QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); - //timestamplabel->setText(timestamp); - - dateBoldLabel->setText(dummyString); - dateLabel->setText(dummyString); - + mAlbumDetails = album; + mAlbumDetails.mThumbnail.data = 0; + updateText(); } void PhotoItem::updatePhotoText(const RsPhotoPhoto &photo) { - QString dummyString("dummytext"); - titleLabel->setText(QString("TITLE")); - - fromBoldLabel->setText(QString("From:")); - fromLabel->setText(QString("Unknown")); - - statusBoldLabel->setText(QString("Status:")); - statusLabel->setText(QString("new photo")); - - dateBoldLabel->setText(QString("Date:")); - dateLabel->setText(QString("now")); + // Save new Photo details. + mPhotoDetails = photo; + mPhotoDetails.mThumbnail.data = 0; + updateText(); } + +void PhotoItem::updateText() +{ + // SET Album Values first -> then overwrite with Photo Values. + if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE) + { + titleLabel->setText(QString::fromUtf8(mAlbumDetails.mMeta.mGroupName.c_str())); + } + + // This needs to be fixed!! TODO + fromLabel->setText(QString::fromStdString(mAlbumDetails.mMeta.mGroupId)); + if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_AUTHOR) + { + // This needs to be fixed!! TODO + fromLabel->setText(QString::fromStdString(mAlbumDetails.mMeta.mGroupId)); + } + + if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE) + { + statusLabel->setText(QString::fromUtf8(mAlbumDetails.mWhere.c_str())); + } + + if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN) + { + dateLabel->setText(QString::fromUtf8(mAlbumDetails.mWhen.c_str())); + } + + // NOW Photo Bits. + if (mIsPhoto) + { + if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE) + { + titleLabel->setText(QString::fromUtf8(mPhotoDetails.mMeta.mMsgName.c_str())); + } + + if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_AUTHOR) + { + // This needs to be fixed!! TODO + fromLabel->setText(QString::fromStdString(mPhotoDetails.mMeta.mAuthorId)); + } + + if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE) + { + statusLabel->setText(QString::fromUtf8(mPhotoDetails.mWhere.c_str())); + } + + if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN) + { + dateLabel->setText(QString::fromUtf8(mPhotoDetails.mWhen.c_str())); + } + } + +} + void PhotoItem::updateImage(const RsPhotoThumbnail &thumbnail) { if (thumbnail.data != NULL) diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoItem.h b/retroshare-gui/src/gui/PhotoShare/PhotoItem.h index 2fe4e4fc0..2e32b3de2 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoItem.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoItem.h @@ -48,9 +48,14 @@ class PhotoItem : public QWidget, private Ui::PhotoItem public: PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album); - PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo); + PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo, const RsPhotoAlbum &album); PhotoItem(PhotoHolder *parent, std::string url); // for new photos. + void setDummyText(); + void updateParent(PhotoHolder *parent); // for external construction. + void updateAlbumText(const RsPhotoAlbum &album); + void updatePhotoText(const RsPhotoPhoto &photo); + void updateText(); bool getPhotoThumbnail(RsPhotoThumbnail &nail); void removeItem(); @@ -62,6 +67,7 @@ public: // details are public - so that can be easily edited. bool mIsPhoto; + bool mWasModified; RsPhotoPhoto mPhotoDetails; RsPhotoAlbum mAlbumDetails; @@ -72,8 +78,6 @@ protected: void mousePressEvent(QMouseEvent *event); private: - void updateAlbumText(const RsPhotoAlbum &album); - void updatePhotoText(const RsPhotoPhoto &photo); void updateImage(const RsPhotoThumbnail &thumbnail); PhotoHolder *mParent; diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideDetails.ui b/retroshare-gui/src/gui/PhotoShare/PhotoSlideDetails.ui new file mode 100644 index 000000000..985d7bd4d --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideDetails.ui @@ -0,0 +1,129 @@ + + + PhotoSlideDetails + + + + 0 + 0 + 667 + 707 + + + + + + + + + + Qt::Vertical + + + + + + + Name + + + + + + + Caption: + + + + + + + + + + Photographer: + + + + + + + + + + Description + + + + + + + + + + Where: + + + + + + + + + + When + + + + + + + + + + Other 1: + + + + + + + + + + HashTags: + + + + + + + + + + Image # + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp new file mode 100644 index 000000000..3bf2b3cbc --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp @@ -0,0 +1,349 @@ +/* + * Retroshare Photo Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#include "gui/PhotoShare/PhotoSlideShow.h" +#include "gui/PhotoShare/PhotoDrop.h" + +#include + +/** Constructor */ +PhotoSlideShow::PhotoSlideShow(QWidget *parent) +: QWidget(parent) +{ + ui.setupUi(this); + + connect(ui.pushButton_ShiftLeft, SIGNAL( clicked( void ) ), this, SLOT( moveLeft( void ) ) ); + connect(ui.pushButton_ShiftRight, SIGNAL( clicked( void ) ), this, SLOT( moveRight( void ) ) ); + connect(ui.pushButton_ShowDetails, SIGNAL( clicked( void ) ), this, SLOT( showPhotoDetails( void ) ) ); + connect(ui.pushButton_StartStop, SIGNAL( clicked( void ) ), this, SLOT( StartStop( void ) ) ); + connect(ui.pushButton_Close, SIGNAL( clicked( void ) ), this, SLOT( closeShow( void ) ) ); + + mPhotoQueue = new TokenQueue(rsPhoto, this); + + mRunning = true; + mShotActive = true; + + mImageIdx = 0; + + //loadImage(); + //QTimer::singleShot(5000, this, SLOT(timerEvent())); +} + + +void PhotoSlideShow::showPhotoDetails() +{ + +} + + +void PhotoSlideShow::moveLeft() +{ + if (mRunning) + { + return; + } + + mImageIdx--; + if (mImageIdx < 0) + { + mImageIdx = mPhotos.size() - 1; + } + loadImage(); + +} + + +void PhotoSlideShow::moveRight() +{ + if (mRunning) + { + return; + } + + mImageIdx++; + if (mImageIdx >= mPhotos.size()) + { + mImageIdx = 0; + } + loadImage(); + +} + + +void PhotoSlideShow::StartStop() +{ + if (mRunning) + { + mRunning = false; + } + else + { + mRunning = true; + if (!mShotActive) // make sure only one timer running + { + mShotActive = true; + QTimer::singleShot(5000, this, SLOT(timerEvent())); + } + } +} + +void PhotoSlideShow::timerEvent() +{ + if (!mRunning) + { + mShotActive = false; + return; + } + + mImageIdx++; + if (mImageIdx >= mPhotos.size()) + { + mImageIdx = 0; + } + loadImage(); + QTimer::singleShot(5000, this, SLOT(timerEvent())); +} + + + +void PhotoSlideShow::closeShow() +{ + mRunning = false; + hide(); +} + + +void PhotoSlideShow::loadImage() +{ + /* get the image */ + int i = 0; + bool found = false; + std::string msgId; + + //std::map::iterator it; + std::map::iterator it; + for(it = mPhotoOrder.begin(); it != mPhotoOrder.end(); it++, i++) + { + if (i == mImageIdx) + { + msgId = it->second; + found = true; + break; + } + } + + RsPhotoPhoto *ptr = NULL; + if (found) + { + ptr = mPhotos[msgId]; + } + + if (ptr) + { + /* load into the slot */ + if (ptr->mThumbnail.data != NULL) + { + QPixmap qtn; + + // copy the data for Qpixmap to use. + RsPhotoThumbnail tn; + tn.copyFrom(ptr->mThumbnail); + qtn.loadFromData(tn.data, tn.size, tn.type.c_str()); + tn.data = 0; + + //ui.imgLabel->setPixmap(qtn); + + QPixmap sqtn = qtn.scaled(ui.albumLabel->width(), ui.imgLabel->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + ui.imgLabel->setPixmap(sqtn); + + } + } +} + + +void PhotoSlideShow::updateMoveButtons(uint32_t status) +{ + std::cerr << "PhotoSlideShow::updateMoveButtons(" << status << ")"; + std::cerr << std::endl; + + switch(status) + { + case PHOTO_SHIFT_NO_BUTTONS: + ui.pushButton_ShiftLeft->setEnabled(false); + ui.pushButton_ShiftRight->setEnabled(false); + break; + case PHOTO_SHIFT_LEFT_ONLY: + ui.pushButton_ShiftLeft->setEnabled(true); + ui.pushButton_ShiftRight->setEnabled(false); + break; + case PHOTO_SHIFT_RIGHT_ONLY: + ui.pushButton_ShiftLeft->setEnabled(false); + ui.pushButton_ShiftRight->setEnabled(true); + break; + case PHOTO_SHIFT_BOTH: + ui.pushButton_ShiftLeft->setEnabled(true); + ui.pushButton_ShiftRight->setEnabled(true); + break; + } +} + + + + +void PhotoSlideShow::clearDialog() +{ +#if 0 + ui.lineEdit_Title->setText(QString("title")); + ui.lineEdit_Caption->setText(QString("Caption")); + ui.lineEdit_Where->setText(QString("Where")); + ui.lineEdit_When->setText(QString("When")); + + ui.scrollAreaWidgetContents->clearPhotos(); + ui.AlbumDrop->clearPhotos(); + + /* clean up album image */ + mAlbumData.mThumbnail.deleteImage(); + + RsPhotoAlbum emptyAlbum; + mAlbumData = emptyAlbum; + + /* add empty image */ + PhotoItem *item = new PhotoItem(NULL, mAlbumData); + ui.AlbumDrop->addPhotoItem(item); + + mAlbumEdit = false; +#endif +} + + +void PhotoSlideShow::loadAlbum(const std::string &albumId) +{ + /* much like main load fns */ + clearDialog(); + + RsTokReqOptions opts; + uint32_t token; + std::list albumIds; + albumIds.push_back(albumId); + + // We need both Album and Photo Data. + + mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0); + +} + + +bool PhotoSlideShow::loadPhotoData(const uint32_t &token) +{ + std::cerr << "PhotoSlideShow::loadPhotoData()"; + std::cerr << std::endl; + + bool moreData = true; + while(moreData) + { + RsPhotoPhoto photo; + + if (rsPhoto->getPhoto(token, photo)) + { + RsPhotoPhoto *ptr = new RsPhotoPhoto; + *ptr = photo; + ptr->mThumbnail.data = 0; + ptr->mThumbnail.copyFrom(photo.mThumbnail); + + mPhotos[photo.mMeta.mMsgId] = ptr; + mPhotoOrder[ptr->mOrder] = photo.mMeta.mMsgId; + + std::cerr << "PhotoSlideShow::addAddPhoto() AlbumId: " << photo.mMeta.mGroupId; + std::cerr << " PhotoId: " << photo.mMeta.mMsgId; + std::cerr << std::endl; + } + else + { + moreData = false; + } + } + + // Load and Start. + loadImage(); + QTimer::singleShot(5000, this, SLOT(timerEvent())); + + return true; +} + +bool PhotoSlideShow::loadAlbumData(const uint32_t &token) +{ + std::cerr << "PhotoSlideShow::loadAlbumData()"; + std::cerr << std::endl; + + bool moreData = true; + while(moreData) + { + RsPhotoAlbum album; + if (rsPhoto->getAlbum(token, album)) + { + std::cerr << " PhotoSlideShow::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl; + //updateAlbumDetails(album); + + RsTokReqOptions opts; + opts.mOptions = RS_TOKREQOPT_MSG_LATEST; + uint32_t token; + std::list albumIds; + albumIds.push_back(album.mMeta.mGroupId); + mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0); + } + else + { + moreData = false; + } + } + return true; +} + + +void PhotoSlideShow::loadRequest(const TokenQueue *queue, const TokenRequest &req) +{ + std::cerr << "PhotoSlideShow::loadRequest()"; + std::cerr << std::endl; + + if (queue == mPhotoQueue) + { + /* now switch on req */ + switch(req.mType) + { + case TOKENREQ_GROUPINFO: + loadAlbumData(req.mToken); + break; + case TOKENREQ_MSGINFO: + loadPhotoData(req.mToken); + break; + default: + std::cerr << "PhotoSlideShow::loadRequest() ERROR: GROUP: INVALID ANS TYPE"; + std::cerr << std::endl; + break; + } + } +} + + + + diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.h b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.h new file mode 100644 index 000000000..7cd473035 --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.h @@ -0,0 +1,92 @@ +/* + * Retroshare Photo Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#ifndef MRK_PHOTO_SLIDE_SHOW_H +#define MRK_PHOTO_SLIDE_SHOW_H + +#include "ui_PhotoSlideShow.h" + +#include +#include "util/TokenQueue.h" + +class PhotoSlideShow : public QWidget, public TokenResponse +{ + Q_OBJECT + +public: + PhotoSlideShow(QWidget *parent = 0); + + void loadAlbum(const std::string &albumId); +virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + + void clearDialog(); + +private slots: + void showPhotoDetails(); + void moveLeft(); + void moveRight(); + void StartStop(); + void timerEvent(); + void closeShow(); + + +private: + + void loadImage(); + void updateMoveButtons(uint32_t status); + + bool loadPhotoData(const uint32_t &token); + bool loadAlbumData(const uint32_t &token); + +//protected: + + std::map mPhotos; + std::map mPhotoOrder; + + bool mRunning; + int mImageIdx; + bool mShotActive; + + TokenQueue *mPhotoQueue; + + Ui::PhotoSlideShow ui; +}; + +#endif + + + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui new file mode 100644 index 000000000..9bc91f506 --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.ui @@ -0,0 +1,144 @@ + + + PhotoSlideShow + + + + 0 + 0 + 747 + 671 + + + + + + + + + + + + + 0 + 0 + + + + Album Name + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Image + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Show/Hide Details + + + + + + + Qt::Horizontal + + + + 68 + 17 + + + + + + + + << + + + + + + + Stop/Run + + + + + + + >> + + + + + + + Qt::Horizontal + + + + 68 + 17 + + + + + + + + Close + + + + + + + + + + + +