本文整理汇总了C++中KToggleAction::setShortcuts方法的典型用法代码示例。如果您正苦于以下问题:C++ KToggleAction::setShortcuts方法的具体用法?C++ KToggleAction::setShortcuts怎么用?C++ KToggleAction::setShortcuts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KToggleAction
的用法示例。
在下文中一共展示了KToggleAction::setShortcuts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupActions
void TestKHTML::setupActions()
{
QDomDocument document = m_part->domDocument();
QDomElement fileMenu = document.documentElement().firstChild().childNodes().item( 0 ).toElement();
QDomElement quitElement = document.createElement("action");
quitElement.setAttribute("name",
KStandardAction::name(KStandardAction::Quit));
fileMenu.appendChild(quitElement);
QDomElement viewMenu = document.documentElement().firstChild().childNodes().item( 2 ).toElement();
QDomElement element = document.createElement("action");
element.setAttribute("name", "debugRenderTree");
viewMenu.appendChild(element);
element = document.createElement("action");
element.setAttribute("name", "debugDOMTree");
viewMenu.appendChild(element);
QDomElement toolBar = document.documentElement().firstChild().nextSibling().toElement();
element = document.createElement("action");
element.setAttribute("name", "editable");
toolBar.insertBefore(element, toolBar.firstChild());
element = document.createElement("action");
element.setAttribute("name", "navigable");
toolBar.insertBefore(element, toolBar.firstChild());
element = document.createElement("action");
element.setAttribute("name", "reload");
toolBar.insertBefore(element, toolBar.firstChild());
element = document.createElement("action");
element.setAttribute("name", "print");
toolBar.insertBefore(element, toolBar.firstChild());
KAction *action = new KAction(KIcon("view-refresh"), "Reload", this );
m_part->actionCollection()->addAction( "reload", action );
connect(action, SIGNAL(triggered(bool)), this, SLOT(reload()));
action->setShortcut(Qt::Key_F5);
KAction *kprint = new KAction(KIcon("document-print"), "Print", this );
m_part->actionCollection()->addAction( "print", kprint );
connect(kprint, SIGNAL(triggered(bool)), m_part->browserExtension(), SLOT(print()));
kprint->setEnabled(true);
KToggleAction *ta = new KToggleAction( KIcon("edit-rename"), "Navigable", this );
actionCollection()->addAction( "navigable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(m_part->isCaretMode());
connect(ta, SIGNAL(toggled(bool)), this, SLOT(toggleNavigable(bool)));
ta = new KToggleAction( KIcon("document-properties"), "Editable", this );
actionCollection()->addAction( "editable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(m_part->isEditable());
connect(ta, SIGNAL(toggled(bool)), this, SLOT(toggleEditable(bool)));
KStandardAction::quit( kapp, SLOT(quit()), m_part->actionCollection() );
guiFactory()->addClient(m_part);
}
示例2: main
int main(int argc, char *argv[])
{
KCmdLineOptions options;
options.add("+file", ki18n("URL to open"));
KCmdLineArgs::init(argc, argv, "testkhtml", 0, ki18n("Testkhtml"),
"1.0", ki18n("a basic web browser using the KHTML library"));
KCmdLineArgs::addCmdLineOptions(options);
KApplication a;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs( );
if ( args->count() == 0 ) {
KCmdLineArgs::usage();
::exit( 1 );
}
new KHTMLGlobal;
KXmlGuiWindow *toplevel = new KXmlGuiWindow();
KHTMLPart *doc = new KHTMLPart( toplevel, toplevel, KHTMLPart::BrowserViewGUI );
Dummy *dummy = new Dummy( doc );
QObject::connect( doc->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
dummy, SLOT(slotOpenURL(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
QObject::connect( doc, SIGNAL(completed()), dummy, SLOT(handleDone()) );
if (args->url(0).url().right(4).toLower() == ".xml") {
KParts::OpenUrlArguments args(doc->arguments());
args.setMimeType("text/xml");
doc->setArguments(args);
}
doc->openUrl( args->url(0) );
toplevel->setCentralWidget( doc->widget() );
toplevel->resize( 800, 600);
QDomDocument d = doc->domDocument();
QDomElement viewMenu = d.documentElement().firstChild().childNodes().item( 2 ).toElement();
QDomElement e = d.createElement( "action" );
e.setAttribute( "name", "debugRenderTree" );
viewMenu.appendChild( e );
e = d.createElement( "action" );
e.setAttribute( "name", "debugDOMTree" );
viewMenu.appendChild( e );
e = d.createElement( "action" );
e.setAttribute( "name", "debugDoBenchmark" );
viewMenu.appendChild( e );
QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement();
e = d.createElement( "action" );
e.setAttribute( "name", "editable" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "navigable" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "reload" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "print" );
toolBar.insertBefore( e, toolBar.firstChild() );
KAction *action = new KAction(KIcon("view-refresh"), "Reload", doc );
doc->actionCollection()->addAction( "reload", action );
QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload()));
action->setShortcut(Qt::Key_F5);
KAction *bench = new KAction( KIcon(), "Benchmark...", doc );
doc->actionCollection()->addAction( "debugDoBenchmark", bench );
QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark()));
KAction *kprint = new KAction(KIcon("document-print"), "Print", doc );
doc->actionCollection()->addAction( "print", kprint );
QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print()));
kprint->setEnabled(true);
KToggleAction *ta = new KToggleAction( KIcon("edit-rename"), "Navigable", doc );
doc->actionCollection()->addAction( "navigable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(doc->isCaretMode());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool)));
ta = new KToggleAction( KIcon("document-properties"), "Editable", doc );
doc->actionCollection()->addAction( "editable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(doc->isEditable());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool)));
toplevel->guiFactory()->addClient( doc );
doc->setJScriptEnabled(true);
doc->setJavaEnabled(true);
doc->setPluginsEnabled( true );
doc->setURLCursor(QCursor(Qt::PointingHandCursor));
a.setTopWidget(doc->widget());
QWidget::connect(doc, SIGNAL(setWindowCaption(QString)),
doc->widget()->topLevelWidget(), SLOT(setCaption(QString)));
doc->widget()->show();
toplevel->show();
doc->view()->viewport()->show();
doc->view()->widget()->show();
//.........这里部分代码省略.........
示例3: grp
//.........这里部分代码省略.........
m_d->mirrorCanvas = new KToggleAction(i18n("Mirror View"), this);
m_d->mirrorCanvas->setChecked(false);
actionCollection()->addAction("mirror_canvas", m_d->mirrorCanvas);
m_d->mirrorCanvas->setShortcut(QKeySequence(Qt::Key_M));
connect(m_d->mirrorCanvas, SIGNAL(toggled(bool)),m_d->canvasController, SLOT(mirrorCanvas(bool)));
KAction *rotateCanvasRight = new KAction(i18n("Rotate Canvas Right"), this);
actionCollection()->addAction("rotate_canvas_right", rotateCanvasRight);
rotateCanvasRight->setShortcut(QKeySequence("Ctrl+]"));
connect(rotateCanvasRight, SIGNAL(triggered()),m_d->canvasController, SLOT(rotateCanvasRight15()));
KAction *rotateCanvasLeft = new KAction(i18n("Rotate Canvas Left"), this);
actionCollection()->addAction("rotate_canvas_left", rotateCanvasLeft);
rotateCanvasLeft->setShortcut(QKeySequence("Ctrl+["));
connect(rotateCanvasLeft, SIGNAL(triggered()),m_d->canvasController, SLOT(rotateCanvasLeft15()));
KAction *resetCanvasTransformations = new KAction(i18n("Reset Canvas Transformations"), this);
actionCollection()->addAction("reset_canvas_transformations", resetCanvasTransformations);
resetCanvasTransformations->setShortcut(QKeySequence("Ctrl+'"));
connect(resetCanvasTransformations, SIGNAL(triggered()),m_d->canvasController, SLOT(resetCanvasTransformations()));
KToggleAction *tAction = new KToggleAction(i18n("Show Status Bar"), this);
tAction->setCheckedState(KGuiItem(i18n("Hide Status Bar")));
tAction->setChecked(true);
tAction->setToolTip(i18n("Shows or hides the status bar"));
actionCollection()->addAction("showStatusBar", tAction);
connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool)));
tAction = new KToggleAction(i18n("Show Canvas Only"), this);
tAction->setCheckedState(KGuiItem(i18n("Return to Window")));
tAction->setToolTip(i18n("Shows just the canvas or the whole window"));
QList<QKeySequence> shortcuts;
shortcuts << QKeySequence(Qt::Key_Tab);
tAction->setShortcuts(shortcuts);
tAction->setChecked(false);
actionCollection()->addAction("view_show_just_the_canvas", tAction);
connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showJustTheCanvas(bool)));
//Workaround, by default has the same shortcut as mirrorCanvas
KAction* action = dynamic_cast<KAction*>(actionCollection()->action("format_italic"));
if (action) {
action->setShortcut(QKeySequence(), KAction::DefaultShortcut);
action->setShortcut(QKeySequence(), KAction::ActiveShortcut);
}
//Workaround, by default has the same shortcut as hide/show dockers
action = dynamic_cast<KAction*>(shell()->actionCollection()->action("view_toggledockers"));
if (action) {
action->setShortcut(QKeySequence(), KAction::DefaultShortcut);
action->setShortcut(QKeySequence(), KAction::ActiveShortcut);
}
if (shell())
{
KoToolBoxFactory toolBoxFactory(m_d->canvasController);
shell()->createDockWidget(&toolBoxFactory);
connect(canvasController, SIGNAL(toolOptionWidgetsChanged(QList<QWidget*>)),
shell()->dockerManager(), SLOT(newOptionWidgets(QList<QWidget*>)));
shell()->dockerManager()->setIcons(false);
}
m_d->statusBar = new KisStatusBar(this);
connect(m_d->canvasController->proxyObject, SIGNAL(documentMousePositionChanged(QPointF)),
m_d->statusBar, SLOT(documentMousePositionChanged(QPointF)));
示例4: initMainWidget
void ActionManagerImpl::initMainWidget(MainWidget* mainWidget)
{
if (d->mainWidget)
return;
d->mainWidget = mainWidget;
KActionCollection* coll = actionCollection();
// Feed/Feed Group popup menu
KAction* action = coll->addAction("feed_homepage");
action->setText(i18n("&Open Homepage"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotOpenHomepage()));
action->setShortcuts(KShortcut( "Ctrl+H" ));
action = coll->addAction("reload_all_tabs");
action->setIcon(KIcon("view-refresh"));
action->setText(i18n("Reload All Tabs"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotReloadAllTabs()));
action->setShortcuts(KShortcut( "Shift+F5" ));
action = coll->addAction("feed_add");
action->setIcon(KIcon("feed-subscribe"));
action->setText(i18n("&Add Feed..."));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedAdd()));
action->setShortcuts(KShortcut( "Insert" ));
action = coll->addAction("feed_add_group");
action->setIcon(KIcon("folder-new"));
action->setText(i18n("Ne&w Folder..."));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedAddGroup()));
action->setShortcuts(KShortcut( "Shift+Insert" ));
action = coll->addAction("feed_remove");
action->setIcon(KIcon("edit-delete"));
action->setText(i18n("&Delete Feed"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedRemove()));
action->setShortcuts(KShortcut( "Alt+Delete" ));
action = coll->addAction("feed_modify");
action->setIcon(KIcon("document-properties"));
action->setText(i18n("&Edit Feed..."));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedModify()));
action->setShortcuts(KShortcut( "F2" ));
// toolbar / View
action = coll->addAction("normal_view");
action->setIcon(KIcon("view-split-top-bottom"));
action->setText(i18n("&Normal View"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotNormalView()));
action->setShortcuts(KShortcut( "Ctrl+Shift+1" ));
action = coll->addAction("widescreen_view");
action->setIcon(KIcon("view-split-left-right"));
action->setText(i18n("&Widescreen View"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotWidescreenView()));
action->setShortcuts(KShortcut( "Ctrl+Shift+2" ));
action = coll->addAction("combined_view");
action->setIcon(KIcon("view-list-text"));
action->setText(i18n("C&ombined View"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotCombinedView()));
action->setShortcuts(KShortcut( "Ctrl+Shift+3" ));
// toolbar / feed menu
action = coll->addAction("feed_fetch");
action->setIcon(KIcon("go-down"));
action->setText(i18n("&Fetch Feed"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFetchCurrentFeed()));
action->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Reload));
action = coll->addAction("feed_fetch_all");
action->setIcon(KIcon("go-bottom"));
action->setText(i18n("Fe&tch All Feeds"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFetchAllFeeds()));
action->setShortcuts(KShortcut( "Ctrl+L" ));
KAction *stopAction = coll->addAction("feed_stop");
stopAction->setIcon(KIcon("process-stop"));
stopAction->setText(i18n("C&ancel Feed Fetches"));
connect(stopAction, SIGNAL(triggered(bool)), Kernel::self()->fetchQueue(), SLOT(slotAbort()));
stopAction->setShortcut(QKeySequence(Qt::Key_Escape));
stopAction->setEnabled(false);
action = coll->addAction("feed_mark_all_as_read");
action->setIcon(KIcon("mail-mark-read"));
action->setText(i18n("&Mark Feed as Read"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotMarkAllRead()));
action->setShortcuts(KShortcut( "Ctrl+R" ));
action = coll->addAction("feed_mark_all_feeds_as_read");
action->setIcon(KIcon("mail-mark-read"));
action->setText(i18n("Ma&rk All Feeds as Read"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotMarkAllFeedsRead()));
action->setShortcuts(KShortcut( "Ctrl+Shift+R" ));
// Settings menu
KToggleAction *sqf = coll->add<KToggleAction>("show_quick_filter");
sqf->setText(i18n("Show Quick Filter"));
//.........这里部分代码省略.........
示例5: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if (a.arguments().count() <= 1) {
qWarning() << "Argument expected: url to open";
return 1;
}
new KHTMLGlobal;
KXmlGuiWindow *toplevel = new KXmlGuiWindow();
KHTMLPart *doc = new KHTMLPart(toplevel, toplevel, KHTMLPart::BrowserViewGUI);
Dummy *dummy = new Dummy(doc);
QObject::connect(doc->browserExtension(), SIGNAL(openUrlRequest(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
dummy, SLOT(slotOpenURL(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)));
QObject::connect(doc, SIGNAL(completed()), dummy, SLOT(handleDone()));
QUrl url = QUrl::fromUserInput(a.arguments().at(1)); // TODO support for relative paths
if (url.path().right(4).toLower() == ".xml") {
KParts::OpenUrlArguments args(doc->arguments());
args.setMimeType("text/xml");
doc->setArguments(args);
}
doc->openUrl(url);
toplevel->setCentralWidget(doc->widget());
toplevel->resize(800, 600);
QDomDocument d = doc->domDocument();
QDomElement viewMenu = d.documentElement().firstChild().childNodes().item(2).toElement();
QDomElement e = d.createElement("action");
e.setAttribute("name", "debugRenderTree");
viewMenu.appendChild(e);
e = d.createElement("action");
e.setAttribute("name", "debugDOMTree");
viewMenu.appendChild(e);
e = d.createElement("action");
e.setAttribute("name", "debugDoBenchmark");
viewMenu.appendChild(e);
QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement();
e = d.createElement("action");
e.setAttribute("name", "editable");
toolBar.insertBefore(e, toolBar.firstChild());
e = d.createElement("action");
e.setAttribute("name", "navigable");
toolBar.insertBefore(e, toolBar.firstChild());
e = d.createElement("action");
e.setAttribute("name", "reload");
toolBar.insertBefore(e, toolBar.firstChild());
e = d.createElement("action");
e.setAttribute("name", "print");
toolBar.insertBefore(e, toolBar.firstChild());
QAction *action = new QAction(QIcon::fromTheme("view-refresh"), "Reload", doc);
doc->actionCollection()->addAction("reload", action);
QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload()));
doc->actionCollection()->setDefaultShortcut(action, Qt::Key_F5);
QAction *bench = new QAction(QIcon(), "Benchmark...", doc);
doc->actionCollection()->addAction("debugDoBenchmark", bench);
QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark()));
QAction *kprint = new QAction(QIcon::fromTheme("document-print"), "Print", doc);
doc->actionCollection()->addAction("print", kprint);
QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print()));
kprint->setEnabled(true);
KToggleAction *ta = new KToggleAction(QIcon::fromTheme("edit-rename"), "Navigable", doc);
doc->actionCollection()->addAction("navigable", ta);
ta->setShortcuts(QList<QKeySequence>());
ta->setChecked(doc->isCaretMode());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool)));
ta = new KToggleAction(QIcon::fromTheme("document-properties"), "Editable", doc);
doc->actionCollection()->addAction("editable", ta);
ta->setShortcuts(QList<QKeySequence>());
ta->setChecked(doc->isEditable());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool)));
toplevel->guiFactory()->addClient(doc);
doc->setJScriptEnabled(true);
doc->setJavaEnabled(true);
doc->setPluginsEnabled(true);
doc->setURLCursor(QCursor(Qt::PointingHandCursor));
a.setActiveWindow(doc->widget());
QWidget::connect(doc, SIGNAL(setWindowCaption(QString)),
doc->widget()->topLevelWidget(), SLOT(setCaption(QString)));
doc->widget()->show();
toplevel->show();
doc->view()->viewport()->show();
doc->view()->widget()->show();
int ret = a.exec();
return ret;
}