diff --git a/libretroshare/src/retroshare/rsphoto.h b/libretroshare/src/retroshare/rsphoto.h index 7e5b6ea99..f94f50f34 100644 --- a/libretroshare/src/retroshare/rsphoto.h +++ b/libretroshare/src/retroshare/rsphoto.h @@ -3,7 +3,7 @@ * * * libretroshare: retroshare core library * * * - * Copyright 2008-2012 by Robert Fernie * + * Copyright 2008-2020 by Robert Fernie * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -26,6 +26,7 @@ #include #include #include "rsgxsservice.h" +#include "rsgxscommon.h" /* The Main Interface Class - for information about your Peers */ class RsPhoto; @@ -37,21 +38,6 @@ extern RsPhoto *rsPhoto; #define RSPHOTO_MODE_OWN 2 #define RSPHOTO_MODE_REMOTE 3 -class RsPhotoThumbnail -{ - public: - RsPhotoThumbnail() - :data(NULL), size(0), type("N/A") { return; } - - bool deleteImage(); - bool copyFrom(const RsPhotoThumbnail &nail); - - // Holds Thumbnail image. - uint8_t *data; - uint32_t size; - std::string type; -}; - /* If these flags are no set - the Photo inherits values from the Album */ @@ -96,7 +82,7 @@ class RsPhotoPhoto int mOrder; - RsPhotoThumbnail mThumbnail; + RsGxsImage mThumbnail; int mMode; @@ -137,7 +123,7 @@ class RsPhotoAlbum std::string mHashTags; - RsPhotoThumbnail mThumbnail; + RsGxsImage mThumbnail; int mMode; diff --git a/libretroshare/src/rsitems/rsphotoitems.cc b/libretroshare/src/rsitems/rsphotoitems.cc index e462d8ee9..31187d9ee 100644 --- a/libretroshare/src/rsitems/rsphotoitems.cc +++ b/libretroshare/src/rsitems/rsphotoitems.cc @@ -37,8 +37,8 @@ RsItem *RsGxsPhotoSerialiser::create_item(uint16_t service, uint8_t item_sub_id) switch(item_sub_id) { case RS_PKT_SUBTYPE_PHOTO_COMMENT_ITEM: return new RsGxsPhotoCommentItem() ; - case RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM: return new RsGxsPhotoAlbumItem() ; - case RS_PKT_SUBTYPE_PHOTO_ITEM: return new RsGxsPhotoPhotoItem() ; + case RS_PKT_SUBTYPE_PHOTO_SHOW_ITEM: return new RsGxsPhotoPhotoItem() ; + case RS_PKT_SUBTYPE_PHOTO_ITEM: return new RsGxsPhotoAlbumItem() ; default: return NULL ; } @@ -55,25 +55,23 @@ void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsG RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME, album.mPhotographer, "mPhotographer"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DATE, album.mWhen, "mWhen"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere"); - RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PIC_TYPE, album.mThumbnail.type,"mThumbnail.type"); - RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data, album.mThumbnail.size); - RsTypeSerializer::serial_process(j, ctx, b, "thumbnail binary data") ; + RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.mData, album.mThumbnail.mSize); + RsTypeSerializer::serial_process(j, ctx, b, "mThumbnail") ; } void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere"); - RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type, "mThumbnail.type"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere"); - RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, photo.mThumbnail.data, photo.mThumbnail.size); - RsTypeSerializer::serial_process(j, ctx, b, "mThumbnail") ; + RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, photo.mThumbnail.mData, photo.mThumbnail.mSize); + RsTypeSerializer::serial_process(j, ctx, b, "mThumbnail") ; } void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { @@ -83,16 +81,16 @@ void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,R void RsGxsPhotoAlbumItem::clear() { - album.mCaption.clear(); - album.mCategory.clear(); - album.mDescription.clear(); - album.mHashTags.clear(); - album.mOther.clear(); - album.mPhotoPath.clear(); - album.mPhotographer.clear(); - album.mWhen.clear(); - album.mWhere.clear(); - album.mThumbnail.deleteImage(); + album.mCaption.clear(); + album.mCategory.clear(); + album.mDescription.clear(); + album.mHashTags.clear(); + album.mOther.clear(); + album.mPhotoPath.clear(); + album.mPhotographer.clear(); + album.mWhen.clear(); + album.mWhere.clear(); + album.mThumbnail.clear(); } void RsGxsPhotoCommentItem::clear() @@ -103,13 +101,13 @@ void RsGxsPhotoCommentItem::clear() void RsGxsPhotoPhotoItem::clear() { - photo.mCaption.clear(); - photo.mCategory.clear(); - photo.mDescription.clear(); - photo.mHashTags.clear(); - photo.mOther.clear(); - photo.mPhotographer.clear(); - photo.mWhen.clear(); - photo.mWhere.clear(); - photo.mThumbnail.deleteImage(); + photo.mCaption.clear(); + photo.mCategory.clear(); + photo.mDescription.clear(); + photo.mHashTags.clear(); + photo.mOther.clear(); + photo.mPhotographer.clear(); + photo.mWhen.clear(); + photo.mWhere.clear(); + photo.mThumbnail.clear(); } diff --git a/libretroshare/src/services/p3photoservice.cc b/libretroshare/src/services/p3photoservice.cc index 608fddbc0..0212aa715 100644 --- a/libretroshare/src/services/p3photoservice.cc +++ b/libretroshare/src/services/p3photoservice.cc @@ -30,56 +30,16 @@ const uint32_t RsPhoto::FLAG_MSG_TYPE_MASK = 0x000f; const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_POST = 0x0001; const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_COMMENT = 0x0002; - - - -bool RsPhotoThumbnail::copyFrom(const RsPhotoThumbnail &nail) -{ - if (data) - { - deleteImage(); - } - - if ((!nail.data) || (nail.size == 0)) - { - return false; - } - - size = nail.size; - type = nail.type; - data = (uint8_t *) rs_malloc(size); - - if(data == NULL) - return false ; - - memcpy(data, nail.data, size); - - return true; -} - -bool RsPhotoThumbnail::deleteImage() -{ - if (data) - { - free(data); - data = NULL; - size = 0; - type.clear(); - } - return true; -} - - RsPhotoPhoto::RsPhotoPhoto() - :mSetFlags(0), mOrder(0), mMode(0), mModFlags(0) + :mSetFlags(0), mOrder(0), mMode(0), mModFlags(0) { - return; + return; } RsPhotoAlbum::RsPhotoAlbum() - :mMode(0), mSetFlags(0), mModFlags(0) + :mMode(0), mSetFlags(0), mModFlags(0) { - return; + return; } RsPhotoComment::RsPhotoComment() @@ -96,19 +56,19 @@ RsPhotoComment::RsPhotoComment(const RsGxsPhotoCommentItem &comment) } std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo) { - out << "RsPhotoPhoto [ "; - out << "Title: " << photo.mMeta.mMsgName; - out << "]"; - return out; + out << "RsPhotoPhoto [ "; + out << "Title: " << photo.mMeta.mMsgName; + out << "]"; + return out; } std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album) { - out << "RsPhotoAlbum [ "; - out << "Title: " << album.mMeta.mGroupName; - out << "]"; - return out; + out << "RsPhotoAlbum [ "; + out << "Title: " << album.mMeta.mGroupName; + out << "]"; + return out; } p3PhotoService::p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs) @@ -125,7 +85,7 @@ const uint16_t GXS_PHOTO_MIN_MINOR_VERSION = 0; RsServiceInfo p3PhotoService::getServiceInfo() { - return RsServiceInfo(RS_SERVICE_GXS_TYPE_PHOTO, + return RsServiceInfo(RS_SERVICE_GXS_TYPE_PHOTO, GXS_PHOTO_APP_NAME, GXS_PHOTO_APP_MAJOR_VERSION, GXS_PHOTO_APP_MINOR_VERSION, @@ -137,20 +97,20 @@ RsServiceInfo p3PhotoService::getServiceInfo() uint32_t p3PhotoService::photoAuthenPolicy() { - uint32_t policy = 0; - uint8_t flag = 0; + uint32_t policy = 0; + uint8_t flag = 0; - flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN; - RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PUBLIC_GRP_BITS); + flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN; + RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PUBLIC_GRP_BITS); - flag |= GXS_SERV::MSG_AUTHEN_CHILD_PUBLISH_SIGN; - RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::RESTRICTED_GRP_BITS); - RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PRIVATE_GRP_BITS); + flag |= GXS_SERV::MSG_AUTHEN_CHILD_PUBLISH_SIGN; + RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::RESTRICTED_GRP_BITS); + RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PRIVATE_GRP_BITS); - flag = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN; - RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::GRP_OPTION_BITS); + flag = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN; + RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::GRP_OPTION_BITS); - return policy; + return policy; } bool p3PhotoService::updated() @@ -175,14 +135,15 @@ void p3PhotoService::groupsChanged(std::list& grpIds) while(!mGroupChange.empty()) { - RsGxsGroupChange* gc = mGroupChange.back(); - std::list& gList = gc->mGrpIdList; - std::list::iterator lit = gList.begin(); - for(; lit != gList.end(); ++lit) - grpIds.push_back(*lit); + RsGxsGroupChange* gc = mGroupChange.back(); + std::list& gList = gc->mGrpIdList; + std::list::iterator lit = gList.begin(); + for(; lit != gList.end(); ++lit) { + grpIds.push_back(*lit); + } - mGroupChange.pop_back(); - delete gc; + mGroupChange.pop_back(); + delete gc; } } @@ -203,105 +164,107 @@ void p3PhotoService::msgsChanged(GxsMsgIdResult& msgs) RsTokenService* p3PhotoService::getTokenService() { - return RsGenExchange::getTokenService(); + return RsGenExchange::getTokenService(); } bool p3PhotoService::getGroupList(const uint32_t& token, - std::list& groupIds) + std::list& groupIds) { - return RsGenExchange::getGroupList(token, groupIds); + bool okay = RsGenExchange::getGroupList(token, groupIds); + return okay; } bool p3PhotoService::getMsgList(const uint32_t& token, - GxsMsgIdResult& msgIds) + GxsMsgIdResult& msgIds) { - return RsGenExchange::getMsgList(token, msgIds); + return RsGenExchange::getMsgList(token, msgIds); } bool p3PhotoService::getGroupSummary(const uint32_t& token, - std::list& groupInfo) + std::list& groupInfo) { - return RsGenExchange::getGroupMeta(token, groupInfo); + bool okay = RsGenExchange::getGroupMeta(token, groupInfo); + return okay; } bool p3PhotoService::getMsgSummary(const uint32_t& token, - MsgMetaResult& msgInfo) + MsgMetaResult& msgInfo) { - return RsGenExchange::getMsgMeta(token, msgInfo); + return RsGenExchange::getMsgMeta(token, msgInfo); } bool p3PhotoService::getAlbum(const uint32_t& token, std::vector& albums) { - std::vector grpData; - bool ok = RsGenExchange::getGroupData(token, grpData); + std::vector grpData; + bool ok = RsGenExchange::getGroupData(token, grpData); - if(ok) - { - std::vector::iterator vit = grpData.begin(); + if(ok) + { + std::vector::iterator vit = grpData.begin(); - for(; vit != grpData.end(); ++vit) - { - RsGxsPhotoAlbumItem* item = dynamic_cast(*vit); - if (item) - { - RsPhotoAlbum album = item->album; - item->album.mMeta = item->meta; - album.mMeta = item->album.mMeta; - delete item; - albums.push_back(album); - } - else - { - std::cerr << "Not a RsGxsPhotoAlbumItem, deleting!" << std::endl; - delete *vit; - } - } - } + for(; vit != grpData.end(); ++vit) + { + RsGxsPhotoAlbumItem* item = dynamic_cast(*vit); + if (item) + { + RsPhotoAlbum album = item->album; + item->album.mMeta = item->meta; + album.mMeta = item->album.mMeta; + delete item; + albums.push_back(album); + } + else + { + std::cerr << "Not a RsGxsPhotoAlbumItem, deleting!" << std::endl; + delete *vit; + } + } + } - return ok; + return ok; } bool p3PhotoService::getPhoto(const uint32_t& token, PhotoResult& photos) { - GxsMsgDataMap msgData; - bool ok = RsGenExchange::getMsgData(token, msgData); + GxsMsgDataMap msgData; + bool ok = RsGenExchange::getMsgData(token, msgData); - if(ok) - { - GxsMsgDataMap::iterator mit = msgData.begin(); + if(ok) + { + GxsMsgDataMap::iterator mit = msgData.begin(); - for(; mit != msgData.end(); ++mit) - { - RsGxsGroupId grpId = mit->first; - std::vector& msgItems = mit->second; - std::vector::iterator vit = msgItems.begin(); + for(; mit != msgData.end(); ++mit) + { + RsGxsGroupId grpId = mit->first; + std::vector& msgItems = mit->second; + std::vector::iterator vit = msgItems.begin(); - for(; vit != msgItems.end(); ++vit) - { - RsGxsPhotoPhotoItem* item = dynamic_cast(*vit); + for(; vit != msgItems.end(); ++vit) + { + RsGxsPhotoPhotoItem* item = dynamic_cast(*vit); - if(item) - { - RsPhotoPhoto photo = item->photo; - photo.mMeta = item->meta; - photos[grpId].push_back(photo); - delete item; - }else - { - std::cerr << "Not a photo Item, deleting!" << std::endl; - delete *vit; - } - } - } - } + if(item) + { + RsPhotoPhoto photo = item->photo; + photo.mMeta = item->meta; + photos[grpId].push_back(photo); + delete item; + }else + { + std::cerr << "Not a photo Item, deleting!" << std::endl; + delete *vit; + } + } + } + } - return ok; + return ok; } bool p3PhotoService::getPhotoComment(const uint32_t &token, PhotoCommentResult &comments) @@ -349,9 +312,7 @@ RsPhotoComment& RsPhotoComment::operator=(const RsGxsPhotoCommentItem& comment) bool p3PhotoService::getPhotoRelatedComment(const uint32_t &token, PhotoRelatedCommentResult &comments) { - return RsGenExchange::getMsgRelatedDataT(token, comments); - } bool p3PhotoService::submitAlbumDetails(uint32_t& token, RsPhotoAlbum& album) @@ -379,28 +340,27 @@ void p3PhotoService::notifyChanges(std::vector& changes) RsGxsMsgChange* mc; if((mc = dynamic_cast(n)) != NULL) { - mMsgChange.push_back(mc); + mMsgChange.push_back(mc); } else if((gc = dynamic_cast(n)) != NULL) { - mGroupChange.push_back(gc); + mGroupChange.push_back(gc); } else { - delete n; + delete n; } } } bool p3PhotoService::submitPhoto(uint32_t& token, RsPhotoPhoto& photo) { - RsGxsPhotoPhotoItem* photoItem = new RsGxsPhotoPhotoItem(); - photoItem->photo = photo; - photoItem->meta = photo.mMeta; - photoItem->meta.mMsgFlags = FLAG_MSG_TYPE_PHOTO_POST; + RsGxsPhotoPhotoItem* photoItem = new RsGxsPhotoPhotoItem(); + photoItem->photo = photo; + photoItem->meta = photo.mMeta; - RsGenExchange::publishMsg(token, photoItem); - return true; + RsGenExchange::publishMsg(token, photoItem); + return true; } bool p3PhotoService::submitComment(uint32_t &token, RsPhotoComment &comment) @@ -415,16 +375,16 @@ bool p3PhotoService::submitComment(uint32_t &token, RsPhotoComment &comment) } bool p3PhotoService::acknowledgeMsg(const uint32_t& token, - std::pair& msgId) + std::pair& msgId) { - return RsGenExchange::acknowledgeTokenMsg(token, msgId); + return RsGenExchange::acknowledgeTokenMsg(token, msgId); } bool p3PhotoService::acknowledgeGrp(const uint32_t& token, - RsGxsGroupId& grpId) + RsGxsGroupId& grpId) { - return RsGenExchange::acknowledgeTokenGrp(token, grpId); + return RsGenExchange::acknowledgeTokenGrp(token, grpId); } bool p3PhotoService::subscribeToAlbum(uint32_t &token, const RsGxsGroupId &grpId, bool subscribe) diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.cpp index 5d5461d79..68c74e221 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.cpp @@ -128,7 +128,7 @@ void AlbumCreateDialog::publishPhotos() } -bool AlbumCreateDialog::getAlbumThumbnail(RsPhotoThumbnail &nail) +bool AlbumCreateDialog::getAlbumThumbnail(RsGxsImage &image) { const QPixmap *tmppix = &mThumbNail; @@ -142,17 +142,11 @@ bool AlbumCreateDialog::getAlbumThumbnail(RsPhotoThumbnail &nail) 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); - + image.copy((uint8_t *) ba.data(), ba.size()); return true; } - nail.data = NULL; - nail.size = 0; + image.clear(); return false; } diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.h b/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.h index 41b0896ba..d136a374b 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.h +++ b/retroshare-gui/src/gui/PhotoShare/AlbumCreateDialog.h @@ -55,7 +55,7 @@ private slots: private: - bool getAlbumThumbnail(RsPhotoThumbnail &nail); + bool getAlbumThumbnail(RsGxsImage &image); private: Ui::AlbumCreateDialog *ui; diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp index 8961e0cd8..c7f0991df 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp @@ -60,17 +60,17 @@ void AlbumDialog::setUp() ui->textEdit_description->setText(QString::fromStdString(mAlbum.mDescription)); - QPixmap qtn; - GxsIdDetails::loadPixmapFromData(mAlbum.mThumbnail.data, mAlbum.mThumbnail.size,qtn, GxsIdDetails::ORIGINAL); - if(mAlbum.mThumbnail.size != 0) + if(mAlbum.mThumbnail.mSize != 0) { - ui->label_thumbNail->setPixmap(qtn); + QPixmap qtn; + GxsIdDetails::loadPixmapFromData(mAlbum.mThumbnail.mData, mAlbum.mThumbnail.mSize,qtn, GxsIdDetails::ORIGINAL); + ui->label_thumbNail->setPixmap(qtn); } else { - // display a default Album icon when album has no Thumbnail - ui->label_thumbNail->setPixmap(QPixmap(":/images/album_default_128.png")); + // display a default Album icon when album has no Thumbnail + ui->label_thumbNail->setPixmap(QPixmap(":/images/album_default_128.png")); } } diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp new file mode 100644 index 000000000..c6ddf6e17 --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp @@ -0,0 +1,41 @@ +/******************************************************************************* + * retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp * + * * + * Copyright (C) 2018 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "AlbumExtra.h" +#include "ui_AlbumExtra.h" + +AlbumExtra::AlbumExtra(QWidget *parent) : + QWidget(NULL), + ui(new Ui::AlbumExtra) +{ + ui->setupUi(this); + setUp(); +} + +AlbumExtra::~AlbumExtra() +{ + delete ui; +} + +void AlbumExtra::setUp() +{ + +} + diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.h b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.h new file mode 100644 index 000000000..1a932bcaa --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.h @@ -0,0 +1,44 @@ +/******************************************************************************* + * retroshare-gui/src/gui/PhotoShare/AlbumExtra.h * + * * + * Copyright (C) 2020 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef ALBUMEXTRA_H +#define ALBUMEXTRA_H + +#include + +namespace Ui { + class AlbumExtra; +} + +class AlbumExtra : public QWidget +{ + Q_OBJECT + +public: + explicit AlbumExtra(QWidget *parent = 0); + virtual ~AlbumExtra(); + +private: + void setUp(); +private: + Ui::AlbumExtra *ui; +}; + +#endif // ALBUMEXTRA_H diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.ui b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.ui new file mode 100644 index 000000000..09780a77a --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.ui @@ -0,0 +1,162 @@ + + + AlbumExtra + + + + 0 + 0 + 513 + 198 + + + + + 0 + 0 + + + + Form + + + + + + Category: + + + + + + + + Animals + + + + + Family + + + + + Friends + + + + + Flowers + + + + + Holiday + + + + + Landscapes + + + + + Pets + + + + + Portraits + + + + + Travel + + + + + Work + + + + + Random + + + + + + + + Quality: + + + + + + + + 0 + 0 + + + + + Resize Images (< 1Mb) + + + + + Resize Images (< 10Mb) + + + + + Send Original Images + + + + + + + + Qt::Horizontal + + + + + + + Caption: + + + + + + + + + + Where: + + + + + + + + + + Photographer: + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp new file mode 100644 index 000000000..33e6cc229 --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp @@ -0,0 +1,186 @@ +/******************************************************************************* + * retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp * + * * + * Copyright (C) 2020 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ +#include + +#include "AlbumGroupDialog.h" +#include "AlbumExtra.h" +#include "gui/gxs/GxsIdDetails.h" + +#include + +const uint32_t AlbumCreateEnabledFlags = ( + GXS_GROUP_FLAGS_NAME | + GXS_GROUP_FLAGS_ICON | + GXS_GROUP_FLAGS_DESCRIPTION | + GXS_GROUP_FLAGS_DISTRIBUTION | + // GXS_GROUP_FLAGS_PUBLISHSIGN | + // GXS_GROUP_FLAGS_SHAREKEYS | // disabled because the UI doesn't handle it yet. + // GXS_GROUP_FLAGS_PERSONALSIGN | + // GXS_GROUP_FLAGS_COMMENTS | + GXS_GROUP_FLAGS_EXTRA | + 0); + +uint32_t AlbumCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC | + //GXS_GROUP_DEFAULTS_DISTRIB_GROUP | + //GXS_GROUP_DEFAULTS_DISTRIB_LOCAL | + + GXS_GROUP_DEFAULTS_PUBLISH_OPEN | + //GXS_GROUP_DEFAULTS_PUBLISH_THREADS | + //GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED | + //GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED | + + //GXS_GROUP_DEFAULTS_PERSONAL_GPG | + GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED | + //GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB | + + //GXS_GROUP_DEFAULTS_COMMENTS_YES | + GXS_GROUP_DEFAULTS_COMMENTS_NO | + 0); + +uint32_t AlbumEditEnabledFlags = AlbumCreateEnabledFlags; +uint32_t AlbumEditDefaultsFlags = AlbumCreateDefaultsFlags; + +AlbumGroupDialog::AlbumGroupDialog(TokenQueue *tokenQueue, QWidget *parent) + : GxsGroupDialog(tokenQueue, AlbumCreateEnabledFlags, AlbumCreateDefaultsFlags, parent) +{ +} + +AlbumGroupDialog::AlbumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent) + : GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, AlbumEditEnabledFlags, AlbumEditDefaultsFlags, parent) +{ +} + +void AlbumGroupDialog::initUi() +{ + switch (mode()) + { + case MODE_CREATE: + setUiText(UITYPE_SERVICE_HEADER, tr("Create New Album")); + setUiText(UITYPE_BUTTONBOX_OK, tr("Create")); + break; + case MODE_SHOW: + setUiText(UITYPE_SERVICE_HEADER, tr("Album")); + break; + case MODE_EDIT: + setUiText(UITYPE_SERVICE_HEADER, tr("Edit ALbum")); + setUiText(UITYPE_BUTTONBOX_OK, tr("Update Album")); + break; + } + + setUiText(UITYPE_ADD_ADMINS_CHECKBOX, tr("Add Album Admins")); + setUiText(UITYPE_CONTACTS_DOCK, tr("Select Album Admins")); + + // Inject Extra Widgets. + injectExtraWidget(new AlbumExtra(this)); +} + +QPixmap AlbumGroupDialog::serviceImage() +{ + return QPixmap(":/images/album_create_64.png"); +} + +void AlbumGroupDialog::prepareAlbumGroup(RsPhotoAlbum &group, const RsGroupMetaData &meta) +{ + group.mMeta = meta; + group.mDescription = getDescription().toUtf8().constData(); + + QPixmap pixmap = getLogo(); + + if (!pixmap.isNull()) { + QByteArray ba; + QBuffer buffer(&ba); + + buffer.open(QIODevice::WriteOnly); + pixmap.save(&buffer, "PNG"); // writes image into ba in PNG format + + group.mThumbnail.copy((uint8_t *) ba.data(), ba.size()); + } else { + group.mThumbnail.clear(); + } + + // Additional Fields that we need to fill in. + group.mCaption = "Caption goes here"; + group.mPhotographer = "photographer"; + group.mWhere = "Where?"; + +} + +bool AlbumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) +{ + // Specific Function. + RsPhotoAlbum grp; + prepareAlbumGroup(grp, meta); + + rsPhoto->submitAlbumDetails(token, grp); + return true; +} + +bool AlbumGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta) +{ + RsPhotoAlbum grp; + prepareAlbumGroup(grp, editedMeta); + + std::cerr << "AlbumGroupDialog::service_EditGroup() submitting changes"; + std::cerr << std::endl; + + // TODO: no interface here, yet. + // rsPhoto->updateGroup(token, grp); + return true; +} + +bool AlbumGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description) +{ + std::cerr << "AlbumGroupDialog::service_loadGroup(" << token << ")"; + std::cerr << std::endl; + + std::vector groups; + if (!rsPhoto->getAlbum(token, groups)) + { + std::cerr << "AlbumGroupDialog::service_loadGroup() Error getting GroupData"; + std::cerr << std::endl; + return false; + } + + if (groups.size() != 1) + { + std::cerr << "AlbumGroupDialog::service_loadGroup() Error Group.size() != 1"; + std::cerr << std::endl; + return false; + } + + std::cerr << "AlbumGroupDialog::service_loadGroup() Unfinished Loading"; + std::cerr << std::endl; + + const RsPhotoAlbum &group = groups[0]; + groupMetaData = group.mMeta; + description = QString::fromUtf8(group.mDescription.c_str()); + + if (group.mThumbnail.mData) { + QPixmap pixmap; + if (GxsIdDetails::loadPixmapFromData(group.mThumbnail.mData, group.mThumbnail.mSize, pixmap,GxsIdDetails::ORIGINAL)) { + setLogo(pixmap); + } + } else { + setLogo(QPixmap(":/images/album_create_64.png")); + } + + // NEED TO Load additional data.... + return true; +} diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.h b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.h new file mode 100644 index 000000000..a06ce3461 --- /dev/null +++ b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.h @@ -0,0 +1,47 @@ +/******************************************************************************* + * retroshare-gui/src/gui/Posted/PostedGroupDialog.h * + * * + * Copyright (C) 2020 by Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program 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 Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + + +#ifndef _ALBUM_GROUP_DIALOG_H +#define _ALBUM_GROUP_DIALOG_H + +#include "gui/gxs/GxsGroupDialog.h" +#include + +class AlbumGroupDialog : public GxsGroupDialog +{ + Q_OBJECT + +public: + AlbumGroupDialog(TokenQueue *tokenQueue, QWidget *parent); + AlbumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent); + +protected: + virtual void initUi(); + virtual QPixmap serviceImage(); + virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); + virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description); + virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta); + +private: + void prepareAlbumGroup(RsPhotoAlbum &group, const RsGroupMetaData &meta); +}; + +#endif diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp index 4637a673a..1eb79dd98 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumItem.cpp @@ -41,17 +41,17 @@ void AlbumItem::setUp() { ui->label_AlbumTitle->setText(QString::fromStdString(mAlbum.mMeta.mGroupName)); ui->label_Photographer->setText(QString::fromStdString(mAlbum.mPhotographer)); - QPixmap qtn; - qtn.loadFromData(mAlbum.mThumbnail.data, mAlbum.mThumbnail.size, mAlbum.mThumbnail.type.c_str()); - if(mAlbum.mThumbnail.size != 0) + if(mAlbum.mThumbnail.mSize != 0) { - ui->label_Thumbnail->setPixmap(qtn); + QPixmap qtn; + qtn.loadFromData(mAlbum.mThumbnail.mData, mAlbum.mThumbnail.mSize, "PNG"); + ui->label_Thumbnail->setPixmap(qtn); } else { - // display a default Album icon when album has no Thumbnail - ui->label_Thumbnail->setPixmap(QPixmap(":/images/album_default_128.png")); + // display a default Album icon when album has no Thumbnail + ui->label_Thumbnail->setPixmap(QPixmap(":/images/album_default_128.png")); } } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp index a3e0e8c69..0d2112304 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp @@ -53,7 +53,7 @@ PhotoDialog::~PhotoDialog() void PhotoDialog::setUp() { QPixmap qtn; - qtn.loadFromData(mPhotoDetails.mThumbnail.data, mPhotoDetails.mThumbnail.size, mPhotoDetails.mThumbnail.type.c_str()); + qtn.loadFromData(mPhotoDetails.mThumbnail.mData, mPhotoDetails.mThumbnail.mSize, "PNG"); ui->label_Photo->setPixmap(qtn); ui->lineEdit_Title->setText(QString::fromStdString(mPhotoDetails.mMeta.mMsgName)); diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp index f0cfaa895..56378467f 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp @@ -60,7 +60,7 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget ui->label_Thumbnail->setPixmap(mThumbNail.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation)); setSelected(false); - getPhotoThumbnail(mPhotoDetails.mThumbnail); + getThumbnail(mPhotoDetails.mThumbnail); connect(ui->lineEdit_Title, SIGNAL(editingFinished()), this, SLOT(setTitle())); connect(ui->lineEdit_PhotoGrapher, SIGNAL(editingFinished()), this, SLOT(setPhotoGrapher())); @@ -83,7 +83,7 @@ void PhotoItem::setSelected(bool selected) update(); } -bool PhotoItem::getPhotoThumbnail(RsPhotoThumbnail &nail) +bool PhotoItem::getThumbnail(RsGxsImage &image) { const QPixmap *tmppix = &mThumbNail; @@ -96,18 +96,11 @@ bool PhotoItem::getPhotoThumbnail(RsPhotoThumbnail &nail) 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); - + image.copy((uint8_t *) ba.data(), ba.size()); return true; } - nail.data = NULL; - nail.size = 0; + image.clear(); return false; } @@ -166,12 +159,12 @@ void PhotoItem::setUp() updateImage(mPhotoDetails.mThumbnail); } -void PhotoItem::updateImage(const RsPhotoThumbnail &thumbnail) +void PhotoItem::updateImage(const RsGxsImage &image) { - if (thumbnail.data != NULL) + if (image.mData != NULL) { QPixmap qtn; - qtn.loadFromData(thumbnail.data, thumbnail.size, thumbnail.type.c_str()); + qtn.loadFromData(image.mData, image.mSize, "PNG"); ui->label_Thumbnail->setPixmap(qtn.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation)); mThumbNail = qtn; } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoItem.h b/retroshare-gui/src/gui/PhotoShare/PhotoItem.h index ee7b4e578..8b5ca5a18 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoItem.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoItem.h @@ -42,13 +42,13 @@ public: void setSelected(bool selected); bool isSelected(){ return mSelected; } const RsPhotoPhoto& getPhotoDetails(); - bool getPhotoThumbnail(RsPhotoThumbnail &nail); + bool getThumbnail(RsGxsImage &image); protected: void mousePressEvent(QMouseEvent *event); private: - void updateImage(const RsPhotoThumbnail &thumbnail); + void updateImage(const RsGxsImage &image); void setUp(); private slots: diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp index 5c00bcb7a..047e6ae58 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp @@ -31,7 +31,7 @@ #include #include -#include "AlbumCreateDialog.h" +#include "AlbumGroupDialog.h" #include "AlbumItem.h" #include "PhotoItem.h" @@ -215,7 +215,7 @@ void PhotoShare::OpenSlideShow() void PhotoShare::createAlbum() { - AlbumCreateDialog albumCreate(mPhotoQueue, rsPhoto, this); + AlbumGroupDialog albumCreate(mPhotoQueue, this); albumCreate.exec(); } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoShare.h b/retroshare-gui/src/gui/PhotoShare/PhotoShare.h index dec0e077a..6703ffc53 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoShare.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoShare.h @@ -28,7 +28,6 @@ #include "retroshare/rsphoto.h" #include "retroshare-gui/mainpage.h" -#include "AlbumCreateDialog.h" #include "AlbumDialog.h" #include "PhotoDialog.h" diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp index 8b1df126f..7e5fb6d00 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp @@ -20,6 +20,7 @@ #include "gui/PhotoShare/PhotoSlideShow.h" #include "gui/PhotoShare/PhotoDrop.h" +#include "gui/gxs/GxsIdDetails.h" #include @@ -175,16 +176,10 @@ void PhotoSlideShow::loadImage() if (ptr) { /* load into the slot */ - if (ptr->mThumbnail.data != NULL) + if (ptr->mThumbnail.mData != 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; - + GxsIdDetails::loadPixmapFromData(ptr->mThumbnail.mData, ptr->mThumbnail.mSize,qtn, GxsIdDetails::ORIGINAL); QPixmap sqtn = qtn.scaled(800, 600, Qt::KeepAspectRatio, Qt::SmoothTransformation); ui.imgLabel->setPixmap(sqtn); @@ -249,8 +244,8 @@ bool PhotoSlideShow::loadPhotoData(const uint32_t &token) RsPhotoPhoto& photo = *vit; RsPhotoPhoto *ptr = new RsPhotoPhoto; *ptr = photo; - ptr->mThumbnail.data = 0; - ptr->mThumbnail.copyFrom(photo.mThumbnail); + + ptr->mThumbnail = photo.mThumbnail; // copies data. ptr->mOrder = i++; mPhotos[photo.mMeta.mMsgId] = ptr; mPhotoOrder[ptr->mOrder] = photo.mMeta.mMsgId; diff --git a/retroshare-gui/src/gui/TheWire/PulseItem.cpp b/retroshare-gui/src/gui/TheWire/PulseItem.cpp index 2eb328b3e..16b01d3a4 100644 --- a/retroshare-gui/src/gui/TheWire/PulseItem.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseItem.cpp @@ -25,8 +25,6 @@ #include "PulseItem.h" -#include - #include #include @@ -35,217 +33,48 @@ ****/ /** Constructor */ -PulseItem::PulseItem(PulseHolder *parent, const RsPhotoAlbum &album, const RsPhotoThumbnail &thumbnail) -:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_ALBUM) + +PulseItem::PulseItem(PulseHolder *parent, std::string path) +:QWidget(NULL), mParent(parent), mType(0) { - setupUi(this); + setupUi(this); + setAttribute ( Qt::WA_DeleteOnClose, true ); - setAttribute ( Qt::WA_DeleteOnClose, true ); - - mDetails = *( (RsPhotoPhoto *) &(album)); - updateAlbumText(album); - updateImage(thumbnail); - - setSelected(false); } - -PulseItem::PulseItem(PulseHolder *parent, const RsPhotoPhoto &photo, const RsPhotoThumbnail &thumbnail) -:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_PHOTO) -{ - setupUi(this); - - setAttribute ( Qt::WA_DeleteOnClose, true ); - - mDetails = *( (RsPhotoPhoto *) &(photo)); - - updatePhotoText(photo); - updateImage(thumbnail); - - setSelected(false); -} - - -PulseItem::PulseItem(PulseHolder *parent, std::string path) // for new photos. -:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_NEW) -{ - setupUi(this); - - setAttribute ( Qt::WA_DeleteOnClose, true ); - -#if 0 - QString dummyString("dummytext"); - titleLabel->setText(QString("NEW PHOTO")); - - 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; - - //QPixmap qtn = QPixmap(QString::fromStdString(path)).scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - QPixmap qtn = QPixmap(QString::fromStdString(path)).scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); - imgLabel->setPixmap(qtn); - setSelected(false); -#endif -} - -void PulseItem::updateAlbumText(const RsPhotoAlbum &album) -{ -#if 0 - 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); -#endif -} - -void PulseItem::updatePhotoText(const RsPhotoPhoto &photo) -{ -#if 0 - 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")); -#endif -} - - -void PulseItem::updateImage(const RsPhotoThumbnail &thumbnail) -{ -#if 0 - if (thumbnail.data != NULL) - { - QPixmap qtn; - qtn.loadFromData(thumbnail.data, thumbnail.size, thumbnail.type.c_str()); - imgLabel->setPixmap(qtn); - } -#endif -} - -bool PulseItem::getPhotoThumbnail(RsPhotoThumbnail &nail) -{ -#if 0 - const QPixmap *tmppix = imgLabel->pixmap(); - - 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; -#endif - return false; -} - - void PulseItem::removeItem() { -#if 0 -#ifdef DEBUG_ITEM - std::cerr << "PulseItem::removeItem()"; - std::cerr << std::endl; -#endif - hide(); - if (mParent) - { - mParent->deletePulseItem(this, mType); - } -#endif } - void PulseItem::setSelected(bool on) { -#if 0 - mSelected = on; - if (mSelected) - { - mParent->notifySelection(this, mType); - frame->setStyleSheet("QFrame#frame{border: 2px solid #55CC55;\nbackground: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #55EE55, stop: 1 #CCCCCC);\nborder-radius: 10px}"); - } - else - { - frame->setStyleSheet("QFrame#frame{border: 2px solid #CCCCCC;\nbackground: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC);\nborder-radius: 10px}"); - } - update(); -#endif } bool PulseItem::isSelected() { - return mSelected; + return mSelected; } - void PulseItem::mousePressEvent(QMouseEvent *event) { - /* We can be very cunning here? - * grab out position. - * flag ourselves as selected. - * then pass the mousePressEvent up for handling by the parent - */ + /* We can be very cunning here? + * grab out position. + * flag ourselves as selected. + * then pass the mousePressEvent up for handling by the parent + */ - QPoint pos = event->pos(); + QPoint pos = event->pos(); - std::cerr << "PulseItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")"; - std::cerr << std::endl; + std::cerr << "PulseItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")"; + std::cerr << std::endl; - setSelected(true); + setSelected(true); - QWidget::mousePressEvent(event); + QWidget::mousePressEvent(event); } - const QPixmap *PulseItem::getPixmap() { -#if 0 - return imgLabel->pixmap(); -#endif - return NULL; + return NULL; } - diff --git a/retroshare-gui/src/gui/TheWire/PulseItem.h b/retroshare-gui/src/gui/TheWire/PulseItem.h index bfbdc710c..6bfeb3506 100644 --- a/retroshare-gui/src/gui/TheWire/PulseItem.h +++ b/retroshare-gui/src/gui/TheWire/PulseItem.h @@ -23,61 +23,37 @@ #include "ui_PulseItem.h" -#include - class PulseItem; class PulseHolder { - public: + public: virtual void deletePulseItem(PulseItem *, uint32_t ptype) = 0; virtual void notifySelection(PulseItem *item, int ptype) = 0; }; - -#define PHOTO_ITEM_TYPE_ALBUM 0x0001 -#define PHOTO_ITEM_TYPE_PHOTO 0x0002 -#define PHOTO_ITEM_TYPE_NEW 0x0003 - class PulseItem : public QWidget, private Ui::PulseItem { Q_OBJECT public: - PulseItem(PulseHolder *parent, const RsPhotoAlbum &album, const RsPhotoThumbnail &thumbnail); - PulseItem(PulseHolder *parent, const RsPhotoPhoto &photo, const RsPhotoThumbnail &thumbnail); - PulseItem(PulseHolder *parent, std::string url); // for new photos. + PulseItem(PulseHolder *parent, std::string url); - bool getPhotoThumbnail(RsPhotoThumbnail &nail); + void removeItem(); - void removeItem(); - - void setSelected(bool on); - bool isSelected(); - - const QPixmap *getPixmap(); - - // details are public - so that can be easily edited. - RsPhotoPhoto mDetails; - -//private slots: + void setSelected(bool on); + bool isSelected(); + const QPixmap *getPixmap(); protected: - void mousePressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); private: - void updateAlbumText(const RsPhotoAlbum &album); - void updatePhotoText(const RsPhotoPhoto &photo); - void updateImage(const RsPhotoThumbnail &thumbnail); - PulseHolder *mParent; - uint32_t mType; - - - bool mSelected; + PulseHolder *mParent; + uint32_t mType; + bool mSelected; }; - #endif - diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index c2d8b86e0..16991b72f 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -160,6 +160,15 @@ void GxsGroupDialog::init() Settings->loadWidgetInformation(this); } +void GxsGroupDialog::injectExtraWidget(QWidget *widget) +{ + // add extra widget into layout. + QVBoxLayout *vbox = new QVBoxLayout(); + vbox->addWidget(widget); + vbox->addStretch(1); + ui.extraFrame->setLayout(vbox); +} + QIcon GxsGroupDialog::serviceWindowIcon() { return qApp->windowIcon(); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h index 13cde700f..709ad4d6f 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h @@ -172,6 +172,13 @@ protected: virtual QPixmap serviceImage() = 0; virtual QIcon serviceWindowIcon(); + /*! + * Inject Extra Widget for additional Group configuration options. + * NB: These are only inserted for createMode currently. + * @param widget Addtional widget which is added to extraFrame. + */ + void injectExtraWidget(QWidget *widget); + /*! * \brief setUiToolTip/setUiText * Sets the text and tooltip of some parts of the UI diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 9ba5af806..f5e25f593 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1154,6 +1154,8 @@ gxsphotoshare { DEFINES += RS_USE_PHOTO # enable in MainWindow HEADERS += \ + gui/PhotoShare/AlbumGroupDialog.h \ + gui/PhotoShare/AlbumExtra.h \ gui/PhotoShare/PhotoDrop.h \ gui/PhotoShare/AlbumItem.h \ gui/PhotoShare/AlbumDialog.h \ @@ -1167,6 +1169,7 @@ gxsphotoshare { gui/PhotoShare/AddCommentDialog.h FORMS += \ + gui/PhotoShare/AlbumExtra.ui \ gui/PhotoShare/PhotoItem.ui \ gui/PhotoShare/PhotoDialog.ui \ gui/PhotoShare/AlbumItem.ui \ @@ -1178,6 +1181,8 @@ gxsphotoshare { gui/PhotoShare/AddCommentDialog.ui SOURCES += \ + gui/PhotoShare/AlbumGroupDialog.cpp \ + gui/PhotoShare/AlbumExtra.cpp \ gui/PhotoShare/PhotoItem.cpp \ gui/PhotoShare/PhotoDialog.cpp \ gui/PhotoShare/PhotoDrop.cpp \