fb2app.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <QErrorMessage>
  2. #include <QLocale>
  3. #include <QTranslator>
  4. #include "fb2app.hpp"
  5. #include "fb2logs.hpp"
  6. #include "fb2main.hpp"
  7. #ifndef PACKAGE_NAME
  8. #define PACKAGE_NAME "fb2edit"
  9. #define PACKAGE_VENDOR "LinTest"
  10. #define PACKAGE_VERSION "0.XX.XX"
  11. #endif // PACKAGE_VERSION
  12. QString FbApplication::lastCommit()
  13. {
  14. #ifdef COMMIT_INFO
  15. return QString(COMMIT_INFO).replace("//", "<br>");
  16. #else
  17. return QString();
  18. #endif // PACKAGE_VERSION
  19. }
  20. void FbApplication::handleMessage(QtMsgType type, const QString& msg)
  21. {
  22. emit logMessage(type, msg);
  23. }
  24. static void fb2MessageHandler(QtMsgType type, const QMessageLogContext&, const QString& msg)
  25. {
  26. ((FbApplication*)qApp)->handleMessage(type, msg);
  27. }
  28. int main(int argc, char *argv[])
  29. {
  30. Q_INIT_RESOURCE(fb2edit);
  31. FbApplication app(argc, argv);
  32. app.setApplicationName(QString(PACKAGE_NAME));
  33. app.setOrganizationName(QString(PACKAGE_VENDOR));
  34. app.setApplicationVersion(QString(PACKAGE_VERSION));
  35. QTranslator translator;
  36. translator.load(QLocale::system().name(), ":ts");
  37. app.installTranslator(&translator);
  38. int count = app.arguments().count();
  39. for (int i = 1; i < count; ++i) {
  40. QString arg = app.arguments().at(i);
  41. (new FbMainWindow(arg))->show();
  42. }
  43. if (count == 1) (new FbMainWindow)->show();
  44. qInstallMessageHandler(fb2MessageHandler);
  45. return app.exec();
  46. }