本文整理汇总了C++中QMenu::actions方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::actions方法的具体用法?C++ QMenu::actions怎么用?C++ QMenu::actions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::actions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createContextMenu
/*!
Return a new context menu
*/
QMenu* DatapickerCurve::createContextMenu() {
QMenu *menu = AbstractAspect::createContextMenu();
Q_ASSERT(menu);
QAction* firstAction = 0;
if (menu->actions().size()>1)
firstAction = menu->actions().at(1);
menu->insertAction(firstAction, updateDatasheetAction);
return menu;
}
示例2: on_CollectionsTree__customContextMenuRequested
void PhotosTab::on_CollectionsTree__customContextMenuRequested (const QPoint& point)
{
const auto& idx = Ui_.CollectionsTree_->indexAt (point);
if (!idx.isValid ())
return;
const auto type = idx.data (CollectionRole::Type).toInt ();
const auto isAll = type == ItemType::AllPhotos;
const auto isColl = type == ItemType::Collection;
const auto isImage = type == ItemType::Image;
QMenu menu;
if (isImage)
{
menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("go-jump-locationbar"),
tr ("Open in browser"),
this,
SLOT (handleImageOpenRequested ()));
menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("download"),
tr ("Download original"),
this,
SLOT (handleImageDownloadRequested ()));
menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("edit-copy"),
tr ("Copy image URL"),
this,
SLOT (handleCopyURLRequested ()));
}
if (auto isd = qobject_cast<ISupportDeletes*> (CurAccObj_))
{
if ((isColl && isd->SupportsFeature (DeleteFeature::DeleteCollections)) ||
(isImage && isd->SupportsFeature (DeleteFeature::DeleteImages)))
menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("list-remove"),
tr ("Delete"),
this,
SLOT (handleDeleteRequested ()));
}
if (auto isu = qobject_cast<ISupportUploads*> (CurAccObj_))
if (isColl || (isAll && !isu->HasUploadFeature (ISupportUploads::Feature::RequiresAlbumOnUpload)))
menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("svn-commit"),
tr ("Upload"),
this,
SLOT (handleUploadRequested ()));
const auto idxVar = QVariant::fromValue (idx);
for (auto act : menu.actions ())
act->setProperty ("Blasq/Index", idxVar);
if (!menu.actions ().isEmpty ())
menu.exec (Ui_.CollectionsTree_->viewport ()->mapToGlobal (point));
}
示例3: customMenu
void VCButton_Test::customMenu()
{
QWidget w;
VCButton btn(&w, m_doc);
QMenu* menu = btn.customMenu(NULL);
QVERIFY(menu != NULL);
QCOMPARE(menu->title(), tr("Icon"));
QCOMPARE(menu->actions().size(), 2);
QCOMPARE(menu->actions()[0], btn.m_chooseIconAction);
QCOMPARE(menu->actions()[1], btn.m_resetIconAction);
delete menu;
}
示例4: showContextMenu
void QgsBrowserDockWidget::showContextMenu( const QPoint & pt )
{
QModelIndex idx = mBrowserView->indexAt( pt );
QgsDataItem* item = mModel->dataItem( idx );
if ( !item )
return;
QMenu* menu = new QMenu( this );
if ( item->type() == QgsDataItem::Directory )
{
QSettings settings;
QStringList favDirs = settings.value( "/browser/favourites" ).toStringList();
bool inFavDirs = favDirs.contains( item->path() );
if ( item->parent() != NULL && !inFavDirs )
{
// only non-root directories can be added as favourites
menu->addAction( tr( "Add as a favourite" ), this, SLOT( addFavourite() ) );
}
else if ( inFavDirs )
{
// only favourites can be removed
menu->addAction( tr( "Remove favourite" ), this, SLOT( removeFavourite() ) );
}
}
else if ( item->type() == QgsDataItem::Layer )
{
menu->addAction( tr( "Add Layer" ), this, SLOT( addCurrentLayer( ) ) );
menu->addAction( tr( "Add Selected Layers" ), this, SLOT( addSelectedLayers() ) );
menu->addAction( tr( "Properties" ), this, SLOT( showProperties( ) ) );
}
QList<QAction*> actions = item->actions();
if ( !actions.isEmpty() )
{
if ( !menu->actions().isEmpty() )
menu->addSeparator();
// add action to the menu
menu->addActions( actions );
}
if ( menu->actions().count() == 0 )
{
delete menu;
return;
}
menu->popup( mBrowserView->mapToGlobal( pt ) );
}
示例5: contextMenuEvent
void ExprTextEdit::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
if (!menu->actions().empty())
{
QAction* f = menu->actions().first();
menu->insertAction(f, _popupEnabledAction);
menu->insertSeparator(f);
}
menu->exec(event->globalPos());
delete menu;
}
示例6: contextMenuEvent
void ActionLineEdit::contextMenuEvent(QContextMenuEvent *e)
{
QMenu *menu = createStandardContextMenu();
if (actions().count() > 0) {
QAction *before = NULL;
if (menu->actions().count() > 0) {
before = menu->actions().first();
}
menu->insertActions(before, actions());
menu->insertSeparator(before);
}
menu->exec(e->globalPos());
delete menu;
}
示例7: contextMenuEvent
void ChatbarTextEdit::contextMenuEvent(QContextMenuEvent *qcme) {
QMenu *menu = createStandardContextMenu();
QAction *action = new QAction(tr("Paste and &Send") + QLatin1Char('\t'), menu);
action->setEnabled(!QApplication::clipboard()->text().isEmpty());
connect(action, SIGNAL(triggered()), this, SLOT(pasteAndSend_triggered()));
if (menu->actions().count() > 6)
menu->insertAction(menu->actions()[6], action);
else
menu->addAction(action);
menu->exec(qcme->globalPos());
delete menu;
}
示例8: kmt
/**
* NOTE: we assume kate is installed
*/
void KMoreToolsTest2::test_buildMenu_ShowConfigureMenuItem()
{
{
KMoreTools kmt(_("unittest-kmoretools/2"));
const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
// porcelain: other (interactive) tests will reuse the kmt id so we make sure that
// no user configurment disburbs this test:
const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
menuBuilder->addMenuItem(kateApp);
QMenu menu;
menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always
qDebug() << menuBuilder->menuStructureAsString(true);
QVERIFY(menuAtLeastOneActionWithText(&menu, _("Configure..."))); // "Kate", "Separator", "Configure..."
{
menu.clear();
menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
QVERIFY(menuAtLeastNoActionWithText(&menu, _("Configure...")));
}
}
{
KMoreTools kmt(_("unittest-kmoretools/2"));
const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
const auto mynotInstalledApp = kmt.registerServiceByDesktopEntryName(_("mynotinstalledapp"));
const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
menuBuilder->addMenuItem(kateApp);
menuBuilder->addMenuItem(mynotInstalledApp);
QMenu menu;
menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always
auto doAssert = [](QMenu* menu) {
QCOMPARE(menu->actions().count(), 3); // "Kate", "Separator", "More..."
auto moreMenu = menu->actions()[2]->menu();
QCOMPARE(moreMenu->actions().count(), 4); // "Not-installed-section", "Not installed app", "Separator", "Configure menu..."
auto configureMenu = moreMenu->actions()[3];
QCOMPARE(configureMenu->data().toString(), QString(_("configureItem")));
};
doAssert(&menu);
{
menu.clear();
menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
doAssert(&menu); // = same as _Always because there is one not-installed item
}
}
}
示例9: addRecentFiles
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();
}
}
示例10: assert
/**
* 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;
}
}
示例11: contextMenuEvent
void MacroItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
{
bool selected = this->isSelected();
event->accept();
if (!selected)
{
this->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);
if ((vertex().isInCycle() && !vertex().topologicalOrderForced() && vertex().topologicalOrder() < 0) || vertex().topologicalOrderForced())
{
QAction* edtAnchor = Resource::action(Resource::EDIT_SETANCHOR);
void* ptrMacro = reinterpret_cast<void*>(&vertex());
edtAnchor->setData(QVariant::fromValue(ptrMacro));
edtAnchor->setChecked(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)
{
this->setSelected(false);
}
}
示例12: initializeLayouts
void LayoutManagement::initializeLayouts()
{
QMenu *saveLayout = static_cast<QMenu*>(pCore->window()->factory()->container(QStringLiteral("layout_save_as"), pCore->window()));
if (m_loadLayout == NULL || saveLayout == NULL) return;
KSharedConfigPtr config = KSharedConfig::openConfig();
KConfigGroup layoutGroup(config, "Layouts");
QStringList entries = layoutGroup.keyList();
QList<QAction *> loadActions = m_loadLayout->actions();
QList<QAction *> saveActions = saveLayout->actions();
for (int i = 1; i < 5; ++i) {
// Rename the layouts actions
foreach(const QString & key, entries) {
if (key.endsWith(QStringLiteral("_%1").arg(i))) {
// Found previously saved layout
QString layoutName = key.section('_', 0, -2);
for (int j = 0; j < loadActions.count(); ++j) {
if (loadActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
loadActions[j]->setText(layoutName);
loadActions[j]->setData(key);
break;
}
}
for (int j = 0; j < saveActions.count(); ++j) {
if (saveActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
saveActions[j]->setText(i18n("Save as %1", layoutName));
saveActions[j]->setData(key);
break;
}
}
}
}
}
}
示例13: menuActionCount
int ScriptToolbox::menuActionCount(QObject * menu)
{
QMenu * m = qobject_cast<QMenu*>(menu);
if (m)
return m->actions().count();
return 0;
}
示例14: openInApplicationMenuAboutToShow
void WebWidget::openInApplicationMenuAboutToShow()
{
QMenu *menu = qobject_cast<QMenu*>(sender());
if (!menu || !menu->actions().isEmpty())
{
return;
}
const QList<ApplicationInformation> applications = Utils::getApplicationsForMimeType(QMimeDatabase().mimeTypeForName(QLatin1String("text/html")));
if (applications.isEmpty())
{
menu->addAction(tr("Default Application"));
}
else
{
for (int i = 0; i < applications.count(); ++i)
{
menu->addAction(applications.at(i).icon, ((applications.at(i).name.isEmpty()) ? tr("Unknown") : applications.at(i).name))->setData(applications.at(i).command);
if (i == 0)
{
menu->addSeparator();
}
}
}
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(openInApplication(QAction*)));
}
示例15: showNotepadContextMenu
void Notepad::showNotepadContextMenu(const QPoint &pt)
{
// Set Notepad popup menu
QMenu *menu = ui->notepadTextEdit->createStandardContextMenu();
QTextCursor cur = ui->notepadTextEdit->textCursor();
QAction* first = menu->actions().at(0);
if (cur.hasSelection()) {
// Get selected text
//this->main->add_debug_output("Selected text: " + cur.selectedText());
this->addr = cur.selectedText();
} else {
// Get word under the cursor
cur.select( QTextCursor::WordUnderCursor);
//this->main->add_debug_output("Word: " + cur.selectedText());
this->addr = cur.selectedText();
}
ui->actionDisassmble_bytes->setText( "Disassemble bytes at: " + this->addr);
ui->actionDisassmble_function->setText( "Disassemble function at: " + this->addr);
ui->actionHexdump_bytes->setText( "Hexdump bytes at: " + this->addr);
ui->actionCompact_Hexdump->setText( "Compact Hexdump at: " + this->addr);
ui->actionHexdump_function->setText( "Hexdump function at: " + this->addr);
menu->insertAction(first, ui->actionDisassmble_bytes);
menu->insertAction(first, ui->actionDisassmble_function);
menu->insertAction(first, ui->actionHexdump_bytes);
menu->insertAction(first, ui->actionCompact_Hexdump);
menu->insertAction(first, ui->actionHexdump_function);
menu->insertSeparator(first);
ui->notepadTextEdit->setContextMenuPolicy(Qt::DefaultContextMenu);
menu->exec(ui->notepadTextEdit->mapToGlobal(pt));
delete menu;
ui->notepadTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
}