diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index ba81ab9bf..251190e62 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -559,9 +559,10 @@ void SubFileItem::cancel() /* Only occurs - if it is downloading */ if (((mType == SFI_TYPE_ATTACH) || (mType == SFI_TYPE_CHANNEL)) && (mFlag & SFI_FLAG_CREATE)) { - hide(); rsFiles->ExtraFileRemove(FileHash());//, RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA); mPath = ""; + del(); + return; // do not update! } else { diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index f7f8ed726..973563148 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -69,7 +69,8 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelMsg())); connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); - connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); + connect(removeAllFilesButton, SIGNAL(clicked() ), this , SLOT(clearAllAttachments())); + //connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(subjectEdit,SIGNAL(textChanged(const QString&)),this,SLOT(updatePreviewText(const QString&))); connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail())); @@ -81,7 +82,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId channelpostButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/comment.png")); attachmentsButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png")); addThumbnailButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-image.png")); - addfilepushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-file.png")); + //addfilepushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-file.png")); aspectRatio_CB->setItemIcon(0,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-auto.svg")); aspectRatio_CB->setItemIcon(1,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-1-1.svg")); @@ -431,6 +432,16 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin if (mCheckAttachment) checkAttachmentReady(); + + updateAttachmentCount(); +} + +void CreateGxsChannelMsg::updateAttachmentCount() +{ + if(mAttachments.size() > 0) + attachmentsButton->setText(tr("Attachments (%1)").arg(mAttachments.size())); + else + attachmentsButton->setText(tr("Attachments")); } void CreateGxsChannelMsg::deleteAttachment() @@ -449,6 +460,21 @@ void CreateGxsChannelMsg::deleteAttachment() } else ++it; + + updateAttachmentCount(); +} + +void CreateGxsChannelMsg::clearAllAttachments() +{ + QLayoutItem* item; + while ( ( item = fileFrame->layout()->takeAt( 0 ) ) != NULL ) + { + delete item->widget(); + delete item; + } + + mAttachments.clear(); + attachmentsButton->setText(tr("Attachments")); } void CreateGxsChannelMsg::addExtraFile() @@ -489,7 +515,7 @@ void CreateGxsChannelMsg::addAttachment(const std::string &path) setThumbNail(path, 2000); /* add widget in for new destination */ - uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA | SFI_FLAG_CREATE; + uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA | SFI_FLAG_CREATE; // check attachment if hash exists already std::list::iterator it; @@ -516,16 +542,18 @@ void CreateGxsChannelMsg::addAttachment(const std::string &path) //SubFileItem *file = new SubFileItem(hash, filename, path, size, flags, mChannelId); SubFileItem *file = new SubFileItem(hash, filename, path, size, flags, RsPeerId()); - mAttachments.push_back(file); + connect(file,SIGNAL(wantsToBeDeleted()),this,SLOT(deleteAttachment())) ; + + mAttachments.push_back(file); QLayout *layout = fileFrame->layout(); layout->addWidget(file); if (mCheckAttachment) - { checkAttachmentReady(); - } - return; + updateAttachmentCount(); + + return; } bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){ @@ -610,7 +638,9 @@ void CreateGxsChannelMsg::checkAttachmentReady() cancelButton->setEnabled(true); } - /* repeat... */ + updateAttachmentCount(); + + /* repeat... */ int msec_rate = 1000; QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void))); } diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index 8f8b6e41c..d6953c6d8 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -59,6 +59,7 @@ private slots: void checkAttachmentReady(); void deleteAttachment(); void updatePreviewText(const QString &); + void clearAllAttachments(); void cancelMsg(); void sendMsg(); @@ -76,6 +77,7 @@ private: void loadChannelInfo(); void loadOriginalChannelPostInfo(); void saveChannelInfo(const RsGroupMetaData &group); + void updateAttachmentCount(); void parseRsFileListAttachments(const std::string &attachList); void sendMessage(const std::string &subject, const std::string &msg, const std::list &files); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index db3da194f..e98875784 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -82,7 +82,7 @@ false - 0 + 1 @@ -186,7 +186,7 @@ p, li { white-space: pre-wrap; } - <html><head/><body><p>Choose aspect ratio policy.</p><p>In 'Auto' mode, the most suitable </p><p>aspect ratio is chosen for you.</p></body></html> + <html><head/><body><p>Choose aspect ratio policy. In 'Auto' mode, the most suitable aspect ratio is chosen for you.</p></body></html> @@ -261,52 +261,99 @@ p, li { white-space: pre-wrap; } - - - 0 - - - 6 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 34 - 34 - - - - <html><head/><body><p>Add File</p></body></html> - - - - - - - :/icons/png/add-file.png:/icons/png/add-file.png - - - - 24 - 24 - - - + + + + + + + + 0 + 0 + + + + + 34 + 34 + + + + <html><head/><body><p>Add File</p></body></html> + + + + + + + :/icons/png/add-file.png:/icons/png/add-file.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 34 + 34 + + + + <html><head/><body><p>Add File</p></body></html> + + + + + + + :/icons/png/cancel.png:/icons/png/cancel.png + + + + 24 + 24 + + + + + + + + Allow channels to get frame for message thumbnail from movie media attachments or not + + + Auto Thumbnail + + + + + + + Qt::Horizontal + + + + 334 + 26 + + + + + - + Qt::ScrollBarAlwaysOn @@ -319,7 +366,7 @@ p, li { white-space: pre-wrap; } 0 0 - 84 + 827 24 @@ -366,29 +413,6 @@ p, li { white-space: pre-wrap; } - - - - Qt::Horizontal - - - - 334 - 26 - - - - - - - - Allow channels to get frame for message thumbnail from movie media attachments or not - - - Auto Thumbnail - - -