main.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <QApplication>
  2. #include <QMessageBox>
  3. #include <QLockFile>
  4. #include <QDir>
  5. #include "widgets/mainwindow.h"
  6. #include <QTextCodec>
  7. #include <QDebug>
  8. #include <QResource>
  9. #include <QFontDatabase>
  10. // Global. Should be updated only by MainWindow!!!
  11. double window_height = 1000;
  12. double window_width = 648;
  13. int main(int argc, char *argv[])
  14. {
  15. setlocale(LC_ALL,"Russian");
  16. QApplication a(argc, argv);
  17. qDebug() << "Checking if there's another instance of Legacy";
  18. QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock"));
  19. if(!lockFile.tryLock(1)){
  20. QMessageBox msgBox;
  21. msgBox.setIcon(QMessageBox::Warning);
  22. msgBox.setText("Приложение уже запущено.\nРазрешено запускать только один экземпляр приложения.");
  23. msgBox.exec();
  24. return 1;
  25. }
  26. qDebug() << "Initialising fonts and resources";
  27. QResource::registerResource(QApplication::applicationDirPath() + "/data01.gtr");
  28. QResource::registerResource(QApplication::applicationDirPath() + "/data02.gtr");
  29. QFontDatabase::addApplicationFont(":/fonts/trpro.ttf");
  30. QFontDatabase::addApplicationFont(":/fonts/CrimsonText.ttf");
  31. QFontDatabase::addApplicationFont(":/fonts/EBGaramond.ttf");
  32. QFontDatabase::addApplicationFont(":/fonts/aniron.ttf");
  33. qDebug() << "Starting main frame initialisation...";
  34. MainWindow* main_window = new MainWindow(nullptr);
  35. main_window->setAttribute(Qt::WA_DeleteOnClose);
  36. qDebug() << "Finished initialisation, starting application...";
  37. return a.exec();
  38. }