mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added optional display status icon from friendslist context menu
This commit is contained in:
parent
3461da7c3a
commit
56b6b0cb5a
@ -65,7 +65,7 @@ static const uint32_t NODE_DETAILS_UPDATE_DELAY = 5; // update each node every 5
|
||||
|
||||
RsFriendListModel::RsFriendListModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, mDisplayGroups(true), mDisplayStatusString(true)
|
||||
, mDisplayGroups(true), mDisplayStatusString(true), mDisplayStatusIcon (false)
|
||||
, mLastInternalDataUpdate(0), mLastNodeUpdate(0)
|
||||
{
|
||||
mFilterStrings.clear();
|
||||
@ -141,6 +141,24 @@ template<> bool RsFriendListModel::convertInternalIdToIndex<8>(quintptr ref,Entr
|
||||
return true;
|
||||
}
|
||||
|
||||
static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay)
|
||||
{
|
||||
int avatarWidth = avatar.width();
|
||||
int avatarHeight = avatar.height();
|
||||
|
||||
QPixmap pixmap(avatar);
|
||||
|
||||
int overlaySize = (avatarWidth > avatarHeight) ? (avatarWidth/2.5) : (avatarHeight/2.5);
|
||||
int overlayX = avatarWidth - overlaySize;
|
||||
int overlayY = avatarHeight - overlaySize;
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.drawPixmap(overlayX, overlayY, overlaySize, overlaySize, overlay);
|
||||
|
||||
QIcon icon;
|
||||
icon.addPixmap(pixmap);
|
||||
return icon;
|
||||
}
|
||||
|
||||
void RsFriendListModel::setDisplayStatusString(bool b)
|
||||
{
|
||||
@ -148,6 +166,12 @@ void RsFriendListModel::setDisplayStatusString(bool b)
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsFriendListModel::setDisplayStatusIcon(bool b)
|
||||
{
|
||||
mDisplayStatusIcon = b;
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsFriendListModel::setDisplayGroups(bool b)
|
||||
{
|
||||
mDisplayGroups = b;
|
||||
@ -908,13 +932,22 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
|
||||
if(!isProfileExpanded(entry))
|
||||
{
|
||||
QPixmap sslAvatar = FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE);
|
||||
QPixmap sslOverlayIcon;
|
||||
sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(onlineRole(entry,col).toInt()));
|
||||
|
||||
|
||||
const HierarchicalProfileInformation *hn = getProfileInfo(entry);
|
||||
|
||||
for(uint32_t i=0;i<hn->child_node_indices.size();++i)
|
||||
if(AvatarDefs::getAvatarFromSslId(RsPeerId(mLocations[hn->child_node_indices[i]].node_info.id.toStdString()), sslAvatar))
|
||||
if (mDisplayStatusIcon)
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
else
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
|
||||
if (mDisplayStatusIcon)
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
else
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
}
|
||||
|
||||
@ -929,8 +962,13 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
|
||||
return QVariant();
|
||||
|
||||
QPixmap sslAvatar;
|
||||
AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar);
|
||||
QPixmap sslOverlayIcon;
|
||||
sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry,col).toInt()));
|
||||
|
||||
AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar);
|
||||
if (mDisplayStatusIcon)
|
||||
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||
else
|
||||
return QVariant(QIcon(sslAvatar));
|
||||
}
|
||||
default: return QVariant();
|
||||
|
@ -129,6 +129,10 @@ public:
|
||||
|
||||
void setDisplayStatusString(bool b);
|
||||
bool getDisplayStatusString() const { return mDisplayStatusString; }
|
||||
void setDisplayStatusIcon(bool b);
|
||||
bool getDisplayStatusIcon() const { return mDisplayStatusIcon; }
|
||||
|
||||
|
||||
|
||||
EntryType getType(const QModelIndex&) const;
|
||||
|
||||
@ -224,6 +228,7 @@ private:
|
||||
|
||||
bool mDisplayGroups ;
|
||||
bool mDisplayStatusString ;
|
||||
bool mDisplayStatusIcon ;
|
||||
rstime_t mLastInternalDataUpdate;
|
||||
rstime_t mLastNodeUpdate;;
|
||||
|
||||
|
@ -261,6 +261,7 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
|
||||
|
||||
connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
|
||||
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) );
|
||||
connect(ui->actionShowStateIcon, SIGNAL(triggered(bool)), this, SLOT(setShowStateIcon(bool)) );
|
||||
connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)) );
|
||||
connect(ui->actionExportFriendlist, SIGNAL(triggered()) , this, SLOT(exportFriendlistClicked()));
|
||||
connect(ui->actionImportFriendlist, SIGNAL(triggered()) , this, SLOT(importFriendlistClicked()));
|
||||
@ -341,10 +342,12 @@ void NewFriendList::headerContextMenuRequested(QPoint /*p*/)
|
||||
|
||||
displayMenu.addAction(ui->actionShowOfflineFriends);
|
||||
displayMenu.addAction(ui->actionShowState);
|
||||
displayMenu.addAction(ui->actionShowStateIcon);
|
||||
displayMenu.addAction(ui->actionShowGroups);
|
||||
|
||||
ui->actionShowOfflineFriends->setChecked(mProxyModel->showOfflineNodes());
|
||||
ui->actionShowState->setChecked(mModel->getDisplayStatusString());
|
||||
ui->actionShowStateIcon->setChecked(mModel->getDisplayStatusIcon());
|
||||
ui->actionShowGroups->setChecked(mModel->getDisplayGroups());
|
||||
|
||||
QHeaderView *header = ui->peerTreeWidget->header();
|
||||
@ -505,6 +508,8 @@ void NewFriendList::processSettings(bool load)
|
||||
|
||||
mModel->setDisplayStatusString(Settings->value("showState", mModel->getDisplayStatusString()).toBool());
|
||||
mModel->setDisplayGroups(Settings->value("showGroups", mModel->getDisplayGroups()).toBool());
|
||||
mModel->setDisplayStatusIcon(Settings->value("showStateIcon", mModel->getDisplayStatusIcon()).toBool());
|
||||
|
||||
|
||||
setColumnVisible(RsFriendListModel::COLUMN_THREAD_IP,Settings->value("showIP", isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP)).toBool());
|
||||
setColumnVisible(RsFriendListModel::COLUMN_THREAD_ID,Settings->value("showID", isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID)).toBool());
|
||||
@ -528,6 +533,8 @@ void NewFriendList::processSettings(bool load)
|
||||
Settings->setValue("hideUnconnected", !mProxyModel->showOfflineNodes());
|
||||
Settings->setValue("showState", mModel->getDisplayStatusString());
|
||||
Settings->setValue("showGroups", mModel->getDisplayGroups());
|
||||
Settings->setValue("showStateIcon", mModel->getDisplayStatusIcon());
|
||||
|
||||
|
||||
Settings->setValue("showIP",isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP));
|
||||
Settings->setValue("showID",isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID));
|
||||
@ -1643,6 +1650,12 @@ void NewFriendList::setShowState(bool show)
|
||||
processSettings(false);
|
||||
}
|
||||
|
||||
void NewFriendList::setShowStateIcon(bool show)
|
||||
{
|
||||
applyWhileKeepingTree([show,this]() { mModel->setDisplayStatusIcon(show) ; });
|
||||
processSettings(false);
|
||||
}
|
||||
|
||||
void NewFriendList::setShowGroups(bool show)
|
||||
{
|
||||
applyWhileKeepingTree([show,this]() { mModel->setDisplayGroups(show) ; });
|
||||
|
@ -87,6 +87,7 @@ public slots:
|
||||
void setShowGroups(bool show);
|
||||
void setShowUnconnected(bool hidden);
|
||||
void setShowState(bool show);
|
||||
void setShowStateIcon(bool show);
|
||||
void headerContextMenuRequested(QPoint);
|
||||
void exportFriendlistClicked();
|
||||
|
||||
|
@ -124,6 +124,14 @@
|
||||
<string>import your friendlist including groups</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowStateIcon">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show status icon</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user