本文整理汇总了C++中KHTMLPart::arguments方法的典型用法代码示例。如果您正苦于以下问题:C++ KHTMLPart::arguments方法的具体用法?C++ KHTMLPart::arguments怎么用?C++ KHTMLPart::arguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KHTMLPart
的用法示例。
在下文中一共展示了KHTMLPart::arguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
//.........这里部分代码省略.........
示例2: 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;
}