app.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. config = new AConfig();
  36. network = new ANetwork();
  37. helper = new Helper();
  38. downloader = new DownloadManager();
  39. writtenLabel = new QLabel();
  40. buildSeparators(9472, 65507, 45, 60, 48, 85);//9472 создаем разделители
  41. }
  42. static App& getInstance() {
  43. static App instance;
  44. return instance;
  45. }
  46. AConfig * config;
  47. ANetwork * network;
  48. Helper * helper;
  49. MainWindow * window;
  50. DownloadManager * downloader;
  51. QLabel * writtenLabel;
  52. QString state;
  53. QString app_folder = "";
  54. QString qsep, qsepn, tsep, tsepn, bsep, bsepn;
  55. QString stylehtml;
  56. bool ready = true;
  57. void log(QString msg){
  58. QString format = "[" + QDate::currentDate().toString(Qt::ISODate).toUtf8() + " " + QTime::currentTime().toString(Qt::ISODate).toUtf8() + "] " + msg;
  59. fprintf(stderr, (format + "\n").toUtf8());
  60. }
  61. void logSectionStart(const char * msg){
  62. topSeparate();
  63. fprintf(stderr, "%s\n", msg);
  64. bottomSeparate();
  65. }
  66. void logSectionEnd(){
  67. fprintf(stderr, " \n");
  68. }
  69. void topSeparate(){
  70. fprintf(stderr, tsepn.toUtf8());
  71. }
  72. void bottomSeparate(){
  73. fprintf(stderr, bsepn.toUtf8());
  74. }
  75. void buildSeparators(int code_top, int code_bottom, int qcode, int tsize, int bsize, int qsize){
  76. for(int i = 0; i < tsize; i++){ tsep.append(QChar(QChar(code_top))); }
  77. tsepn = tsep + "\n";
  78. for(int i = 0; i < bsize; i++){ bsep.append(QChar(QChar(code_bottom))); }
  79. bsepn = bsep + "\n";
  80. for(int i = 0; i < qsize; i++){ qsep.append(QChar(QChar(qcode))); }
  81. qsepn = qsep + "\n";
  82. }
  83. };
  84. #endif // APP_H