Commit f3e3435b authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Remove workaround for missing focus indicator for text labels

GnuPG-bug-id: 6036
parent 052383e0
Pipeline #193322 passed with stage
in 4 minutes and 57 seconds
......@@ -251,7 +251,6 @@ ResultItemWidget::ResultItemWidget(const std::shared_ptr<const Task::Result> &re
overview->setHtml(d->m_result->overview());
overview->setStyleSheet(styleSheet);
overview->setLinkColor(linkColor);
overview->setSelectTextOnFocus(true);
setFocusPolicy(overview->focusPolicy());
setFocusProxy(overview);
connect(overview, &QLabel::linkActivated,
......@@ -281,7 +280,6 @@ ResultItemWidget::ResultItemWidget(const std::shared_ptr<const Task::Result> &re
detailsLabel->setHtml(d->m_result->details());
detailsLabel->setStyleSheet(styleSheet);
detailsLabel->setLinkColor(linkColor);
detailsLabel->setSelectTextOnFocus(true);
connect(detailsLabel, &QLabel::linkActivated,
this, [this](const auto &link) { d->slotLinkActivated(link); });
vlay->addWidget(detailsLabel);
......
......@@ -98,7 +98,6 @@ public:
ui.resultLabel = new HtmlLabel{q};
ui.resultLabel->setWordWrap(true);
ui.resultLabel->setFocusPolicy(Qt::ClickFocus);
ui.resultLabel->setSelectTextOnFocus(true);
labelHelper.addLabel(ui.resultLabel);
scrollAreaLayout->addWidget(ui.resultLabel);
}
......
......@@ -43,7 +43,6 @@ public:
int anchorIndex(int start);
void invalidateAnchorCache();
bool mSelectTextOnFocus = false;
bool mAnchorsValid = false;
std::vector<AnchorData> mAnchors;
QColor linkColor;
......@@ -153,11 +152,6 @@ HtmlLabel::HtmlLabel(const QString &html, QWidget *parent)
HtmlLabel::~HtmlLabel() = default;
void HtmlLabel::setSelectTextOnFocus(bool select)
{
d->mSelectTextOnFocus = select;
}
void HtmlLabel::setHtml(const QString &html)
{
if (html.isEmpty()) {
......@@ -226,23 +220,6 @@ int HtmlLabel::selectedAnchor() const
return d->anchorIndex(selectionStart());
}
void HtmlLabel::focusInEvent(QFocusEvent *ev)
{
QLabel::focusInEvent(ev);
if (d->mSelectTextOnFocus) {
// if the text label gets focus, then select its text; this is a workaround
// for missing focus indicators for labels in many Qt styles
const Qt::FocusReason reason = ev->reason();
const auto isKeyboardFocusEvent = reason == Qt::TabFocusReason
|| reason == Qt::BacktabFocusReason
|| reason == Qt::ShortcutFocusReason;
if (!text().isEmpty() && isKeyboardFocusEvent) {
Kleo::selectLabelText(this);
}
}
}
bool HtmlLabel::focusNextPrevChild(bool next)
{
const bool result = QLabel::focusNextPrevChild(next);
......
......@@ -27,8 +27,6 @@ public:
explicit HtmlLabel(const QString &html, QWidget *parent = nullptr);
~HtmlLabel() override;
void setSelectTextOnFocus(bool select);
void setHtml(const QString &html);
void setLinkColor(const QColor &color);
......@@ -41,7 +39,6 @@ public:
int selectedAnchor() const override;
protected:
void focusInEvent(QFocusEvent *ev) override;
bool focusNextPrevChild(bool next) override;
private:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment