|
|
@ -10,6 +10,7 @@ |
|
|
|
#include <webpage.hxx> |
|
|
|
#include <webpage.hxx> |
|
|
|
#include <editor.hxx> |
|
|
|
#include <editor.hxx> |
|
|
|
#include <commands.hxx> |
|
|
|
#include <commands.hxx> |
|
|
|
|
|
|
|
#include <scriptfile.hxx> |
|
|
|
#include <QMainWindow> |
|
|
|
#include <QMainWindow> |
|
|
|
#include <QSettings> |
|
|
|
#include <QSettings> |
|
|
|
#include <QWebFrame> |
|
|
|
#include <QWebFrame> |
|
|
@ -63,11 +64,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
_web->installEventFilter(this); // track mouse and keyboard
|
|
|
|
_web->installEventFilter(this); // track mouse and keyboard
|
|
|
|
page->setForwardUnsupportedContent(true); |
|
|
|
page->setForwardUnsupportedContent(true); |
|
|
|
_commands->setText(Script().commands(Script::HTML)); |
|
|
|
_commands->setText(Script().commands(Script::HTML)); |
|
|
|
connect(page, SIGNAL(uploadFile(QString)), SLOT(uploadFile(QString))); |
|
|
|
assert(connect(page, SIGNAL(uploadFile(QString)), SLOT(uploadFile(QString)))); |
|
|
|
connect(page, SIGNAL(unsupportedContent(QNetworkReply*)), |
|
|
|
assert(connect(page, SIGNAL(unsupportedContent(QNetworkReply*)), |
|
|
|
SLOT(unsupportedContent(QNetworkReply*))); |
|
|
|
SLOT(unsupportedContent(QNetworkReply*)))); |
|
|
|
connect(page, SIGNAL(downloadRequested(const QNetworkRequest&)), |
|
|
|
assert(connect(page, SIGNAL(downloadRequested(const QNetworkRequest&)), |
|
|
|
SLOT(downloadRequested(const QNetworkRequest&))); |
|
|
|
SLOT(downloadRequested(const QNetworkRequest&)))); |
|
|
|
|
|
|
|
assert(connect(_testscript, SIGNAL(include(QString)), SLOT(include(QString)))); |
|
|
|
if (setupScript.size()) loadSetup(setupScript); |
|
|
|
if (setupScript.size()) loadSetup(setupScript); |
|
|
|
if (scriptFile.size()) loadFile(scriptFile); |
|
|
|
if (scriptFile.size()) loadFile(scriptFile); |
|
|
|
} |
|
|
|
} |
|
|
@ -338,6 +340,32 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
if (!vb) return; |
|
|
|
if (!vb) return; |
|
|
|
vb->setValue(vb->maximum()); |
|
|
|
vb->setValue(vb->maximum()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void include(QString name) { |
|
|
|
|
|
|
|
if (_testscripts.contains(name)) return; |
|
|
|
|
|
|
|
_testscripts[name] = new ScriptFile(this); |
|
|
|
|
|
|
|
assert(connect(_testscripts[name], SIGNAL(include(QString)), SLOT(include(QString)))); |
|
|
|
|
|
|
|
assert(connect(_testscripts[name], SIGNAL(close(ScriptFile*)), SLOT(remove(ScriptFile*)))); |
|
|
|
|
|
|
|
QFile file(name); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) |
|
|
|
|
|
|
|
throw std::runtime_error("file open failed"); |
|
|
|
|
|
|
|
_testscripts[name]->editor()->setPlainText(QString::fromUtf8(file.readAll())); |
|
|
|
|
|
|
|
if (file.error()!=QFileDevice::NoError) |
|
|
|
|
|
|
|
throw std::runtime_error("file read failed"); |
|
|
|
|
|
|
|
_testscripts[name]->name(name); |
|
|
|
|
|
|
|
tabifyDockWidget(_scriptDock, _testscripts[name]); |
|
|
|
|
|
|
|
QDockWidget* d(0); |
|
|
|
|
|
|
|
for (QWidget* w(QApplication::focusWidget()); w&&!(d=qobject_cast<QDockWidget*>(w)); |
|
|
|
|
|
|
|
w=qobject_cast<QWidget*>(w->parent())); |
|
|
|
|
|
|
|
if (d) d->raise(); |
|
|
|
|
|
|
|
} catch(const std::exception& x) { |
|
|
|
|
|
|
|
remove(_testscripts[name]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void remove(ScriptFile* scriptfile) { |
|
|
|
|
|
|
|
_testscripts.remove(scriptfile->name()); |
|
|
|
|
|
|
|
delete scriptfile; |
|
|
|
|
|
|
|
} |
|
|
|
protected: |
|
|
|
protected: |
|
|
|
void closeEvent(QCloseEvent* event) { |
|
|
|
void closeEvent(QCloseEvent* event) { |
|
|
|
QSettings settings("mrw", "webtester"); |
|
|
|
QSettings settings("mrw", "webtester"); |
|
|
@ -452,7 +480,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
void loadFile(QString name) { |
|
|
|
void loadFile(QString name) { |
|
|
|
QFile file(name); |
|
|
|
QFile file(name); |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) |
|
|
|
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) |
|
|
|
throw std::runtime_error("file open failed"); |
|
|
|
throw std::runtime_error("file open failed"); |
|
|
|
_testscript->setPlainText(QString::fromUtf8(file.readAll())); |
|
|
|
_testscript->setPlainText(QString::fromUtf8(file.readAll())); |
|
|
|
if (file.error()!=QFileDevice::NoError) |
|
|
|
if (file.error()!=QFileDevice::NoError) |
|
|
@ -900,6 +928,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { |
|
|
|
bool _typing; // user is typing
|
|
|
|
bool _typing; // user is typing
|
|
|
|
bool _inEventFilter; // actually handling event filter
|
|
|
|
bool _inEventFilter; // actually handling event filter
|
|
|
|
Script _setupScript; |
|
|
|
Script _setupScript; |
|
|
|
|
|
|
|
QMap<QString, ScriptFile*> _testscripts; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#endif // TESTGUI_HXX
|
|
|
|
#endif // TESTGUI_HXX
|
|
|
|