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


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

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


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

示例1: setupMenuFile

void KUI_project::setupMenuFile()
{
  
  KMenu *fileMenu = new KMenu(i18n("&File"),this);
   
  KAction *action = KStandardAction::openNew(this, SLOT(newProjectDialogSlot()), collection);
  fileMenu->addAction(collection->addAction("new_file", action));
  
  fileMenu->addSeparator();
  
  action = KStandardAction::open(this, SLOT(openFileSlot()), collection);
  fileMenu->addAction(collection->addAction("open_file", action));
  
  action = KStandardAction::save(this, SLOT(saveFileSlot()), collection);
  action->setEnabled(false);
  //fileMenu->addAction(collection->addAction("save_file", action)); 
  
  action = KStandardAction::saveAs(this, SLOT(saveAsFileSlot()), collection);
  action->setEnabled(false);      
  //fileMenu->addAction(collection->addAction("save_as_file", action));
  
  fileMenu->addSeparator();
  
  action = KStandardAction::quit(this, SLOT(close()), collection);
  fileMenu->addAction(collection->addAction("quit", action)); 
  
  menuBar->addMenu(fileMenu);
}
开发者ID:mluscon,项目名称:KDE-Usability-Inspector,代码行数:28,代码来源:KUI_project.cpp

示例2: slotContextMenu

void ActionWidget::slotContextMenu( K3ListView *, Q3ListViewItem *item,
                                    const QPoint& pos )
{
    if ( !item )
        return;

    KMenu *menu = new KMenu;
    QAction* addCmd = menu->addAction( i18n("Add Command") );
    QAction* rmCmd = menu->addAction( i18n("Remove Command") );
    if ( !item->parent() ) {// no "command" item
        rmCmd->setEnabled( false );
        item->setOpen( true );
    }

    QAction* executed = menu->exec( pos );
    if ( executed == addCmd ) {
        Q3ListViewItem *p = item->parent() ? item->parent() : item;
        Q3ListViewItem *cmdItem = new Q3ListViewItem( p, item,
                         i18n("Click here to set the command to be executed"),
                         i18n("<new command>") );
        cmdItem->setPixmap( 0, SmallIcon( "exec" ) );
    }
    else if ( executed == rmCmd )
        delete item;

    delete menu;
}
开发者ID:jschwartzenberg,项目名称:kicker,代码行数:27,代码来源:configdialog.cpp

示例3: contextMenu

void Container::contextMenu( int currentTab, QPoint pos )
{
    KMenu menu;

    emit tabContextMenuRequested(viewForWidget(widget(currentTab)), &menu);

    menu.addSeparator();
    QAction* closeTabAction = menu.addAction( KIcon("document-close"), i18n( "Close File" ) );
    QAction* closeOtherTabsAction = menu.addAction( KIcon("document-close"), i18n( "Close Other Files" ) );
    QAction* closeAllTabsAction = menu.addAction( KIcon("document-close"), i18n( "Close All Files" ) );

    QAction* triggered = menu.exec(pos);

    if (triggered) {
        if ( triggered == closeTabAction ) {
            closeRequest(currentTab);
        } else if ( triggered == closeOtherTabsAction ) {
            // activate the remaining tab
            widgetActivated(currentTab);
            // first get the widgets to be closed since otherwise the indices will be wrong
            QList<QWidget*> otherTabs;
            for ( int i = 0; i < count(); ++i ) {
                if ( i != currentTab ) {
                    otherTabs << widget(i);
                }
            }
            // finally close other tabs
            foreach( QWidget* tab, otherTabs ) {
                closeRequest(tab);
            }
        } else if ( triggered == closeAllTabsAction ) {
开发者ID:portaloffreedom,项目名称:kdev-golang-plugin,代码行数:31,代码来源:container.cpp

示例4: KStatusNotifierItem

/** class Tray
  * Reimplementation of the KStatusNotifierItem class
  */
Tray::Tray(MainWindow * parent)
    : KStatusNotifierItem(parent)
{
    // set up the context menu
    KMenu * 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("options_configure") );

    // Set up basic tray parameters
    setCategory(ApplicationStatus);
    setIconByName("kget");
    setTitle(i18n("KGet"));
    setContextMenu(cm);
    setAssociatedWidget(parent);
    setToolTipIconByName("kget");
    setToolTipTitle(i18n("Download Manager"));
    // Not of much use atm, but maybe we want to set this later?
    // setToolTipSubTitle("[..]");

    // filter middle mouse clicks to ask scheduler to paste URL
    connect( this, SIGNAL(secondaryActivateRequested(QPoint)),
             this, SLOT(slotActivated()) );
}
开发者ID:KDE,项目名称:kget,代码行数:32,代码来源:tray.cpp

示例5: on_editor_contextMenu

void SxEditor::on_editor_contextMenu( QMenu* menu, bool *pbContinue )
{
	KMenu *pMenu = qobject_cast<KMenu*>(menu);
	{
		QAction *action = pMenu->addAction("粗体", this, SLOT(on_common_command_clicked()));
		action->setObjectName("bold");
	}
	{
		QAction *action = pMenu->addAction("斜体", this, SLOT(on_common_command_clicked()));
		action->setObjectName("italic");
	}
	{
		QAction *action = pMenu->addAction("下划线", this, SLOT(on_common_command_clicked()));
		action->setObjectName("underline");
	}
	{
		QAction *action = pMenu->addAction("删除线", this, SLOT(on_common_command_clicked()));
		action->setObjectName("throughout");
	}
	{
		QAction *action = menu->addSeparator();
	}

	{
		QAction *action = menu->addAction("选择全部", this, SLOT(on_common_command_clicked()));
		action->setObjectName("selectAll");
	}

	{
		QAction *action = menu->addAction("粘贴", this, SLOT(on_common_command_clicked()));
		bool bEnable = false;
		QClipboard *clipboard = QApplication::clipboard();
		if(clipboard )
		{
			const QMimeData *mimedata = clipboard->mimeData();
			if (mimedata->hasHtml() || mimedata->hasImage() || mimedata->hasText() || mimedata->hasUrls() || mimedata->hasFormat(KTextEditMime))
			{
				bEnable = true;
			}
		}
		action->setEnabled(bEnable && !m_pTextEdit->isReadOnly());
		action->setObjectName("paste");
	}

	QTextCursor cursor = m_pTextEdit->textCursor();
	bool hasText = !cursor.selection().isEmpty();
	{
		QAction *action = menu->addAction("剪切", this, SLOT(on_common_command_clicked()));
		action->setEnabled(hasText && !m_pTextEdit->isReadOnly());
		action->setObjectName("cut");
	}

	{
		QAction *action = menu->addAction("复制", this, SLOT(on_common_command_clicked()));
		action->setEnabled(hasText);
		action->setObjectName("copy");
	}
	*pbContinue  = false;
}
开发者ID:kxtry,项目名称:sxnote,代码行数:59,代码来源:sxeditor.cpp

示例6: setServiceMenu

void Configuration::setServiceMenu()
{
    KMenu *menu = qobject_cast<KMenu*>(sender());

    if (menu->actions().count() > 1)
    {
        return;
    }

    KServiceGroup::Ptr rootGroup = KServiceGroup::group(menu->actions()[0]->data().toString());

    if (!rootGroup || !rootGroup->isValid() || rootGroup->noDisplay())
    {
        return;
    }

    KServiceGroup::List list = rootGroup->entries(true, true, true, true);

    QAction *action = menu->addAction(KIcon("list-add"), i18n("Add This Menu"));
    action->setData(rootGroup->relPath());

    menu->addSeparator();

    for (int i = 0; i < list.count(); ++i)
    {
        if (list.at(i)->isType(KST_KService))
        {
            const KService::Ptr service = KService::Ptr::staticCast(list.at(i));

            action = menu->addAction(KIcon(service->icon()), service->name());
            action->setEnabled(false);
        }
        else if (list.at(i)->isType(KST_KServiceGroup))
        {
            const KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast(list.at(i));

            if (group->noDisplay() || group->childCount() == 0)
            {
                continue;
            }

            KMenu *subMenu = new KMenu(menu);

            QAction *action = subMenu->addAction(QString());
            action->setData(group->relPath());
            action->setVisible(false);

            action = menu->addAction(KIcon(group->icon()), group->caption());
            action->setMenu(subMenu);

            connect(subMenu, SIGNAL(aboutToShow()), this, SLOT(setServiceMenu()));
        }
        else if (list.at(i)->isType(KST_KServiceSeparator))
        {
            menu->addSeparator();
        }
    }
}
开发者ID:amithash,项目名称:fancytasks,代码行数:58,代码来源:FancyTasksConfiguration.cpp

示例7: themeMenuAboutToShow

void Widget::themeMenuAboutToShow()
{
  if ( !d->mStorageModel )
    return;

  KMenu * menu = dynamic_cast< KMenu * >( sender() );
  if ( !menu )
    return;

  menu->clear();

  menu->addTitle( i18n( "Theme" ) );

  QActionGroup * grp = new QActionGroup( menu );

  const QHash< QString, Theme * > & themes = Manager::instance()->themes();

  QAction * act;

  QList< const Theme * > sortedThemes;

  for ( QHash< QString, Theme * >::ConstIterator ci = themes.constBegin(); ci != themes.constEnd(); ++ci )
  {
    int idx = 0;
    int cnt = sortedThemes.count();
    while ( idx < cnt )
    {
      if ( sortedThemes.at( idx )->name() > ( *ci )->name() )
      {
        sortedThemes.insert( idx, *ci );
        break;
      }
      idx++;
    }

    if ( idx == cnt )
      sortedThemes.append( *ci );
  }

  for ( QList< const Theme * >::ConstIterator it = sortedThemes.constBegin(); it != sortedThemes.constEnd(); ++it )
  {
    act = menu->addAction( ( *it )->name() );
    act->setCheckable( true );
    grp->addAction( act );
    act->setChecked( d->mLastThemeId == ( *it )->id() );
    act->setData( QVariant( ( *it )->id() ) );
    connect( act, SIGNAL( triggered( bool ) ),
             SLOT( themeSelected( bool ) ) );
  }

  menu->addSeparator();

  act = menu->addAction( i18n( "Configure..." ) );
  connect( act, SIGNAL( triggered( bool ) ),
           SLOT( configureThemes() ) );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:56,代码来源:widgetbase.cpp

示例8: DemoWidget

 DemoWidget() : QWidget()
 {
     menu = new KMenu("Popup Menu:");
     menu->addAction( "Item1" );
     menu->addAction( "Item2" );
     menu->addSeparator();
     QAction *a = new QAction( "Quit", this );
     menu->addAction( a );
     connect( a, SIGNAL(triggered()), qApp, SLOT(quit()));
 }
开发者ID:vasi,项目名称:kdelibs,代码行数:10,代码来源:kpopuptest.cpp

示例9: contextMenu

void TabBar::contextMenu(int tab, const QPoint &pos)
{
    KActionMenu *closedTabsMenu = setupHistoryActions();

    m_actualIndex = tab;

    KMenu menu;
    MainWindow *mainWindow = rApp->mainWindow();

    menu.addAction(mainWindow->actionByName(QL1S("new_tab")));
    menu.addAction(mainWindow->actionByName(QL1S("clone_tab")));
    if (count() > 1)
    {
        menu.addAction(mainWindow->actionByName(QL1S("detach_tab")));
    }
    menu.addAction(mainWindow->actionByName(QL1S("open_last_closed_tab")));
    menu.addAction(closedTabsMenu);
    menu.addSeparator();
    menu.addAction(mainWindow->actionByName(QL1S("close_tab")));
    if (count() > 1)
    {
        menu.addAction(mainWindow->actionByName(QL1S("close_other_tabs")));
    }
    menu.addSeparator();
    menu.addAction(mainWindow->actionByName(QL1S("reload_tab")));
    if (count() > 1)
    {
        menu.addAction(mainWindow->actionByName(QL1S("reload_all_tabs")));
    }
    menu.exec(pos);
}
开发者ID:Arakmar,项目名称:rekonq,代码行数:31,代码来源:tabbar.cpp

示例10: setupMenuSettings

void KUI_project::setupMenuSettings()
{
  KMenu *settingsMenu = new KMenu(i18n("&Settings"),this);
  
  menuBar->addMenu(settingsMenu);
  
  KAction *action = KStandardAction::configureToolbars(this, SLOT(), collection);
  settingsMenu->addAction(collection->addAction("configure_toolbars", action));
  
  action = KStandardAction::preferences(this, SLOT(), collection);
  settingsMenu->addAction(collection->addAction("configure_kui", action));
}
开发者ID:mluscon,项目名称:KDE-Usability-Inspector,代码行数:12,代码来源:KUI_project.cpp

示例11: init

void kMyMoneyCalendar::init(const QDate &dt)
{
  styleControl = new QPushButton(i18n("Select Style"), this);
  yearForward = new QToolButton(this);
  yearBackward = new QToolButton(this);
  monthForward = new QToolButton(this);
  monthBackward = new QToolButton(this);
  selectMonth = new QToolButton(this);
  selectYear = new QToolButton(this);
  line = new KLineEdit(this);
  val = new KDateValidator(this);
  fontsize = 10;

  d->selectWeek = new QToolButton(this);

  KMenu* kpopupmenuNew = new KMenu(this);
  kpopupmenuNew->addAction(i18n("Week"), this, SLOT(slotSetStyleWeekly()));
  kpopupmenuNew->addAction(i18n("Month"), this, SLOT(slotSetStyleMonthly()));
  styleControl->setMenu(kpopupmenuNew);

  styleControl->setToolTip(i18n("Choose Style"));
  yearForward->setToolTip(i18n("Next year"));
  yearBackward->setToolTip(i18n("Previous year"));
  monthForward->setToolTip(i18n("Next month"));
  monthBackward->setToolTip(i18n("Previous month"));
  d->selectWeek->setToolTip(i18n("Select a week"));
  selectMonth->setToolTip(i18n("Select a month"));
  selectYear->setToolTip(i18n("Select a year"));

  // -----
  setFontSize(10);
  line->setValidator(val);
  line->installEventFilter(this);
  yearForward->setIcon(QIcon(BarIcon("arrow-right-double")));
  yearBackward->setIcon(QIcon(BarIcon("arrow-left-double")));
  monthForward->setIcon(QIcon(BarIcon("arrow-right")));
  monthBackward->setIcon(QIcon(BarIcon("arrow-left")));
  setDate(dt); // set button texts
  connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
  connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
  connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()));
  connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()));
  connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()));
  connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
  connect(d->selectWeek, SIGNAL(clicked()), SLOT(selectWeekClicked()));
  connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
  connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
  connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
  if (table)
    table->setFocus();
}
开发者ID:CGenie,项目名称:kmymoney,代码行数:51,代码来源:kmymoneycalendar.cpp

