void TextInputWidget::showContextMenu(const QPoint &pt) { QMenu *menu = createStandardContextMenu(); QList<QAction *> actions=menu->actions(); //hack menu for(int i=0;i<actions.size();i++) { //qDebug()<<actions[i]->text(); if(actions[i]->text().contains("undo",Qt::CaseInsensitive)) { menu->removeAction(actions[i]); } if(actions[i]->text().contains("redo",Qt::CaseInsensitive)) { menu->removeAction(actions[i]); } if(actions[i]->text().contains("delete",Qt::CaseInsensitive)) { menu->removeAction(actions[i]); } if(actions[i]->text().contains("cu",Qt::CaseInsensitive)) { actions[i]->disconnect(SIGNAL(triggered(bool))); connect(actions[i],SIGNAL(triggered(bool)),this,SLOT(cut())); } if(actions[i]->text().contains("paste",Qt::CaseInsensitive)) { actions[i]->disconnect(SIGNAL(triggered(bool))); connect(actions[i],SIGNAL(triggered(bool)),this,SLOT(paste())); }
/** * View Menu * Interface modification, load other interfaces, activate Extensions * \param current, set to NULL for menu creation, else for menu update **/ QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi ) { QAction *action; QMenu *menu; MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi; assert( mi ); if( !current ) { menu = new QMenu( qtr( "&View" ), mi ); } else { menu = current; //menu->clear(); //HACK menu->clear() does not delete submenus QList<QAction*> actions = menu->actions(); foreach( QAction *a, actions ) { QMenu *m = a->menu(); if( a->parent() == menu ) delete a; else menu->removeAction( a ); if( m && m->parent() == menu ) delete m; } }
void MainWindowMenuManager::RemoveMenus (const QMap<QString, QList<QAction*>>& menus) { for (const auto& menuName : menus.keys ()) { QMenu *toRemove = nullptr; if (menuName == "view") toRemove = MenuView_; else if (menuName == "tools") toRemove = MenuTools_; const auto& actions = menus [menuName]; if (toRemove) for (const auto action : actions) toRemove->removeAction (action); else { for (auto action : Menu_->actions ()) if (action->text () == menuName) { Menu_->removeAction (action); break; } } } }
void QtMenu::removeMenuAction(QMenu& qMenu, QAction& qAction) { qMenu.removeAction(&qAction); auto children = qMenu.findChildren<QMenu*>(QString(), Qt::FindDirectChildrenOnly); for (auto& child : children) { removeMenuAction(*child, qAction); // we check actions.isEmpty rather than child.isEmpty as child.isEmpty doesnt include hidden actions if (child->actions().isEmpty()) { auto childAction = child->menuAction(); qMenu.removeAction(childAction); child->deleteLater(); } } }
void IFPGUIModule::doUninstall() { QMenu* toolsMenu = mainWindow->getToolsMenu(); animViewerAction->setParent(NULL); toolsMenu->removeAction(animViewerAction); }
void MainWindow::on_actionClearMenuRecentFiles_triggered() { QMenu* menu = ui->menuRecentFiles; for (int i = menu->actions().size() - separatorAndMenuCount - 1; i >= 0; i--) { menu->removeAction(menu->actions().at(i)); } updateMenuState(); }
VarView::VarView(QWidget *parent) : QWidget(parent), ui(new Ui::VarView) { ui->setupUi(this); setWindowTitle(QString::fromUtf8("Переменные программы")); VarModel *varModel = ModelManager::getInstance()->getVarModel(); varModel->setIsRefresh(false); ui->table->setModel(varModel); QMenu *menu = ui->table->getMenu(); menu->removeAction(ui->table->actionAdd); menu->removeAction(ui->table->actionEdit); menu->removeAction(ui->table->actionDel); }
void ScriptToolbox::menuRemove(QObject * menu, QObject * action) { QMenu * m = qobject_cast<QMenu*>(menu); QAction * act = qobject_cast<QAction*>(action); if (!act) { QMenu * ma = qobject_cast<QMenu*>(action); act = ma->menuAction(); } if(m && act) m->removeAction(act); }
/** * @brief Finishes drawing a rectangle. */ void TilesetView::end_state_drawing_rectangle() { QRect rectangle = current_area_item->rect().toRect(); if (!rectangle.isEmpty() && sceneRect().contains(rectangle) && get_items_intersecting_current_area().isEmpty() && model->is_selection_empty() && !is_read_only()) { // Context menu to create a pattern. QMenu menu; EnumMenus<Ground>::create_actions( menu, EnumMenuCheckableOption::NON_CHECKABLE, [=](Ground ground) { QString pattern_id; do { ++last_integer_pattern_id; pattern_id = QString::number(last_integer_pattern_id); } while (model->id_to_index(pattern_id) != -1); emit create_pattern_requested(pattern_id, rectangle, ground); }); // Put most actions in a submenu to make the context menu smaller. QMenu sub_menu(tr("New pattern (more options)")); int i = 0; for (QAction* action : menu.actions()) { Ground ground = static_cast<Ground>(action->data().toInt()); if (ground == Ground::TRAVERSABLE || ground == Ground::WALL) { action->setText(tr("New pattern (%1)").arg(GroundTraits::get_friendly_name(ground))); } else { menu.removeAction(action); sub_menu.addAction(action); } ++i; } menu.addMenu(&sub_menu); menu.addSeparator(); menu.addAction(tr("Cancel")); menu.exec(cursor().pos() + QPoint(1, 1)); } scene->removeItem(current_area_item); delete current_area_item; current_area_item = nullptr; initially_selected_items.clear(); start_state_normal(); }
void Controls::addRecentFiles(const QString &fileName) { QMenu *rf = m_ui->menuRecent_Models; QStringList files; { QSettings settings; settings.beginGroup("General"); int numFiles = settings.beginReadArray("RecentFiles"); for (int i = 0; i < numFiles; ++i) { settings.setArrayIndex(i); QByteArray coded = settings.value("file").toByteArray(); files.append(QUrl::fromPercentEncoding(coded)); } } files.removeAll(fileName); files.push_front(fileName); if (files.size() > 10) files.pop_back(); QAction *act; while (rf->actions().count() > 0) { act = rf->actions().at(0); rf->removeAction(act); delete act; } for (int i = 0; i < files.count(); ++i) { act = new QAction(files.at(i), this); connect(act, SIGNAL(triggered()), this, SLOT(load())); rf->addAction(act); } { QSettings settings; settings.beginGroup("General"); settings.beginWriteArray("RecentFiles", files.count()); for (int i = 0; i < files.count(); ++i) { settings.setArrayIndex(i); QByteArray coded = QUrl::toPercentEncoding(files.at(i)); settings.setValue("file", coded); } settings.endArray(); settings.endGroup(); settings.sync(); } }
//@Override /*public*/ void AudioTableAction::setMenuBar(BeanTableFrame* f) { QMenuBar* menuBar = f->menuBar(); // ResourceBundle rbapps = ResourceBundle.getBundle("apps.AppsBundle"); QList<QAction*> subElements = menuBar->actions(); QMenu* fileMenu = nullptr; for (int i = 0; i < menuBar->actions().count(); i++) { //if (menuBar->actionAt(i) instanceof JMenu) if(qobject_cast<QMenu*>(menuBar->actions().at(i)) != nullptr) { if( ((QMenu*) menuBar->actions().at(i))->title()==(tr("File"))) { fileMenu = (QMenu*) menuBar->actions().at(i); } } } if (fileMenu == nullptr) { return; } subElements = fileMenu->actions(); for (int i = 0; i < subElements.length(); i++) { QList<QAction*> popsubElements = ((QMenu*)subElements.at(i))->actions(); for (int x = 0; x < popsubElements.length(); x++) { // if (popsubElements[x] instanceof JMenuItem) if(qobject_cast<QMenu*>(popsubElements.at(x))!= nullptr) { if (((QMenu*) popsubElements[x])->title()==(tr("Print Table")))\ { QMenu* printMenu = ((QMenu*) popsubElements[x]); fileMenu->removeAction((QAction*)printMenu); break; } } } } fileMenu->addAction(atp->getPrintItem()); }
//------------------------------------------------------------------------------ QMenu* LineEdit::createStandardContextMenu() { QMenu* popup = QLineEdit::createStandardContextMenu(); if ( ! undoRedoEnabled) { QList<QAction*> actions = popup->actions(); for (int i=0; i<actions.size(); ++i) { if (actions.at(i)->text().contains(tr("Undo")) || actions.at(i)->text().contains(tr("&Redo"))) { popup->removeAction(actions.at(i)); } } } return popup; }
/** Unload a plugin by its name. */ bool PluginManager::unloadPlugin(const QString &absFilePath) { BasicPlugin *basic = _loadedPlugins.value(absFilePath); for (QObject *dependency : _dependencies.values(basic->name())) { if (QAction *action = qobject_cast<QAction*>(dependency)) { QMenu *menu = qobject_cast<QMenu*>(action->parent()); menu->removeAction(action); } else if (QMenu *menu = qobject_cast<QMenu*>(dependency)) { delete menu; } } _loadedPlugins.remove(absFilePath); _dependencies.remove(basic->name()); basic->cleanUpBeforeDestroy(); delete basic; basic = nullptr; auto settings = SettingsPrivate::instance(); settings->disablePlugin(absFilePath); return true; }
void ChatView::contextMenu(QMenu *menu, const QWebHitTestResult &result) { menu->addSeparator(); const QUrl url = result.linkUrl(); if (url.scheme() == LS("chat") && url.host() == LS("channel")) Hooks::ChannelMenu::bind(menu, ChatUrls::channel(url), Hooks::ChatViewScope); else Hooks::ChannelMenu::bind(menu, ChatClient::channels()->get(m_id), Hooks::ChatViewScope); menu->addSeparator(); QMenu *display = menu->addMenu(SCHAT_ICON(Gear), tr("Display")); display->addAction(m_seconds); display->addAction(m_service); developerMenu(display); display->removeAction(pageAction(QWebPage::Reload)); menu->addAction(m_autoscroll); menu->addSeparator(); ClientChannel channel = ChatClient::channels()->get(id()); if (channel && channel->data().value(LS("page")) == 1) menu->addAction(m_reload); else menu->addAction(m_clear); if (!result.isContentEditable()) { menu->removeAction(pageAction(QWebPage::SelectAll)); menu->addAction(pageAction(QWebPage::SelectAll)); } menu->removeAction(pageAction(QWebPage::Reload)); menu->removeAction(pageAction(QWebPage::InspectElement)); connect(menu, SIGNAL(triggered(QAction*)), SLOT(menuTriggered(QAction*))); ChatViewHooks::contextMenu(this, menu, result); }
QMenu *TikzCommandInserter::getMenu(const TikzCommandList &commandList) { QMenu *menu = new QMenu(commandList.title, m_parentWidget); const int numOfCommands = commandList.commands.size(); QAction *action = new QAction("test", menu); int whichSection = 0; // get left margin of the menu (to be added to the minimum width of the menu) menu->addAction(action); QFont actionFont = action->font(); actionFont.setPointSize(actionFont.pointSize() - 1); QFontMetrics actionFontMetrics(actionFont); int menuLeftMargin = menu->width() - actionFontMetrics.boundingRect(action->text()).width(); menu->removeAction(action); int menuMinimumWidth = 0; for (int i = 0; i < numOfCommands; ++i) { const QString name = commandList.commands.at(i).name; if (name.isEmpty()) // add separator or submenu { if (commandList.commands.at(i).type == 0) { action = new QAction(menu); action->setSeparator(true); menu->addAction(action); } else // type == -1, so add submenu; this assumes that the i-th command with type == -1 corresponds with the i-th submenu (see getCommands()) { menu->addMenu(getMenu(commandList.children.at(whichSection))); ++whichSection; } } else // add command { action = new QAction(name, menu); action->setData(commandList.commands.at(i).number); // link to the corresponding item in m_tikzCommandsList action->setStatusTip(commandList.commands.at(i).description); menuMinimumWidth = qMax(menuMinimumWidth, actionFontMetrics.boundingRect(commandList.commands.at(i).description).width()); connect(action, SIGNAL(triggered()), this, SLOT(insertTag())); connect(action, SIGNAL(hovered()), this, SLOT(updateDescriptionMenuItem())); menu->addAction(action); } } // if the menu does not only contain submenus, then we add a menu item // at the bottom of the menu which shows the description of the currently // highlighted menu item if (whichSection < menu->actions().size()) { action = new QAction(this); action->setSeparator(true); menu->addAction(action); action = new QAction(this); QFont actionFont = action->font(); actionFont.setPointSize(actionFont.pointSize() - 1); action->setFont(actionFont); connect(action, SIGNAL(triggered()), this, SLOT(insertTag())); menu->addAction(action); // make sure that the menu width does not change when the content // of the above menu item changes menu->setMinimumWidth(menuMinimumWidth + menuLeftMargin); } return menu; }
void EffectRack::menuRequested(QListWidgetItem* it)/*{{{*/ { if (it == 0 || track == 0) return; RackSlot* curitem = (RackSlot*) it; Pipeline* epipe = track->efxPipe(); int idx = row(curitem); QString name; bool mute = false; bool nativeGui = false; Pipeline* pipe = track->efxPipe(); if (pipe) { name = pipe->name(idx); mute = (pipe->isActive(idx) == false); nativeGui = pipe->hasNativeGui(idx); } //enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SAVE }; enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SHOW_NATIVE, SAVE }; QMenu* menu = new QMenu; QAction* newAction = menu->addAction(tr("new")); QAction* changeAction = menu->addAction(tr("change")); QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); //, UP, UP); QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); //, DOWN, DOWN); QAction* removeAction = menu->addAction(tr("remove")); //, REMOVE, REMOVE); QAction* bypassAction = menu->addAction(tr("bypass")); //, BYPASS, BYPASS); QAction* showGuiAction = menu->addAction(tr("show gui")); //, SHOW, SHOW); QAction* showNativeGuiAction = menu->addAction(tr("show native gui")); //, SHOW_NATIVE, SHOW_NATIVE); QAction* saveAction = menu->addAction(tr("save preset")); newAction->setData(NEW); changeAction->setData(CHANGE); upAction->setData(UP); downAction->setData(DOWN); removeAction->setData(REMOVE); bypassAction->setData(BYPASS); showGuiAction->setData(SHOW); showNativeGuiAction->setData(SHOW_NATIVE); saveAction->setData(SAVE); bypassAction->setCheckable(true); showGuiAction->setCheckable(true); showNativeGuiAction->setCheckable(true); bypassAction->setChecked(mute); showGuiAction->setChecked(pipe->guiVisible(idx)); showNativeGuiAction->setEnabled(nativeGui); if (nativeGui) showNativeGuiAction->setChecked(pipe->nativeGuiVisible(idx)); if (pipe->empty(idx)) { menu->removeAction(changeAction); menu->removeAction(saveAction); upAction->setEnabled(false); downAction->setEnabled(false); removeAction->setEnabled(false); bypassAction->setEnabled(false); showGuiAction->setEnabled(false); showNativeGuiAction->setEnabled(false); } else { menu->removeAction(newAction); if (idx == 0) upAction->setEnabled(true); if (idx == ((int)epipe->size() - 1)) downAction->setEnabled(false); } QPoint pt = QCursor::pos(); QAction* act = menu->exec(pt, 0); //delete menu; if (!act) { delete menu; return; } int sel = act->data().toInt(); delete menu; int pdepth = epipe->size(); switch (sel) { case NEW: { choosePlugin(it); break; } case CHANGE: { choosePlugin(it, true); break; } case REMOVE: { BasePlugin* oldPlugin = (*epipe)[idx]; oldPlugin->setActive(false); oldPlugin->aboutToRemove(); if(debugMsg) qCritical("Plugin to remove now and here"); audio->msgAddPlugin(track, idx, 0); song->dirty = true; break; } case BYPASS: { bool flag = !pipe->isActive(idx); pipe->setActive(idx, flag); break; } case SHOW: { bool flag = !pipe->guiVisible(idx); pipe->showGui(idx, flag); break; } case SHOW_NATIVE: { printf("Show native GUI called\n"); bool flag = !pipe->nativeGuiVisible(idx); pipe->showNativeGui(idx, flag); break; } case UP: if (idx > 0) { setCurrentItem(item(idx - 1)); pipe->move(idx, true); } break; case DOWN: if (idx < pdepth) { setCurrentItem(item(idx + 1)); pipe->move(idx, false); } break; case SAVE: savePreset(idx); break; } //Already done on songChanged //updateContents(); song->update(SC_RACK); }/*}}}*/
void QMenuProto::removeAction(QAction *action) { QMenu *item = qscriptvalue_cast<QMenu*>(thisObject()); if (item) item->removeAction(action); }
void removeAction(QAction* action) { menu ? menu->removeAction(action) : menuBar->removeAction(action); }