Commit 58a522f5 authored by Victor Yacovlev's avatar Victor Yacovlev

Eliminated WebKit dependency for 'classic' and 'highgrade'.

parent 013203df
......@@ -22,7 +22,7 @@ else()
endif()
set(CONFIGURATION_TEMPLATE
"CourseManager,Editor,Browser,Actor*,KumirAnalizer,*CodeGenerator,KumirCodeRun,!CoreGUI\(notabs,icon=classic,nostartpage,nosessions\)"
"CourseManager,Editor,Actor*,KumirAnalizer,*CodeGenerator,KumirCodeRun,!CoreGUI\(notabs,icon=classic,nostartpage,nosessions\)"
)
set(SPLASHSCREEN
"coregui/splashscreens/classic.png"
......
......@@ -22,7 +22,7 @@ else()
endif()
set(CONFIGURATION_TEMPLATE
"CourseManager,Editor,Browser,Actor*,KumirAnalizer\(preload=Files,preload=Strings\),*CodeGenerator,KumirCodeRun,!CoreGUI\(notabs,icon=highgrade,nostartpage,nosessions\)"
"CourseManager,Editor,Actor*,KumirAnalizer\(preload=Files,preload=Strings\),*CodeGenerator,KumirCodeRun,!CoreGUI\(notabs,icon=highgrade,nostartpage,nosessions\)"
)
set(SPLASHSCREEN
"coregui/splashscreens/highgrade.png"
......
......@@ -62,6 +62,12 @@ void Component::addJavaScriptObjects()
}
}
void Component::setContent(const QString &data)
{
setHtml(data);
pageAction(QWebPage::Back)->setEnabled(false);
}
void Component::go(const QUrl &url)
{
setUrl(url);
......
......@@ -38,6 +38,7 @@ public:
public slots:
void go(const QUrl & url);
void setContent(const QString & data);
void evaluateCommand(const QString & method, const QVariantList & arguments);
protected:
void showEvent(QShowEvent *e);
......
......@@ -7,13 +7,13 @@ endif(NOT DEFINED USE_QT)
if(${USE_QT} GREATER 4)
# Find Qt5
find_package(Qt5 5.3.0 COMPONENTS Core Widgets Xml WebKitWidgets REQUIRED)
include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5WebKitWidgets_INCLUDE_DIRS} BEFORE)
set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5WebKitWidgets_LIBRARIES})
find_package(Qt5 5.3.0 COMPONENTS Core Widgets Xml REQUIRED)
include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} BEFORE)
set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Xml_LIBRARIES} )
else()
# Find Qt4
set(QT_USE_QTMAIN 1)
find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtSvg QtWebkit REQUIRED)
find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml REQUIRED)
include(${QT_USE_FILE})
endif()
include(../../kumir2_plugin.cmake)
......
......@@ -2,6 +2,9 @@
#include "ui_mainwindow.h"
//#include "interface.h"
#include "interfaces/browserinterface.h"
#include "interfaces/browser_instanceinterface.h"
MainWindowTask::MainWindowTask(QWidget *parent) :
QMainWindow(parent),
......@@ -65,11 +68,59 @@ isTeacher=false;
onTask=false;
cursFile="";
setWindowIcon(QIcon(resourcesRoot.absoluteFilePath("10.png")));
#ifdef QT_DEBUG
ui->webView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
#endif
setupWebView();
//ui->textBrowser->setVisible(false);
};
void MainWindowTask::setupWebView()
{
using namespace ExtensionSystem;
using namespace Shared;
BrowserInterface * browserPlugin
= PluginManager::instance()->findPlugin<BrowserInterface>();
QWidget * webViewComponent = 0;
simpleBrowserWidget_ = 0;
browserPluginInstance_ = 0;
if (browserPlugin) {
browserPluginInstance_ = browserPlugin->createBrowser();
webViewComponent = browserPluginInstance_->widget();
}
else {
simpleBrowserWidget_ = new QTextBrowser();
webViewComponent = simpleBrowserWidget_;
}
webViewComponent->setParent(ui->webView);
webViewComponent->setMinimumWidth(200);
QVBoxLayout * l = new QVBoxLayout;
l->setContentsMargins(0, 0, 0, 0);
ui->webView->setLayout(l);
l->addWidget(webViewComponent);
}
void MainWindowTask::setTaskViewHtml(const QString &data)
{
if (simpleBrowserWidget_) {
simpleBrowserWidget_->setHtml(data);
}
else if (browserPluginInstance_) {
browserPluginInstance_->setContent(data);
}
}
void MainWindowTask::setTaskViewUrl(const QUrl &url)
{
if (simpleBrowserWidget_) {
simpleBrowserWidget_->setSource(url);
}
else if (browserPluginInstance_) {
browserPluginInstance_->go(url);
}
}
QList<QAction*> MainWindowTask::getActions()
{
QList<QAction*> toRet;
......@@ -259,7 +310,7 @@ for(int i=0;i<prgElListT.count();i++)
if(cText.right(4)==".htm" ||cText.right(5)==".html" )
{
loadHtml(cText);
}else ui->webView->setHtml(cText);
}else setTaskViewHtml(cText);
// if(isTeacher)ui->actionEdit->setEnabled(true);
setWindowTitle(course->name()+trUtf8(" - Практикум"));
updateLastFiles(fileName);
......@@ -324,7 +375,7 @@ void MainWindowTask::loadCourse()
if(cText.right(4)==".htm" ||cText.right(5)==".html" )
{
loadHtml(cText);
}else ui->webView->setHtml(cText);
}else setTaskViewHtml(cText);
// if(isTeacher)ui->actionEdit->setEnabled(true);
setWindowTitle(course->name()+trUtf8(" - Практикум"));
updateLastFiles(fileName);
......@@ -435,7 +486,7 @@ void MainWindowTask::showText(const QModelIndex & index )
if(taskText.right(4)==".htm" ||taskText.right(5)==".html" )
{
loadHtml(taskText);
}else ui->webView->setHtml(taskText);
}else setTaskViewHtml(taskText);
qDebug()<<"TaskText:"<<course->getTaskText(index);
curTaskIdx=index;
......@@ -457,20 +508,23 @@ void MainWindowTask::showText(const QModelIndex & index )
};
void MainWindowTask::loadHtml(QString fileName)
{
qDebug()<<"LoadHtml"<<fileName;
if(fileName.isEmpty())return;
QFile inp(curDir+'/'+fileName);
if (!inp.open(QIODevice::ReadOnly))
{
QMessageBox::information( 0, "", trUtf8("Ошибка чтения: ") + fileName, 0,0,0);
return;
};
QString htmlData=QString::fromUtf8(inp.readAll());
//ui->textBrowser->setHtml(htmlData);
{
const QString absolutePath = QDir(curDir).absoluteFilePath(fileName);
const QUrl url = QUrl::fromLocalFile(absolutePath);
setTaskViewUrl(url);
// qDebug()<<"LoadHtml"<<fileName;
// if(fileName.isEmpty())return;
// QFile inp(curDir+'/'+fileName);
// if (!inp.open(QIODevice::ReadOnly))
// {
// QMessageBox::information( 0, "", trUtf8("Ошибка чтения: ") + fileName, 0,0,0);
// return;
// };
// QString htmlData=QString::fromUtf8(inp.readAll());
// //ui->textBrowser->setHtml(htmlData);
ui->webView->setHtml(htmlData,QUrl("file://"+curDir+'/'+fileName));
inp.close();
// ui->webView->setHtml(htmlData,QUrl("file://"+curDir+'/'+fileName));
// inp.close();
};
void MainWindowTask::startTask()
......
......@@ -21,11 +21,16 @@
#include "../coursemanager_plugin.h"
#include "editdialog.h"
#include "newkursdialog.h"
#include <QTextBrowser>
#ifdef interface
#undef interface // used name 'interface' conflicts with Windows SDK
#endif
namespace Shared { namespace Browser {
class InstanceInterface;
} }
class KumZadanie
{
public:
......@@ -135,6 +140,9 @@ protected:
void closeEvent(QCloseEvent *event);
void showEvent(QShowEvent * event);
private:
void setupWebView();
void setTaskViewHtml(const QString & data);
void setTaskViewUrl(const QUrl & url);
void markProgChange();
void createMoveMenu();
void setUpDown(QModelIndex index);
......@@ -163,6 +171,9 @@ private:
QFileInfo baseKursFile; //4 mode
Ui::MainWindowTask *ui;
bool isReadOnly;
Shared::Browser::InstanceInterface * browserPluginInstance_;
QTextBrowser * simpleBrowserWidget_;
};
......
......@@ -67,12 +67,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QWebView" name="webView">
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
<widget class="QWidget" name="webView">
</widget>
</widget>
</item>
......
......@@ -13,6 +13,7 @@ public:
virtual QWidget * widget() = 0;
virtual void go(const QUrl & url) = 0;
virtual void setContent(const QString & data) = 0;
virtual QUrl currentLocation() const = 0;
virtual QString title() const = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment