Changeset View
Changeset View
Standalone View
Standalone View
plugin/kquickstyleitem.cpp
Show First 20 Lines • Show All 1546 Lines • ▼ Show 20 Line(s) | |||||
1547 | void KQuickStyleItem::setControl(QQuickItem *control) | 1547 | void KQuickStyleItem::setControl(QQuickItem *control) | ||
1548 | { | 1548 | { | ||
1549 | if (control == m_control) { | 1549 | if (control == m_control) { | ||
1550 | return; | 1550 | return; | ||
1551 | } | 1551 | } | ||
1552 | 1552 | | |||
1553 | if (m_control) { | 1553 | if (m_control) { | ||
1554 | m_control->removeEventFilter(this); | 1554 | m_control->removeEventFilter(this); | ||
1555 | disconnect(m_control, 0, this, 0); | ||||
1555 | } | 1556 | } | ||
1556 | 1557 | | |||
1557 | m_control = control; | 1558 | m_control = control; | ||
1559 | | ||||
1560 | if (m_control) { | ||||
1558 | m_control->installEventFilter(this); | 1561 | m_control->installEventFilter(this); | ||
1559 | 1562 | | |||
1563 | if (m_control->window()) { | ||||
1564 | m_window = m_control->window(); | ||||
1565 | m_window->installEventFilter(this); | ||||
1566 | } | ||||
1567 | connect(m_control, &QQuickItem::windowChanged, this, | ||||
1568 | [this](QQuickWindow *window) { | ||||
1569 | if (m_window) { | ||||
1570 | m_window->removeEventFilter(this); | ||||
1571 | } | ||||
1572 | m_window = window; | ||||
1573 | if (m_window) { | ||||
1574 | m_window->installEventFilter(this); | ||||
1575 | } | ||||
1576 | }); | ||||
1577 | } | ||||
1578 | | ||||
1560 | emit controlChanged(); | 1579 | emit controlChanged(); | ||
1561 | } | 1580 | } | ||
1562 | 1581 | | |||
1563 | QSGNode *KQuickStyleItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) | 1582 | QSGNode *KQuickStyleItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) | ||
1564 | { | 1583 | { | ||
1565 | if (m_image.isNull()) { | 1584 | if (m_image.isNull()) { | ||
1566 | delete node; | 1585 | delete node; | ||
1567 | return nullptr; | 1586 | return nullptr; | ||
Show All 36 Lines | 1611 | { | |||
1604 | } else if (!m_image.isNull()) { | 1623 | } else if (!m_image.isNull()) { | ||
1605 | m_image = QImage(); | 1624 | m_image = QImage(); | ||
1606 | QQuickItem::update(); | 1625 | QQuickItem::update(); | ||
1607 | } | 1626 | } | ||
1608 | } | 1627 | } | ||
1609 | 1628 | | |||
1610 | bool KQuickStyleItem::eventFilter(QObject *watched, QEvent *event) | 1629 | bool KQuickStyleItem::eventFilter(QObject *watched, QEvent *event) | ||
1611 | { | 1630 | { | ||
1631 | if (watched == m_control) { | ||||
1612 | if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) { | 1632 | if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) { | ||
1613 | QFocusEvent *fe = static_cast<QFocusEvent *>(event); | 1633 | QFocusEvent *fe = static_cast<QFocusEvent *>(event); | ||
1614 | m_lastFocusReason = fe->reason(); | 1634 | m_lastFocusReason = fe->reason(); | ||
1615 | } | 1635 | } | ||
1636 | } else if (watched == m_window.data()) { | ||||
broulik: Check `watched == m_window`? | |||||
1637 | if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { | ||||
You could just check KeyPress || KeyRelease since you're doing the same thing in both branches broulik: You could just check `KeyPress || KeyRelease` since you're doing the same thing in both branches | |||||
1638 | QKeyEvent *ke = static_cast<QKeyEvent *>(event); | ||||
1639 | if (ke->key() == Qt::Key_Alt) { | ||||
1640 | updateItem(); | ||||
1641 | } | ||||
1642 | | ||||
1643 | } | ||||
1644 | } | ||||
1616 | 1645 | | |||
1617 | return QQuickItem::eventFilter(watched, event); | 1646 | return QQuickItem::eventFilter(watched, event); | ||
1618 | } | 1647 | } | ||
1619 | 1648 | | |||
1620 | QPixmap QQuickTableRowImageProvider1::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) | 1649 | QPixmap QQuickTableRowImageProvider1::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) | ||
1621 | { | 1650 | { | ||
1622 | Q_UNUSED (requestedSize); | 1651 | Q_UNUSED (requestedSize); | ||
1623 | int width = 16; | 1652 | int width = 16; | ||
Show All 39 Lines |
Check watched == m_window?