triggerVisibleIndexRangeUpdate();
}
+void KFileItemListView::focusInEvent(QFocusEvent *event)
+{
+ Q_UNUSED(event)
+ updateSelectedWidgets();
+}
+
+void KFileItemListView::focusOutEvent(QFocusEvent *event)
+{
+ Q_UNUSED(event)
+ updateSelectedWidgets();
+}
+
+void KFileItemListView::updateSelectedWidgets()
+{
+ const auto visibleWidgets = visibleItemListWidgets();
+ for (KItemListWidget *widget : visibleWidgets) {
+ if (widget->isSelected()) {
+ auto w = qobject_cast<KFileItemListWidget *>(widget);
+ if (w) {
+ w->forceUpdate();
+ }
+ }
+ }
+}
+
void KFileItemListView::slotItemsRemoved(const KItemRangeList &itemRanges)
{
KStandardItemListView::slotItemsRemoved(itemRanges);
void onTransactionBegin() override;
void onTransactionEnd() override;
void resizeEvent(QGraphicsSceneResizeEvent *event) override;
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
protected Q_SLOTS:
void slotItemsRemoved(const KItemRangeList &itemRanges) override;
QSize availableIconSize() const;
private:
+ void updateSelectedWidgets();
+
KFileItemModelRolesUpdater *m_modelRolesUpdater;
QTimer *m_updateVisibleIndexRangeTimer;
QTimer *m_updateIconSizeTimer;
view->setHoverSequenceState(itemUrl, 0);
}
+void KFileItemListWidget::forceUpdate()
+{
+ updateAdditionalInfoTextColor();
+ // icon layout does not include the icons in the item selection rectangle
+ // so its icon does not need updating
+ if (listView()->itemLayout() != KStandardItemListView::ItemLayout::IconsLayout) {
+ invalidateIconCache();
+ }
+ update();
+}
+
void KFileItemListWidget::hoverSequenceIndexChanged(int sequenceIndex)
{
KFileItemListView *view = listView();
static KItemListWidgetInformant *createInformant();
+ /// Force-update the displayed icon
+ void forceUpdate();
+
protected:
virtual void hoverSequenceStarted() override;
virtual void hoverSequenceIndexChanged(int sequenceIndex) override;
smoothScroller->handleWheelEvent(event);
}
+void KItemListContainer::focusInEvent(QFocusEvent *event)
+{
+ KItemListView *view = m_controller->view();
+ if (view) {
+ QApplication::sendEvent(view, event);
+ }
+}
+
+void KItemListContainer::focusOutEvent(QFocusEvent *event)
+{
+ KItemListView *view = m_controller->view();
+ if (view) {
+ QApplication::sendEvent(view, event);
+ }
+}
+
void KItemListContainer::slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous)
{
Q_UNUSED(previous)
void resizeEvent(QResizeEvent *event) override;
void scrollContentsBy(int dx, int dy) override;
void wheelEvent(QWheelEvent *event) override;
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
private Q_SLOTS:
void slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
updateFont();
break;
+ case QEvent::FocusIn:
+ focusInEvent(static_cast<QFocusEvent *>(event));
+ event->accept();
+ return true;
+ break;
+
+ case QEvent::FocusOut:
+ focusOutEvent(static_cast<QFocusEvent *>(event));
+ event->accept();
+ return true;
+ break;
+
default:
// Forward all other events to the controller and handle them there
if (!m_editingRole && m_controller && m_controller->processEvent(event, transform())) {
drawItemStyleOption(painter, widget, activeState | QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item);
}
- if (m_current && m_editedRole.isEmpty() && widget->hasFocus()) {
+ if (m_current && m_editedRole.isEmpty()) {
QStyleOptionFocusRect focusRectOption;
initStyleOption(&focusRectOption);
focusRectOption.rect = textFocusRect().toRect();
focusRectOption.state = QStyle::State_Enabled | QStyle::State_Item | QStyle::State_KeyboardFocusChange;
- if (m_selected) {
+ if (m_selected && widget->hasFocus()) {
focusRectOption.state |= QStyle::State_Selected;
}
}
painter->setFont(m_customizedFont);
- painter->setPen(textColor(widget));
+ painter->setPen(textColor(*widget));
const TextInfo *textInfo = m_textInfo.value("text");
if (!textInfo) {
}
}
-QColor KStandardItemListWidget::textColor(QWidget *widget) const
+QColor KStandardItemListWidget::textColor(const QWidget &widget) const
{
if (!isSelected()) {
if (m_isHidden) {
}
}
- const QPalette::ColorGroup group = isActiveWindow() && widget->hasFocus() ? QPalette::Active : QPalette::Inactive;
+ const QPalette::ColorGroup group = isActiveWindow() && widget.hasFocus() ? QPalette::Active : QPalette::Inactive;
const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : normalTextColorRole();
return styleOption().palette.color(group, role);
}
void KStandardItemListWidget::updateAdditionalInfoTextColor()
{
QColor c1;
+ const bool hasFocus = scene()->views()[0]->parentWidget()->hasFocus();
if (m_customTextColor.isValid()) {
c1 = m_customTextColor;
- } else if (isSelected() && (m_layout != DetailsLayout || m_highlightEntireRow)) {
+ } else if (isSelected() && hasFocus && (m_layout != DetailsLayout || m_highlightEntireRow)) {
// The detail text colour needs to match the main text (HighlightedText) for the same level
// of readability. We short circuit early here to avoid interpolating with another colour.
m_additionalInfoTextColor = styleOption().palette.color(QPalette::HighlightedText);
virtual QPalette::ColorRole normalTextColorRole() const;
void setTextColor(const QColor &color);
- QColor textColor(QWidget *widget) const;
+ QColor textColor(const QWidget &widget) const;
void setOverlay(const QPixmap &overlay);
QPixmap overlay() const;
QPointF pos;
QStaticText staticText;
};
+ void updateAdditionalInfoTextColor();
public Q_SLOTS:
void finishRoleEditing();
void updateCompactLayoutTextCache();
void updateDetailsLayoutTextCache();
- void updateAdditionalInfoTextColor();
-
void drawPixmap(QPainter *painter, const QPixmap &pixmap);
void drawSiblingsInformation(QPainter *painter);