diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index 350ccf09f..e3e62a249 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -319,7 +319,7 @@ void GxsGroupDialog::setupReadonly() { ui.groupName->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_NAME)); - ui.groupLogo->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ICON)); + //ui.groupLogo->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ICON)); ui.addLogoButton->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ICON)); ui.groupDesc->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DESCRIPTION)); @@ -470,7 +470,7 @@ bool GxsGroupDialog::prepareGroupMetaData(RsGroupMetaData &meta) return false; }//switch (ui.idChooser->getChosenId(meta.mAuthorId)) - QString name = misc::removeNewLine(ui.groupName->text()); + QString name = getName(); uint32_t flags = GXS_SERV::FLAG_PRIVACY_PUBLIC; if(name.isEmpty()) { @@ -506,8 +506,8 @@ void GxsGroupDialog::createGroup() std::cerr << "GxsGroupDialog::createGroup()"; std::cerr << std::endl; - QString name = misc::removeNewLine(ui.groupName->text()); - + /* Check name */ + QString name = getName(); if(name.isEmpty()) { /* error message */ @@ -679,21 +679,31 @@ void GxsGroupDialog::addGroupLogo() if (img.isNull()) return; - - picture = img; - - // to show the selected - ui.groupLogo->setPixmap(picture); + + setLogo(img); } QPixmap GxsGroupDialog::getLogo() { - return picture; + return mPicture; +} + +void GxsGroupDialog::setLogo(const QPixmap &pixmap) +{ + mPicture = pixmap; + + // to show the selected + ui.groupLogo->setPixmap(mPicture); +} + +QString GxsGroupDialog::getName() +{ + return misc::removeNewLine(ui.groupName->text()); } QString GxsGroupDialog::getDescription() { - return ui.groupDesc->toPlainText(); + return ui.groupDesc->toPlainText(); } /*********************************************************************************** @@ -707,13 +717,17 @@ void GxsGroupDialog::sendShareList(std::string /*groupId*/) void GxsGroupDialog::setShareList() { - if (ui.pubKeyShare_cb->isChecked()){ - this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height()); - ui.contactsdockWidget->show(); - } else { // hide share widget - ui.contactsdockWidget->hide(); - this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); + if (ui.pubKeyShare_cb->isChecked()) { + QMessageBox::warning(this, "", "ToDo"); + ui.pubKeyShare_cb->setChecked(false); } +// if (ui.pubKeyShare_cb->isChecked()){ +// this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height()); +// ui.contactsdockWidget->show(); +// } else { // hide share widget +// ui.contactsdockWidget->hide(); +// this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); +// } } /*********************************************************************************** diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h index fe44c8a37..c74ae9b94 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h @@ -195,6 +195,19 @@ protected: */ QPixmap getLogo(); + /*! + * This sets a group logo into the ui \n + * Should be calleld by deriving service + * @param pixmap + */ + void setLogo(const QPixmap &pixmap); + + /*! + * This returns a group name string from the ui + * @return group name string + */ + QString getName(); + /*! * This returns a group description string from the ui * @return group description string @@ -234,7 +247,7 @@ private: bool prepareGroupMetaData(RsGroupMetaData &meta); std::list mShareList; - QPixmap picture; + QPixmap mPicture; RsTokenService *mTokenService; TokenQueue *mExternalTokenQueue; TokenQueue *mInternalTokenQueue; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp index 620862faf..5b79a750b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.cpp @@ -19,6 +19,8 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ +#include + #include "GxsChannelGroupDialog.h" #include @@ -94,8 +96,7 @@ QPixmap GxsChannelGroupDialog::serviceImage() { case MODE_CREATE: return QPixmap(":/images/add_channel64.png"); - break; - case MODE_SHOW: + case MODE_SHOW: return QPixmap(":/images/channels.png"); case MODE_EDIT: return QPixmap(":/images/channels.png"); @@ -104,12 +105,31 @@ QPixmap GxsChannelGroupDialog::serviceImage() return QPixmap(); } +void GxsChannelGroupDialog::prepareChannelGroup(RsGxsChannelGroup &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.mImage.copy((uint8_t *) ba.data(), ba.size()); + } else { + group.mImage.clear(); + } +} + bool GxsChannelGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) { // Specific Function. RsGxsChannelGroup grp; - grp.mMeta = meta; - grp.mDescription = getDescription().toUtf8().constData(); + prepareChannelGroup(grp, meta); rsGxsChannels->createGroup(token, grp); return true; @@ -118,8 +138,7 @@ bool GxsChannelGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMe bool GxsChannelGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta) { RsGxsChannelGroup grp; - grp.mMeta = editedMeta; - grp.mDescription = getDescription().toUtf8().constData(); + prepareChannelGroup(grp, editedMeta); std::cerr << "GxsChannelGroupDialog::service_EditGroup() submitting changes"; std::cerr << std::endl; @@ -151,8 +170,16 @@ bool GxsChannelGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsG std::cerr << "GxsChannelsGroupDialog::service_loadGroup() Unfinished Loading"; std::cerr << std::endl; - groupMetaData = groups[0].mMeta; - description = QString::fromUtf8(groups[0].mDescription.c_str()); + const RsGxsChannelGroup &group = groups[0]; + groupMetaData = group.mMeta; + description = QString::fromUtf8(group.mDescription.c_str()); + + if (group.mImage.mData) { + QPixmap pixmap; + if (pixmap.loadFromData(group.mImage.mData, group.mImage.mSize, "PNG")) { + setLogo(pixmap); + } + } return true; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.h b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.h index 8b5b9d270..dc9af67fb 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelGroupDialog.h @@ -39,6 +39,9 @@ protected: 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 prepareChannelGroup(RsGxsChannelGroup &group, const RsGroupMetaData &meta); }; #endif diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp index db97782d1..cef0e70c6 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp @@ -28,7 +28,7 @@ const uint32_t ForumCreateEnabledFlags = ( GXS_GROUP_FLAGS_NAME | - GXS_GROUP_FLAGS_ICON | +// GXS_GROUP_FLAGS_ICON | GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DISTRIBUTION | // GXS_GROUP_FLAGS_PUBLISHSIGN |