当前位置: 首页>>代码示例>>C++>>正文


C++ contextMenu函数代码示例

本文整理汇总了C++中contextMenu函数的典型用法代码示例。如果您正苦于以下问题:C++ contextMenu函数的具体用法?C++ contextMenu怎么用?C++ contextMenu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了contextMenu函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: contextMenu

void CurvesDialog::contextMenuEvent(QContextMenuEvent *e)
{
  QPoint pos = available->viewport()->mapFromGlobal(QCursor::pos());
  QRect rect = available->visualItemRect(available->currentItem());
  if (rect.contains(pos))
  {
    QMenu contextMenu(this);
    QList<QListWidgetItem *> lst = available->selectedItems();
    if (lst.size() > 1)
      contextMenu.insertItem(tr("&Plot Selection"), this, SLOT(addCurves()));
    else if (lst.size() == 1)
      contextMenu.insertItem(tr("&Plot"), this, SLOT(addCurves()));
    contextMenu.exec(QCursor::pos());
  }

  pos = contents->viewport()->mapFromGlobal(QCursor::pos());
  rect = contents->visualItemRect(contents->currentItem());
  if (rect.contains(pos))
  {
    QMenu contextMenu(this);
    QList<QListWidgetItem *> lst = contents->selectedItems();
    if (lst.size() > 1)
      contextMenu.insertItem(tr("&Delete Selection"), this, SLOT(removeCurves()));
    else if (lst.size() == 1)
      contextMenu.insertItem(tr("&Delete Curve"), this, SLOT(removeCurves()));
    contextMenu.exec(QCursor::pos());
  }

  e->accept();
}
开发者ID:jkrueger1,项目名称:mantid,代码行数:30,代码来源:CurvesDialog.cpp

示例2: KSystemTray

amaroK::TrayIcon::TrayIcon( QWidget *playerWidget )
        : KSystemTray( playerWidget )
        , EngineObserver( EngineController::instance() )
        , trackLength( 0 )
        , mergeLevel( -1 )
        , overlay( 0 )
        , blinkTimerID( 0 )
        , overlayVisible( false )
{
    KActionCollection* const ac = amaroK::actionCollection();

    setAcceptDrops( true );

    ac->action( "prev"        )->plug( contextMenu() );
    ac->action( "play_pause"  )->plug( contextMenu() );
    ac->action( "stop"        )->plug( contextMenu() );
    ac->action( "next"        )->plug( contextMenu() );

    //seems to be necessary
    KAction *quit = actionCollection()->action( "file_quit" );
    quit->disconnect();
    connect( quit, SIGNAL(activated()), kapp, SLOT(quit()) );

    baseIcon     = KSystemTray::loadIcon( "amarok" );
    playOverlay  = amaroK::loadOverlay( "play" );
    pauseOverlay = amaroK::loadOverlay( "pause" );
    overlayVisible = false;

    //paintIcon();
    setPixmap( baseIcon );
}
开发者ID:tmarques,项目名称:waheela,代码行数:31,代码来源:systray.cpp

示例3: KStatusNotifierItem

TrayIcon::TrayIcon(MainWindow* parent)
  : KStatusNotifierItem(parent)
{
    setObjectName( "Ktimetracker Tray" );
    // the timer that updates the "running" icon in the tray
    _taskActiveTimer = new QTimer(this);
    connect( _taskActiveTimer, SIGNAL( timeout() ), this,
                               SLOT( advanceClock()) );

    if (icons == 0)
    {
        icons = new QVector<QPixmap*>(8);
        for (int i=0; i<8; i++)
        {
            QPixmap *icon = new QPixmap();
        QString name;
        name.sprintf("active-icon-%d.xpm",i);
        *icon = UserIcon(name);
        icons->insert(i,icon);
        }
    }
    TimetrackerWidget *timetrackerWidget = static_cast< TimetrackerWidget * >( parent->centralWidget() );
    if ( timetrackerWidget )
    {
        KAction *action = timetrackerWidget->action( "configure_ktimetracker" );
        if ( action ) contextMenu()->addAction( action );
        action = timetrackerWidget->action( "stopAll" );
        if ( action ) contextMenu()->addAction( action );
    }
    resetClock();
    initToolTip();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:32,代码来源:tray.cpp

示例4: KSystemTrayIcon

Knazar::Knazar(KAboutData *aboutData)
    : KSystemTrayIcon("knazar")
{
    new KnazarAdaptor(this);
    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerObject("/KNazar", this);

    aboutApplicationDialog = new KAboutApplicationDialog(aboutData);

    //Initialize actions
    actionAbout = new KAction(KIcon("help-about"), i18n("About KNazar"), this);
    actionProtect = new KAction(KIcon("flag-blue"), i18n("Protect"), this);
    actionRelease = new KAction(KIcon("flag-red"), i18n("Release"), this);

    // Connect actions
    connect(actionAbout, SIGNAL(triggered(bool)), aboutApplicationDialog, SLOT(show()));
    connect(actionProtect, SIGNAL(triggered(bool)), this, SLOT(protect_from_harmful_looks()));
    connect(actionRelease, SIGNAL(triggered(bool)), this, SLOT(release_the_protection()));

    // Add them to menu
    contextMenu()->addAction(actionProtect);
    contextMenu()->addAction(actionRelease);
    contextMenu()->addSeparator();
    contextMenu()->addAction(actionAbout);

    // Initialize variables
    protection_working = true;
    number_of_attacks = defated_attacks = 0;
    setToolTip(i18n("KNazar - No harmful look allowed!" ));
    normalIcon = icon();
    grayIcon.addPixmap(icon().pixmap(22, 22, QIcon::Disabled));
}
开发者ID:Tayyib,项目名称:uludag,代码行数:32,代码来源:knazar.cpp

示例5: QDialog

zoomWindow::zoomWindow(Image *image, Site *site, QMap<QString,Site*> *sites, QWidget *)
    : QDialog(0, Qt::Window), ui(new Ui::zoomWindow), m_site(site), timeout(300), m_loaded(0), oldsize(0), image(NULL), movie(NULL), m_program(qApp->arguments().at(0)), m_reply(NULL), m_finished(false), m_thread(false), m_data(QByteArray()), m_size(0), m_sites(sites), m_source(), m_th(NULL), m_fullScreen(NULL)
{
	ui->setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose);

	QList<Favorite> favorites = loadFavorites();
	for (Favorite fav : favorites)
		m_favorites.append(fav.getName());
	m_viewItLater = loadViewItLater();
    m_ignore = loadIgnored();
	m_image = new Image(site, image->details(), image->page());
	connect(m_image, &Image::urlChanged, this, &zoomWindow::urlChanged);

	m_mustSave = 0;

	QSettings settings(savePath("settings.ini"), QSettings::IniFormat);
	restoreGeometry(settings.value("Zoom/geometry").toByteArray());
	ui->buttonPlus->setChecked(settings.value("Zoom/plus", false).toBool());

	QShortcut *escape = new QShortcut(QKeySequence(Qt::Key_Escape), this);
		connect(escape, SIGNAL(activated()), this, SLOT(close()));
	QShortcut *save = new QShortcut(QKeySequence::Save, this);
		connect(save, SIGNAL(activated()), this, SLOT(saveImage()));
	QShortcut *saveAs = new QShortcut(QKeySequence("Ctrl+Shift+S"), this);
		connect(saveAs, SIGNAL(activated()), this, SLOT(saveImageAs()));

	m_labelTagsLeft = new QAffiche(QVariant(), 0, QColor(), this);
		m_labelTagsLeft->setContextMenuPolicy(Qt::CustomContextMenu);
		m_labelTagsLeft->setTextInteractionFlags(Qt::TextBrowserInteraction);
		connect(m_labelTagsLeft, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
		connect(m_labelTagsLeft, SIGNAL(linkActivated(QString)), this, SLOT(openUrl(QString)));
		connect(m_labelTagsLeft, SIGNAL(linkHovered(QString)), this, SLOT(linkHovered(QString)));
		connect(m_labelTagsLeft, SIGNAL(middleClicked()), this, SLOT(openInNewTab()));
		ui->scrollAreaWidgetContents->layout()->addWidget(m_labelTagsLeft);

	m_labelTagsTop = new QAffiche(QVariant(), 0, QColor(), this);
		m_labelTagsTop->setWordWrap(true);
		m_labelTagsTop->setContextMenuPolicy(Qt::CustomContextMenu);
		m_labelTagsTop->setTextInteractionFlags(Qt::TextBrowserInteraction);
		connect(m_labelTagsTop, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
		connect(m_labelTagsTop, SIGNAL(linkActivated(QString)), this, SLOT(openUrl(QString)));
		connect(m_labelTagsTop, SIGNAL(linkHovered(QString)), this, SLOT(linkHovered(QString)));
		connect(m_labelTagsTop, SIGNAL(middleClicked()), this, SLOT(openInNewTab()));
		ui->verticalLayout->insertWidget(0, m_labelTagsTop, 0);

	m_imageTime = NULL;
	go();
}
开发者ID:larry-he,项目名称:imgbrd-grabber,代码行数:49,代码来源:zoomwindow.cpp

示例6: KSystemTray

KXNeurTray::KXNeurTray()
 : KSystemTray()
{
    QPixmap pic;
    actions = new KActionCollection(this);
    menu = contextMenu();
    KApplication *app = KApplication::kApplication();

    // languages set in KXNeurApp::refresh_lang()
    menu->insertSeparator();

    mode = new KAction(i18n("Set manual mode"), "embedjs", 0, app, SLOT(slotUpdateMode()), actions);
    mode->plug(menu);
    run = new KAction(i18n("Stop xneur daemon"), "stop", 0, app, SLOT(slotUpdateRun()), actions);
    run->plug(menu);

    menu->insertSeparator();
    KAction *pref = KStdAction::preferences(app, SLOT(slotPref()), actions);
    pref->plug(menu);
    KAction *help = KStdAction::help(this, SLOT(slotHelp()), actions);
    help->plug(menu);
    KAction *about = KStdAction::aboutApp(this, SLOT(slotAbout()), actions);
    about->plug(menu);

    QObject::connect(menu, SIGNAL(activated(int)), app, SLOT(setMenuLang(int)));

    pic = kapp->iconLoader()->loadIcon("keyboard_layout", KIcon::Small);
    menu->changeTitle(menu->idAt(0), pic, i18n("KXNeur"));
    setPixmap(pic);
}
开发者ID:voidptr,项目名称:xneur-option,代码行数:30,代码来源:kxneurtray.cpp

示例7: QMenu

void db_x509req::showContextMenu(QContextMenuEvent *e, const QModelIndex &index)
{
	QMenu *menu = new QMenu(mainwin);
	QMenu *subExport;
	currentIdx = index;

	pki_x509req *req = static_cast<pki_x509req*>(index.internalPointer());

	menu->addAction(tr("New Request"), this, SLOT(newItem()));
	menu->addAction(tr("Import"), this, SLOT(load()));
	if (index != QModelIndex()) {
		if (!req->getRefKey())
			menu->addAction(tr("Extract public Key"),
				this, SLOT(extractPubkey()));
		menu->addAction(tr("Rename"), this, SLOT(edit()));
		menu->addAction(tr("Show Details"), this, SLOT(showItem()));
		menu->addAction(tr("Sign"), this, SLOT(signReq()));
		subExport = menu->addMenu(tr("Export"));
		subExport->addAction(tr("Clipboard"), this,
					SLOT(pem2clipboard()));
		subExport->addAction(tr("File"), this, SLOT(store()));
		subExport->addAction(tr("Template"), this, SLOT(toTemplate()));
		subExport->addAction(tr("OpenSSL config"), this,
					SLOT(toOpenssl()));
		menu->addAction(tr("Delete"), this, SLOT(delete_ask()));

		subExport->setEnabled(!req->isSpki());
	}
	contextMenu(e, menu);
	currentIdx = QModelIndex();
	return;
}
开发者ID:jbfavre,项目名称:xca,代码行数:32,代码来源:db_x509req.cpp

示例8: contextMenu

void PerformanceCounterSelection::counterTree_contextMenu(const QPoint &pos)
{
  RDTreeWidgetItem *item = ui->counterTree->itemAt(pos);

  QMenu contextMenu(this);

  QAction expandAll(tr("&Expand All"), this);
  QAction collapseAll(tr("&Collapse All"), this);

  contextMenu.addAction(&expandAll);
  contextMenu.addAction(&collapseAll);

  expandAll.setIcon(Icons::arrow_out());
  collapseAll.setIcon(Icons::arrow_in());

  expandAll.setEnabled(item && item->childCount() > 0);
  collapseAll.setEnabled(item && item->childCount() > 0);

  QObject::connect(&expandAll, &QAction::triggered,
                   [this, item]() { ui->counterTree->expandAllItems(item); });

  QObject::connect(&collapseAll, &QAction::triggered,
                   [this, item]() { ui->counterTree->collapseAllItems(item); });

  RDDialog::show(&contextMenu, ui->counterTree->viewport()->mapToGlobal(pos));
}
开发者ID:cgmb,项目名称:renderdoc,代码行数:26,代码来源:PerformanceCounterSelection.cpp

示例9: KSystemTrayIcon

DockWidget::DockWidget(QWidget *parent, const char *name, PPPStats *st)
  : KSystemTrayIcon(parent), stats(st) {

  setObjectName(name);

  // load pixmaps
  dock_none_pixmap = UserIcon("dock_none");
  dock_left_pixmap = UserIcon("dock_left");
  dock_right_pixmap = UserIcon("dock_right");
  dock_both_pixmap = UserIcon("dock_both");

  setIcon(dock_none_pixmap);

  // popup menu for right mouse button
  popup_m = contextMenu();
  popup_m->addAction(i18n("Details"), p_kppp, SLOT(showStats()));
  popup_m->addSeparator();
  popup_m->addAction(i18n("Disconnect"), p_kppp, SLOT(disconnect()));
  // TODO see if we can rather connect the quit action to the
  // main window's quit handling, bypassing KSystemTrayIcon::maybeQuit
  QAction *quit =
    actionCollection()->action(KStandardAction::name(KStandardAction::Quit));
  if (quit != 0)
    quit->setVisible(false);
  // connect to stats for little modem animation
  connect(stats, SIGNAL(statsChanged(int)), SLOT(paintIcon(int)));

  DockWidget::dock_widget = this;
}
开发者ID:KDE,项目名称:kppp,代码行数:29,代码来源:docking.cpp

示例10: contextMenu

void nineButtonSelector::contextMenuEvent( QContextMenuEvent * )
{
	captionMenu contextMenu( windowTitle() );
	contextMenu.addAction( embed::getIconPixmap( "help" ), tr( "&Help" ),
			       this, SLOT( displayHelp() ) );
	contextMenu.exec( QCursor::pos() );
}
开发者ID:Orpheon,项目名称:lmms,代码行数:7,代码来源:nine_button_selector.cpp

示例11: KSystemTrayIcon

/** class Tray
  * Reimplmentation of the system tray class adding drag/drop
  * capabilities and the quit action.
  */
Tray::Tray(MainWindow * parent)
    : KSystemTrayIcon(parent),
      grayedIcon( 0 ),
      alternateIcon( 0 ),
      playOverlay( 0 ),
      m_downloading( false )
{
    baseIcon = new QPixmap( KSystemTrayIcon::loadIcon("kget").pixmap(22) );
    // 12x12 pixel overlay looks fine, amarok uses 10x10
    playOverlay = new QPixmap( SmallIcon( "media-playback-start", 12 ) );

    paintIcon();

    // add preferences action to the context menu
    QMenu * cm = contextMenu();
    cm->addAction( parent->actionCollection()->action("new_download") );
    cm->addAction( parent->actionCollection()->action("import_links") );
    cm->addSeparator();
    cm->addAction( parent->actionCollection()->action("start_all_download") );
    cm->addAction( parent->actionCollection()->action("stop_all_download") );
    cm->addSeparator();
    cm->addAction( parent->actionCollection()->action("konqueror_integration") );
    cm->addAction( parent->actionCollection()->action("show_drop_target") );
    cm->addAction( parent->actionCollection()->action("options_configure") );

    // add tooltip telling "I'm kget"
    setToolTip(i18n("KGet - Download Manager"));

    // connecting the "Exit" menu item to the quit() of our app
    connect( this, SIGNAL( quitSelected() ), kapp, SLOT(quit()));
    connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ),
                   SLOT( slotActivated( QSystemTrayIcon::ActivationReason ) ) );
}
开发者ID:mfuchs,项目名称:kget-gsoc,代码行数:37,代码来源:tray.cpp

示例12: DCOPObject

knazar::knazar()
    : DCOPObject( "DCOPNazarIface" ), KSystemTray( 0, "knazar" )
{
	// Insert TrayIcon
	trayIcon = KSystemTray::loadIcon( "knazar" );
	setPixmap( trayIcon );

	// Initialize and Register KNazar DCOP Interface so any KDE program can make Nazar easily
	if ( !kapp->dcopClient()->isRegistered() )
	{
		kapp->dcopClient()->registerAs( "knazar" );
		kapp->dcopClient()->setDefaultObject( objId() );
	}


	// Build PopupMenu
	KPopupMenu* menu = contextMenu();

	( new KAction( i18n( "Protect" ), "ledgreen", 0, this, SLOT( protect_from_harmfull_looks() ), this ) )->plug( menu );
	( new KAction( i18n( "Release" ), "ledred", 0, this, SLOT( release_the_protection() ), this ) )->plug( menu );
	menu->insertSeparator();
	( new KAction( i18n( "About" ), "about", 0, this, SLOT( about() ), this ) )->plug( menu );

	// Initialize variables
	protection_working = true;
	number_of_attacks = defated_attacks = 0;
	QToolTip::add( this, i18n( "knazar - No Harmfull look allowed!" ));
}
开发者ID:Tayyib,项目名称:uludag,代码行数:28,代码来源:knazar.cpp

示例13: getGroup

/*! \brief show the context menu
 */
void XletSwitchBoard::contextMenuEvent(QContextMenuEvent *event)
{
    // check if there is a group under the cursor
    Group *group = getGroup(m_layout->getPosInGrid(event->pos()));

    QMenu contextMenu(this);
    QAction *action;
    if (group) {
        action = contextMenu.addAction(tr("Remove group %1").arg(group->name()),
                                       this, SLOT(removeGroup()));
        action->setProperty("group", QVariant::fromValue((void *)group));

        action = contextMenu.addAction(tr("Change color of group %1").arg(group->name()),
                                       this, SLOT(changeGroupColor()));
        action->setProperty("group", QVariant::fromValue((void *)group));

        action = contextMenu.addAction(tr("Rename group %1").arg(group->name()),
                                       this, SLOT(changeGroupName())); 
        action->setProperty("group", QVariant::fromValue((void *)group));
    }

    action = contextMenu.addAction(tr("Add Phone number entry"),
                                   this, SLOT(addPhoneNumberEntry()));
    action->setProperty("pos", m_layout->getPosInGrid(event->pos()));

    action = new QAction(tr("Draw the grid"), this);
    action->setCheckable(true);
    action->setChecked(m_drawGrid);
    connect(action, SIGNAL(toggled(bool)),
            this, SLOT(drawTheGrid(bool)));
    contextMenu.addAction(action);

    contextMenu.exec(event->globalPos());
}
开发者ID:Eyepea,项目名称:xivo-gallifrey,代码行数:36,代码来源:switchboardwindow.cpp

示例14: contextMenu

void QueryResultsNode::contextMenu(const QModelIndexList &list, INodeView *view)
{
    typedef QSet<QueryResultItem::Holder>              ItemsSet;
    typedef QList<QueryResultItem::Holder>             ItemsList;
    typedef QMap<QueryResultItem::Holder, QModelIndex> ItemsIndexMap;

    ItemsSet set;
    ItemsList items;
    QueryResultItem::Holder item;
    ItemsIndexMap itemsIndex;
    ContextMenu contextMenu(m_container.container());

    for (ItemsList::size_type i = 0, size = list.size(); i < size; ++i)
        if ((item = static_cast<QueryResultItem *>(list.at(i).internalPointer())).as<QueryResultItem>()->isPath() && !set.contains(item))
        {
            set.insert(item);
            itemsIndex[item] = list.at(i);
            contextMenu.add(item, item.as<QueryResultPathItem>()->info());
        }

    items = set.toList();

    contextMenu.add(Default::GlobalActions::instance()->copyAction(), ContextMenu::GeneralSection);
    contextMenu.add(Default::GlobalActions::instance()->cutAction(), ContextMenu::GeneralSection);

    if (items.size() == 1 && items.at(0).as<QueryResultPathItem>()->info()->isDir())
        contextMenu.add(Default::GlobalActions::instance()->pasteIntoFolderAction(), ContextMenu::GeneralSection);

    contextMenu.add(Default::GlobalActions::instance()->propertiesAction(), ContextMenu::PropertiesSection);

    if (const Action *action = contextMenu.exec())
    {
        Action::FilesList files = contextMenu.files(action);

        if (action->isAsynchronous())
        {
            ::Tools::Memory::ScopedPointer<PerformActionTask> task;

            if (task = static_cast<const AsyncAction *>(action)->process(this, m_container.container(), files))
            {
                Union update;
                Snapshot::Files list(m_container.container());

                for (Action::FilesList::size_type i = 0, size = files.size(); i < size; ++i)
                {
                    item = files.at(i).first;

//                    item->lock(static_cast<const AsyncAction *>(action)->lockReason());
//                    update.add(itemsIndex.value(item));
                    list.add(item.as<QueryResultPathItem>()->info()->fileName(), item);
                }

//                addTask(task.take(), list);
//                updateFirstColumn(update);
            }
        }
        else
            static_cast<const SyncAction *>(action)->process(m_container.container(), files);
    }
}
开发者ID:vilkov,项目名称:qfm,代码行数:60,代码来源:idm_queryresultsnode.cpp

示例15: contextMenu

void sampleTCOView::contextMenuEvent( QContextMenuEvent * _cme )
{
	QMenu contextMenu( this );
	if( fixedTCOs() == false )
	{
		contextMenu.addAction( embed::getIconPixmap( "cancel" ),
					tr( "Delete (middle mousebutton)" ),
						this, SLOT( remove() ) );
		contextMenu.addSeparator();
		contextMenu.addAction( embed::getIconPixmap( "edit_cut" ),
					tr( "Cut" ), this, SLOT( cut() ) );
	}
	contextMenu.addAction( embed::getIconPixmap( "edit_copy" ),
					tr( "Copy" ), m_tco, SLOT( copy() ) );
	contextMenu.addAction( embed::getIconPixmap( "edit_paste" ),
					tr( "Paste" ), m_tco, SLOT( paste() ) );
	contextMenu.addSeparator();
	contextMenu.addAction( embed::getIconPixmap( "muted" ),
				tr( "Mute/unmute (<Ctrl> + middle click)" ),
						m_tco, SLOT( toggleMute() ) );
	contextMenu.addAction( embed::getIconPixmap( "record" ),
				tr( "Set/clear record" ),
						m_tco, SLOT( toggleRecord() ) );
	constructContextMenu( &contextMenu );

	contextMenu.exec( QCursor::pos() );
}
开发者ID:Orpheon,项目名称:lmms,代码行数:27,代码来源:sample_track.cpp


注:本文中的contextMenu函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。