forked from openkylin/qt5-ukui-platformtheme
issues#I8XUSP qtreeview焦点样式绘制
This commit is contained in:
parent
09e86432f1
commit
c4f525496f
|
@ -1498,7 +1498,24 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case PE_FrameFocusRect: {
|
case PE_FrameFocusRect: {
|
||||||
if (qobject_cast<const QAbstractItemView *>(widget))
|
if (qApp->focusWidget() && qApp->focusWidget()->inherits("QTreeView"))
|
||||||
|
{
|
||||||
|
sp->initConfigTreeParameters(isUseDarkPalette(), option, widget);
|
||||||
|
QPen focusPen = sp->m_TreeParameters.treeFocusPen;
|
||||||
|
painter->save();
|
||||||
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
painter->setPen(focusPen);
|
||||||
|
int width = focusPen.width();
|
||||||
|
if(width == 1 && sp->m_TreeParameters.radius != 0)
|
||||||
|
painter->translate(0.5, 0.5);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, sp->m_TreeParameters.radius != 0);
|
||||||
|
|
||||||
|
painter->drawRoundedRect(option->rect.adjusted(width/2, width/2, -width/2, -width/2),
|
||||||
|
sp->m_TreeParameters.radius, sp->m_TreeParameters.radius);
|
||||||
|
painter->restore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (qobject_cast<const QAbstractItemView *>(widget))
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3331,7 +3348,27 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
|
||||||
painter->drawPath(path);
|
painter->drawPath(path);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
else if(isTree){
|
// else if(isTree){
|
||||||
|
// if(focus){
|
||||||
|
// auto tree = qobject_cast<const QTreeView*>(widget);
|
||||||
|
// QRect treeItemRec = QRect(tree->viewport()->x(), option->rect.y(), tree->width(), option->rect.height());
|
||||||
|
// qDebug() << "treeItemRec......" << treeItemRec;
|
||||||
|
|
||||||
|
// QStyleOptionFocusRect o;
|
||||||
|
// o.QStyleOption::operator=(*vi);
|
||||||
|
// o.rect = treeItemRec;//proxy()->subElementRect(SE_ItemViewItemFocusRect, vi, widget);
|
||||||
|
// qDebug() << "ooooooo" << o.rect << proxy()->subElementRect(SE_TreeViewDisclosureItem, vi, widget);
|
||||||
|
// painter->save();
|
||||||
|
// painter->setPen(QPen(QColor(Qt::blue), 1));
|
||||||
|
// painter->setBrush(Qt::NoBrush);
|
||||||
|
// painter->drawRect(o.rect);
|
||||||
|
// painter->restore();
|
||||||
|
|
||||||
|
// drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter, tree);
|
||||||
|
// auto t = const_cast<QTreeView *>(tree);
|
||||||
|
// t->setProperty("focusRect", vi->rect);
|
||||||
|
//drawPrimitive(QStyle::PE_IndicatorBranch, option, painter, tree);
|
||||||
|
// }
|
||||||
// auto tree = qobject_cast<const QTreeView*>(widget);
|
// auto tree = qobject_cast<const QTreeView*>(widget);
|
||||||
// auto t = const_cast<QTreeView *>(tree);
|
// auto t = const_cast<QTreeView *>(tree);
|
||||||
// tree->model()->index()
|
// tree->model()->index()
|
||||||
|
@ -3359,7 +3396,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
|
||||||
// painter->restore();
|
// painter->restore();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue