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


C++ KMenu::addMenu方法代码示例

本文整理汇总了C++中KMenu::addMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ KMenu::addMenu方法的具体用法?C++ KMenu::addMenu怎么用?C++ KMenu::addMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KMenu的用法示例。


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

示例1: contextMenuEvent

void ProjectView::contextMenuEvent(QContextMenuEvent *event)
{
	QSignalMapper signalMapper, serviceSignalMapper;
	KMenu popup;
	QAction *action = NULL;

	QTreeWidgetItem* treeWidgetItem = itemAt(event->pos());
	if(!treeWidgetItem) {
		return;
	}

	ProjectViewItem *projectViewItem = dynamic_cast<ProjectViewItem*>(treeWidgetItem);
	if(!projectViewItem) {
		return;
	}

	if(projectViewItem->type() == KileType::Folder) {
		return;
	}

	bool insertsep = false;
	bool isKilePrFile = false;
	if(projectViewItem->type() != KileType::Project && projectViewItem->projectItem()
	                                                && projectViewItem->projectItem()->project()) {
		isKilePrFile = projectViewItem->projectItem()->project()->url() == projectViewItem->url();
	}

	if(projectViewItem->type() == KileType::ProjectExtra && !isKilePrFile) {
		QMenu *servicesMenu = popup.addMenu(KIcon("fork"), i18n("&Open With"));
		connect(&serviceSignalMapper, SIGNAL(mapped(int)), this, SLOT(slotRun(int)));
		m_offerList = KMimeTypeTrader::self()->query(KMimeType::findByUrl(projectViewItem->url())->name(), "Application");
		for (int i = 0; i < m_offerList.count(); ++i) {
			action = new KAction(servicesMenu);
			action->setIcon(KIcon(m_offerList[i]->icon()));
			action->setText(m_offerList[i]->name());
			connect(action, SIGNAL(triggered()), &serviceSignalMapper, SLOT(map()));
			serviceSignalMapper.setMapping(action, i + 1);
			servicesMenu->addAction(action);
		}

		servicesMenu->addSeparator();
		action = servicesMenu->addAction(i18n("Other..."), &serviceSignalMapper, SLOT(map()));
		serviceSignalMapper.setMapping(action, 0);
		insertsep = true;
	}
开发者ID:puneetsl,项目名称:Mikhail,代码行数:45,代码来源:projectview.cpp

示例2: QWidget


//.........这里部分代码省略.........
	audioStreamBox->setModel(audioStreamModel);

	subtitleBox = new KComboBox(toolBar);
	textSubtitlesOff = i18nc("subtitle selection entry", "off");
	connect(subtitleBox, SIGNAL(currentIndexChanged(int)),
		this, SLOT(currentSubtitleChanged(int)));
	toolBar->addWidget(subtitleBox);

	subtitleModel = new QStringListModel(toolBar);
	subtitleBox->setModel(subtitleModel);

	KMenu *audioMenu = new KMenu(i18nc("'Playback' menu", "Audio"), this);

	KAction *action = new KAction(KIcon(QLatin1String("audio-volume-high")),
		i18nc("'Audio' menu", "Increase Volume"), this);
	action->setShortcut(KShortcut(Qt::Key_Plus, Qt::Key_VolumeUp));
	connect(action, SIGNAL(triggered()), this, SLOT(increaseVolume()));
	audioMenu->addAction(collection->addAction(QLatin1String("controls_increase_volume"), action));

	action = new KAction(KIcon(QLatin1String("audio-volume-low")),
		i18nc("'Audio' menu", "Decrease Volume"), this);
	action->setShortcut(KShortcut(Qt::Key_Minus, Qt::Key_VolumeDown));
	connect(action, SIGNAL(triggered()), this, SLOT(decreaseVolume()));
	audioMenu->addAction(collection->addAction(QLatin1String("controls_decrease_volume"), action));

	muteAction = new KAction(i18nc("'Audio' menu", "Mute Volume"), this);
	mutedIcon = KIcon(QLatin1String("audio-volume-muted"));
	unmutedIcon = KIcon(QLatin1String("audio-volume-medium"));
	muteAction->setIcon(unmutedIcon);
	muteAction->setShortcut(KShortcut(Qt::Key_M, Qt::Key_VolumeMute));
	connect(muteAction, SIGNAL(triggered()), this, SLOT(mutedChanged()));
	toolBar->addAction(collection->addAction(QLatin1String("controls_mute_volume"), muteAction));
	audioMenu->addAction(muteAction);
	menu->addMenu(audioMenu);

	KMenu *videoMenu = new KMenu(i18nc("'Playback' menu", "Video"), this);
	menu->addMenu(videoMenu);
	menu->addSeparator();

	deinterlaceAction = new KAction(KIcon(QLatin1String("format-justify-center")),
		i18nc("'Video' menu", "Deinterlace"), this);
	deinterlaceAction->setCheckable(true);
	deinterlaceAction->setChecked(
		KGlobal::config()->group("MediaObject").readEntry("Deinterlace", true));
	deinterlaceAction->setShortcut(Qt::Key_I);
	connect(deinterlaceAction, SIGNAL(toggled(bool)), this, SLOT(deinterlacingChanged(bool)));
	backend->setDeinterlacing(deinterlaceAction->isChecked());
	videoMenu->addAction(collection->addAction(QLatin1String("controls_deinterlace"), deinterlaceAction));

	KMenu *aspectMenu = new KMenu(i18nc("'Video' menu", "Aspect Ratio"), this);
	QActionGroup *aspectGroup = new QActionGroup(this);
	connect(aspectGroup, SIGNAL(triggered(QAction*)),
		this, SLOT(aspectRatioChanged(QAction*)));

	action = new KAction(i18nc("'Aspect Ratio' menu", "Automatic"), aspectGroup);
	action->setCheckable(true);
	action->setChecked(true);
	action->setData(AspectRatioAuto);
	aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_auto"), action));

	action = new KAction(i18nc("'Aspect Ratio' menu", "Fit to Window"), aspectGroup);
	action->setCheckable(true);
	action->setData(AspectRatioWidget);
	aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_widget"), action));

	action = new KAction(i18nc("'Aspect Ratio' menu", "4:3"), aspectGroup);
开发者ID:Brandhand,项目名称:kaffeine-vlc,代码行数:67,代码来源:mediawidget.cpp

示例3: checkAnchor

void TwitterPostWidget::checkAnchor(const QUrl& url)
{
    QString scheme = url.scheme();
    TwitterApiMicroBlog* blog = qobject_cast<TwitterApiMicroBlog*>(currentAccount()->microblog());
    TwitterApiAccount *account = qobject_cast<TwitterApiAccount*>(currentAccount());
    if( scheme == "tag" ) {
        blog->searchBackend()->requestSearchResults(currentAccount(),
                                                    KUrl::fromPunycode(url.host().toUtf8()),
                                                    (int)TwitterSearch::ReferenceHashtag);
    } else if(scheme == "user") {
        KMenu menu;
        KAction * info = new KAction( KIcon("user-identity"), i18nc("Who is user", "Who is %1", url.host()),
                                      &menu );
        KAction * from = new KAction(KIcon("edit-find-user"), i18nc("Posts from user", "Posts from %1",url.host()),
                                     &menu);
        KAction * to = new KAction(KIcon("meeting-attending"), i18nc("Replies to user", "Replies to %1",
                                                                     url.host()),
                                   &menu);
        KAction *cont = new KAction(KIcon("user-properties"),i18nc("Including user name", "Including %1",
                                                                   url.host()),
                                    &menu);
        KAction * openInBrowser = new KAction(KIcon("applications-internet"),
                                              i18nc("Open profile page in browser",
                                                    "Open profile in browser"), &menu);
        from->setData(TwitterSearch::FromUser);
        to->setData(TwitterSearch::ToUser);
        cont->setData(TwitterSearch::ReferenceUser);
        menu.addAction(info);
        menu.addAction(from);
        menu.addAction(to);
        menu.addAction(cont);
        menu.addAction(openInBrowser);

        //Subscribe/UnSubscribe/Block
        bool isSubscribe = false;
        QString accountUsername = currentAccount()->username().toLower();
        QString postUsername = url.host().toLower();
        KAction *subscribe = 0, *block = 0, *replyTo = 0, *dMessage = 0;
        if(accountUsername != postUsername){
            menu.addSeparator();
            QMenu *actionsMenu = menu.addMenu(KIcon("applications-system"), i18n("Actions"));
            replyTo = new KAction(KIcon("edit-undo"), i18nc("Write a message to user attention", "Write to %1",
                                                          url.host()), actionsMenu);
            actionsMenu->addAction(replyTo);
            if( account->friendsList().contains( url.host(),
                Qt::CaseInsensitive ) ){
                dMessage = new KAction(KIcon("mail-message-new"), i18nc("Send direct message to user",
                                                                        "Send private message to %1",
                                                                        url.host()), actionsMenu);
                actionsMenu->addAction(dMessage);
                isSubscribe = false;//It's UnSubscribe
                subscribe = new KAction( KIcon("list-remove-user"),
                                         i18nc("Unfollow user",
                                               "Unfollow %1", url.host()), actionsMenu);
            } else {
                isSubscribe = true;
                subscribe = new KAction( KIcon("list-add-user"),
                                         i18nc("Follow user",
                                               "Follow %1", url.host()), actionsMenu);
            }
            block = new KAction( KIcon("dialog-cancel"),
                                 i18nc("Block user",
                                       "Block %1", url.host()), actionsMenu);
            actionsMenu->addAction(subscribe);
            actionsMenu->addAction(block);
        }

        QAction * ret = menu.exec(QCursor::pos());
        if(ret == 0)
            return;
        if(ret == info) {
            TwitterApiWhoisWidget *wd = new TwitterApiWhoisWidget(account, url.host(),  currentPost(), this);
            wd->show(QCursor::pos());
            return;
        } else if(ret == subscribe){
            if(isSubscribe) {
                blog->createFriendship(currentAccount(), url.host());
            } else {
                blog->destroyFriendship(currentAccount(), url.host());
            }
            return;
        }else if(ret == block){
            blog->blockUser(currentAccount(), url.host());
            return;
        } else if(ret == openInBrowser){
            Choqok::openUrl( QUrl( currentAccount()->microblog()->profileUrl(currentAccount(), url.host()) ) );
            return;
        } else if(ret == replyTo){
            emit reply( QString("@%1").arg(url.host()), QString() );
            return;
        } else if(ret == dMessage){
                blog->showDirectMessageDialog(account,url.host());
            return;
        }
        int type = ret->data().toInt();
        blog->searchBackend()->requestSearchResults(currentAccount(),
                                                    url.host(),
                                                    type);
    } else
        TwitterApiPostWidget::checkAnchor(url);
//.........这里部分代码省略.........
开发者ID:Boris-de,项目名称:choqok,代码行数:101,代码来源:twitterpostwidget.cpp

示例4: KAction

NavigatorConfigAction::NavigatorConfigAction( QWidget * parent )
    : KAction( parent )
{

    KMenu * navigatorMenu = new KMenu( 0 );
    setMenu( navigatorMenu );
    setText( i18n( "Track Progression" ) );

    QActionGroup * navigatorActions = new QActionGroup( navigatorMenu );
    navigatorActions->setExclusive( true );

    m_standardNavigatorAction = navigatorActions->addAction( i18n( "Standard" ) );
    m_standardNavigatorAction->setIcon( KIcon( "media-standard-track-progression-amarok" ) );
    m_standardNavigatorAction->setCheckable( true );
    //action->setIcon( true );

    m_onlyQueueNavigatorAction = navigatorActions->addAction( i18n( "Only Queue" ) );
    m_onlyQueueNavigatorAction->setIcon( KIcon( "media-standard-track-progression-amarok" ) );
    m_onlyQueueNavigatorAction->setCheckable( true );

    QAction * action = new QAction( parent );
    action->setSeparator( true );
    navigatorActions->addAction( action );

    m_repeatTrackNavigatorAction = navigatorActions->addAction( i18n( "Repeat Track" ) );
    m_repeatTrackNavigatorAction->setIcon( KIcon( "media-repeat-track-amarok" ) );
    m_repeatTrackNavigatorAction->setCheckable( true );

    m_repeatAlbumNavigatorAction = navigatorActions->addAction( i18n( "Repeat Album" ) );
    m_repeatAlbumNavigatorAction->setIcon( KIcon( "media-repeat-album-amarok" ) );
    m_repeatAlbumNavigatorAction->setCheckable( true );

    m_repeatPlaylistNavigatorAction = navigatorActions->addAction( i18n( "Repeat Playlist" ) );
    m_repeatPlaylistNavigatorAction->setIcon( KIcon( "media-repeat-playlist-amarok" ) );
    m_repeatPlaylistNavigatorAction->setCheckable( true );

    action = new QAction( parent );
    action->setSeparator( true );
    navigatorActions->addAction( action );

    m_randomTrackNavigatorAction = navigatorActions->addAction( i18n( "Random Tracks" ) );
    m_randomTrackNavigatorAction->setIcon( KIcon( "media-random-tracks-amarok" ) );
    m_randomTrackNavigatorAction->setCheckable( true );

    m_randomAlbumNavigatorAction = navigatorActions->addAction( i18n( "Random Albums" ) );
    m_randomAlbumNavigatorAction->setIcon( KIcon( "media-random-albums-amarok" ) );
    m_randomAlbumNavigatorAction->setCheckable( true );

    navigatorMenu->addActions( navigatorActions->actions() );

    QMenu * favorMenu = navigatorMenu->addMenu( i18n( "Favor" ) );
    QActionGroup * favorActions = new QActionGroup( favorMenu );

    m_favorNoneAction = favorActions->addAction( i18n( "None" ) );
    m_favorNoneAction->setCheckable( true );

    m_favorScoresAction = favorActions->addAction( i18n( "Higher Scores" ) );
    m_favorScoresAction->setCheckable( true );

    m_favorRatingsAction = favorActions->addAction( i18n( "Higher Ratings" ) );
    m_favorRatingsAction->setCheckable( true );

    m_favorLastPlayedAction = favorActions->addAction( i18n( "Not Recently Played" ) );
    m_favorLastPlayedAction->setCheckable( true );

    favorMenu->addActions( favorActions->actions() );

    //make sure the correct entry is selected from start:
    switch( AmarokConfig::trackProgression() )
    {
        case AmarokConfig::EnumTrackProgression::OnlyQueue:
            m_onlyQueueNavigatorAction->setChecked( true );
            setIcon( m_onlyQueueNavigatorAction->icon() );
            break;

        case AmarokConfig::EnumTrackProgression::RepeatTrack:
            m_repeatTrackNavigatorAction->setChecked( true );
            setIcon( m_repeatTrackNavigatorAction->icon() );
            break;

        case AmarokConfig::EnumTrackProgression::RepeatAlbum:
            m_repeatAlbumNavigatorAction->setChecked( true );
            setIcon( m_repeatAlbumNavigatorAction->icon() );
            break;

        case AmarokConfig::EnumTrackProgression::RepeatPlaylist:
            m_repeatPlaylistNavigatorAction->setChecked( true );
            setIcon( m_repeatPlaylistNavigatorAction->icon() );
            break;

        case AmarokConfig::EnumTrackProgression::RandomTrack:
            m_randomTrackNavigatorAction->setChecked( true );
            setIcon( m_randomTrackNavigatorAction->icon() );
            break;

        case AmarokConfig::EnumTrackProgression::RandomAlbum:
            m_randomAlbumNavigatorAction->setChecked( true );
            setIcon( m_randomAlbumNavigatorAction->icon() );
            break;

//.........这里部分代码省略.........
开发者ID:ErrAza,项目名称:amarok,代码行数:101,代码来源:NavigatorConfigAction.cpp


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