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)
|
RsFriendListModel::RsFriendListModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
, mDisplayGroups(true), mDisplayStatusString(true)
|
, mDisplayGroups(true), mDisplayStatusString(true), mDisplayStatusIcon (false)
|
||||||
, mLastInternalDataUpdate(0), mLastNodeUpdate(0)
|
, mLastInternalDataUpdate(0), mLastNodeUpdate(0)
|
||||||
{
|
{
|
||||||
mFilterStrings.clear();
|
mFilterStrings.clear();
|
||||||
@ -141,6 +141,24 @@ template<> bool RsFriendListModel::convertInternalIdToIndex<8>(quintptr ref,Entr
|
|||||||
return true;
|
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)
|
void RsFriendListModel::setDisplayStatusString(bool b)
|
||||||
{
|
{
|
||||||
@ -148,6 +166,12 @@ void RsFriendListModel::setDisplayStatusString(bool b)
|
|||||||
postMods();
|
postMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsFriendListModel::setDisplayStatusIcon(bool b)
|
||||||
|
{
|
||||||
|
mDisplayStatusIcon = b;
|
||||||
|
postMods();
|
||||||
|
}
|
||||||
|
|
||||||
void RsFriendListModel::setDisplayGroups(bool b)
|
void RsFriendListModel::setDisplayGroups(bool b)
|
||||||
{
|
{
|
||||||
mDisplayGroups = b;
|
mDisplayGroups = b;
|
||||||
@ -908,14 +932,23 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
|
|||||||
if(!isProfileExpanded(entry))
|
if(!isProfileExpanded(entry))
|
||||||
{
|
{
|
||||||
QPixmap sslAvatar = FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE);
|
QPixmap sslAvatar = FilesDefs::getPixmapFromQtResourcePath(AVATAR_DEFAULT_IMAGE);
|
||||||
|
QPixmap sslOverlayIcon;
|
||||||
|
sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(onlineRole(entry,col).toInt()));
|
||||||
|
|
||||||
|
|
||||||
const HierarchicalProfileInformation *hn = getProfileInfo(entry);
|
const HierarchicalProfileInformation *hn = getProfileInfo(entry);
|
||||||
|
|
||||||
for(uint32_t i=0;i<hn->child_node_indices.size();++i)
|
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(AvatarDefs::getAvatarFromSslId(RsPeerId(mLocations[hn->child_node_indices[i]].node_info.id.toStdString()), sslAvatar))
|
||||||
return QVariant(QIcon(sslAvatar));
|
if (mDisplayStatusIcon)
|
||||||
|
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||||
|
else
|
||||||
|
return QVariant(QIcon(sslAvatar));
|
||||||
|
|
||||||
return QVariant(QIcon(sslAvatar));
|
if (mDisplayStatusIcon)
|
||||||
|
return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon)));
|
||||||
|
else
|
||||||
|
return QVariant(QIcon(sslAvatar));
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -929,9 +962,14 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QPixmap sslAvatar;
|
QPixmap sslAvatar;
|
||||||
AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar);
|
QPixmap sslOverlayIcon;
|
||||||
|
sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry,col).toInt()));
|
||||||
|
|
||||||
return QVariant(QIcon(sslAvatar));
|
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();
|
default: return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,10 @@ public:
|
|||||||
|
|
||||||
void setDisplayStatusString(bool b);
|
void setDisplayStatusString(bool b);
|
||||||
bool getDisplayStatusString() const { return mDisplayStatusString; }
|
bool getDisplayStatusString() const { return mDisplayStatusString; }
|
||||||
|
void setDisplayStatusIcon(bool b);
|
||||||
|
bool getDisplayStatusIcon() const { return mDisplayStatusIcon; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EntryType getType(const QModelIndex&) const;
|
EntryType getType(const QModelIndex&) const;
|
||||||
|
|
||||||
@ -224,6 +228,7 @@ private:
|
|||||||
|
|
||||||
bool mDisplayGroups ;
|
bool mDisplayGroups ;
|
||||||
bool mDisplayStatusString ;
|
bool mDisplayStatusString ;
|
||||||
|
bool mDisplayStatusIcon ;
|
||||||
rstime_t mLastInternalDataUpdate;
|
rstime_t mLastInternalDataUpdate;
|
||||||
rstime_t mLastNodeUpdate;;
|
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->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
|
||||||
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(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->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)) );
|
||||||
connect(ui->actionExportFriendlist, SIGNAL(triggered()) , this, SLOT(exportFriendlistClicked()));
|
connect(ui->actionExportFriendlist, SIGNAL(triggered()) , this, SLOT(exportFriendlistClicked()));
|
||||||
connect(ui->actionImportFriendlist, SIGNAL(triggered()) , this, SLOT(importFriendlistClicked()));
|
connect(ui->actionImportFriendlist, SIGNAL(triggered()) , this, SLOT(importFriendlistClicked()));
|
||||||
@ -341,10 +342,12 @@ void NewFriendList::headerContextMenuRequested(QPoint /*p*/)
|
|||||||
|
|
||||||
displayMenu.addAction(ui->actionShowOfflineFriends);
|
displayMenu.addAction(ui->actionShowOfflineFriends);
|
||||||
displayMenu.addAction(ui->actionShowState);
|
displayMenu.addAction(ui->actionShowState);
|
||||||
|
displayMenu.addAction(ui->actionShowStateIcon);
|
||||||
displayMenu.addAction(ui->actionShowGroups);
|
displayMenu.addAction(ui->actionShowGroups);
|
||||||
|
|
||||||
ui->actionShowOfflineFriends->setChecked(mProxyModel->showOfflineNodes());
|
ui->actionShowOfflineFriends->setChecked(mProxyModel->showOfflineNodes());
|
||||||
ui->actionShowState->setChecked(mModel->getDisplayStatusString());
|
ui->actionShowState->setChecked(mModel->getDisplayStatusString());
|
||||||
|
ui->actionShowStateIcon->setChecked(mModel->getDisplayStatusIcon());
|
||||||
ui->actionShowGroups->setChecked(mModel->getDisplayGroups());
|
ui->actionShowGroups->setChecked(mModel->getDisplayGroups());
|
||||||
|
|
||||||
QHeaderView *header = ui->peerTreeWidget->header();
|
QHeaderView *header = ui->peerTreeWidget->header();
|
||||||
@ -505,6 +508,8 @@ void NewFriendList::processSettings(bool load)
|
|||||||
|
|
||||||
mModel->setDisplayStatusString(Settings->value("showState", mModel->getDisplayStatusString()).toBool());
|
mModel->setDisplayStatusString(Settings->value("showState", mModel->getDisplayStatusString()).toBool());
|
||||||
mModel->setDisplayGroups(Settings->value("showGroups", mModel->getDisplayGroups()).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_IP,Settings->value("showIP", isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP)).toBool());
|
||||||
setColumnVisible(RsFriendListModel::COLUMN_THREAD_ID,Settings->value("showID", isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID)).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("hideUnconnected", !mProxyModel->showOfflineNodes());
|
||||||
Settings->setValue("showState", mModel->getDisplayStatusString());
|
Settings->setValue("showState", mModel->getDisplayStatusString());
|
||||||
Settings->setValue("showGroups", mModel->getDisplayGroups());
|
Settings->setValue("showGroups", mModel->getDisplayGroups());
|
||||||
|
Settings->setValue("showStateIcon", mModel->getDisplayStatusIcon());
|
||||||
|
|
||||||
|
|
||||||
Settings->setValue("showIP",isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP));
|
Settings->setValue("showIP",isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP));
|
||||||
Settings->setValue("showID",isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID));
|
Settings->setValue("showID",isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID));
|
||||||
@ -1643,6 +1650,12 @@ void NewFriendList::setShowState(bool show)
|
|||||||
processSettings(false);
|
processSettings(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewFriendList::setShowStateIcon(bool show)
|
||||||
|
{
|
||||||
|
applyWhileKeepingTree([show,this]() { mModel->setDisplayStatusIcon(show) ; });
|
||||||
|
processSettings(false);
|
||||||
|
}
|
||||||
|
|
||||||
void NewFriendList::setShowGroups(bool show)
|
void NewFriendList::setShowGroups(bool show)
|
||||||
{
|
{
|
||||||
applyWhileKeepingTree([show,this]() { mModel->setDisplayGroups(show) ; });
|
applyWhileKeepingTree([show,this]() { mModel->setDisplayGroups(show) ; });
|
||||||
|
@ -87,6 +87,7 @@ public slots:
|
|||||||
void setShowGroups(bool show);
|
void setShowGroups(bool show);
|
||||||
void setShowUnconnected(bool hidden);
|
void setShowUnconnected(bool hidden);
|
||||||
void setShowState(bool show);
|
void setShowState(bool show);
|
||||||
|
void setShowStateIcon(bool show);
|
||||||
void headerContextMenuRequested(QPoint);
|
void headerContextMenuRequested(QPoint);
|
||||||
void exportFriendlistClicked();
|
void exportFriendlistClicked();
|
||||||
|
|
||||||
|
@ -124,6 +124,14 @@
|
|||||||
<string>import your friendlist including groups</string>
|
<string>import your friendlist including groups</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionShowStateIcon">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Show status icon</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
Loading…
Reference in New Issue
Block a user