mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 07:16:11 -05:00
Merge pull request #1920 from PhenomRetroShare/Fix_GroupTreeWidgetQSS
Fix GroupTreeWidget with RSElidedItemDelegate for StyleSheet.
This commit is contained in:
commit
d2794ed6d2
@ -24,8 +24,8 @@ before_install:
|
|||||||
sudo apt-get install -y
|
sudo apt-get install -y
|
||||||
build-essential libssl-dev libsqlcipher-dev libbz2-dev libsqlite3-dev
|
build-essential libssl-dev libsqlcipher-dev libbz2-dev libsqlite3-dev
|
||||||
libupnp-dev pkg-config qt5-default libxss-dev qtmultimedia5-dev
|
libupnp-dev pkg-config qt5-default libxss-dev qtmultimedia5-dev
|
||||||
libqt5x11extras5-dev libqt5designer5 libxapian-dev qttools5-dev
|
libqt5x11extras5-dev libqt5designer5 libqt5svg5-dev
|
||||||
rapidjson-dev ;
|
libxapian-dev qttools5-dev rapidjson-dev ;
|
||||||
fi
|
fi
|
||||||
- if [ $TRAVIS_OS_NAME == osx ]; then brew update ; fi
|
- if [ $TRAVIS_OS_NAME == osx ]; then brew update ; fi
|
||||||
- if [ $TRAVIS_OS_NAME == osx ]; then brew install qt5; fi
|
- if [ $TRAVIS_OS_NAME == osx ]; then brew install qt5; fi
|
||||||
|
@ -18,28 +18,20 @@
|
|||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "GroupTreeWidget.h"
|
#include "GroupTreeWidget.h"
|
||||||
#include "ui_GroupTreeWidget.h"
|
#include "ui_GroupTreeWidget.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QHeaderView>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QMovie>
|
|
||||||
#include <QToolButton>
|
|
||||||
|
|
||||||
#include "retroshare/rsgxsflags.h"
|
#include "retroshare/rsgxsflags.h"
|
||||||
|
|
||||||
#include "PopularityDefs.h"
|
#include "PopularityDefs.h"
|
||||||
#include "RSElidedItemDelegate.h"
|
#include "RSElidedItemDelegate.h"
|
||||||
#include "RSTreeWidgetItem.h"
|
#include "RSTreeWidgetItem.h"
|
||||||
#include "gui/common/ElidedLabel.h"
|
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
#include "util/QtVersion.h"
|
#include "util/QtVersion.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define COLUMN_NAME 0
|
#define COLUMN_NAME 0
|
||||||
@ -66,9 +58,6 @@
|
|||||||
#define FILTER_NAME_INDEX 0
|
#define FILTER_NAME_INDEX 0
|
||||||
#define FILTER_DESC_INDEX 1
|
#define FILTER_DESC_INDEX 1
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ElidedLabel*)
|
|
||||||
Q_DECLARE_METATYPE(QLabel*)
|
|
||||||
|
|
||||||
GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::GroupTreeWidget)
|
QWidget(parent), ui(new Ui::GroupTreeWidget)
|
||||||
{
|
{
|
||||||
@ -151,38 +140,6 @@ GroupTreeWidget::~GroupTreeWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getNameWidget(QTreeWidget *treeWidget, QTreeWidgetItem *item, ElidedLabel *&nameLabel, QLabel *&waitLabel)
|
|
||||||
{
|
|
||||||
QWidget *widget = treeWidget->itemWidget(item, COLUMN_NAME);
|
|
||||||
|
|
||||||
if (!widget) {
|
|
||||||
widget = new QWidget;
|
|
||||||
widget->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
nameLabel = new ElidedLabel(widget);
|
|
||||||
waitLabel = new QLabel(widget);
|
|
||||||
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
|
|
||||||
waitLabel->setMovie(movie);
|
|
||||||
waitLabel->setHidden(true);
|
|
||||||
|
|
||||||
widget->setProperty("nameLabel", qVariantFromValue(nameLabel));
|
|
||||||
widget->setProperty("waitLabel", qVariantFromValue(waitLabel));
|
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
|
||||||
layout->setSpacing(0);
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
|
|
||||||
layout->addWidget(nameLabel);
|
|
||||||
layout->addWidget(waitLabel);
|
|
||||||
|
|
||||||
widget->setLayout(layout);
|
|
||||||
|
|
||||||
treeWidget->setItemWidget(item, COLUMN_NAME, widget);
|
|
||||||
} else {
|
|
||||||
nameLabel = widget->property("nameLabel").value<ElidedLabel*>();
|
|
||||||
waitLabel = widget->property("waitLabel").value<QLabel*>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GroupTreeWidget::changeEvent(QEvent *e)
|
void GroupTreeWidget::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
QWidget::changeEvent(e);
|
QWidget::changeEvent(e);
|
||||||
@ -346,11 +303,6 @@ void GroupTreeWidget::updateColors()
|
|||||||
}
|
}
|
||||||
|
|
||||||
item->setForeground(COLUMN_NAME, brush);
|
item->setForeground(COLUMN_NAME, brush);
|
||||||
|
|
||||||
ElidedLabel *nameLabel = NULL;
|
|
||||||
QLabel *waitLabel = NULL;
|
|
||||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
|
||||||
nameLabel->setTextColor(brush.color());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,23 +343,17 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc
|
|||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
ui->treeWidget->addTopLevelItem(item);
|
ui->treeWidget->addTopLevelItem(item);
|
||||||
|
|
||||||
ElidedLabel *nameLabel = NULL;
|
item->setText(COLUMN_NAME, name);
|
||||||
QLabel *waitLabel = NULL;
|
|
||||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
|
||||||
|
|
||||||
nameLabel->setText(name);
|
|
||||||
item->setData(COLUMN_DATA, ROLE_NAME, name);
|
item->setData(COLUMN_DATA, ROLE_NAME, name);
|
||||||
font = item->font(COLUMN_NAME);
|
font = item->font(COLUMN_NAME);
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
item->setFont(COLUMN_NAME, font);
|
item->setFont(COLUMN_NAME, font);
|
||||||
nameLabel->setFont(font);
|
|
||||||
item->setIcon(COLUMN_NAME, icon);
|
item->setIcon(COLUMN_NAME, icon);
|
||||||
|
|
||||||
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->setForeground(COLUMN_NAME, QBrush(textColorCategory()));
|
||||||
nameLabel->setTextColor(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);
|
||||||
@ -514,11 +460,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
|||||||
categoryItem->addChild(item);
|
categoryItem->addChild(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElidedLabel *nameLabel = NULL;
|
item->setText(COLUMN_NAME, itemInfo.name);
|
||||||
QLabel *waitLabel = NULL;
|
|
||||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
|
||||||
|
|
||||||
nameLabel->setText(itemInfo.name);
|
|
||||||
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
|
item->setData(COLUMN_DATA, ROLE_NAME, itemInfo.name);
|
||||||
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
|
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
|
||||||
|
|
||||||
@ -535,12 +477,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
|||||||
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
|
item->setData(COLUMN_DATA, ROLE_POSTS, -itemInfo.max_visible_posts);// negative for correct sorting
|
||||||
|
|
||||||
/* Set icon */
|
/* Set icon */
|
||||||
if (waitLabel->isVisible()) {
|
|
||||||
/* Item is waiting, save icon in role */
|
|
||||||
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, itemInfo.icon);
|
|
||||||
} else {
|
|
||||||
item->setIcon(COLUMN_NAME, itemInfo.icon);
|
item->setIcon(COLUMN_NAME, itemInfo.icon);
|
||||||
}
|
|
||||||
|
|
||||||
/* Set popularity */
|
/* Set popularity */
|
||||||
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
|
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
|
||||||
@ -582,7 +519,6 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
|||||||
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
item->setData(COLUMN_DATA, ROLE_COLOR, GROUPTREEWIDGET_COLOR_STANDARD);
|
||||||
}
|
}
|
||||||
item->setForeground(COLUMN_NAME, brush);
|
item->setForeground(COLUMN_NAME, brush);
|
||||||
nameLabel->setTextColor(brush.color());
|
|
||||||
|
|
||||||
/* Calculate score */
|
/* Calculate score */
|
||||||
calculateScore(item, filterText);
|
calculateScore(item, filterText);
|
||||||
@ -616,11 +552,8 @@ void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
|||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ElidedLabel *nameLabel = NULL;
|
|
||||||
QLabel *waitLabel = NULL;
|
|
||||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
|
||||||
|
|
||||||
QFont font = nameLabel->font();
|
QFont font = item->font(COLUMN_NAME);
|
||||||
|
|
||||||
if (unreadCount) {
|
if (unreadCount) {
|
||||||
item->setData(COLUMN_DATA, ROLE_UNREAD, unreadCount);
|
item->setData(COLUMN_DATA, ROLE_UNREAD, unreadCount);
|
||||||
@ -631,7 +564,7 @@ void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
|||||||
font.setBold(false);
|
font.setBold(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
nameLabel->setFont(font);
|
item->setFont(COLUMN_NAME, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id)
|
QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id)
|
||||||
@ -677,40 +610,7 @@ bool GroupTreeWidget::setWaiting(const QString &id, bool wait)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElidedLabel *nameLabel = NULL;
|
item->setData(COLUMN_NAME, Qt::StatusTipRole, wait ? "waiting" : "");
|
||||||
QLabel *waitLabel = NULL;
|
|
||||||
getNameWidget(ui->treeWidget, item, nameLabel, waitLabel);
|
|
||||||
if (wait) {
|
|
||||||
if (waitLabel->isVisible()) {
|
|
||||||
/* Allready waiting */
|
|
||||||
} else {
|
|
||||||
/* Save icon in role */
|
|
||||||
QIcon icon = item->icon(COLUMN_NAME);
|
|
||||||
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, icon);
|
|
||||||
|
|
||||||
/* Create empty icon of the same size */
|
|
||||||
QPixmap pixmap(ui->treeWidget->iconSize());
|
|
||||||
pixmap.fill(Qt::transparent);
|
|
||||||
item->setIcon(COLUMN_NAME, QIcon(pixmap));
|
|
||||||
|
|
||||||
/* Show waitLabel and hide nameLabel */
|
|
||||||
nameLabel->setHidden(true);
|
|
||||||
waitLabel->setVisible(true);
|
|
||||||
waitLabel->movie()->start();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (waitLabel->isVisible()) {
|
|
||||||
/* Show nameLabel and hide waitLabel */
|
|
||||||
waitLabel->movie()->stop();
|
|
||||||
waitLabel->setHidden(true);
|
|
||||||
nameLabel->setVisible(true);
|
|
||||||
|
|
||||||
/* Set icon saved in role */
|
|
||||||
item->setIcon(COLUMN_NAME, item->data(COLUMN_DATA, ROLE_SAVED_ICON).value<QIcon>());
|
|
||||||
item->setData(COLUMN_DATA, ROLE_SAVED_ICON, QIcon());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,6 +619,25 @@ RSTreeWidget *GroupTreeWidget::treeWidget()
|
|||||||
return ui->treeWidget;
|
return ui->treeWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GroupTreeWidget::setWaitingSVG(const QString &value)
|
||||||
|
{
|
||||||
|
if (ui->treeWidget->itemDelegate())
|
||||||
|
ui->treeWidget->itemDelegate()->setProperty("waitingSVG",value);
|
||||||
|
|
||||||
|
for(int i=0; i<COLUMN_COUNT; i++)
|
||||||
|
if (ui->treeWidget->itemDelegateForColumn(i))
|
||||||
|
ui->treeWidget->itemDelegateForColumn(i)->setProperty("waitingSVG",value);
|
||||||
|
}
|
||||||
|
void GroupTreeWidget::setWaitingSVG_Over(const bool &value)
|
||||||
|
{
|
||||||
|
if (ui->treeWidget->itemDelegate())
|
||||||
|
ui->treeWidget->itemDelegate()->setProperty("waitingSVG_Over",value);
|
||||||
|
|
||||||
|
for(int i=0; i<COLUMN_COUNT; i++)
|
||||||
|
if (ui->treeWidget->itemDelegateForColumn(i))
|
||||||
|
ui->treeWidget->itemDelegateForColumn(i)->setProperty("waitingSVG_Over",value);
|
||||||
|
}
|
||||||
|
|
||||||
bool GroupTreeWidget::getGroupName(QString id, QString& name)
|
bool GroupTreeWidget::getGroupName(QString id, QString& name)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = getItemFromId(id);
|
QTreeWidgetItem *item = getItemFromId(id);
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#ifndef GROUPTREEWIDGET_H
|
#ifndef GROUPTREEWIDGET_H
|
||||||
#define GROUPTREEWIDGET_H
|
#define GROUPTREEWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
@ -68,6 +66,8 @@ class GroupTreeWidget : public QWidget
|
|||||||
|
|
||||||
Q_PROPERTY(QColor textColorCategory READ textColorCategory WRITE setTextColorCategory)
|
Q_PROPERTY(QColor textColorCategory READ textColorCategory WRITE setTextColorCategory)
|
||||||
Q_PROPERTY(QColor textColorPrivateKey READ textColorPrivateKey WRITE setTextColorPrivateKey)
|
Q_PROPERTY(QColor textColorPrivateKey READ textColorPrivateKey WRITE setTextColorPrivateKey)
|
||||||
|
Q_PROPERTY(QString waitingSVG WRITE setWaitingSVG)
|
||||||
|
Q_PROPERTY(bool waitingSVG_Over WRITE setWaitingSVG_Over)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GroupTreeWidget(QWidget *parent = 0);
|
GroupTreeWidget(QWidget *parent = 0);
|
||||||
@ -109,6 +109,10 @@ public:
|
|||||||
|
|
||||||
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
|
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
|
||||||
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
|
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
|
||||||
|
|
||||||
|
void setWaitingSVG(const QString &value);
|
||||||
|
void setWaitingSVG_Over(const bool &value);
|
||||||
|
|
||||||
bool getGroupName(QString id, QString& name);
|
bool getGroupName(QString id, QString& name);
|
||||||
|
|
||||||
int subscribeFlags(const QString &id);
|
int subscribeFlags(const QString &id);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "gui/common/StyledElidedLabel.h"
|
#include "gui/common/StyledElidedLabel.h"
|
||||||
#include "util/rsdebug.h"
|
#include "util/rsdebug.h"
|
||||||
|
|
||||||
|
#include <QAbstractItemView>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
@ -32,7 +33,9 @@
|
|||||||
RSElidedItemDelegate::RSElidedItemDelegate(QObject *parent)
|
RSElidedItemDelegate::RSElidedItemDelegate(QObject *parent)
|
||||||
: RSStyledItemDelegate(parent)
|
: RSStyledItemDelegate(parent)
|
||||||
, mOnlyPlainText(false), mPaintRoundedRect(true)
|
, mOnlyPlainText(false), mPaintRoundedRect(true)
|
||||||
|
, mWaitingSVG(":/icons/svg/waiting.svg"), mWaitingSVG_Over(true)
|
||||||
{
|
{
|
||||||
|
mSVG_Renderer = new QSvgRenderer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize RSElidedItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
QSize RSElidedItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
@ -123,6 +126,14 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
ownStyle->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &option, painter, widget);
|
ownStyle->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &option, painter, widget);
|
||||||
}
|
}
|
||||||
// draw the icon
|
// draw the icon
|
||||||
|
{
|
||||||
|
if (!ownOption.icon.isNull())
|
||||||
|
{
|
||||||
|
QString status;
|
||||||
|
if (index.data(Qt::StatusTipRole).canConvert(QMetaType::QString))
|
||||||
|
status = index.data(Qt::StatusTipRole).toString();
|
||||||
|
|
||||||
|
if (mWaitingSVG_Over || (status.toLower() != "waiting"))
|
||||||
{
|
{
|
||||||
QIcon::Mode mode = QIcon::Normal;
|
QIcon::Mode mode = QIcon::Normal;
|
||||||
if (!(ownOption.state & QStyle::State_Enabled))
|
if (!(ownOption.state & QStyle::State_Enabled))
|
||||||
@ -132,6 +143,20 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
QIcon::State state = ownOption.state & QStyle::State_Open ? QIcon::On : QIcon::Off;
|
QIcon::State state = ownOption.state & QStyle::State_Open ? QIcon::On : QIcon::Off;
|
||||||
ownOption.icon.paint(painter, iconRect, ownOption.decorationAlignment, mode, state);
|
ownOption.icon.paint(painter, iconRect, ownOption.decorationAlignment, mode, state);
|
||||||
}
|
}
|
||||||
|
if (status.toLower() == "waiting")
|
||||||
|
{
|
||||||
|
if (mLastSVG_Loaded != mWaitingSVG)
|
||||||
|
mSVG_Renderer->load(mWaitingSVG);
|
||||||
|
mLastSVG_Loaded = mWaitingSVG;
|
||||||
|
|
||||||
|
const QAbstractItemView* aiv = dynamic_cast<const QAbstractItemView*>(option.widget);
|
||||||
|
if (aiv)
|
||||||
|
connect(mSVG_Renderer, SIGNAL(repaintNeeded()), aiv->viewport(),SLOT(update()));
|
||||||
|
|
||||||
|
mSVG_Renderer->render(painter, iconRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// draw the text
|
// draw the text
|
||||||
if (!ownOption.text.isEmpty()) {
|
if (!ownOption.text.isEmpty()) {
|
||||||
QPalette::ColorGroup cg = ownOption.state & QStyle::State_Enabled
|
QPalette::ColorGroup cg = ownOption.state & QStyle::State_Enabled
|
||||||
@ -141,6 +166,7 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
if (ownOption.state & QStyle::State_Selected) {
|
if (ownOption.state & QStyle::State_Selected) {
|
||||||
painter->setPen(ownOption.palette.color(cg, QPalette::HighlightedText));
|
painter->setPen(ownOption.palette.color(cg, QPalette::HighlightedText));
|
||||||
} else {
|
} else {
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
|
||||||
if (ownOption.state & QStyle::State_MouseOver) {
|
if (ownOption.state & QStyle::State_MouseOver) {
|
||||||
//TODO: Manage to get palette with HOVER css pseudoclass
|
//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
|
// For now this is hidden by Qt: https://code.woboq.org/qt5/qtbase/src/widgets/styles/qstylesheetstyle.cpp.html#6103
|
||||||
@ -227,6 +253,7 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
painter->setPen(moColor);
|
painter->setPen(moColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
if (textColor.spec()==QColor::Invalid) {
|
if (textColor.spec()==QColor::Invalid) {
|
||||||
painter->setPen(ownOption.palette.color(cg, QPalette::Text));
|
painter->setPen(ownOption.palette.color(cg, QPalette::Text));
|
||||||
} else { //Only get color from index for unselected(as Qt does)
|
} else { //Only get color from index for unselected(as Qt does)
|
||||||
|
@ -23,11 +23,18 @@
|
|||||||
|
|
||||||
#include <gui/common/RSItemDelegate.h>
|
#include <gui/common/RSItemDelegate.h>
|
||||||
|
|
||||||
|
#include <QSvgRenderer>
|
||||||
|
|
||||||
class RSElidedItemDelegate : public RSStyledItemDelegate
|
class RSElidedItemDelegate : public RSStyledItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
// For now, these properties cannot be changed by StyleSheet
|
||||||
|
// If needed, you can add properties to owner widget then copy them in this delegate.
|
||||||
Q_PROPERTY(bool isOnlyPlainText READ isOnlyPlainText WRITE setOnlyPlainText)
|
Q_PROPERTY(bool isOnlyPlainText READ isOnlyPlainText WRITE setOnlyPlainText)
|
||||||
Q_PROPERTY(bool paintRoundedRect READ paintRoundedRect WRITE setPaintRoundedRect)
|
Q_PROPERTY(bool paintRoundedRect READ paintRoundedRect WRITE setPaintRoundedRect)
|
||||||
|
Q_PROPERTY(QString waitingSVG READ waitingSVG WRITE setWaitingSVG)
|
||||||
|
Q_PROPERTY(bool waitingSVG_Over READ waitingSVG_Over WRITE setWaitingSVG_Over)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RSElidedItemDelegate(QObject *parent = 0);
|
RSElidedItemDelegate(QObject *parent = 0);
|
||||||
@ -39,6 +46,10 @@ public:
|
|||||||
void setOnlyPlainText(const bool &value) { mOnlyPlainText = value; }
|
void setOnlyPlainText(const bool &value) { mOnlyPlainText = value; }
|
||||||
bool paintRoundedRect() const { return mPaintRoundedRect; }
|
bool paintRoundedRect() const { return mPaintRoundedRect; }
|
||||||
void setPaintRoundedRect(const bool &value) { mPaintRoundedRect = value; }
|
void setPaintRoundedRect(const bool &value) { mPaintRoundedRect = value; }
|
||||||
|
QString waitingSVG() const {return mWaitingSVG; }
|
||||||
|
void setWaitingSVG(const QString &value) {mWaitingSVG = value; }
|
||||||
|
bool waitingSVG_Over() const {return mWaitingSVG_Over; }
|
||||||
|
void setWaitingSVG_Over(const bool &value) {mWaitingSVG_Over = value; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool editorEvent(QEvent *event,
|
bool editorEvent(QEvent *event,
|
||||||
@ -49,7 +60,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
bool mOnlyPlainText;
|
bool mOnlyPlainText;
|
||||||
bool mPaintRoundedRect;
|
bool mPaintRoundedRect;
|
||||||
|
QSvgRenderer* mSVG_Renderer;
|
||||||
|
mutable QString mLastSVG_Loaded;
|
||||||
|
QString mWaitingSVG;
|
||||||
|
bool mWaitingSVG_Over;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSELIDEDITEMDELEGATE_H
|
#endif // RSELIDEDITEMDELEGATE_H
|
||||||
|
@ -217,6 +217,7 @@
|
|||||||
<file>icons/svg/thumbs-up.svg</file>
|
<file>icons/svg/thumbs-up.svg</file>
|
||||||
<file>icons/svg/upload.svg</file>
|
<file>icons/svg/upload.svg</file>
|
||||||
<file>icons/svg/video.svg</file>
|
<file>icons/svg/video.svg</file>
|
||||||
|
<file>icons/svg/waiting.svg</file>
|
||||||
<file>icons/switch00_128.png</file>
|
<file>icons/switch00_128.png</file>
|
||||||
<file>icons/switch01_128.png</file>
|
<file>icons/switch01_128.png</file>
|
||||||
<file>icons/switch10_128.png</file>
|
<file>icons/switch10_128.png</file>
|
||||||
|
32
retroshare-gui/src/gui/icons/svg/waiting.svg
Normal file
32
retroshare-gui/src/gui/icons/svg/waiting.svg
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
height="128"
|
||||||
|
width="128"
|
||||||
|
xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<circle cx="64" cy="64" fill="none"
|
||||||
|
stroke="#039bd5" stroke-opacity="1"
|
||||||
|
stroke-width="10" r="32"
|
||||||
|
stroke-dasharray="40,20,10,15,10,20"
|
||||||
|
stroke-linecap="round">
|
||||||
|
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="2s" values="0 64 64;360 64 64" keyTimes="0;1"/>
|
||||||
|
</circle>
|
||||||
|
<circle cx="64" cy="64" fill="none"
|
||||||
|
stroke="#ffffff" stroke-opacity="1"
|
||||||
|
stroke-width="10" r="22"
|
||||||
|
stroke-dasharray="40,20,10,15,10,20"
|
||||||
|
stroke-linecap="round">
|
||||||
|
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="2s" values="360 64 64;0 64 64" keyTimes="0;1"/>
|
||||||
|
</circle>
|
||||||
|
<circle cx="64" cy="64" fill="none"
|
||||||
|
stroke="#000000" stroke-opacity="1"
|
||||||
|
stroke-width="10" r="42"
|
||||||
|
stroke-dasharray="40,20,10,15,10,20"
|
||||||
|
stroke-linecap="round">
|
||||||
|
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="2s" values="360 64 64;0 64 64" keyTimes="0;1"/>
|
||||||
|
</circle>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -2143,3 +2143,10 @@ PostedCardView > QFrame#mainFrame[new=true] {
|
|||||||
WireGroupItem QFrame#frame{
|
WireGroupItem QFrame#frame{
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GxsChannelDialog GroupTreeWidget#groupTreeWidget{
|
||||||
|
background-color: #F050F0;
|
||||||
|
qproperty-waitingSVG_Over: false;
|
||||||
|
qproperty-waitingSVG: url(%THISPATH%/qdarkstyle/channel_waiting.svg);
|
||||||
|
}
|
||||||
|
|
||||||
|
26
retroshare-gui/src/qss/qdarkstyle/channel_waiting.svg
Normal file
26
retroshare-gui/src/qss/qdarkstyle/channel_waiting.svg
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
height="128"
|
||||||
|
width="128"
|
||||||
|
xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<circle cx="64" cy="64" fill="#039bd5" fill-opacity="1" stroke="none" stroke-width="1.6" r="64"/>
|
||||||
|
<g>
|
||||||
|
<rect x="20" y="32" width="84" height="64"
|
||||||
|
fill="none"
|
||||||
|
stroke-width="5" stroke="#ffffff" stroke-opacity="1"
|
||||||
|
rx="16">
|
||||||
|
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1s" values="0 64 64;360 64 64" keyTimes="0;1"/>
|
||||||
|
</rect>
|
||||||
|
<polygon points="55.92,50 80.16,64 55.92,78"
|
||||||
|
fill="none"
|
||||||
|
stroke-width="5" stroke="#ffffff" stroke-opacity="1"
|
||||||
|
stroke-linejoin="round" rx="10">
|
||||||
|
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1s" values="360 64 64;0 64 64" keyTimes="0;1"/>
|
||||||
|
</polygon>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 996 B |
@ -19,7 +19,7 @@
|
|||||||
!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri")
|
!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri")
|
||||||
|
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
QT += network xml
|
QT += network xml svg
|
||||||
CONFIG += qt gui uic qrc resources idle
|
CONFIG += qt gui uic qrc resources idle
|
||||||
CONFIG += console
|
CONFIG += console
|
||||||
TARGET = retroshare
|
TARGET = retroshare
|
||||||
|
Loading…
x
Reference in New Issue
Block a user