File indexing completed on 2024-12-22 03:46:51
0001 /* 0002 This file is part of the KTextTemplate library 0003 0004 SPDX-FileCopyrightText: 2011 Stephen Kelly <steveire@gmail.com> 0005 0006 SPDX-License-Identifier: LGPL-2.1-or-later 0007 0008 */ 0009 0010 #include "mainwindow.h" 0011 0012 #include <QDebug> 0013 #include <QHBoxLayout> 0014 #include <QWebView> 0015 0016 #include "ktexttemplate_paths.h" 0017 #include <KTextTemplate/Engine> 0018 #include <KTextTemplate/FileSystemTemplateLoader> 0019 0020 #include "localrequestmanager.h" 0021 #include <QCoreApplication> 0022 0023 MainWindow::MainWindow(QWidget *parent) 0024 : QWidget(parent) 0025 { 0026 QHBoxLayout *layout = new QHBoxLayout(this); 0027 0028 QWebView *wv = new QWebView; 0029 0030 KTextTemplate::Engine *engine = new KTextTemplate::Engine(this); 0031 engine->addDefaultLibrary("customplugin"); 0032 0033 QSharedPointer<KTextTemplate::FileSystemTemplateLoader> loader(new KTextTemplate::FileSystemTemplateLoader); 0034 loader->setTemplateDirs(QStringList() << KTEXTTEMPLATE_TEMPLATE_PATH); 0035 engine->addTemplateLoader(loader); 0036 0037 wv->page()->setNetworkAccessManager(new LocalRequestManager(engine, this)); 0038 0039 wv->load(QUrl("template:///home/main.html")); 0040 0041 layout->addWidget(wv); 0042 } 0043 0044 #include "moc_mainwindow.cpp"