void PopupMenu::popupChildMenu(PressSource source) { if (_childMenuIndex >= 0) { _menus.at(_childMenuIndex)->hideMenu(true); _childMenuIndex = -1; } if (_selected >= 0 && _selected < _menus.size() && _menus.at(_selected)) { QPoint p(_inner.x() + (rtl() ? _padding.right() : _inner.width() - _padding.left()), _inner.y() + _st.skip + itemY(_selected)); _childMenuIndex = _selected; _menus.at(_childMenuIndex)->showMenu(geometry().topLeft() + p, this, source); } }
void PopupMenu::updateSelectedItem() { if (_selected >= 0) { update(_padding.left(), _padding.top() + _st.skip + itemY(_selected), width() - _padding.left() - _padding.right(), _actions.at(_selected)->isSeparator() ? _separatorHeight : _itemHeight); } }
// Draw visible port connection relation arrows. void qjackctlConnectorView::paintEvent ( QPaintEvent * ) { if (m_pConnectView == NULL) return; if (m_pConnectView->OListView() == NULL || m_pConnectView->IListView() == NULL) return; qjackctlClientListView *pOListView = m_pConnectView->OListView(); qjackctlClientListView *pIListView = m_pConnectView->IListView(); const int yc = QWidget::pos().y(); const int yo = pOListView->pos().y(); const int yi = pIListView->pos().y(); QPainter painter(this); int x1, y1, h1; int x2, y2, h2; int i, rgb[3] = { 0x33, 0x66, 0x99 }; // Draw all lines anti-aliased... painter.setRenderHint(QPainter::Antialiasing); // Inline adaptive to darker background themes... if (QWidget::palette().window().color().value() < 0x7f) for (i = 0; i < 3; ++i) rgb[i] += 0x33; // Initialize color changer. i = 0; // Almost constants. x1 = 0; x2 = QWidget::width(); h1 = (pOListView->header())->sizeHint().height(); h2 = (pIListView->header())->sizeHint().height(); // For each output client item... const int iItemCount = pOListView->topLevelItemCount(); for (int iItem = 0; iItem < iItemCount; ++iItem) { QTreeWidgetItem *pItem = pOListView->topLevelItem(iItem); if (pItem->type() != QJACKCTL_CLIENTITEM) continue; qjackctlClientItem *pOClient = static_cast<qjackctlClientItem *> (pItem); if (pOClient == NULL) continue; // Set new connector color. ++i; QPen pen(QColor(rgb[i % 3], rgb[(i / 3) % 3], rgb[(i / 9) % 3])); // For each port item const int iChildCount = pOClient->childCount(); for (int iChild = 0; iChild < iChildCount; ++iChild) { QTreeWidgetItem *pChild = pOClient->child(iChild); if (pChild->type() != QJACKCTL_PORTITEM) continue; qjackctlPortItem *pOPort = static_cast<qjackctlPortItem *> (pChild); if (pOPort) { // Set proposed line width... const int w1 = (pOPort->isHilite() ? 2 : 1); // Get starting connector arrow coordinates. y1 = itemY(pOPort) + (yo - yc); // Get port connections... QListIterator<qjackctlPortItem *> iter(pOPort->connects()); while (iter.hasNext()) { qjackctlPortItem *pIPort = iter.next(); // Obviously, should be a connection // from pOPort to pIPort items: y2 = itemY(pIPort) + (yi - yc); pen.setWidth(pIPort->isHilite() ? 2 : w1); drawConnectionLine(&painter, x1, y1, x2, y2, h1, h2, pen); } } } } }