Merge pull request #14393 from NomAnor/visibility-icon
Change visibility icon default to enabled and tweak visuals
This commit is contained in:
@@ -1688,15 +1688,19 @@ void TreeWidget::mousePressEvent(QMouseEvent* event)
|
||||
// Rect occupied by the item relative to viewport
|
||||
auto iconRect = visualItemRect(objitem);
|
||||
|
||||
auto style = this->style();
|
||||
|
||||
// If the checkboxes are visible, these are displayed before the icon
|
||||
// and we have to compensate for its width.
|
||||
if (isSelectionCheckBoxesEnabled()) {
|
||||
auto style = this->style();
|
||||
int checkboxWidth = style->pixelMetric(QStyle::PM_IndicatorWidth)
|
||||
+ style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
|
||||
iconRect.adjust(checkboxWidth, 0, 0, 0);
|
||||
}
|
||||
|
||||
int const margin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
|
||||
iconRect.adjust(margin, 0, 0, 0);
|
||||
|
||||
// We are interested in the first icon (visibility icon)
|
||||
iconRect.setWidth(iconSize());
|
||||
|
||||
@@ -5308,7 +5312,7 @@ void DocumentObjectItem::testStatus(bool resetStatus, QIcon& icon1, QIcon& icon2
|
||||
previousStatus = currentStatus;
|
||||
|
||||
QIcon::Mode mode = QIcon::Normal;
|
||||
if (isVisibilityIconEnabled() || (currentStatus & Status::Visible)) {
|
||||
if (currentStatus & Status::Visible) {
|
||||
// Note: By default the foreground, i.e. text color is invalid
|
||||
// to make use of the default color of the tree widget's palette.
|
||||
// If we temporarily set this color to dark and reset to an invalid
|
||||
@@ -5426,17 +5430,19 @@ void DocumentObjectItem::testStatus(bool resetStatus, QIcon& icon1, QIcon& icon2
|
||||
|
||||
// Prepend the visibility pixmap to the final icon pixmaps and use these as the icon.
|
||||
QIcon new_icon;
|
||||
auto style = this->getTree()->style();
|
||||
int const spacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
|
||||
for (auto state: {QIcon::On, QIcon::Off}) {
|
||||
QPixmap px_org = icon.pixmap(0xFFFF, 0xFFFF, QIcon::Normal, state);
|
||||
|
||||
QPixmap px(2*px_org.width(), px_org.height());
|
||||
QPixmap px(2*px_org.width() + spacing, px_org.height());
|
||||
px.fill(Qt::transparent);
|
||||
|
||||
QPainter pt;
|
||||
pt.begin(&px);
|
||||
pt.setPen(Qt::NoPen);
|
||||
pt.drawPixmap(0, 0, px_org.width(), px_org.height(), (currentStatus & Status::Visible) ? pxVisible : pxInvisible);
|
||||
pt.drawPixmap(px_org.width(), 0, px_org.width(), px_org.height(), px_org);
|
||||
pt.drawPixmap(px_org.width() + spacing, 0, px_org.width(), px_org.height(), px_org);
|
||||
pt.end();
|
||||
|
||||
new_icon.addPixmap(px, QIcon::Normal, state);
|
||||
|
||||
Reference in New Issue
Block a user