mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 02:50:07 -05:00
added DL menu entry
This commit is contained in:
parent
03ac2eb53c
commit
503aa9929f
@ -75,6 +75,7 @@ static const int CHANNEL_TABS_FILES = 2;
|
|||||||
#define STAR_OVERLAY_IMAGE ":icons/star_overlay_128.png"
|
#define STAR_OVERLAY_IMAGE ":icons/star_overlay_128.png"
|
||||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||||
#define IMAGE_GRID_VIEW ":icons/png/menu.png"
|
#define IMAGE_GRID_VIEW ":icons/png/menu.png"
|
||||||
|
#define IMAGE_DOWNLOAD ":icons/png/download.png"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ChannelPostFileInfo)
|
Q_DECLARE_METATYPE(ChannelPostFileInfo)
|
||||||
|
|
||||||
@ -99,6 +100,11 @@ void ChannelPostDelegate::zoom(bool zoom_or_unzoom)
|
|||||||
else
|
else
|
||||||
mZoom /= 1.02;
|
mZoom /= 1.02;
|
||||||
|
|
||||||
|
if(mZoom < 0.5)
|
||||||
|
mZoom = 0.5;
|
||||||
|
if(mZoom > 2.0)
|
||||||
|
mZoom = 2.0;
|
||||||
|
|
||||||
std::cerr << "zoom factor: " << mZoom << std::endl;
|
std::cerr << "zoom factor: " << mZoom << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +121,8 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||||||
|
|
||||||
if(mUseGrid || index.column()==0)
|
if(mUseGrid || index.column()==0)
|
||||||
{
|
{
|
||||||
|
// Draw a thumnail
|
||||||
|
|
||||||
uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0;
|
uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0;
|
||||||
ChannelPostThumbnailView w(post,flags);
|
ChannelPostThumbnailView w(post,flags);
|
||||||
|
|
||||||
@ -136,7 +144,11 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||||||
{
|
{
|
||||||
QPainter p(&pixmap);
|
QPainter p(&pixmap);
|
||||||
QFontMetricsF fm(option.font);
|
QFontMetricsF fm(option.font);
|
||||||
|
|
||||||
|
if(mUseGrid)
|
||||||
p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
||||||
|
else
|
||||||
|
p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.5*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +174,10 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||||||
painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::fromUtf8(post.mMeta.mMsgName.c_str()));
|
painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::fromUtf8(post.mMeta.mMsgName.c_str()));
|
||||||
y += font_height;
|
y += font_height;
|
||||||
|
|
||||||
painter->drawText(QPoint(p.x()+0.5*font_height,y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString());
|
painter->drawText(QPoint(p.x()+0.5*font_height,y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString(Qt::DefaultLocaleShortDate));
|
||||||
|
y += font_height;
|
||||||
|
|
||||||
|
painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::number(post.mCount)+ " " +((post.mCount>1)?tr("files"):tr("file")) + " (" + QString::number(post.mSize) + " " + tr("bytes") + ")" );
|
||||||
y += font_height;
|
y += font_height;
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
@ -418,6 +433,16 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&)
|
|||||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GRID_VIEW), tr("Switch to grid view"), this, SLOT(switchView()));
|
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GRID_VIEW), tr("Switch to grid view"), this, SLOT(switchView()));
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
|
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||||
|
|
||||||
|
if(index.isValid())
|
||||||
|
{
|
||||||
|
RsGxsChannelPost post = index.data(Qt::UserRole).value<RsGxsChannelPost>() ;
|
||||||
|
|
||||||
|
if(!post.mFiles.empty())
|
||||||
|
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOAD), tr("Download files"), this, SLOT(download()));
|
||||||
|
}
|
||||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()));
|
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()));
|
||||||
|
|
||||||
if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags))
|
if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags))
|
||||||
@ -478,6 +503,30 @@ void GxsChannelPostsWidgetWithModel::copyMessageLink()
|
|||||||
QMessageBox::critical(NULL,tr("Link creation error"),tr("Link could not be created: ")+e.what());
|
QMessageBox::critical(NULL,tr("Link creation error"),tr("Link could not be created: ")+e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void GxsChannelPostsWidgetWithModel::download()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||||
|
RsGxsChannelPost post = index.data(Qt::UserRole).value<RsGxsChannelPost>() ;
|
||||||
|
|
||||||
|
std::string destination;
|
||||||
|
rsGxsChannels->getChannelDownloadDirectory(mGroup.mMeta.mGroupId,destination);
|
||||||
|
|
||||||
|
for(auto file:post.mFiles)
|
||||||
|
{
|
||||||
|
std::list<RsPeerId> sources;
|
||||||
|
std::string destination;
|
||||||
|
|
||||||
|
// Add possible direct sources.
|
||||||
|
FileInfo fileInfo;
|
||||||
|
rsFiles->FileDetails(file.mHash, RS_FILE_HINTS_REMOTE, fileInfo);
|
||||||
|
|
||||||
|
for(std::vector<TransferInfo>::const_iterator it = fileInfo.peers.begin(); it != fileInfo.peers.end(); ++it) {
|
||||||
|
sources.push_back((*it).peerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
rsFiles->FileRequest(file.mName, file.mHash, file.mSize, destination, RS_FILE_REQ_ANONYMOUS_ROUTING, sources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidgetWithModel::editPost()
|
void GxsChannelPostsWidgetWithModel::editPost()
|
||||||
{
|
{
|
||||||
|
@ -138,6 +138,7 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void showPostDetails();
|
void showPostDetails();
|
||||||
void updateGroupData();
|
void updateGroupData();
|
||||||
|
void download();
|
||||||
void createMsg();
|
void createMsg();
|
||||||
void toggleAutoDownload();
|
void toggleAutoDownload();
|
||||||
void subscribeGroup(bool subscribe);
|
void subscribeGroup(bool subscribe);
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
<string>Add new post</string>
|
<string>Add new post</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../icons.qrc">
|
<iconset>
|
||||||
<normaloff>:/icons/png/add.png</normaloff>:/icons/png/add.png</iconset>
|
<normaloff>:/icons/png/add.png</normaloff>:/icons/png/add.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -594,8 +594,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
<header>gui/common/LineEditClear.h</header>
|
<header>gui/common/LineEditClear.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources/>
|
||||||
<include location="../icons.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user