Draw a simple rounded rectangle to indicate keyboard focus in the tag browser

This commit is contained in:
Kovid Goyal 2020-11-02 21:55:55 +05:30
parent 9ac1509053
commit a575a05530
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 1 deletions

View File

@ -352,7 +352,22 @@ class CalibreStyle: public QProxyStyle {
}
}
return; // }}}
case PE_FrameFocusRect: // }}}
if (!widget || !widget->property("frame_for_focus").toBool())
break;
if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {
if (!(fropt->state & State_KeyboardFocusChange))
break;
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->translate(0.5, 0.5);
painter->setPen(option->palette.color(QPalette::Text));
painter->setBrush(Qt::transparent);
painter->drawRoundedRect(option->rect.adjusted(0, 0, -1, -1), 4, 4);
painter->restore();
return;
}
break; // }}}
default:
break;
}

View File

@ -172,6 +172,7 @@ class TagsView(QTreeView): # {{{
def __init__(self, parent=None):
QTreeView.__init__(self, parent=None)
self.setProperty('frame_for_focus', True)
self.setMouseTracking(True)
self.alter_tb = None
self.disable_recounting = False