Skip to content
Permalink
Browse files

Merge PR #2661: Restore green background for strong certificate in Us…

…erView (root channel) and ServerView (ConnectDialog)
  • Loading branch information...
mkrautz committed Nov 26, 2016
2 parents 89b3916 + b3a1722 commit 153c0aa9d5b4a12546447f3204a057c395d99d8d
Showing with 34 additions and 0 deletions.
  1. +18 −0 src/mumble/ConnectDialog.cpp
  2. +10 −0 src/mumble/ConnectDialog.h
  3. +6 −0 src/mumble/UserView.cpp
@@ -53,6 +53,22 @@ void PingStats::reset() {
init();
}

ServerViewDelegate::ServerViewDelegate(QObject *p) : QStyledItemDelegate(p) {
}

ServerViewDelegate::~ServerViewDelegate() {
}

void ServerViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
// Allow a ServerItem's BackgroundRole to override the current theme's default color.
QVariant bg = index.data(Qt::BackgroundRole);
if (bg.isValid()) {
painter->fillRect(option.rect, bg.value<QBrush>());
}

QStyledItemDelegate::paint(painter, option, index);
}

ServerView::ServerView(QWidget *p) : QTreeWidget(p) {
siFavorite = new ServerItem(tr("Favorite"), ServerItem::FavoriteType);
addTopLevelItem(siFavorite);
@@ -838,6 +854,8 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo
qpbAdd->setHidden(g.s.disableConnectDialogEditing);
qpbEdit->setHidden(g.s.disableConnectDialogEditing);

qtwServers->setItemDelegate(new ServerViewDelegate());

// Hide ping and user count if we are not allowed to ping.
if (!bAllowPing) {
qtwServers->setColumnCount(1);
@@ -74,6 +74,16 @@ struct PingStats {

class ServerItem;

class ServerViewDelegate : public QStyledItemDelegate {
Q_OBJECT
Q_DISABLE_COPY(ServerViewDelegate)
public:
ServerViewDelegate(QObject *p = NULL);
~ServerViewDelegate();

void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
};

class ServerView : public QTreeWidget {
Q_OBJECT
Q_DISABLE_COPY(ServerView)
@@ -28,6 +28,12 @@ void UserDelegate::paint(QPainter * painter, const QStyleOptionViewItem &option,
QVariant data = m->data(idxc1);
QList<QVariant> ql = data.toList();

// Allow a UserView's BackgroundRole to override the current theme's default color.
QVariant bg = index.data(Qt::BackgroundRole);
if (bg.isValid()) {
painter->fillRect(option.rect, bg.value<QBrush>());
}

painter->save();

QStyleOptionViewItemV4 o = option;

0 comments on commit 153c0aa

Please sign in to comment.
You can’t perform that action at this time.