mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-28 10:32:22 -04:00
Moved most of the hardcoded colors of lists and trees to the file qss.default (with help from braindead).
Now the stylesheet can redefine these colors. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5843 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9c1d702128
commit
a8d1d05405
19 changed files with 387 additions and 104 deletions
|
@ -28,7 +28,6 @@
|
|||
#include <QDateTime>
|
||||
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "retroshare/rsstatus.h"
|
||||
|
||||
#include "GroupDefs.h"
|
||||
#include "gui/chat/ChatDialog.h"
|
||||
|
@ -235,6 +234,19 @@ void FriendList::processSettings(bool bLoad)
|
|||
}
|
||||
}
|
||||
|
||||
void FriendList::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::StyleChange:
|
||||
insertPeers();
|
||||
break;
|
||||
default:
|
||||
// remove compiler warnings
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FriendList::initializeHeader(bool afterLoadSettings)
|
||||
{
|
||||
// set column size
|
||||
|
@ -683,7 +695,7 @@ void FriendList::insertPeers()
|
|||
groupItem->setSizeHint(COLUMN_NAME, QSize(26, 26));
|
||||
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP24));
|
||||
groupItem->setForeground(COLUMN_NAME, QBrush(QColor(123, 123, 123)));
|
||||
groupItem->setForeground(COLUMN_NAME, QBrush(textColorGroup()));
|
||||
|
||||
/* used to find back the item */
|
||||
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id));
|
||||
|
@ -957,10 +969,10 @@ void FriendList::insertPeers()
|
|||
|
||||
if (rsState == 0) {
|
||||
sslFont.setBold(true);
|
||||
sslColor = Qt::darkBlue;
|
||||
sslColor = mTextColorStatus[RS_STATUS_ONLINE];
|
||||
} else {
|
||||
sslFont = StatusDefs::font(rsState);
|
||||
sslColor = StatusDefs::textColor(rsState);
|
||||
sslColor = mTextColorStatus[rsState];
|
||||
}
|
||||
} else if (sslDetail.state & RS_PEER_STATE_ONLINE) {
|
||||
sslItem->setHidden(mHideUnconnected);
|
||||
|
@ -973,7 +985,7 @@ void FriendList::insertPeers()
|
|||
}
|
||||
|
||||
sslFont.setBold(true);
|
||||
sslColor = Qt::black;
|
||||
sslColor = mTextColorStatus[RS_STATUS_ONLINE];
|
||||
} else {
|
||||
sslItem->setHidden(mHideUnconnected);
|
||||
if (sslDetail.connectState) {
|
||||
|
@ -983,7 +995,7 @@ void FriendList::insertPeers()
|
|||
}
|
||||
|
||||
sslFont.setBold(false);
|
||||
sslColor = Qt::black;
|
||||
sslColor = mTextColorStatus[RS_STATUS_OFFLINE];
|
||||
}
|
||||
|
||||
if (std::find(privateChatIds.begin(), privateChatIds.end(), sslDetail.id) != privateChatIds.end()) {
|
||||
|
@ -1011,7 +1023,7 @@ void FriendList::insertPeers()
|
|||
bestRSState = RS_STATUS_ONLINE;
|
||||
}
|
||||
|
||||
QColor textColor = StatusDefs::textColor(bestRSState);
|
||||
QColor textColor = mTextColorStatus[bestRSState];
|
||||
QFont font = StatusDefs::font(bestRSState);
|
||||
for(int i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpgItem->setTextColor(i, textColor);
|
||||
|
@ -1047,8 +1059,9 @@ void FriendList::insertPeers()
|
|||
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
QColor textColor = mTextColorStatus[RS_STATUS_ONLINE];
|
||||
for(int i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpgItem->setTextColor(i,(Qt::black));
|
||||
gpgItem->setTextColor(i, textColor);
|
||||
gpgItem->setFont(i,font);
|
||||
}
|
||||
} else {
|
||||
|
@ -1062,7 +1075,7 @@ void FriendList::insertPeers()
|
|||
gpgItem->setHidden(mHideUnconnected);
|
||||
gpgIcon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE));
|
||||
|
||||
QColor textColor = StatusDefs::textColor(RS_STATUS_OFFLINE);
|
||||
QColor textColor = mTextColorStatus[RS_STATUS_OFFLINE];
|
||||
QFont font = StatusDefs::font(RS_STATUS_OFFLINE);
|
||||
for(int i = 0; i < COLUMN_COUNT; i++) {
|
||||
gpgItem->setTextColor(i, textColor);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <QWidget>
|
||||
|
||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||
#include "retroshare/rsstatus.h"
|
||||
|
||||
namespace Ui {
|
||||
class FriendList;
|
||||
|
@ -40,6 +41,13 @@ class FriendList : public RsAutoUpdatePage
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor textColorGroup READ textColorGroup WRITE setTextColorGroup)
|
||||
Q_PROPERTY(QColor textColorStatusOffline READ textColorStatusOffline WRITE setTextColorStatusOffline)
|
||||
Q_PROPERTY(QColor textColorStatusAway READ textColorStatusAway WRITE setTextColorStatusAway)
|
||||
Q_PROPERTY(QColor textColorStatusBusy READ textColorStatusBusy WRITE setTextColorStatusBusy)
|
||||
Q_PROPERTY(QColor textColorStatusOnline READ textColorStatusOnline WRITE setTextColorStatusOnline)
|
||||
Q_PROPERTY(QColor textColorStatusInactive READ textColorStatusInactive WRITE setTextColorStatusInactive)
|
||||
|
||||
public:
|
||||
explicit FriendList(QWidget *parent = 0);
|
||||
~FriendList();
|
||||
|
@ -55,6 +63,20 @@ public:
|
|||
|
||||
virtual void updateDisplay();
|
||||
|
||||
QColor textColorGroup() const { return mTextColorGroup; }
|
||||
QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; }
|
||||
QColor textColorStatusAway() const { return mTextColorStatus[RS_STATUS_AWAY]; }
|
||||
QColor textColorStatusBusy() const { return mTextColorStatus[RS_STATUS_BUSY]; }
|
||||
QColor textColorStatusOnline() const { return mTextColorStatus[RS_STATUS_ONLINE]; }
|
||||
QColor textColorStatusInactive() const { return mTextColorStatus[RS_STATUS_INACTIVE]; }
|
||||
|
||||
void setTextColorGroup(QColor color) { mTextColorGroup = color; }
|
||||
void setTextColorStatusOffline(QColor color) { mTextColorStatus[RS_STATUS_OFFLINE] = color; }
|
||||
void setTextColorStatusAway(QColor color) { mTextColorStatus[RS_STATUS_AWAY] = color; }
|
||||
void setTextColorStatusBusy(QColor color) { mTextColorStatus[RS_STATUS_BUSY] = color; }
|
||||
void setTextColorStatusOnline(QColor color) { mTextColorStatus[RS_STATUS_ONLINE] = color; }
|
||||
void setTextColorStatusInactive(QColor color) { mTextColorStatus[RS_STATUS_INACTIVE] = color; }
|
||||
|
||||
public slots:
|
||||
void filterItems(const QString &text);
|
||||
|
||||
|
@ -72,6 +94,9 @@ public slots:
|
|||
void sortPeersAscendingOrder();
|
||||
void sortPeersDescendingOrder();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
Ui::FriendList *ui;
|
||||
RSTreeWidgetItemCompareRole *m_compareRole;
|
||||
|
@ -88,6 +113,10 @@ private:
|
|||
std::set<std::string> *openGroups;
|
||||
std::set<std::string> *openPeers;
|
||||
|
||||
/* Color definitions (for standard see qss.default) */
|
||||
QColor mTextColorGroup;
|
||||
QColor mTextColorStatus[RS_STATUS_COUNT];
|
||||
|
||||
QTreeWidgetItem *getCurrentPeer() const;
|
||||
static bool filterItem(QTreeWidgetItem *item, const QString &text);
|
||||
void updateHeader();
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/common/PeerDefs.h"
|
||||
#include "gui/common/GroupDefs.h"
|
||||
#include "rshare.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsstatus.h>
|
||||
|
@ -40,8 +41,6 @@
|
|||
#define ROLE_ID Qt::UserRole
|
||||
#define ROLE_SORT Qt::UserRole + 1
|
||||
|
||||
#define COLOR_CONNECT Qt::blue
|
||||
|
||||
#define IMAGE_GROUP16 ":/images/user/group16.png"
|
||||
#define IMAGE_FRIENDINFO ":/images/peerdetails_16x16.png"
|
||||
|
||||
|
@ -98,6 +97,9 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
|
|||
|
||||
ui->filterLineEdit->setPlaceholderText(tr("Search Friends"));
|
||||
ui->filterLineEdit->showFilterIcon();
|
||||
|
||||
/* Refresh style to have the correct text color */
|
||||
Rshare::refreshStyleSheet(this, false);
|
||||
}
|
||||
|
||||
FriendSelectionWidget::~FriendSelectionWidget()
|
||||
|
@ -105,6 +107,19 @@ FriendSelectionWidget::~FriendSelectionWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::StyleChange:
|
||||
fillList();
|
||||
break;
|
||||
default:
|
||||
// remove compiler warnings
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::setHeaderText(const QString &text)
|
||||
{
|
||||
ui->friendList->headerItem()->setText(COLUMN_NAME, text);
|
||||
|
@ -253,7 +268,7 @@ void FriendSelectionWidget::fillList()
|
|||
}
|
||||
|
||||
if (state != (int) RS_STATUS_OFFLINE) {
|
||||
item->setTextColor(COLUMN_NAME, COLOR_CONNECT);
|
||||
item->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
}
|
||||
|
||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||
|
@ -304,7 +319,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|||
if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) {
|
||||
QColor color;
|
||||
if (status != (int) RS_STATUS_OFFLINE) {
|
||||
color = COLOR_CONNECT;
|
||||
color = textColorOnline();
|
||||
}
|
||||
|
||||
item->setTextColor(COLUMN_NAME, color);
|
||||
|
|
|
@ -36,6 +36,8 @@ class FriendSelectionWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor textColorOnline READ textColorOnline WRITE setTextColorOnline)
|
||||
|
||||
public:
|
||||
enum IdType
|
||||
{
|
||||
|
@ -68,6 +70,13 @@ public:
|
|||
void setSelectedSslIds(const std::list<std::string> &sslIds, bool add) { setSelectedIds(IDTYPE_SSL, sslIds, add); }
|
||||
void setSelectedGroupIds(const std::list<std::string> &groupIds, bool add) { setSelectedIds(IDTYPE_GROUP, groupIds, add); }
|
||||
|
||||
QColor textColorOnline() const { return mTextColorOnline; }
|
||||
|
||||
void setTextColorOnline(QColor color) { mTextColorOnline = color; }
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
signals:
|
||||
void contentChanged();
|
||||
void customContextMenuRequested(const QPoint &pos);
|
||||
|
@ -93,6 +102,9 @@ private:
|
|||
bool showGroups;
|
||||
bool inItemChanged;
|
||||
|
||||
/* Color definitions (for standard see qss.default) */
|
||||
QColor mTextColorOnline;
|
||||
|
||||
Ui::FriendSelectionWidget *ui;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#define ROLE_POPULARITY Qt::UserRole + 3
|
||||
#define ROLE_LASTPOST Qt::UserRole + 4
|
||||
#define ROLE_SEARCH_SCORE Qt::UserRole + 5
|
||||
#define ROLE_COLOR Qt::UserRole + 6
|
||||
|
||||
#define FILTER_NAME_INDEX 0
|
||||
#define FILTER_DESC_INDEX 1
|
||||
|
@ -102,7 +103,11 @@ void GroupTreeWidget::changeEvent(QEvent *e)
|
|||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
case QEvent::StyleChange:
|
||||
updateColors();
|
||||
break;
|
||||
default:
|
||||
// remove compiler warnings
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -188,6 +193,27 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton)
|
|||
toolButton->setMenu(displayMenu);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::updateColors()
|
||||
{
|
||||
QBrush brush;
|
||||
QBrush standardBrush = ui->treeWidget->palette().color(QPalette::Text);
|
||||
|
||||
QTreeWidgetItemIterator itemIterator(ui->treeWidget);
|
||||
QTreeWidgetItem *item;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
itemIterator++;
|
||||
|
||||
int color = item->data(COLUMN_DATA, ROLE_COLOR).toInt();
|
||||
if (color >= 0) {
|
||||
brush = QBrush(mTextColor[color]);
|
||||
} else {
|
||||
brush = standardBrush;
|
||||
}
|
||||
|
||||
item->setForeground(COLUMN_NAME, brush);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::customContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
emit treeCustomContextMenuRequested(pos);
|
||||
|
@ -218,7 +244,8 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc
|
|||
item->setFont(COLUMN_NAME, font);
|
||||
item->setIcon(COLUMN_NAME, icon);
|
||||
item->setSizeHint(COLUMN_NAME, QSize(18, 18));
|
||||
item->setForeground(COLUMN_NAME, QBrush(QColor(79, 79, 79)));
|
||||
item->setForeground(COLUMN_NAME, QBrush(textColorCategory()));
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_CATEGORY);
|
||||
|
||||
ui->treeWidget->addTopLevelItem(item);
|
||||
|
||||
|
@ -294,7 +321,11 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
|||
/* Set color */
|
||||
QBrush brush;
|
||||
if (itemInfo.privatekey) {
|
||||
brush = QBrush(Qt::blue);
|
||||
brush = QBrush(textColorPrivateKey());
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_PRIVATEKEY);
|
||||
} else {
|
||||
brush = ui->treeWidget->palette().color(QPalette::Text);
|
||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
||||
}
|
||||
item->setForeground(COLUMN_NAME, brush);
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@ class QToolButton;
|
|||
class RshareSettings;
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
|
||||
#define GROUPTREEWIDGET_COLOR_STANDARD -1
|
||||
#define GROUPTREEWIDGET_COLOR_CATEGORY 0
|
||||
#define GROUPTREEWIDGET_COLOR_PRIVATEKEY 1
|
||||
#define GROUPTREEWIDGET_COLOR_COUNT 2
|
||||
|
||||
namespace Ui {
|
||||
class GroupTreeWidget;
|
||||
}
|
||||
|
@ -58,6 +63,9 @@ class GroupTreeWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QColor textColorCategory READ textColorCategory WRITE setTextColorCategory)
|
||||
Q_PROPERTY(QColor textColorPrivateKey READ textColorPrivateKey WRITE setTextColorPrivateKey)
|
||||
|
||||
public:
|
||||
GroupTreeWidget(QWidget *parent = 0);
|
||||
~GroupTreeWidget();
|
||||
|
@ -79,6 +87,12 @@ public:
|
|||
QTreeWidgetItem *getItemFromId(const QString &id);
|
||||
QTreeWidgetItem *activateId(const QString &id, bool focus);
|
||||
|
||||
QColor textColorCategory() const { return mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY]; }
|
||||
QColor textColorPrivateKey() const { return mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY]; }
|
||||
|
||||
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
|
||||
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
|
||||
|
||||
signals:
|
||||
void treeCustomContextMenuRequested(const QPoint &pos);
|
||||
void treeCurrentItemChanged(const QString &id);
|
||||
|
@ -96,6 +110,7 @@ private slots:
|
|||
private:
|
||||
void calculateScore(QTreeWidgetItem *item, const QString &filterText);
|
||||
void resort(QTreeWidgetItem *categoryItem);
|
||||
void updateColors();
|
||||
|
||||
private:
|
||||
QMenu *displayMenu;
|
||||
|
@ -107,6 +122,9 @@ private:
|
|||
|
||||
RSTreeWidgetItemCompareRole *compareRole;
|
||||
|
||||
/* Color definitions (for standard see qss.default) */
|
||||
QColor mTextColor[GROUPTREEWIDGET_COLOR_COUNT];
|
||||
|
||||
Ui::GroupTreeWidget *ui;
|
||||
};
|
||||
|
||||
|
|
|
@ -101,25 +101,6 @@ QString StatusDefs::tooltip(unsigned int status)
|
|||
return "";
|
||||
}
|
||||
|
||||
QColor StatusDefs::textColor(unsigned int status)
|
||||
{
|
||||
switch (status) {
|
||||
case RS_STATUS_OFFLINE:
|
||||
return Qt::black;
|
||||
case RS_STATUS_AWAY:
|
||||
return Qt::gray;
|
||||
case RS_STATUS_BUSY:
|
||||
return Qt::gray;
|
||||
case RS_STATUS_ONLINE:
|
||||
return Qt::darkBlue;
|
||||
case RS_STATUS_INACTIVE:
|
||||
return Qt::gray;
|
||||
}
|
||||
|
||||
std::cerr << "StatusDefs::textColor: Unknown status requested " << status;
|
||||
return Qt::black;
|
||||
}
|
||||
|
||||
QFont StatusDefs::font(unsigned int status)
|
||||
{
|
||||
QFont font;
|
||||
|
|
|
@ -36,7 +36,6 @@ public:
|
|||
static const char* imageUser(unsigned int status);
|
||||
static QString tooltip(unsigned int status);
|
||||
|
||||
static QColor textColor(unsigned int status);
|
||||
static QFont font(unsigned int status);
|
||||
|
||||
static QString peerStateString(int peerState);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue