mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed display of share flags as a proper nice icon set
This commit is contained in:
parent
8fe85b9bdd
commit
3430eece22
@ -30,6 +30,7 @@
|
||||
#include <gui/common/RsUrlHandler.h>
|
||||
#include <gui/common/FilesDefs.h>
|
||||
#include <gui/common/GroupDefs.h>
|
||||
#include <gui/gxs/GxsIdDetails.h>
|
||||
#include "RemoteDirModel.h"
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
@ -270,8 +271,55 @@ QString RetroshareDirModel::getAgeIndicatorString(const DirDetails &details) con
|
||||
return ret;
|
||||
}
|
||||
|
||||
const QIcon& RetroshareDirModel::getFlagsIcon(FileStorageFlags flags)
|
||||
{
|
||||
static QIcon *static_icons[8] = {NULL};
|
||||
|
||||
int n=0;
|
||||
if(flags & DIR_FLAGS_ANONYMOUS_DOWNLOAD) n += 1 ;
|
||||
if(flags & DIR_FLAGS_ANONYMOUS_SEARCH ) n += 2 ;
|
||||
if(flags & DIR_FLAGS_BROWSABLE ) n += 4 ;
|
||||
n-= 1;
|
||||
|
||||
if(static_icons[n] == NULL)
|
||||
{
|
||||
QList<QIcon> icons ;
|
||||
|
||||
if(flags & DIR_FLAGS_ANONYMOUS_SEARCH)
|
||||
icons.push_back(QIcon(":icons/search_red_128.png")) ;
|
||||
else
|
||||
icons.push_back(QIcon(":icons/void_128.png")) ;
|
||||
|
||||
if(flags & DIR_FLAGS_ANONYMOUS_DOWNLOAD)
|
||||
icons.push_back(QIcon(":icons/anonymous_blue_128.png")) ;
|
||||
else
|
||||
icons.push_back(QIcon(":icons/void_128.png")) ;
|
||||
|
||||
if(flags & DIR_FLAGS_BROWSABLE)
|
||||
icons.push_back(QIcon(":icons/browsable_green_128.png")) ;
|
||||
else
|
||||
icons.push_back(QIcon(":icons/void_128.png")) ;
|
||||
|
||||
QPixmap pix ;
|
||||
GxsIdDetails::GenerateCombinedPixmap(pix, icons, 128);
|
||||
|
||||
static_icons[n] = new QIcon(pix);
|
||||
|
||||
std::cerr << "Generated icon for flags " << std::hex << flags << std::endl;
|
||||
}
|
||||
return *static_icons[n] ;
|
||||
}
|
||||
|
||||
QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
if(coln == 3)
|
||||
{
|
||||
if(details.type == DIR_TYPE_PERSON) return QVariant() ;
|
||||
|
||||
return getFlagsIcon(details.flags) ;
|
||||
}
|
||||
|
||||
|
||||
if(coln > 0)
|
||||
return QVariant() ;
|
||||
|
||||
@ -351,7 +399,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
case 2:
|
||||
return misc::userFriendlyDuration(details.min_age);
|
||||
case 3:
|
||||
return getFlagsString(details.flags);
|
||||
return getFlagsIcon(details.flags);//getFlagsString(details.flags);
|
||||
// case 4:
|
||||
// {
|
||||
// QString ind("");
|
||||
@ -382,7 +430,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
case 2:
|
||||
return misc::userFriendlyDuration(details.min_age);
|
||||
case 3:
|
||||
return getFlagsString(details.flags);
|
||||
return QVariant();//getFlagsString(details.flags);
|
||||
case 4:
|
||||
return getGroupsString(details.parent_groups) ;
|
||||
|
||||
|
@ -97,6 +97,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
||||
static QString getGroupsString(const std::list<RsNodeGroupId> &) ;
|
||||
QString getAgeIndicatorString(const DirDetails &) const;
|
||||
// void getAgeIndicatorRec(const DirDetails &details, QString &ret) const;
|
||||
static const QIcon& getFlagsIcon(FileStorageFlags flags) ;
|
||||
|
||||
virtual QVariant displayRole(const DirDetails&,int) const = 0 ;
|
||||
virtual QVariant sortRole(const QModelIndex&,const DirDetails&,int) const =0;
|
||||
|
@ -62,7 +62,6 @@ ShareManager::ShareManager()
|
||||
ui.headerFrame->setHeaderText(tr("Share Manager"));
|
||||
|
||||
isLoading = false;
|
||||
load();
|
||||
|
||||
Settings->loadWidgetInformation(this);
|
||||
|
||||
@ -80,13 +79,12 @@ ShareManager::ShareManager()
|
||||
QHeaderView* header = ui.shareddirList->horizontalHeader();
|
||||
QHeaderView_setSectionResizeModeColumn(header, COLUMN_PATH, QHeaderView::Stretch);
|
||||
|
||||
// header->setResizeMode(COLUMN_NETWORKWIDE, QHeaderView::ResizeToContents);
|
||||
// header->setResizeMode(COLUMN_BROWSABLE, QHeaderView::ResizeToContents);
|
||||
|
||||
header->setHighlightSections(false);
|
||||
|
||||
setAcceptDrops(true);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
void ShareManager::doubleClickedCell(int row,int column)
|
||||
@ -240,20 +238,11 @@ void ShareManager::showYourself()
|
||||
|
||||
void ShareManager::updateFlags()
|
||||
{
|
||||
if(isLoading)
|
||||
return ;
|
||||
|
||||
isLoading = true ; // stops GUI update. Otherwise each call to rsFiles->updateShareFlags() modifies the GUI that we count on to check
|
||||
// what has changed => fail!
|
||||
|
||||
for(int row=0;row<ui.shareddirList->rowCount();++row)
|
||||
{
|
||||
FileStorageFlags flags = (dynamic_cast<GroupFlagsWidget*>(ui.shareddirList->cellWidget(row,COLUMN_SHARE_FLAGS)))->flags() ;
|
||||
|
||||
mDirInfos[row].shareflags = flags ;
|
||||
}
|
||||
|
||||
isLoading = false ; // re-enable GUI load
|
||||
load() ; // update the GUI.
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,10 @@
|
||||
#include <QTreeView>
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QProcess>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
#include "SharedFilesDialog.h"
|
||||
#include "settings/AddFileAssociationDialog.h"
|
||||
@ -114,6 +116,36 @@ private:
|
||||
RetroshareDirModel *m_dirModel;
|
||||
};
|
||||
|
||||
// This class allows to draw the item in the share flags column using an appropriate size
|
||||
|
||||
class ShareFlagsItemDelegate: public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
ShareFlagsItemDelegate() {}
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
Q_ASSERT(index.isValid());
|
||||
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
// disable default icon
|
||||
opt.icon = QIcon();
|
||||
// draw default item
|
||||
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0);
|
||||
|
||||
const QRect r = option.rect;
|
||||
|
||||
// get pixmap
|
||||
QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
|
||||
QPixmap pix = icon.pixmap(r.size());
|
||||
|
||||
// draw pixmap at center of item
|
||||
const QPoint p = QPoint((r.width() - pix.width())/2, (r.height() - pix.height())/2);
|
||||
painter->drawPixmap(r.topLeft() + p, pix);
|
||||
}
|
||||
};
|
||||
|
||||
/** Constructor */
|
||||
SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareDirModel *_flat_model,QWidget *parent)
|
||||
: RsAutoUpdatePage(1000,parent),model(NULL)
|
||||
@ -220,7 +252,9 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
||||
editshareAct = new QAction(QIcon(IMAGE_EDITSHARE), tr("Edit Share Permissions"), this) ;
|
||||
connect(editshareAct, SIGNAL(triggered()), this, SLOT(editSharePermissions())) ;
|
||||
|
||||
ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES)) ;
|
||||
ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES)) ;
|
||||
|
||||
ui.dirTreeView->setItemDelegateForColumn(COLUMN_FRIEND,new ShareFlagsItemDelegate()) ;
|
||||
}
|
||||
|
||||
RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent)
|
||||
|
@ -29,6 +29,7 @@
|
||||
<file>icons/avatar_128.png</file>
|
||||
<file>icons/avatar_grey_128.png</file>
|
||||
<file>icons/blank_red_128.png</file>
|
||||
<file>icons/void_128.png</file>
|
||||
<file>icons/blank_green_128.png</file>
|
||||
<file>icons/blank_blue_128.png</file>
|
||||
<file>icons/browsable_green_128.png</file>
|
||||
|
BIN
retroshare-gui/src/gui/icons/void_128.png
Normal file
BIN
retroshare-gui/src/gui/icons/void_128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Loading…
Reference in New Issue
Block a user