void TabOrderEditor::contextMenuEvent(QContextMenuEvent *e) { QMenu menu(this); const int target_index = widgetIndexAt(e->pos()); QAction *setIndex = menu.addAction(tr("Start from Here")); setIndex->setEnabled(target_index >= 0); QAction *resetIndex = menu.addAction(tr("Restart")); menu.addSeparator(); QAction *showDialog = menu.addAction(tr("Tab Order List...")); showDialog->setEnabled(m_tab_order_list.size() > 1); QAction *result = menu.exec(e->globalPos()); if (result == resetIndex) { m_current_index = 0; m_beginning = true; update(); } else if (result == setIndex) { m_beginning = false; m_current_index = target_index + 1; if (m_current_index >= m_tab_order_list.size()) m_current_index = 0; update(); } else if (result == showDialog) { showTabOrderDialog(); } }
void TabOrderEditor::mousePressEvent(QMouseEvent *e) { e->accept(); if (!m_indicator_region.contains(e->pos())) { if (QWidget *child = m_bg_widget->childAt(e->pos())) { QDesignerFormEditorInterface *core = m_form_window->core(); if (core->widgetFactory()->isPassiveInteractor(child)) { QMouseEvent event(QEvent::MouseButtonPress, child->mapFromGlobal(e->globalPos()), e->button(), e->buttons(), e->modifiers()); qApp->sendEvent(child, &event); QMouseEvent event2(QEvent::MouseButtonRelease, child->mapFromGlobal(e->globalPos()), e->button(), e->buttons(), e->modifiers()); qApp->sendEvent(child, &event2); updateBackground(); } } return; } if (e->button() != Qt::LeftButton) return; const int target_index = widgetIndexAt(e->pos()); if (target_index == -1) return; m_beginning = false; if (e->modifiers() & Qt::ControlModifier) { m_current_index = target_index + 1; if (m_current_index >= m_tab_order_list.size()) m_current_index = 0; update(); return; } if (m_current_index == -1) return; m_tab_order_list.swap(target_index, m_current_index); ++m_current_index; if (m_current_index == m_tab_order_list.size()) m_current_index = 0; TabOrderCommand *cmd = new TabOrderCommand(formWindow()); cmd->init(m_tab_order_list); formWindow()->commandHistory()->push(cmd); }
void TabOrderEditor::mouseDoubleClickEvent(QMouseEvent *e) { if (e->button() != Qt::LeftButton) return; const int target_index = widgetIndexAt(e->pos()); if (target_index >= 0) return; m_beginning = true; m_current_index = 0; update(); }