示例12: customContextMenuRequested

void ArchiveMailWidget::customContextMenuRequested(const QPoint&)
{
  const QList<QTreeWidgetItem *> listItems = mWidget->treeWidget->selectedItems();
  KMenu menu;
  menu.addAction(i18n("Add..."),this,SLOT(slotAddItem()));
  if( !listItems.isEmpty() ) {
   if( listItems.count() == 1) {
      menu.addAction(i18n("Open Containing Folder..."),this,SLOT(slotOpenFolder()));
    }
    menu.addSeparator();
    menu.addAction(i18n("Delete"),this,SLOT(slotRemoveItem()));
  }
  menu.exec(QCursor::pos());
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:14,代码来源:archivemaildialog.cpp

示例13: popupMenu

void DockContainer::popupMenu(QPoint p)
{
    KMenu *pm = new KMenu(this);
    QAction *kill  = pm->addAction( i18n("Kill This Applet"));
    QAction *change = pm->addAction( i18n("Change Command"));
    QAction *r = pm->exec(p);
        /* pm is destroyed now .. if it is destroyed later,
           there is a risk that kill() double-frees it */
    delete pm;
    
    if (r == kill)
	this->kill();
    if (r == change)
        askNewCommand(false);
}
开发者ID:jschwartzenberg,项目名称:kicker,代码行数:15,代码来源:dockcontainer.cpp

示例14: slotInitMenu

/******************************************************************************
* Called when the New From Template action is clicked.
* Creates a popup menu listing all alarm templates, in sorted name order.
*/
void TemplateMenuAction::slotInitMenu()
{
	KMenu* m = menu();
	m->clear();
	mOriginalTexts.clear();

	// Compile a sorted list of template names
	int i, end;
	QStringList sorted;
	KAEvent::List templates = KAlarm::templateList();
	for (i = 0, end = templates.count();  i < end;  ++i)
	{
		QString name = templates[i]->templateName();
		int j = 0;
		for (int jend = sorted.count();
		     j < jend  &&  QString::localeAwareCompare(name, sorted[j]) > 0;
		     ++j) ;
		sorted.insert(j, name);
	}

	for (i = 0, end = sorted.count();  i < end;  ++i)
	{
		QAction* act = m->addAction(sorted[i]);
		mOriginalTexts[act] = sorted[i];   // keep original text, since action text has shortcuts added
	}
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:30,代码来源:templatemenuaction.cpp

示例15: QWidget

ComponentWidget::ComponentWidget(QWidget *parent, Clock *clock) : QWidget(parent),
    m_clock(clock),
    m_component(InvalidComponent)
{
    m_componentUi.setupUi(this);

    KMenu *menu = new KMenu(m_componentUi.componentButton);

    for (int i = 1; i < LastComponent; ++i) {
        QAction *action = new QAction(Clock::getComponentName(static_cast<ClockComponent>(i)), this);
        action->setData(i);

        menu->addAction(action);
    }

    m_componentUi.componentButton->setMenu(menu);
    m_componentUi.optionsButton->setMenu(new KMenu(m_componentUi.optionsButton));

    if (!parent) {
        m_componentUi.insertButton->hide();
        m_componentUi.verticalLayout->addWidget(m_componentUi.previewLabel);
    }

    connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(selectComponent(QAction*)));
    connect(m_componentUi.insertButton, SIGNAL(clicked()), this, SLOT(insertComponent()));
}
开发者ID:B-Rich,项目名称:plasmoid-adjustable-clock,代码行数:26,代码来源:ComponentWidget.cpp


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