hybridwebpage.cpp 972 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <QDebug>
  2. #include <QCoreApplication>
  3. #include "hybridwebpage.h"
  4. #if defined(Q_OS_SYMBIAN) && defined(WINSCW)
  5. #define EMULATOR
  6. #endif
  7. HybridWebPage::HybridWebPage(QObject *parent)
  8. : QWebPage(parent)
  9. {
  10. #if QT_VERSION >= 0x040600
  11. settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
  12. #endif
  13. }
  14. void HybridWebPage::javaScriptConsoleMessage(const QString& message,
  15. int lineNumber, const QString& sourceID)
  16. {
  17. QString consoleMessage = tr("[JS] message: %1 lineNumber: %2 sourceID: %3").arg(
  18. message).arg(lineNumber).arg(sourceID);
  19. qDebug() << consoleMessage;
  20. if(m_logFile.isOpen())
  21. {
  22. QTextStream log(&m_logFile);
  23. log << consoleMessage;
  24. }
  25. }
  26. void HybridWebPage::enableLogging()
  27. {
  28. if(!m_logFile.isOpen())
  29. {
  30. m_logFile.setFileName("c:\\data\\hag_console.log");
  31. if(!m_logFile.open(QIODevice::Append | QIODevice::Text))
  32. return;
  33. }
  34. }