mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 15:39:36 -05:00
Merge pull request #1943 from PhenomRetroShare/Fix_RsElidedItemDelegateStyleSheet
Fix RSElidedItemDelegate to use StyleSheet as default but defined colors
This commit is contained in:
commit
fd6b69bcac
@ -452,7 +452,7 @@ void FeedReaderDialog::calculateFeedItem(QTreeWidgetItem *item, uint32_t &unread
|
|||||||
font.setBold(unreadCountItem != 0);
|
font.setBold(unreadCountItem != 0);
|
||||||
item->setFont(i, font);
|
item->setFont(i, font);
|
||||||
|
|
||||||
item->setTextColor(COLUMN_FEED_NAME, deactivated ? colorDeactivated : colorActivated);
|
item->setData(COLUMN_FEED_NAME, Qt::ForegroundRole, deactivated ? colorDeactivated : colorActivated);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon icon = item->data(COLUMN_FEED_DATA, ROLE_FEED_ICON).value<QIcon>();
|
QIcon icon = item->data(COLUMN_FEED_DATA, ROLE_FEED_ICON).value<QIcon>();
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "chat/ChatTabWidget.h"
|
#include "chat/ChatTabWidget.h"
|
||||||
#include "chat/CreateLobbyDialog.h"
|
#include "chat/CreateLobbyDialog.h"
|
||||||
#include "common/RSTreeWidgetItem.h"
|
#include "common/RSTreeWidgetItem.h"
|
||||||
|
#include "common/RSElidedItemDelegate.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "gui/Identity/IdEditDialog.h"
|
#include "gui/Identity/IdEditDialog.h"
|
||||||
@ -157,6 +158,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
|
|||||||
ui.lobbyTreeWidget->setColumnHidden(COLUMN_USER_COUNT,true) ;
|
ui.lobbyTreeWidget->setColumnHidden(COLUMN_USER_COUNT,true) ;
|
||||||
ui.lobbyTreeWidget->setColumnHidden(COLUMN_TOPIC,true) ;
|
ui.lobbyTreeWidget->setColumnHidden(COLUMN_TOPIC,true) ;
|
||||||
ui.lobbyTreeWidget->setSortingEnabled(true) ;
|
ui.lobbyTreeWidget->setSortingEnabled(true) ;
|
||||||
|
ui.lobbyTreeWidget->setItemDelegateForColumn(COLUMN_NAME, new RSElidedItemDelegate());
|
||||||
|
|
||||||
float fact = QFontMetricsF(font()).height()/14.0f;
|
float fact = QFontMetricsF(font()).height()/14.0f;
|
||||||
|
|
||||||
@ -386,6 +388,8 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
|
|||||||
item->setData(COLUMN_DATA, ROLE_FLAGS, lobby_flags.toUInt32());
|
item->setData(COLUMN_DATA, ROLE_FLAGS, lobby_flags.toUInt32());
|
||||||
item->setData(COLUMN_DATA, ROLE_AUTOSUBSCRIBE, autoSubscribe);
|
item->setData(COLUMN_DATA, ROLE_AUTOSUBSCRIBE, autoSubscribe);
|
||||||
|
|
||||||
|
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||||
|
// As palette is not updated by stylesheet
|
||||||
QColor color = treeWidget->palette().color(QPalette::Active, QPalette::Text);
|
QColor color = treeWidget->palette().color(QPalette::Active, QPalette::Text);
|
||||||
|
|
||||||
if (!subscribed) {
|
if (!subscribed) {
|
||||||
@ -395,7 +399,7 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int column = 0; column < COLUMN_COUNT; ++column) {
|
for (int column = 0; column < COLUMN_COUNT; ++column) {
|
||||||
item->setTextColor(column, color);
|
item->setData(column, Qt::ForegroundRole, color);
|
||||||
}
|
}
|
||||||
QString tooltipstr = QObject::tr("Subject:")+" "+item->text(COLUMN_TOPIC)+"\n"
|
QString tooltipstr = QObject::tr("Subject:")+" "+item->text(COLUMN_TOPIC)+"\n"
|
||||||
+QObject::tr("Participants:")+" "+QString::number(count)+"\n"
|
+QObject::tr("Participants:")+" "+QString::number(count)+"\n"
|
||||||
@ -407,7 +411,7 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
|
|||||||
tooltipstr += QObject::tr("\nSecurity: no anonymous IDs") ;
|
tooltipstr += QObject::tr("\nSecurity: no anonymous IDs") ;
|
||||||
QColor foreground = QColor(0, 128, 0); // green
|
QColor foreground = QColor(0, 128, 0); // green
|
||||||
for (int column = 0; column < COLUMN_COUNT; ++column)
|
for (int column = 0; column < COLUMN_COUNT; ++column)
|
||||||
item->setTextColor(column, foreground);
|
item->setData(column, Qt::ForegroundRole, foreground);
|
||||||
}
|
}
|
||||||
item->setToolTip(0,tooltipstr) ;
|
item->setToolTip(0,tooltipstr) ;
|
||||||
}
|
}
|
||||||
|
@ -415,9 +415,8 @@ void SearchDialog::download()
|
|||||||
std::cout << *it << "-" << std::endl;
|
std::cout << *it << "-" << std::endl;
|
||||||
|
|
||||||
QColor foreground = textColorDownloading();
|
QColor foreground = textColorDownloading();
|
||||||
QBrush brush(foreground);
|
|
||||||
for (int i = 0; i < item->columnCount(); ++i)
|
for (int i = 0; i < item->columnCount(); ++i)
|
||||||
item->setForeground(i, brush);
|
item->setData(i, Qt::ForegroundRole, foreground );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1269,10 +1268,9 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
|||||||
foreground = textColorHighSources();
|
foreground = textColorHighSources();
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush brush(foreground);
|
|
||||||
for (int i = 0; i < item->columnCount(); ++i)
|
for (int i = 0; i < item->columnCount(); ++i)
|
||||||
{
|
{
|
||||||
item->setForeground(i, brush);
|
item->setData(i, Qt::ForegroundRole, foreground);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1355,10 +1353,9 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setForeground) {
|
if (setForeground) {
|
||||||
QBrush brush(foreground);
|
|
||||||
for (int i = 0; i < item->columnCount(); ++i)
|
for (int i = 0; i < item->columnCount(); ++i)
|
||||||
{
|
{
|
||||||
item->setForeground(i, brush);
|
item->setData(i, Qt::ForegroundRole, foreground);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,17 +1388,18 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
|||||||
|
|
||||||
if(isBanned)
|
if(isBanned)
|
||||||
{
|
{
|
||||||
item->setForeground(RSID_COL_NICKNAME,QBrush(Qt::red));
|
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||||
item->setForeground(RSID_COL_KEYID,QBrush(Qt::red));
|
item->setData(RSID_COL_NICKNAME, Qt::ForegroundRole, QColor(Qt::red));
|
||||||
item->setForeground(RSID_COL_IDTYPE,QBrush(Qt::red));
|
item->setData(RSID_COL_KEYID , Qt::ForegroundRole, QColor(Qt::red));
|
||||||
item->setForeground(RSID_COL_VOTES,QBrush(Qt::red));
|
item->setData(RSID_COL_IDTYPE , Qt::ForegroundRole, QColor(Qt::red));
|
||||||
|
item->setData(RSID_COL_VOTES , Qt::ForegroundRole, QColor(Qt::red));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item->setForeground(RSID_COL_NICKNAME,QBrush(Qt::black));
|
item->setData(RSID_COL_NICKNAME, Qt::ForegroundRole, QVariant());
|
||||||
item->setForeground(RSID_COL_KEYID,QBrush(Qt::black));
|
item->setData(RSID_COL_KEYID , Qt::ForegroundRole, QVariant());
|
||||||
item->setForeground(RSID_COL_IDTYPE,QBrush(Qt::black));
|
item->setData(RSID_COL_IDTYPE , Qt::ForegroundRole, QVariant());
|
||||||
item->setForeground(RSID_COL_VOTES,QBrush(Qt::black));
|
item->setData(RSID_COL_VOTES , Qt::ForegroundRole, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
||||||
@ -1423,9 +1424,10 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
|||||||
|
|
||||||
if(idd.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED)
|
if(idd.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED)
|
||||||
{
|
{
|
||||||
item->setForeground(RSID_COL_NICKNAME,QBrush(Qt::red));
|
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||||
item->setForeground(RSID_COL_KEYID,QBrush(Qt::red));
|
item->setData(RSID_COL_NICKNAME, Qt::ForegroundRole, QColor(Qt::red));
|
||||||
item->setForeground(RSID_COL_IDTYPE,QBrush(Qt::red));
|
item->setData(RSID_COL_KEYID , Qt::ForegroundRole, QColor(Qt::red));
|
||||||
|
item->setData(RSID_COL_IDTYPE , Qt::ForegroundRole, QColor(Qt::red));
|
||||||
|
|
||||||
tooltip += tr("\nThis identity has a unsecure fingerprint (It's probably quite old).\nYou should get rid of it now and use a new one.\nThese identities will soon be not supported anymore.") ;
|
tooltip += tr("\nThis identity has a unsecure fingerprint (It's probably quite old).\nYou should get rid of it now and use a new one.\nThese identities will soon be not supported anymore.") ;
|
||||||
}
|
}
|
||||||
|
@ -250,19 +250,21 @@ void ShareManager::load()
|
|||||||
|
|
||||||
listWidget->item(row,COLUMN_GROUPS)->setText(getGroupString(mDirInfos[row].parent_groups));
|
listWidget->item(row,COLUMN_GROUPS)->setText(getGroupString(mDirInfos[row].parent_groups));
|
||||||
|
|
||||||
|
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||||
|
// As palette is not updated by stylesheet
|
||||||
QFont font = listWidget->item(row,COLUMN_GROUPS)->font();
|
QFont font = listWidget->item(row,COLUMN_GROUPS)->font();
|
||||||
font.setBold(mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE) ;
|
font.setBold(mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE) ;
|
||||||
listWidget->item(row,COLUMN_GROUPS)->setTextColor( (mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE)? (Qt::black):(Qt::lightGray)) ;
|
listWidget->item(row,COLUMN_GROUPS)->setData(Qt::ForegroundRole, QColor((mDirInfos[row].shareflags & DIR_FLAGS_BROWSABLE) ? (Qt::black):(Qt::lightGray)) );
|
||||||
listWidget->item(row,COLUMN_GROUPS)->setFont(font);
|
listWidget->item(row,COLUMN_GROUPS)->setFont(font);
|
||||||
|
|
||||||
if(QDir(QString::fromUtf8(mDirInfos[row].filename.c_str())).exists())
|
if(QDir(QString::fromUtf8(mDirInfos[row].filename.c_str())).exists())
|
||||||
{
|
{
|
||||||
listWidget->item(row,COLUMN_PATH)->setTextColor(Qt::black);
|
listWidget->item(row,COLUMN_PATH)->setData(Qt::ForegroundRole, QColor(Qt::black));
|
||||||
listWidget->item(row,COLUMN_PATH)->setToolTip(tr("Double click to change shared directory path")) ;
|
listWidget->item(row,COLUMN_PATH)->setToolTip(tr("Double click to change shared directory path")) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
listWidget->item(row,COLUMN_PATH)->setTextColor(Qt::lightGray);
|
listWidget->item(row,COLUMN_PATH)->setData(Qt::ForegroundRole, QColor(Qt::lightGray));
|
||||||
listWidget->item(row,COLUMN_PATH)->setToolTip(tr("Directory does not exist! Double click to change shared directory path")) ;
|
listWidget->item(row,COLUMN_PATH)->setToolTip(tr("Directory does not exist! Double click to change shared directory path")) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,10 +616,12 @@ void ChatLobbyDialog::updateParticipantsList()
|
|||||||
else
|
else
|
||||||
widgetitem = dynamic_cast<GxsIdRSTreeWidgetItem*>(qlFoundParticipants.at(0));
|
widgetitem = dynamic_cast<GxsIdRSTreeWidgetItem*>(qlFoundParticipants.at(0));
|
||||||
|
|
||||||
|
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||||
|
// As palette is not updated by stylesheet
|
||||||
if (isParticipantMuted(it2->first)) {
|
if (isParticipantMuted(it2->first)) {
|
||||||
widgetitem->setTextColor(COLUMN_NAME,QColor(255,0,0));
|
widgetitem->setData(COLUMN_NAME, Qt::ForegroundRole, QColor(255,0,0));
|
||||||
} else {
|
} else {
|
||||||
widgetitem->setTextColor(COLUMN_NAME,ui.participantsList->palette().color(QPalette::Active, QPalette::Text));
|
widgetitem->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt();
|
time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt();
|
||||||
|
@ -239,7 +239,10 @@ bool ElidedLabel::paintElidedLine( QPainter* painter, QString plainText
|
|||||||
*rectElision = mRectElision;
|
*rectElision = mRectElision;
|
||||||
|
|
||||||
if(drawRoundedRect)
|
if(drawRoundedRect)
|
||||||
if (painter) painter->drawRoundedRect(mRectElision, 2 , 2);
|
if (painter) {
|
||||||
|
painter->setBrush(QBrush(Qt::transparent));
|
||||||
|
painter->drawRoundedRect(mRectElision, 2 , 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (painter) painter->restore();
|
if (painter) painter->restore();
|
||||||
|
@ -717,7 +717,7 @@ void FriendList::insertPeers()
|
|||||||
groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
|
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP24));
|
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP24));
|
||||||
groupItem->setForeground(COLUMN_NAME, QBrush(textColorGroup()));
|
groupItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorGroup());
|
||||||
|
|
||||||
/* used to find back the item */
|
/* used to find back the item */
|
||||||
QString strID = QString::fromStdString(groupInfo->id.toStdString());
|
QString strID = QString::fromStdString(groupInfo->id.toStdString());
|
||||||
@ -1110,8 +1110,8 @@ void FriendList::insertPeers()
|
|||||||
for (int i = 0; i < columnCount; ++i) {
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
sslItem->setData(i, ROLE_SORT_STATE, peerState);
|
sslItem->setData(i, ROLE_SORT_STATE, peerState);
|
||||||
|
|
||||||
sslItem->setTextColor(i, sslColor);
|
sslItem->setData(i, Qt::ForegroundRole, sslColor);
|
||||||
sslItem->setFont(i, sslFont);
|
sslItem->setData(i, Qt::FontRole, sslFont);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1222,8 +1222,8 @@ void FriendList::insertPeers()
|
|||||||
for (int i = 0; i < columnCount; ++i) {
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
gpgItem->setData(i, ROLE_SORT_STATE, bestPeerState);
|
gpgItem->setData(i, ROLE_SORT_STATE, bestPeerState);
|
||||||
|
|
||||||
gpgItem->setTextColor(i, gpgColor);
|
gpgItem->setData(i, Qt::ForegroundRole, gpgColor);
|
||||||
gpgItem->setFont(i, gpgFont);
|
gpgItem->setData(i, Qt::FontRole, gpgFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openPeers.find(gpgId) != openPeers.end()) {
|
if (openPeers.find(gpgId) != openPeers.end()) {
|
||||||
|
@ -215,7 +215,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state != (int) RS_STATUS_OFFLINE) {
|
if (state != (int) RS_STATUS_OFFLINE) {
|
||||||
item->setTextColor(COLUMN_NAME, textColorOnline);
|
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline);
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||||
@ -452,7 +452,7 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state != (int) RS_STATUS_OFFLINE) {
|
if (state != (int) RS_STATUS_OFFLINE) {
|
||||||
gpgItem->setTextColor(COLUMN_NAME, textColorOnline());
|
gpgItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||||
}
|
}
|
||||||
|
|
||||||
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
|
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
|
||||||
@ -589,7 +589,7 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
||||||
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
||||||
|
|
||||||
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
|
//gxsItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||||
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
||||||
gxsItem->setIcon(COLUMN_NAME, identicon);
|
gxsItem->setIcon(COLUMN_NAME, identicon);
|
||||||
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
||||||
@ -643,7 +643,7 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
||||||
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
||||||
|
|
||||||
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
|
//gxsItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||||
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
||||||
gxsItem->setIcon(COLUMN_NAME, identicon);
|
gxsItem->setIcon(COLUMN_NAME, identicon);
|
||||||
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
||||||
@ -769,14 +769,12 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|||||||
case IDTYPE_GPG:
|
case IDTYPE_GPG:
|
||||||
{
|
{
|
||||||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) {
|
if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) {
|
||||||
QColor color;
|
|
||||||
if (status != (int) RS_STATUS_OFFLINE) {
|
if (status != (int) RS_STATUS_OFFLINE) {
|
||||||
color = textColorOnline();
|
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||||
} else {
|
} else {
|
||||||
color = ui->friendList->palette().color(QPalette::Text);
|
item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setTextColor(COLUMN_NAME, color);
|
|
||||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus)));
|
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus)));
|
||||||
|
|
||||||
item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus);
|
item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus);
|
||||||
@ -788,14 +786,12 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|||||||
case IDTYPE_SSL:
|
case IDTYPE_SSL:
|
||||||
{
|
{
|
||||||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) {
|
if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) {
|
||||||
QColor color;
|
|
||||||
if (status != (int) RS_STATUS_OFFLINE) {
|
if (status != (int) RS_STATUS_OFFLINE) {
|
||||||
color = textColorOnline();
|
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
|
||||||
} else {
|
} else {
|
||||||
color = ui->friendList->palette().color(QPalette::Text);
|
item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setTextColor(COLUMN_NAME, color);
|
|
||||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
||||||
|
|
||||||
item->setData(COLUMN_NAME, ROLE_SORT_STATE, status);
|
item->setData(COLUMN_NAME, ROLE_SORT_STATE, status);
|
||||||
|
@ -287,9 +287,6 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton)
|
|||||||
|
|
||||||
void GroupTreeWidget::updateColors()
|
void GroupTreeWidget::updateColors()
|
||||||
{
|
{
|
||||||
QBrush brush;
|
|
||||||
QBrush standardBrush = ui->treeWidget->palette().color(QPalette::Text);
|
|
||||||
|
|
||||||
QTreeWidgetItemIterator itemIterator(ui->treeWidget);
|
QTreeWidgetItemIterator itemIterator(ui->treeWidget);
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
while ((item = *itemIterator) != NULL) {
|
while ((item = *itemIterator) != NULL) {
|
||||||
@ -297,12 +294,11 @@ void GroupTreeWidget::updateColors()
|
|||||||
|
|
||||||
int color = item->data(COLUMN_DATA, ROLE_COLOR).toInt();
|
int color = item->data(COLUMN_DATA, ROLE_COLOR).toInt();
|
||||||
if (color >= 0) {
|
if (color >= 0) {
|
||||||
brush = QBrush(mTextColor[color]);
|
item->setData(COLUMN_NAME, Qt::TextColorRole, mTextColor[color]);
|
||||||
} else {
|
} else {
|
||||||
brush = standardBrush;
|
item->setData(COLUMN_NAME, Qt::TextColorRole, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setForeground(COLUMN_NAME, brush);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +352,7 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc
|
|||||||
int S = QFontMetricsF(font).height();
|
int S = QFontMetricsF(font).height();
|
||||||
|
|
||||||
item->setSizeHint(COLUMN_NAME, QSize(S*1.9, S*1.9));
|
item->setSizeHint(COLUMN_NAME, QSize(S*1.9, S*1.9));
|
||||||
item->setForeground(COLUMN_NAME, QBrush(textColorCategory()));
|
item->setData(COLUMN_NAME, Qt::TextColorRole, textColorCategory());
|
||||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_CATEGORY);
|
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_CATEGORY);
|
||||||
|
|
||||||
item->setExpanded(expand);
|
item->setExpanded(expand);
|
||||||
@ -513,15 +509,14 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
|||||||
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
|
item->setData(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS, itemInfo.subscribeFlags);
|
||||||
|
|
||||||
/* Set color */
|
/* Set color */
|
||||||
QBrush brush;
|
|
||||||
if (itemInfo.publishKey) {
|
if (itemInfo.publishKey) {
|
||||||
brush = QBrush(textColorPrivateKey());
|
|
||||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
|
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
|
||||||
|
item->setData(COLUMN_NAME, Qt::BackgroundRole, QBrush(textColorPrivateKey()));
|
||||||
} else {
|
} else {
|
||||||
brush = ui->treeWidget->palette().color(QPalette::Text);
|
// Let StyleSheet color
|
||||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
||||||
|
item->setData(COLUMN_NAME, Qt::BackgroundRole, QVariant());
|
||||||
}
|
}
|
||||||
item->setForeground(COLUMN_NAME, brush);
|
|
||||||
|
|
||||||
/* Calculate score */
|
/* Calculate score */
|
||||||
calculateScore(item, filterText);
|
calculateScore(item, filterText);
|
||||||
|
@ -36,6 +36,36 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
//#define DEBUG_EID_PAINT 1
|
||||||
|
|
||||||
|
/* To test it you can make an empty.qss file with:
|
||||||
|
QTreeView::item, QTreeWidget::item{
|
||||||
|
color: #AB0000;
|
||||||
|
background-color: #00DC00;
|
||||||
|
}
|
||||||
|
QTreeView::item:selected, QTreeWidget::item:selected{
|
||||||
|
color: #00CD00;
|
||||||
|
background-color: #0000BA;
|
||||||
|
}
|
||||||
|
QTreeView::item:hover, QTreeWidget::item:hover{
|
||||||
|
color: #0000EF;
|
||||||
|
background-color: #FEDCBA;
|
||||||
|
}
|
||||||
|
QQTreeView::item:selected:hover, TreeWidget::item:selected:hover{
|
||||||
|
color: #ABCDEF;
|
||||||
|
background-color: #FE0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
ForumsDialog, GxsForumThreadWidget
|
||||||
|
{
|
||||||
|
qproperty-textColorRead: darkgray;
|
||||||
|
qproperty-textColorUnread: white;
|
||||||
|
qproperty-textColorUnreadChildren: red;
|
||||||
|
qproperty-textColorNotSubscribed: white;
|
||||||
|
qproperty-textColorMissing: darkred;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
RSElidedItemDelegate::RSElidedItemDelegate(QObject *parent)
|
RSElidedItemDelegate::RSElidedItemDelegate(QObject *parent)
|
||||||
: RSStyledItemDelegate(parent)
|
: RSStyledItemDelegate(parent)
|
||||||
, mOnlyPlainText(false), mPaintRoundedRect(true)
|
, mOnlyPlainText(false), mPaintRoundedRect(true)
|
||||||
@ -63,6 +93,18 @@ QSize RSElidedItemDelegate::sizeHint(const QStyleOptionViewItem &option, const Q
|
|||||||
return contSize;
|
return contSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QColor getImagePixelColor(QImage img, int x, int y)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
// RsDbg() << " RSEID: Found Color " << img.pixelColor(x,y).name(QColor::HexArgb).toStdString() << " at " << x << "," << y << std::endl;
|
||||||
|
#endif
|
||||||
|
return img.pixelColor(x,y);
|
||||||
|
#else
|
||||||
|
return img.pixel(x,y);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if(!index.isValid())
|
if(!index.isValid())
|
||||||
@ -71,15 +113,16 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
painter->save();
|
painter->save();
|
||||||
// To draw with default for debug purpose
|
|
||||||
//QStyledItemDelegate::paint(painter, option, index);
|
|
||||||
|
|
||||||
QStyleOptionViewItem ownOption (option);
|
QStyleOptionViewItem ownOption (option);
|
||||||
initStyleOption(&ownOption, index);
|
initStyleOption(&ownOption, index);
|
||||||
//Prefer use icon from option
|
//Prefer use icon from option
|
||||||
if (!option.icon.isNull())
|
if (!option.icon.isNull())
|
||||||
ownOption.icon = option.icon;
|
ownOption.icon = option.icon;
|
||||||
|
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << __PRETTY_FUNCTION__ << std::endl << " RSEID: Enter for item with text:" << ownOption.text.toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
const QWidget* widget = option.widget;
|
const QWidget* widget = option.widget;
|
||||||
QStyle* ownStyle = widget ? widget->style() : QApplication::style();
|
QStyle* ownStyle = widget ? widget->style() : QApplication::style();
|
||||||
|
|
||||||
@ -89,28 +132,180 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
td.setHtml(ownOption.text);
|
td.setHtml(ownOption.text);
|
||||||
ownOption.text = td.toPlainText();
|
ownOption.text = td.toPlainText();
|
||||||
}
|
}
|
||||||
//Get Font as option.font is not accurate
|
// Get Font as option.font is not accurate
|
||||||
if (index.data(Qt::FontRole).type() == QVariant::Font) {
|
if (index.data(Qt::FontRole).type() == QVariant::Font) {
|
||||||
QFont font = index.data(Qt::FontRole).value<QFont>();
|
QFont font = index.data(Qt::FontRole).value<QFont>();
|
||||||
ownOption.font = font;
|
ownOption.font = font;
|
||||||
ownOption.fontMetrics = QFontMetrics(font);
|
ownOption.fontMetrics = QFontMetrics(font);
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
QFontInfo info(font);
|
||||||
|
RsDbg() << " RSEID: Found font in model:" << info.family().toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
// Get Text color from model if one exists
|
||||||
QColor textColor;
|
QColor textColor;
|
||||||
if (index.data(Qt::TextColorRole).canConvert(QMetaType::QColor)) {
|
if (index.data(Qt::TextColorRole).isValid()) {
|
||||||
textColor = QColor(index.data(Qt::TextColorRole).toString());//Needs to pass from string else loose RBG format.
|
//textColor = QColor(index.data(Qt::TextColorRole).toString());//Needs to pass from string else loose RBG format.
|
||||||
|
textColor = index.data(Qt::TextColorRole).value<QColor>();
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << " RSEID: Found text color in model:" << textColor.name().toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (index.data(Qt::BackgroundRole).canConvert(QMetaType::QBrush)) {
|
// Get Brush from model if one exists
|
||||||
QBrush brush(index.data(Qt::BackgroundRole).convert(QMetaType::QBrush));
|
QBrush bgBrush;
|
||||||
ownOption.backgroundBrush = brush;
|
bgBrush.setColor(QColor());// To get color().spec()==QColor::Invalid)
|
||||||
|
if (index.data(Qt::BackgroundRole).isValid()) {
|
||||||
|
bgBrush = index.data(Qt::BackgroundRole).value<QBrush>();
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << " RSEID: Found bg brush in model:" << bgBrush.color().name().toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//Code from: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qcommonstyle.cpp.html#2271
|
// If we get text and bg color from model, no need to retrieve it from base
|
||||||
|
if ( (bgBrush.color().spec()==QColor::Invalid) || (textColor.spec()!=QColor::Invalid) )
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << " RSEID:"
|
||||||
|
<< ((bgBrush.color().spec()==QColor::Invalid) ? " Brush not defined" : "")
|
||||||
|
<< ((textColor.spec()==QColor::Invalid) ? " Text Color not defined" : "")
|
||||||
|
<< " so get it from base image." << std::endl;
|
||||||
|
#endif
|
||||||
|
// QPalette is not updated by StyleSheet all occurs in internal class. (QRenderRule)
|
||||||
|
// https://code.woboq.org/qt5/qtbase/src/widgets/styles/qstylesheetstyle.cpp.html#4138
|
||||||
|
// void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
||||||
|
// case CE_ItemViewItem:
|
||||||
|
// So we have to print it in Image to get colors by pixel
|
||||||
|
QSize moSize=sizeHint(option,index);
|
||||||
|
if (moSize.width() <= 20)
|
||||||
|
moSize.setWidth(20);
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << " RSEID: for item size = " << moSize.width() << "x" << moSize.height() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QImage moImg(moSize,QImage::Format_ARGB32);
|
||||||
|
QPainter moPnt;
|
||||||
|
moPnt.begin(&moImg);
|
||||||
|
moPnt.setCompositionMode (QPainter::CompositionMode_Source);
|
||||||
|
moPnt.fillRect(moImg.rect(), Qt::transparent);
|
||||||
|
moPnt.setCompositionMode (QPainter::CompositionMode_SourceOver);
|
||||||
|
|
||||||
|
QStyleOptionViewItem moOption (option);
|
||||||
|
// Define option to get only what we want
|
||||||
|
{
|
||||||
|
moOption.rect = QRect(QPoint(0,0),moSize);
|
||||||
|
moOption.state = ownOption.state;
|
||||||
|
moOption.text = " ████████████████";//Add a blank char to get BackGround Color at top left
|
||||||
|
// Remove unwanted info. Yes it can draw without that all public data ...
|
||||||
|
moOption.backgroundBrush = QBrush();
|
||||||
|
moOption.checkState = Qt::Unchecked;
|
||||||
|
moOption.decorationAlignment = Qt::AlignLeft;
|
||||||
|
moOption.decorationPosition = QStyleOptionViewItem::Left;
|
||||||
|
moOption.decorationSize = QSize();
|
||||||
|
moOption.displayAlignment = Qt::AlignLeft | Qt::AlignTop;
|
||||||
|
moOption.features=0;
|
||||||
|
moOption.font = QFont();
|
||||||
|
moOption.icon = QIcon();
|
||||||
|
moOption.index = QModelIndex();
|
||||||
|
moOption.locale = QLocale();
|
||||||
|
moOption.showDecorationSelected = false;
|
||||||
|
moOption.textElideMode = Qt::ElideNone;
|
||||||
|
moOption.viewItemPosition = QStyleOptionViewItem::Middle;
|
||||||
|
//moOption.widget = nullptr; //Needed.
|
||||||
|
|
||||||
|
moOption.direction = Qt::LayoutDirectionAuto;
|
||||||
|
moOption.fontMetrics = QFontMetrics(QFont());
|
||||||
|
moOption.palette = QPalette();
|
||||||
|
moOption.styleObject = nullptr;
|
||||||
|
}
|
||||||
|
QStyledItemDelegate::paint(&moPnt, moOption, QModelIndex());
|
||||||
|
|
||||||
|
//// But these lines doesn't works.
|
||||||
|
{
|
||||||
|
//QStyleOptionViewItem moOptionsState;
|
||||||
|
//moOptionsState.initFrom(moOption.widget);
|
||||||
|
//moOptionsState.rect = QRect(QPoint(0,0),moSize);
|
||||||
|
//moOptionsState.state = QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Sibling;
|
||||||
|
//moOptionsState.text = "████████";
|
||||||
|
//moOptionsState.widget = option.widget;
|
||||||
|
//QStyledItemDelegate::paint(&moPnt, moOptionsState, QModelIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
moPnt.end();
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
// To save what it paint in application path
|
||||||
|
moImg.save("image.png");
|
||||||
|
#endif
|
||||||
|
// Get Color in this rect.
|
||||||
|
{
|
||||||
|
QColor moColor;
|
||||||
|
QColor moBGColor=getImagePixelColor(moImg,1,1); // BackGround may be paint.
|
||||||
|
QColor moColorBorder;// To avoid Border pixel
|
||||||
|
int moWidth = moImg.size().width(), moHeight = moImg.size().height();
|
||||||
|
for (int x = 0; (x<moWidth) && (moColor.spec() == QColor::Invalid); x++)
|
||||||
|
for (int y = 0; (y<moHeight) && (moColor.spec() == QColor::Invalid); y++)
|
||||||
|
if (getImagePixelColor(moImg,x,y) != moBGColor)
|
||||||
|
{
|
||||||
|
if (getImagePixelColor(moImg,x,y) == moColorBorder)
|
||||||
|
moColor = getImagePixelColor(moImg,x,y);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (moColorBorder.spec() == QColor::Invalid)
|
||||||
|
{
|
||||||
|
// First pixel border move inside
|
||||||
|
x+=5;
|
||||||
|
y+=5;
|
||||||
|
}
|
||||||
|
moColorBorder = getImagePixelColor(moImg,x,y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not found color is same as BackGround.
|
||||||
|
if (moColor.spec() == QColor::Invalid)
|
||||||
|
moColor = moBGColor;
|
||||||
|
|
||||||
|
if (bgBrush.color().spec()==QColor::Invalid)
|
||||||
|
{
|
||||||
|
bgBrush = QBrush(moBGColor);
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << " RSEID: bg brush setted to " << moBGColor.name(QColor::HexArgb).toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (textColor.spec()==QColor::Invalid)
|
||||||
|
{
|
||||||
|
textColor = moColor;
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << " RSEID: text color setted to " << moColor.name(QColor::HexArgb).toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->setPen(textColor);
|
||||||
|
painter->setBrush(bgBrush);
|
||||||
|
ownOption.backgroundBrush = bgBrush;
|
||||||
|
|
||||||
|
// Code from: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qcommonstyle.cpp.html#2271
|
||||||
QRect checkRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &ownOption, widget);
|
QRect checkRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &ownOption, widget);
|
||||||
QRect iconRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemDecoration, &ownOption, widget);
|
QRect iconRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemDecoration, &ownOption, widget);
|
||||||
QRect textRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemText, &ownOption, widget);
|
QRect textRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemText, &ownOption, widget);
|
||||||
|
|
||||||
// draw the background
|
// Draw the background
|
||||||
ownStyle->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, widget);
|
if (bgBrush.color().alpha() == 0)
|
||||||
|
// No BackGround Color found, use default delegate to draw it.
|
||||||
|
ownStyle->proxy()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, widget);// This prefer draw StyleSheet bg than item one.
|
||||||
|
else
|
||||||
|
painter->fillRect(ownOption.rect,bgBrush);
|
||||||
|
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
{
|
||||||
|
QStyleOptionViewItem tstOption = option;
|
||||||
|
// Reduce rect to get this item bg color external and base internal
|
||||||
|
tstOption.rect.adjust(3,3,-6,-6);
|
||||||
|
// To draw with base for debug purpose
|
||||||
|
QStyledItemDelegate::paint(painter, tstOption, index);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// draw the check mark
|
// draw the check mark
|
||||||
if (ownOption.features & QStyleOptionViewItem::HasCheckIndicator) {
|
if (ownOption.features & QStyleOptionViewItem::HasCheckIndicator) {
|
||||||
QStyleOptionViewItem option(*&ownOption);
|
QStyleOptionViewItem option(*&ownOption);
|
||||||
@ -177,118 +372,19 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
}
|
}
|
||||||
// draw the text
|
// draw the text
|
||||||
if (!ownOption.text.isEmpty()) {
|
if (!ownOption.text.isEmpty()) {
|
||||||
QPalette::ColorGroup cg = ownOption.state & QStyle::State_Enabled
|
#ifdef DEBUG_EID_PAINT
|
||||||
? QPalette::Normal : QPalette::Disabled;
|
// To draw text near base one.
|
||||||
if (cg == QPalette::Normal && !(ownOption.state & QStyle::State_Active))
|
ownOption.text = ownOption.text.prepend("__");
|
||||||
cg = QPalette::Inactive;
|
|
||||||
if (ownOption.state & QStyle::State_Selected) {
|
|
||||||
painter->setPen(ownOption.palette.color(cg, QPalette::HighlightedText));
|
|
||||||
} else {
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
|
|
||||||
if (ownOption.state & QStyle::State_MouseOver) {
|
|
||||||
//TODO: Manage to get palette with HOVER css pseudoclass
|
|
||||||
// For now this is hidden by Qt: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qstylesheetstyle.cpp.html#6103
|
|
||||||
// So we print default in image and get it's color...
|
|
||||||
QSize moSize=sizeHint(option,index);
|
|
||||||
QImage moImg(moSize,QImage::Format_ARGB32);
|
|
||||||
QPainter moPnt;
|
|
||||||
moPnt.begin(&moImg);
|
|
||||||
moPnt.setPen(Qt::black);//Fill Image with Black
|
|
||||||
moPnt.setBrush(Qt::black);
|
|
||||||
moPnt.drawRect(moImg.rect());
|
|
||||||
|
|
||||||
QStyleOptionViewItem moOption (option);
|
|
||||||
// Define option to get only what we want
|
|
||||||
{
|
|
||||||
moOption.rect = QRect(QPoint(0,0),moSize);
|
|
||||||
moOption.state = QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Sibling;
|
|
||||||
moOption.text = " ████████████████";//Add a blank char to get BackGround Color at top left
|
|
||||||
// Remove unwanted info. Yes it can draw without that all public data ...
|
|
||||||
moOption.backgroundBrush = QBrush();
|
|
||||||
moOption.checkState = Qt::Unchecked;
|
|
||||||
moOption.decorationAlignment = Qt::AlignLeft;
|
|
||||||
moOption.decorationPosition = QStyleOptionViewItem::Left;
|
|
||||||
moOption.decorationSize = QSize();
|
|
||||||
moOption.displayAlignment = Qt::AlignLeft | Qt::AlignTop;
|
|
||||||
moOption.features=0;
|
|
||||||
moOption.font = QFont();
|
|
||||||
moOption.icon = QIcon();
|
|
||||||
moOption.index = QModelIndex();
|
|
||||||
moOption.locale = QLocale();
|
|
||||||
moOption.showDecorationSelected = false;
|
|
||||||
moOption.textElideMode = Qt::ElideNone;
|
|
||||||
moOption.viewItemPosition = QStyleOptionViewItem::Middle;
|
|
||||||
//moOption.widget = nullptr; //Needed.
|
|
||||||
|
|
||||||
moOption.direction = Qt::LayoutDirectionAuto;
|
|
||||||
moOption.fontMetrics = QFontMetrics(QFont());
|
|
||||||
moOption.palette = QPalette();
|
|
||||||
moOption.styleObject = nullptr;
|
|
||||||
}
|
|
||||||
QStyledItemDelegate::paint(&moPnt, moOption, QModelIndex());
|
|
||||||
|
|
||||||
//// But these lines doesn't works.
|
|
||||||
{
|
|
||||||
//QStyleOptionViewItem moOptionsState;
|
|
||||||
//moOptionsState.initFrom(moOption.widget);
|
|
||||||
//moOptionsState.rect = QRect(QPoint(0,0),moSize);
|
|
||||||
//moOptionsState.state = QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Sibling;
|
|
||||||
//moOptionsState.text = "████████";
|
|
||||||
//moOptionsState.widget = option.widget;
|
|
||||||
//QStyledItemDelegate::paint(&moPnt, moOptionsState, QModelIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
moPnt.end();
|
|
||||||
// To save what it paint
|
|
||||||
//moImg.save("image.bmp");
|
|
||||||
|
|
||||||
// Get Color in this black rect.
|
|
||||||
QColor moColor;
|
|
||||||
QColor moBGColor=moImg.pixelColor(1,1); //BackGround may be paint.
|
|
||||||
QColor moColorBorder;// To avoid Border pixel
|
|
||||||
int moWidth = moImg.size().width(), moHeight = moImg.size().height();
|
|
||||||
for (int x = 0; (x<moWidth) && (moColor.spec() == QColor::Invalid); x++)
|
|
||||||
for (int y = 0; (y<moHeight) && (moColor.spec() == QColor::Invalid); y++)
|
|
||||||
if (moImg.pixelColor(x,y) != moBGColor)
|
|
||||||
{
|
|
||||||
if (moImg.pixelColor(x,y) == moColorBorder)
|
|
||||||
moColor = QColor(moImg.pixelColor(x,y).name());
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (moColorBorder.spec() == QColor::Invalid)
|
|
||||||
{
|
|
||||||
// First pixel border move inside
|
|
||||||
x+=5;
|
|
||||||
y+=5;
|
|
||||||
}
|
|
||||||
moColorBorder = QColor(moImg.pixelColor(x,y).name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If not found color is same as BackGround.
|
|
||||||
if (moColor.spec() == QColor::Invalid)
|
|
||||||
moColor = moBGColor;
|
|
||||||
|
|
||||||
painter->setPen(moColor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
if (textColor.spec()==QColor::Invalid) {
|
|
||||||
painter->setPen(ownOption.palette.color(cg, QPalette::Text));
|
|
||||||
} else { //Only get color from index for unselected(as Qt does)
|
|
||||||
painter->setPen(textColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ownOption.state & QStyle::State_Editing) {
|
|
||||||
painter->setPen(ownOption.palette.color(cg, QPalette::Text));
|
|
||||||
painter->drawRect(textRect.adjusted(0, 0, -1, -1));
|
|
||||||
}
|
|
||||||
//d->viewItemDrawText(p, &ownOption, textRect);
|
|
||||||
QTextLayout textLayout(ownOption.text, painter->font());
|
QTextLayout textLayout(ownOption.text, painter->font());
|
||||||
QTextOption to = textLayout.textOption();
|
QTextOption to = textLayout.textOption();
|
||||||
StyledElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode()&QTextOption::WordWrap,mPaintRoundedRect);
|
StyledElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode()&QTextOption::WordWrap,mPaintRoundedRect);
|
||||||
}
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
RsDbg() << " RSEID: Finished" << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RSElidedItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
|
bool RSElidedItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||||
|
@ -537,8 +537,9 @@ bool RsCollectionDialog::addChild(QTreeWidgetItem* parent, const std::vector<Col
|
|||||||
|
|
||||||
if (colFileInfo.filename_has_wrong_characters)
|
if (colFileInfo.filename_has_wrong_characters)
|
||||||
{
|
{
|
||||||
|
//TODO (Phenom): Add qproperty for these text colors in stylesheets
|
||||||
wrong_chars = true ;
|
wrong_chars = true ;
|
||||||
item->setTextColor(COLUMN_FILE, QColor(255,80,120)) ;
|
item->setData(COLUMN_FILE, Qt::ForegroundRole, QColor(255,80,120)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentsFounds.empty()) {
|
if (parentsFounds.empty()) {
|
||||||
|
@ -451,7 +451,7 @@ void MessagesDialog::fillQuickView()
|
|||||||
text = TagDefs::name(tag->first, tag->second.first);
|
text = TagDefs::name(tag->first, tag->second.first);
|
||||||
|
|
||||||
item = new QListWidgetItem (text, ui.quickViewWidget);
|
item = new QListWidgetItem (text, ui.quickViewWidget);
|
||||||
item->setForeground(QBrush(QColor(tag->second.second)));
|
item->setData(Qt::ForegroundRole, QColor(tag->second.second));
|
||||||
item->setIcon(QIcon(":/images/foldermail.png"));
|
item->setIcon(QIcon(":/images/foldermail.png"));
|
||||||
item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_TAG);
|
item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_TAG);
|
||||||
item->setData(ROLE_QUICKVIEW_ID, tag->first);
|
item->setData(ROLE_QUICKVIEW_ID, tag->first);
|
||||||
@ -1262,7 +1262,7 @@ void MessagesDialog::updateMessageSummaryList()
|
|||||||
qf.setBold(true);
|
qf.setBold(true);
|
||||||
item->setFont(qf);
|
item->setFont(qf);
|
||||||
item->setIcon(QIcon(":/images/folder-inbox-new.png"));
|
item->setIcon(QIcon(":/images/folder-inbox-new.png"));
|
||||||
item->setForeground(QBrush(mTextColorInbox));
|
item->setData(Qt::ForegroundRole, mTextColorInbox);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1272,7 +1272,7 @@ void MessagesDialog::updateMessageSummaryList()
|
|||||||
qf.setBold(false);
|
qf.setBold(false);
|
||||||
item->setFont(qf);
|
item->setFont(qf);
|
||||||
item->setIcon(QIcon(":/images/folder-inbox.png"));
|
item->setIcon(QIcon(":/images/folder-inbox.png"));
|
||||||
item->setForeground(QBrush(ui.messageTreeWidget->palette().color(QPalette::Text)));
|
item->setData(Qt::ForegroundRole, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
|
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
|
||||||
|
@ -140,7 +140,7 @@ void MessagePage::fillTags()
|
|||||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||||
|
|
||||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
pItemWidget->setData(Qt::ForegroundRole, QColor(Tag->second.second));
|
||||||
pItemWidget->setData(Qt::UserRole, Tag->first);
|
pItemWidget->setData(Qt::UserRole, Tag->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ void MessagePage::addTag()
|
|||||||
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
QString text = TagDefs::name(Tag->first, Tag->second.first);
|
||||||
|
|
||||||
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
|
||||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
pItemWidget->setData(Qt::ForegroundRole, QColor(Tag->second.second));
|
||||||
pItemWidget->setData(Qt::UserRole, TagDlg.m_nId);
|
pItemWidget->setData(Qt::UserRole, TagDlg.m_nId);
|
||||||
|
|
||||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||||
@ -186,7 +186,7 @@ void MessagePage::editTag()
|
|||||||
if (Tag->first >= RS_MSGTAGTYPE_USER) {
|
if (Tag->first >= RS_MSGTAGTYPE_USER) {
|
||||||
pItemWidget->setText(QString::fromStdString(Tag->second.first));
|
pItemWidget->setText(QString::fromStdString(Tag->second.first));
|
||||||
}
|
}
|
||||||
pItemWidget->setTextColor(QColor(Tag->second.second));
|
pItemWidget->setData(Qt::ForegroundRole, QColor(Tag->second.second));
|
||||||
|
|
||||||
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), TagDlg.m_nId) == m_changedTagIds.end()) {
|
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), TagDlg.m_nId) == m_changedTagIds.end()) {
|
||||||
m_changedTagIds.push_back(TagDlg.m_nId);
|
m_changedTagIds.push_back(TagDlg.m_nId);
|
||||||
|
Loading…
Reference in New Issue
Block a user