Open Source Snapmatic picture and Savegame viewer/editor for GTA V https://gta5view.syping.de/

StringParser.cpp 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*****************************************************************************
  2. * gta5view Grand Theft Auto V Profile Viewer
  3. * Copyright (C) 2016-2017 Syping
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *****************************************************************************/
  18. #include "StringParser.h"
  19. #include <QTextDocument>
  20. #include <QLibraryInfo>
  21. #include <QTextCodec>
  22. #include <QByteArray>
  23. #include <QFileInfo>
  24. #include <QString>
  25. #include <QList>
  26. #include <QDir>
  27. #ifdef GTA5SYNC_PROJECT
  28. #include <QApplication>
  29. #include "config.h"
  30. #endif
  31. StringParser::StringParser()
  32. {
  33. }
  34. QString StringParser::escapeString(const QString &toEscape)
  35. {
  36. #if QT_VERSION >= 0x050000
  37. return toEscape.toHtmlEscaped();
  38. #else
  39. return Qt::escape(toEscape);
  40. #endif
  41. }
  42. #ifdef GTA5SYNC_PROJECT
  43. QString StringParser::convertBuildedString(const QString &buildedStr)
  44. {
  45. QString outputStr = buildedStr;
  46. QByteArray sharePath = GTA5SYNC_SHARE;
  47. outputStr.replace("APPNAME:", GTA5SYNC_APPSTR);
  48. outputStr.replace("SHAREDDIR:", QString::fromUtf8(sharePath));
  49. outputStr.replace("RUNDIR:", QFileInfo(qApp->applicationFilePath()).absoluteDir().absolutePath());
  50. outputStr.replace("QCONFLANG:", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  51. outputStr.replace("QCONFPLUG:", QLibraryInfo::location(QLibraryInfo::PluginsPath));
  52. outputStr.replace("SEPARATOR:", QDir::separator());
  53. return outputStr;
  54. }
  55. #endif