PageRenderTime 41ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/PaperSizeScroll/_snip_pieces/xsl-fo_open/srcm/session/SessionManager.h

http://fop-miniscribus.googlecode.com/
C Header | 126 lines | 93 code | 30 blank | 3 comment | 6 complexity | be821529d06459ad505f142928b4ed5e MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0
  1. #ifndef SESSIONMANAGER_H
  2. #define SESSIONMANAGER_H
  3. #include <QtGui>
  4. #include <QDebug>
  5. #include <QApplication>
  6. #include <QtGui>
  7. #include <QtCore>
  8. #include <QHttp>
  9. #include <QAbstractSocket>
  10. #include <QFileInfo>
  11. #include <QHttp>
  12. #include <QUrl>
  13. #include <QTimer>
  14. #include "Basic_Config.h"
  15. #include "GSInterlace.h"
  16. #include "pics_structure.h"
  17. #include "richdoc_structure.h"
  18. #include <QSettings>
  19. #define _PARSE_DEBUG_FOP_ 1
  20. static inline QByteArray FiStream( const QString file )
  21. {
  22. QByteArray stream;
  23. QFile f(file);
  24. if (f.exists()) {
  25. if (f.open(QFile::ReadOnly)) {
  26. stream = f.readAll();
  27. f.close();
  28. return stream;
  29. }
  30. }
  31. return stream;
  32. }
  33. class SessionManager {
  34. public:
  35. static SessionManager* instance();
  36. void LoadFontDir( const QString path );
  37. inline QString tra_file() const { return transfile; }
  38. void Set_Translate_File( const QString file );
  39. inline QMap<int,M_PageSize> mpages() { return history_page_norms; }
  40. inline QStringList FontList() { return FF_db.families(); }
  41. M_PageSize FindPagePsize( const QRect paper );
  42. QString DebugAttributes();
  43. inline bool Lastsignature() { return true; } /* is open a miniscribus file true xsl-fo chunk unrelax false */
  44. int CurrentDocWidth;
  45. QMap<int,QString> LastCharOpen;
  46. QMap<int,QString> LastBlockOpen;
  47. QMap<QString,QByteArray> SvgList;
  48. QMap<QString,SPics> current_pics;
  49. private:
  50. SessionManager();
  51. static SessionManager* st_;
  52. void FormatRegister( const QString txt , QPrinter::PageSize pp );
  53. QString transfile;
  54. QFontDatabase FF_db;
  55. QTranslator PPtr;
  56. QMap<QString,SPics> history_pics; /* name + class */
  57. QMap<int,M_PageSize> history_page_norms;
  58. };
  59. /* tr macro on no Q_OBJECT class !!!! */
  60. static inline void OpenDesk( QUrl loc )
  61. {
  62. #if defined Q_WS_MAC
  63. /* direct to open */
  64. QProcess *m = new QProcess();
  65. QStringList macs;
  66. macs << loc.toString();
  67. m->startDetached(QString("open") , macs );
  68. return;
  69. #endif
  70. #if defined Q_WS_WIN
  71. QString fullFileName = loc.toString();
  72. if (fullFileName.startsWith("http://", Qt::CaseInsensitive) ||
  73. fullFileName.startsWith("https://", Qt::CaseInsensitive) ||
  74. fullFileName.startsWith("ftp://", Qt::CaseInsensitive) ||
  75. fullFileName.startsWith("news://", Qt::CaseInsensitive) ||
  76. fullFileName.startsWith("mailto:", Qt::CaseInsensitive) ||
  77. fullFileName.startsWith("webdav://", Qt::CaseInsensitive) )
  78. {
  79. } else {
  80. fullFileName.prepend("file:///"); /* or qurl to localfile */
  81. }
  82. bool wr = QDesktopServices::openUrl(QUrl(fullFileName));
  83. if (!wr) {
  84. QMessageBox::warning(0,QString("Error"),
  85. QString("Window Unable to open action file or dir %1").arg(loc.toString()));
  86. }
  87. return;
  88. #endif
  89. /* linux */
  90. bool r = QDesktopServices::openUrl(loc);
  91. if (!r) {
  92. QMessageBox::warning(0,QString("Error"),
  93. QString("Linux Unable to open action file or dir %1").arg(loc.toString()));
  94. }
  95. }
  96. #endif // SESSIONMANAGER_H