add attachment count to channel creation window and fixed item removal (was previously only hidden!)

This commit is contained in:
csoler 2020-10-24 00:02:26 +02:00
parent 0f3e054778
commit 25c836d443
4 changed files with 137 additions and 80 deletions

View File

@ -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
{

View File

@ -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<SubFileItem* >::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)));
}

View File

@ -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<RsGxsFile> &files);

View File

@ -82,7 +82,7 @@
<bool>false</bool>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="stackedWidgetPage1">
<layout class="QGridLayout" name="gridLayout_2">
@ -186,7 +186,7 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QComboBox" name="aspectRatio_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Choose aspect ratio policy.&lt;/p&gt;&lt;p&gt;In 'Auto' mode, the most suitable &lt;/p&gt;&lt;p&gt;aspect ratio is chosen for you.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Choose aspect ratio policy. In 'Auto' mode, the most suitable aspect ratio is chosen for you.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="iconSize">
<size>
@ -261,52 +261,99 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<widget class="QWidget" name="stackedWidgetPage2">
<layout class="QGridLayout" name="attachmentsTabGLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="addFileButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>34</width>
<height>34</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add File&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/add-file.png</normaloff>:/icons/png/add-file.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="addFileButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>34</width>
<height>34</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add File&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/add-file.png</normaloff>:/icons/png/add-file.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeAllFilesButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>34</width>
<height>34</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add File&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/cancel.png</normaloff>:/icons/png/cancel.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="thumbNailCb">
<property name="toolTip">
<string>Allow channels to get frame for message thumbnail from movie media attachments or not</string>
</property>
<property name="text">
<string>Auto Thumbnail</string>
</property>
</widget>
</item>
<item>
<spacer name="attachmentsHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>334</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="5">
<item>
<widget class="QScrollArea" name="attachmentsScrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
@ -319,7 +366,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>84</width>
<width>827</width>
<height>24</height>
</rect>
</property>
@ -366,29 +413,6 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="0" column="2">
<spacer name="attachmentsHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>334</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="thumbNailCb">
<property name="toolTip">
<string>Allow channels to get frame for message thumbnail from movie media attachments or not</string>
</property>
<property name="text">
<string>Auto Thumbnail</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>