void HistoryManager::contextMenuRequested(const QPoint &position) { if (!ui->historyTree->itemAt(position)) { return; } QUrl link = QUrl::fromEncoded(ui->historyTree->itemAt(position)->text(1).toUtf8()); if (link.isEmpty()) { return; } QMenu menu; menu.addAction(tr("Open link in actual tab"), getQupZilla(), SLOT(loadActionUrl()))->setData(link); menu.addAction(tr("Open link in new tab"), this, SLOT(loadInNewTab()))->setData(link); menu.addSeparator(); menu.addAction(tr("Copy address"), this, SLOT(copyUrl()))->setData(link); //Prevent choosing first option with double rightclick QPoint pos = QCursor::pos(); QPoint p(pos.x(), pos.y() + 1); menu.exec(p); }
void TicketListV::rightClickMenu(const QPoint& pos){ QPoint point = this->ui->tableView->mapToGlobal(pos); QMenu rightClickMenu; QAction* editTicketAction = rightClickMenu.addAction("Edit Ticket"); QAction* editCustomerAction = rightClickMenu.addAction("Edit Customer"); QAction* ticketHistoryAction = rightClickMenu.addAction("Ticket History"); QAction* select = rightClickMenu.exec(point); if(select == editTicketAction){ editTicket(); } else if (select == editCustomerAction){ editCus(); } else if (select == ticketHistoryAction){ QItemSelectionModel *selectModel = ui->tableView->selectionModel(); QModelIndex row = selectModel->currentIndex(); QString stringID = ui->tableView->model()->data(ui->tableView->model()->index(row.row(), 0)).toString(); HistoryView *historyView = new HistoryView(0, stringID); historyView->exec(); } }
QModelIndex cast( NifModel * nif, const QModelIndex & index ) { QModelIndex idx = index; if ( nif->itemType( index ).toLower() != "texcoord" ) { idx = nif->getIndex( nif->getBlock( index ), "UV Sets" ); } QMenu menu; static const char * const flipCmds[3] = { "S = 1.0 - S", "T = 1.0 - T", "S <=> T" }; for ( int c = 0; c < 3; c++ ) menu.addAction( flipCmds[c] ); QAction * act = menu.exec( QCursor::pos() ); if ( act ) { for ( int c = 0; c < 3; c++ ) if ( act->text() == flipCmds[c] ) flip( nif, idx, c ); } return index; }
/** * Allow changing terrain properties through a context menu. */ void TerrainView::contextMenuEvent(QContextMenuEvent *event) { Terrain *terrain = terrainAt(indexAt(event->pos())); if (!terrain) return; if (!mTilesetDocument) return; QMenu menu; QIcon propIcon(QLatin1String(":images/16x16/document-properties.png")); QAction *terrainProperties = menu.addAction(propIcon, tr("Terrain &Properties...")); Utils::setThemeIcon(terrainProperties, "document-properties"); connect(terrainProperties, &QAction::triggered, this, &TerrainView::editTerrainProperties); menu.exec(event->globalPos()); }
void ConnectionItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) { if(isSelected()) { QGraphicsScene* graphicsScene = scene(); if(StreamEditorScene* streamScene = qobject_cast<StreamEditorScene*>(graphicsScene)) { QMenu menu; QList<QAction*> actions = streamScene->selectionModel()->createThreadActions(&menu); if(actions.count()) { foreach(QAction* action, actions) menu.addAction(action); menu.exec(event->screenPos()); } } } }
void FloatEdit::contextMenuEvent( QContextMenuEvent * event ) { QMenu * mnuContext = new QMenu( this ); mnuContext->setMouseTracking( true ); QMenu * mnuStd = createStandardContextMenu(); if( validator->canMin() ) mnuContext->addAction( actMin ); if( validator->canMax() ) mnuContext->addAction( actMax ); if( validator->canMin() || validator->canMax() ) mnuContext->addSeparator(); mnuContext->addActions( mnuStd->actions() ); mnuContext->exec( event->globalPos() ); delete mnuStd; delete mnuContext; }
void TemplatesView::contextMenuEvent(QContextMenuEvent *event) { const QModelIndex index = indexAt(event->pos()); if (!index.isValid()) return; QMenu menu; Utils::addFileManagerActions(menu, mModel->filePath(index)); if (ObjectTemplate *objectTemplate = mModel->toObjectTemplate(index)) { menu.addSeparator(); QAction *action = menu.addAction(tr("Select All Instances")); connect(action, &QAction::triggered, [objectTemplate] { MapDocumentActionHandler *handler = MapDocumentActionHandler::instance(); handler->selectAllInstances(objectTemplate); }); } menu.exec(event->globalPos()); }
void SkpMainWindow::skp_on_activated(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Context: { QMenu menu; menu.addAction(tr("show"), this, SLOT(skp_on_Show())); menu.addAction(tr("hide"), this, SLOT(skp_on_min())); menu.addAction(tr("quit"), this, SLOT(skp_on_close())); QPoint globalPoint = QCursor::pos(); menu.exec(globalPoint); } break; case QSystemTrayIcon::DoubleClick: case QSystemTrayIcon::Trigger: default: skp_on_Show(); break; } }
void WangSetView::contextMenuEvent(QContextMenuEvent *event) { WangSet *wangSet = wangSetAt(indexAt(event->pos())); if (!wangSet) return; if (!mTilesetDocument) return; QMenu menu; QIcon propIcon(QLatin1String(":images/16x16/document-properties.png")); QAction *wangSetProperties = menu.addAction(propIcon, tr("Wang Set &Properties...")); Utils::setThemeIcon(wangSetProperties, "document-properties"); connect(wangSetProperties, SIGNAL(triggered()), SLOT(editWangSetProperties())); menu.exec(event->globalPos()); }
void CustomLabel::contextMenuEvent(QContextMenuEvent* e) { if (editable_) { QMenu* men = new QMenu(this); men->addAction("Rename"); men->addAction("Set Default"); QAction* ac = men->exec(e->globalPos()); if(ac != 0) { if(ac->iconText().compare("Rename") == 0) { edit_->setText(text()); edit_->setFocus(); edit_->setCursorPosition(edit_->text().length()); edit_->resize(size()); edit_->show(); } else { propertyWidget_->getProperty()->reset(); if(dynamic_cast<TransFuncProperty*>(propertyWidget_->getProperty())) propertyWidget_->getProperty()->invalidate(); } } } }
void DisplayPrefsDialog::colorItemMenu( const QPoint & pos ) { QTreeWidgetItem * c = mColorTree->currentItem(); int cc = mColorTree->currentColumn(); if( c && cc > 0 && c->type() == ColorItemType ) { ColorItem * ci = static_cast<ColorItem*>(c); QMenu * m = new QMenu(this); QAction * c = m->addAction( "Clear" ); QAction * r = m->exec( mColorTree->mapToGlobal(pos) ); if( r==c ) { if( cc == 1 ) ci->fg = QColor(); else if( cc == 2 ) ci->bg = QColor(); ci->update(); mChanges = true; ApplyButton->setEnabled(true); } delete m; } }
/** \return **/ void BlTreeWidget::contextMenuEvent ( QContextMenuEvent * ) { BL_FUNC_DEBUG int column = currentColumn(); if ( column < 0 ) return; QMenu *menu = new QMenu ( this ); /// Lanzamos el evento para que pueda ser capturado por terceros. emit pintaMenu ( menu ); /// Lanzamos la propagación del menú a través de las clases derivadas. createMenu ( menu ); QAction *adjustColumnSize = menu->addAction ( _ ( "Ajustar columa" ) ); QAction *adjustAllColumnsSize = menu->addAction ( _ ( "Ajustar columnas" ) ); QAction *menuOption = menu->exec ( QCursor::pos() ); /// Si no hay ninguna opción pulsada se sale sin hacer nada. if ( !menuOption ) return; if ( menuOption == adjustAllColumnsSize ) { for (int i = 0; i < columnCount(); i++) { resizeColumnToContents (i); } // end for } else if ( menuOption == adjustColumnSize ) { resizeColumnToContents ( column ); } // end if emit trataMenu ( menuOption ); /// Activamos las herederas. execMenuAction ( menuOption ); delete menu; }
void FolderView::onFileClicked(int type, FmFileInfo* fileInfo) { if(type == ActivatedClick) { if(fileLauncher_) { GList* files = g_list_append(nullptr, fileInfo); fileLauncher_->launchFiles(nullptr, files); g_list_free(files); } } else if(type == ContextMenuClick) { FmPath* folderPath = nullptr; FmFileInfoList* files = selectedFiles(); if (files) { FmFileInfo* first = fm_file_info_list_peek_head(files); if (fm_file_info_list_get_length(files) == 1 && fm_file_info_is_dir(first)) folderPath = fm_file_info_get_path(first); } if (!folderPath) folderPath = path(); QMenu* menu = nullptr; if(fileInfo) { // show context menu if (FmFileInfoList* files = selectedFiles()) { Fm::FileMenu* fileMenu = new Fm::FileMenu(files, fileInfo, folderPath); fileMenu->setFileLauncher(fileLauncher_); prepareFileMenu(fileMenu); fm_file_info_list_unref(files); menu = fileMenu; } } else { Fm::FolderMenu* folderMenu = new Fm::FolderMenu(this); prepareFolderMenu(folderMenu); menu = folderMenu; } if (menu) { menu->exec(QCursor::pos()); delete menu; } } }
bool SelectGroupParticipantsWindow::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::ContextMenu) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event); QPoint p = mouseEvent->globalPos(); QModelIndex index = ui->listView->indexAt( ui->listView->viewport()->mapFromGlobal(p)); if (index.isValid()) { QString jid = index.data(Qt::UserRole + 1).toString(); QMenu *menu = new QMenu(this); QAction *removeContact = new QAction("Remove Contact",this); menu->addAction(removeContact); QAction *action = menu->exec(p); if (action == removeContact) { QMessageBox msg(this); msg.setText("Are you sure you want to remove this contact from this group?"); msg.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); if (msg.exec() == QMessageBox::Yes) { model->removeRow(index.row()); participants.remove(jid); ui->listView->clearSelection(); } return true; } } } return QMainWindow::eventFilter(obj, event); }
void FooTabBar::contextMenuRequested (const QPoint &position) { /* Renane Playlist Remove Playlist Add New Playlist --- Move Left Move Right --- Save All Playlists... Save Playlist... Load Playlist... --- "<playlist-name>" Contents > -- odpuścić na razie */ QMenu menu; menu.addAction(tr("New Playlist..."), this, SIGNAL(newTab()), QKeySequence::New); int index = tabAt(position); if (-1 != index) { menu.addAction(tr("&Duplicate Playlist"), this, SLOT(cloneTab()))->setData(index); menu.addSeparator(); menu.addAction(tr("&Close Playlist"), this, SLOT(closeTab()), QKeySequence::Close)->setData(index); menu.addSeparator(); menu.addAction (tr ("Close &Other Playlists"), this, SLOT (closeOtherTabs()))->setData(index); menu.addSeparator(); menu.addAction (tr ("&Rename Playlist"), this, SLOT(renameTab()))->setData(index); } menu.exec (QCursor::pos()); }
int PolyClipSelection::popupMenu() { QMenu menu; QAction* ci = menu.addAction(QObject::tr("Inner")); QAction* co = menu.addAction(QObject::tr("Outer")); QAction* cs = menu.addAction(QObject::tr("Split")); QAction* ca = menu.addAction(QObject::tr("Cancel")); ci->setVisible(testRole(SelectionRole::Inner)); co->setVisible(testRole(SelectionRole::Outer)); cs->setVisible(testRole(SelectionRole::Split)); if (getPositions().size() < 3) { ci->setEnabled(false); co->setEnabled(false); } QAction* id = menu.exec(QCursor::pos()); if (id == ci) { m_selectedRole = SelectionRole::Inner; return Finish; } else if (id == co) { m_selectedRole = SelectionRole::Outer; return Finish; } else if (id == cs) { m_selectedRole = SelectionRole::Split; return Finish; } else if (id == ca) { m_selectedRole = SelectionRole::None; return Cancel; } else { m_selectedRole = SelectionRole::None; return Restart; } }
void MyGroupBox::contextMenuEvent(QContextMenuEvent *event) { QMenu *menu = new QMenu; actionResetToDefault = menu->addAction(tr("Reset to default")); actionAddToFlightAnimation = menu->addAction(tr("Add to flight animation")); actionAddToKeyframeAnimation = menu->addAction(tr("Add to keyframe animation")); QAction *selectedItem = menu->exec(event->globalPos()); if (selectedItem) { if (selectedItem == actionResetToDefault) { if (parameterContainer) { setChecked(defaultValue); emit toggled(defaultValue); } else { qCritical() << " MyGroupBox::contextMenuEvent(QContextMenuEvent *event): parameter container not assigned. Object:" << objectName(); } } else if (selectedItem == actionAddToFlightAnimation) { if (parameterContainer) { gAnimFrames->AddAnimatedParameter(parameterName, parameterContainer->GetAsOneParameter(parameterName)); gFlightAnimation->RefreshTable(); } } else if (selectedItem == actionAddToKeyframeAnimation) { if (parameterContainer) { gKeyframes->AddAnimatedParameter(parameterName, parameterContainer->GetAsOneParameter(parameterName)); gKeyframeAnimation->RefreshTable(); } } } delete menu; }
void MacroPinItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) { MacroItem* macroItem = dynamic_cast<MacroItem*>(this->parentItem()); Q_ASSERT(macroItem != 0); bool selected = macroItem->isSelected(); event->accept(); if (!selected) { macroItem->setSelected(true); } QMenu popup; QAction* edtCut = Resource::action(Resource::EDIT_CUT); QAction* edtCopy = Resource::action(Resource::EDIT_COPY); QAction* edtDel = Resource::action(Resource::EDIT_DELETE); QAction* macroWatch = Resource::action(Resource::MACRO_WATCHOUTPUT); if (this->pin().direction() == graph::Defines::Outgoing) { macroWatch->setData(reinterpret_cast<qulonglong>(&(this->pin()))); popup.addAction(macroWatch); popup.addSeparator(); } if ((macroItem->vertex().isInCycle() && !macroItem->vertex().topologicalOrderForced() && macroItem->vertex().topologicalOrder() < 0) || macroItem->vertex().topologicalOrderForced()) { QAction* edtAnchor = Resource::action(Resource::EDIT_SETANCHOR); void* ptrMacro = reinterpret_cast<void*>(&(macroItem->vertex())); edtAnchor->setData(QVariant::fromValue(ptrMacro)); edtAnchor->setChecked(macroItem->vertex().topologicalOrderForced()); popup.addAction(edtAnchor); popup.addSeparator(); } popup.addAction(edtCut); popup.addAction(edtCopy); popup.addAction(edtDel); popup.exec(event->screenPos(),popup.actions().first()); if (!selected) { macroItem->setSelected(false); } }
/** * Allow changing tile properties through a context menu. */ void TilesetView::contextMenuEvent(QContextMenuEvent *event) { const QModelIndex index = indexAt(event->pos()); const TilesetModel *m = tilesetModel(); Tile *tile = m->tileAt(index); const bool isExternal = m->tileset()->isExternal(); QMenu menu; QIcon propIcon(QLatin1String(":images/16x16/document-properties.png")); if (tile) { // Select this tile to make sure it is clear that only the properties // of a single tile are being edited. selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Clear); QAction *tileProperties = menu.addAction(propIcon, tr("Tile &Properties...")); tileProperties->setEnabled(!isExternal); Utils::setThemeIcon(tileProperties, "document-properties"); menu.addSeparator(); connect(tileProperties, SIGNAL(triggered()), SLOT(editTileProperties())); } menu.addSeparator(); QAction *toggleGrid = menu.addAction(tr("Show &Grid")); toggleGrid->setCheckable(true); toggleGrid->setChecked(mDrawGrid); Preferences *prefs = Preferences::instance(); connect(toggleGrid, SIGNAL(toggled(bool)), prefs, SLOT(setShowTilesetGrid(bool))); menu.exec(event->globalPos()); }
void Canvas::keyPressEvent(QKeyEvent *event) { QGraphicsView::keyPressEvent(event); if (event->isAccepted()) return; if (event->key() == Qt::Key_Space) { QGraphicsItem* i = scene->itemAt( mapToScene(mapFromGlobal(QCursor::pos())), QTransform()); Control* control = dynamic_cast<Control*>(i); if (control) { control->toggleInspector(); } } else if (event->key() == Qt::Key_Alt) { hideUI(); } else if (event->key() == Qt::Key_A && (event->modifiers() & Qt::ShiftModifier)) { QMenu* m = new QMenu(this); auto window = dynamic_cast<MainWindow*>(parent()->parent()); Q_ASSERT(window); window->populateMenu(m, false); m->exec(QCursor::pos()); m->deleteLater(); } else if (event->key() == Qt::Key_S && (event->modifiers() & Qt::ShiftModifier)) { ports_visible = !ports_visible; emit(showPorts(ports_visible)); } }
void NetworkReplyWidget::contextMenu(QPoint pos) { const auto index = ui->replyView->indexAt(pos); if (!index.isValid()) return; const auto objectId = index.sibling(index.row(), NetworkReplyModelColumn::ObjectColumn).data(NetworkReplyModelRole::ObjectIdRole).value<ObjectId>(); const auto url = index.sibling(index.row(), NetworkReplyModelColumn::UrlColumn).data(Qt::DisplayRole).toString(); QMenu menu; if (!url.isEmpty()) { auto action = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy URL")); connect(action, &QAction::triggered, this, [url]() { QGuiApplication::clipboard()->setText(url); }); menu.addSeparator(); } ContextMenuExtension ext(objectId); ext.populateMenu(&menu); menu.exec(ui->replyView->viewport()->mapToGlobal(pos)); }
void MainWindow::showContextMenu(const QPoint &pos) { QPoint globalPos = ui->imageList->mapToGlobal(pos); QListWidgetItem* temp = ui->imageList->itemAt(pos); if(temp != NULL) { QMenu menu; QAction *deleteImageAction = new QAction(QIcon(":icons/discard"), "Delete image", this); menu.addAction(deleteImageAction); QAction* selectedItem = menu.exec(globalPos); if (selectedItem) { QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Delete image", "Are you sure you want to delete this image?"); if(reply == QMessageBox::Yes) { actionDeleteImage(pos); } } } }
void URDFProperty::on_treeWidget_customContextMenuRequested(const QPoint &pos) { QTreeWidgetItem *sel = tree_widget_->selectedItems()[0]; QMenu *menu = new QMenu(tree_widget_.get()); menu->addAction("Add"); menu->addAction("Remove"); QAction *selected_item = menu->exec(tree_widget_->mapToGlobal(pos)); if (selected_item) { if (selected_item->text() == "Add") { if (sel == link_root_ || sel->parent() == link_root_) { addLink(); } else if (sel == joint_root_ || isJoint(sel)) { addJoint(sel); } } else { if (sel->parent() == link_root_) { link_names_.removeOne(sel->text(0)); link_root_->removeChild(sel); } else if (isJoint(sel)) { joint_names_.removeOne(sel->text(0)); sel->parent()->removeChild(sel); } } } delete menu; }
void ServiceDiscoveryWidget::on_DiscoveryTree__customContextMenuRequested (const QPoint& point) { const auto& idx = FilterModel_->mapToSource (Ui_.DiscoveryTree_->indexAt (point)); if (!idx.isValid ()) return; const auto& actions = SDSession_->GetActionsFor (idx); if (actions.isEmpty ()) return; QMenu *menu = new QMenu (tr ("Discovery actions")); for (auto i = actions.begin (), end = actions.end (); i != end; ++i) menu->addAction (i->second)->setProperty ("Azoth/ID", i->first); QAction *result = menu->exec (Ui_.DiscoveryTree_->viewport ()->mapToGlobal (point)); menu->deleteLater (); if (!result) return; const QByteArray& id = result->property ("Azoth/ID").toByteArray (); SDSession_->ExecuteAction (idx, id); }
void FWObjectDropArea::contextMenuEvent (QContextMenuEvent * e) { QMenu *popup; popup=new QMenu(this); QAction *sitAct = popup->addAction( tr("Show in the tree") , this , SLOT( showInTreeObject( )) ); QAction *editAct = popup->addAction( tr("Edit") , this , SLOT( editObject( )) ); popup->addSeparator(); QAction *psAct = popup->addAction( tr("Paste") , this , SLOT( pasteObject( )) ); popup->addSeparator(); QAction *dlAct = popup->addAction( tr("Delete") , this , SLOT( deleteObject( )) ); sitAct->setEnabled(object!=nullptr); editAct->setEnabled(object!=nullptr); dlAct->setEnabled(object!=nullptr); psAct->setEnabled(FWObjectClipboard::obj_clipboard->size()>0); popup->exec(e->globalPos ()); delete popup; }
void BookmarksToolbar::showBookmarkContextMenu(const QPoint &pos) { Q_UNUSED(pos) ToolButton* button = qobject_cast<ToolButton*>(sender()); if (!button) { return; } QVariant buttonPointer = qVariantFromValue((void*) button); QMenu menu; menu.addAction(IconProvider::fromTheme("go-next"), tr("Move right"), this, SLOT(moveRight()))->setData(buttonPointer); menu.addAction(IconProvider::fromTheme("go-previous"), tr("Move left"), this, SLOT(moveLeft()))->setData(buttonPointer); menu.addSeparator(); menu.addAction(IconProvider::fromTheme("list-remove"), tr("Remove bookmark"), this, SLOT(removeButton()))->setData(buttonPointer); //Prevent choosing first option with double rightclick QPoint position = QCursor::pos(); QPoint p(position.x(), position.y() + 1); menu.exec(p); }
void mail_listview::popup_ctxt_menu_headers(const QPoint& pos) { QModelIndex index = indexAt(pos); if (!index.isValid()) return; QMenu* menu = make_header_menu(this); QAction* action = menu->exec(mapToGlobal(pos)); if (action!=NULL && action->data().isValid()) { int section = action->data().toInt(); if (action->isChecked()) { // show header()->showSection(section); } else { header()->hideSection(section); } compute_visible_sections(); } delete menu; }
void MyTableWidgetAnim::tableContextMenuRequest(QPoint point) { QModelIndex index = indexAt(point); int row = index.row(); int column = index.column(); QMenu *menu = new QMenu; QAction *actionRender = NULL; QAction *interpolateForward = NULL; if(row == 0) { actionRender = menu->addAction(tr("Render this frame")); } else { if(column < columnCount() - 1) { interpolateForward = menu->addAction(tr("Interpolate next frames")); } } QAction *selectedItem = menu->exec(viewport()->mapToGlobal(point)); if (selectedItem) { if (selectedItem == actionRender) { gFlightAnimation->RenderFrame(column); } else if (selectedItem == interpolateForward) { gFlightAnimation->InterpolateForward(row, column); } } delete menu; }
/** * When y-axis is clicked, the pixel coordinates are converted to graph * coordinates, and displayed in a pop-up menu. * @param &y :: A reference to a click on the y-axis. */ void LabelTool::yAxisClicked(const QwtPolygon &y) { populateMantidCurves(); // Obtains the x value of the pixel coordinate. QPoint yy = y.point(0); int yPosition = yy.y(); // Obtains the origins of the graph area and of the axis. QPoint canvasOrigin = d_graph->plotWidget()->canvas()->pos(); int canvasOriginY = canvasOrigin.y(); QPoint yOrigin = d_graph->plotWidget()->axisWidget(QwtPlot::yLeft)->pos(); int yAxisOriginYValue = yOrigin.y(); /** * The difference in the origins is calculated then taken into account when * converting the pixel coordinates of the * axis into graph coordinates. */ int deltaOrigins = canvasOriginY - yAxisOriginYValue; int yPositionCorrected = yPosition - deltaOrigins; double yPos = d_graph->plotWidget()->invTransform(QwtPlot::yLeft, yPositionCorrected); if (yPos < 0) { return; } m_yPosSigFigs.setNum(yPos, 'f', 6); QMenu *clickMenu = new QMenu(d_graph); QAction *addYAxisLabel = new QAction(m_yPosSigFigs, this); clickMenu->addAction(addYAxisLabel); connect(addYAxisLabel, SIGNAL(triggered()), this, SLOT(insertYCoord())); clickMenu->exec(QCursor::pos()); }
/// Context menu for tree. void VondelWindow::on_treeBook_customContextMenuRequested(QPoint pos) { QMenu *menu = new QMenu; QTreeWidgetItem *item = ui->treeBook->itemAt(pos.x(), pos.y()); int id = item->type() - QTreeWidgetItem::UserType; if (id >= 2000) { id -= 1999; // Scene selected. //VondelScene *scene = vondelBook.getScene(id); menu->addAction(tr("Scene")); menu->addAction(ui->action_Add_New_Scene); menu->setActiveAction(ui->action_Add_New_Scene); } else if (id >= 1000) { id -=999; // Chapter selected. menu->addAction(ui->action_Add_New_Scene); menu->addAction(ui->action_Add_New_Chapter); } else { // Book selected. menu->addAction(ui->action_Add_New_Chapter); menu->addAction(ui->action_Add_New_Character); } menu->exec(QCursor::pos()); }