本文整理汇总了C++中KAction::setMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ KAction::setMenu方法的具体用法?C++ KAction::setMenu怎么用?C++ KAction::setMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KAction
的用法示例。
在下文中一共展示了KAction::setMenu方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotAboutToShowContextMenu
void TextEdit::slotAboutToShowContextMenu(QMenu* menu)
{
if(menu){
kDebug();
KAction *act = new KAction(i18n("Set spell check language"), menu);
act->setMenu(d->langActions);
menu->addAction(act);
KAction *shorten = new KAction(i18nc("Replace URLs by a shortened URL", "Shorten URLs"), menu);
connect(shorten, SIGNAL(triggered(bool)), SLOT(shortenUrls()));
menu->addAction(shorten);
}
}
示例2: setupActions
void MainWindow::setupActions()
{
kDebug() << "setup actions...";
// this let shortcuts work..
actionCollection()->addAssociatedWidget(this);
KAction *a;
// new window action
a = new KAction(KIcon("window-new"), i18n("&New Window"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_N));
actionCollection()->addAction(QL1S("new_window"), a);
connect(a, SIGNAL(triggered(bool)), Application::instance(), SLOT(newWindow()));
// Standard Actions
KStandardAction::open(this, SLOT(fileOpen()), actionCollection());
KStandardAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
KStandardAction::print(this, SLOT(printRequested()), actionCollection());
KStandardAction::quit(this , SLOT(close()), actionCollection());
a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection());
KShortcut findShortcut = KStandardShortcut::find();
findShortcut.setAlternate(Qt::Key_Slash);
a->setShortcut(findShortcut);
KStandardAction::findNext(this, SLOT(findNext()) , actionCollection());
KStandardAction::findPrev(this, SLOT(findPrevious()) , actionCollection());
a = KStandardAction::fullScreen(this, SLOT(viewFullScreen(bool)), this, actionCollection());
KShortcut fullScreenShortcut = KStandardShortcut::fullScreen();
fullScreenShortcut.setAlternate(Qt::Key_F11);
a->setShortcut(fullScreenShortcut);
a = actionCollection()->addAction(KStandardAction::Home);
connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(homePage(Qt::MouseButtons, Qt::KeyboardModifiers)));
KStandardAction::preferences(this, SLOT(preferences()), actionCollection());
a = KStandardAction::redisplay(m_view, SLOT(webReload()), actionCollection());
a->setText(i18n("Reload"));
KShortcut reloadShortcut = KStandardShortcut::reload();
reloadShortcut.setAlternate(Qt::CTRL + Qt::Key_R);
a->setShortcut(reloadShortcut);
a = new KAction(KIcon("process-stop"), i18n("&Stop"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Period));
actionCollection()->addAction(QL1S("stop"), a);
connect(a, SIGNAL(triggered(bool)), m_view, SLOT(webStop()));
// stop reload Action
m_stopReloadAction = new KAction(this);
actionCollection()->addAction(QL1S("stop_reload") , m_stopReloadAction);
m_stopReloadAction->setShortcutConfigurable(false);
connect(m_view, SIGNAL(browserTabLoading(bool)), this, SLOT(browserLoading(bool)));
browserLoading(false); //first init for blank start page
a = new KAction(i18n("Open Location"), this);
KShortcut openLocationShortcut(Qt::CTRL + Qt::Key_L);
openLocationShortcut.setAlternate(Qt::Key_F6);
a->setShortcut(openLocationShortcut);
actionCollection()->addAction(QL1S("open_location"), a);
connect(a, SIGNAL(triggered(bool)) , this, SLOT(openLocation()));
// set zoom bar actions
m_zoomBar->setupActions(this);
// tab list
m_tabListMenu = new KMenu();
m_tabListMenu->addAction("hack"); // necessary to show the menu on the right side the first time
connect(m_tabListMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowTabListMenu()));
connect(m_tabListMenu, SIGNAL(triggered(QAction*)), this, SLOT(openActionTab(QAction*)));
KActionMenu *tabAction = new KActionMenu(i18n("Tab List"), this);
tabAction->setMenu(m_tabListMenu);
tabAction->setIcon(KIcon("document-multiple"));
tabAction->setDelayed(false);
actionCollection()->addAction(QL1S("tab_list"), tabAction);
// =============================== Tools Actions =================================
a = new KAction(i18n("View Page S&ource"), this);
a->setIcon(KIcon("application-xhtml+xml"));
a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_U));
actionCollection()->addAction(QL1S("page_source"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(viewPageSource()));
a = Application::instance()->privateBrowsingAction();
a->setShortcut(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_P);
actionCollection()->addAction(QL1S("private_browsing"), a);
a = new KAction(KIcon("edit-clear"), i18n("Clear Private Data..."), this);
a->setShortcut(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Delete);
actionCollection()->addAction(QL1S("clear_private_data"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData()));
// ========================= History related actions ==============================
a = actionCollection()->addAction(KStandardAction::Back);
connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons, Qt::KeyboardModifiers)));
m_historyBackMenu = new KMenu(this);
a->setMenu(m_historyBackMenu);
connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBackMenu()));
//.........这里部分代码省略.........