app.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef APP_H
  2. #define APP_H
  3. #include "mainwindow.h"
  4. #include "ui_mainwindow.h"
  5. #include "config.h"
  6. #include "network.h"
  7. #include "helper.h"
  8. #include "downloadmanager.h"
  9. #include <QRegExp>
  10. #include <QBitmap>
  11. #include <QClipboard>
  12. #include <QException>
  13. #include <QWidget>
  14. #include <QGraphicsDropShadowEffect>
  15. #include <QDesktopWidget>
  16. #include <QFile>
  17. #include <QFileInfo>
  18. #include <QDir>
  19. #include <QFileDialog>
  20. #include <QMessageBox>
  21. #include <QRect>
  22. #include <QGridLayout>
  23. #include <QMovie>
  24. #include <QListWidget>
  25. #include <QtConcurrent/QtConcurrent>
  26. #include <QMessageLogger>
  27. #include <QDebug>
  28. #include <QFutureWatcher>
  29. #include "LotroDat.h"
  30. #include <string>
  31. using namespace LOTRO_DAT;
  32. class App {
  33. public:
  34. App() {
  35. instance = nullptr;
  36. config = new AConfig();
  37. network = new ANetwork();
  38. helper = new Helper();
  39. downloader = new DownloadManager();
  40. writtenLabel = new QLabel();
  41. //datfile = new DatFile();
  42. db = new Database();
  43. buildSeparators(9472, 65507, 45, 60, 48, 85);//9472 создаем разделители
  44. }
  45. static App& getInstance() {
  46. if (instance == nullptr) {
  47. instance = new App();
  48. }
  49. return *instance;
  50. }
  51. AConfig * config;
  52. ANetwork * network;
  53. Helper * helper;
  54. MainWindow * window;
  55. DownloadManager * downloader;
  56. QLabel * writtenLabel;
  57. QString state;
  58. //DatFile * datfile;
  59. Database * db;
  60. QString app_folder = "";
  61. QString qsep, qsepn, tsep, tsepn, bsep, bsepn;
  62. QString stylehtml;
  63. DatFile datfiles[5];
  64. bool ready = true;
  65. void log(QString msg){
  66. QString format = "[" + QDate::currentDate().toString(Qt::ISODate).toUtf8() + " " + QTime::currentTime().toString(Qt::ISODate).toUtf8() + "] " + msg;
  67. fprintf(stderr, (format + "\n").toUtf8());
  68. }
  69. void logSectionStart(const char * msg){
  70. topSeparate();
  71. fprintf(stderr, "%s\n", msg);
  72. bottomSeparate();
  73. }
  74. void logSectionEnd(){
  75. fprintf(stderr, " \n");
  76. }
  77. void topSeparate(){
  78. fprintf(stderr, tsepn.toUtf8());
  79. }
  80. void bottomSeparate(){
  81. fprintf(stderr, bsepn.toUtf8());
  82. }
  83. void buildSeparators(int code_top, int code_bottom, int qcode, int tsize, int bsize, int qsize){
  84. for(int i = 0; i < tsize; i++){ tsep.append(QChar(QChar(code_top))); }
  85. tsepn = tsep + "\n";
  86. for(int i = 0; i < bsize; i++){ bsep.append(QChar(QChar(code_bottom))); }
  87. bsepn = bsep + "\n";
  88. for(int i = 0; i < qsize; i++){ qsep.append(QChar(QChar(qcode))); }
  89. qsepn = qsep + "\n";
  90. }
  91. private:
  92. static App * instance;
  93. };
  94. #endif // APP_H