main.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <QDebug>
  2. #include <QDir>
  3. #include <QApplication>
  4. #include <QWebFrame>
  5. #include "mainwindow.h"
  6. class HybridFWApplication : public QApplication
  7. {
  8. public:
  9. HybridFWApplication(int & argc, char ** argv ) : QApplication(argc, argv) {}
  10. void setWebFrame(QWebFrame *webFrame) { m_webFrame = webFrame; }
  11. private:
  12. QWebFrame *m_webFrame;
  13. };
  14. /**
  15. * Takes three arguments:
  16. * Launcher.exe <identifier> <path> <panning enabled>
  17. * e.g. Launcher.exe 1234 widget\main.html true
  18. */
  19. int main(int argc, char *argv[])
  20. {
  21. HybridFWApplication a(argc, argv);
  22. if (argc == 4) {
  23. QFileInfo f(argv[2]);
  24. QString file = f.canonicalFilePath();
  25. if (QFile::exists(file)) {
  26. MainWindow w(argv[1], file, (QString(argv[3]) == "true"));
  27. a.setWebFrame(w.webFrame());
  28. w.showMaximized();
  29. return a.exec();
  30. }
  31. }
  32. QString args = "";
  33. for (int i=0;i<argc;i++) {
  34. args += "\n" + QString(argv[i]);
  35. }
  36. // Called if a valid file was not given
  37. MainWindow w(QString::number(argc) + "; " + args);
  38. w.show();
  39. return a.exec();
  40. }