ccApplication.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  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; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: CloudCompare project #
  15. //# #
  16. //##########################################################################
  17. #include <QtGlobal>
  18. #ifdef Q_OS_MAC
  19. #include <QFileOpenEvent>
  20. #endif
  21. // qCC_io
  22. #include "FileIO.h"
  23. #include "ccApplication.h"
  24. #include "mainwindow.h"
  25. //! Map between a file version, and the first version of CloudCompare that was able to load it
  26. struct FileVersionToCCVersion : QMap<short, QString>
  27. {
  28. FileVersionToCCVersion()
  29. {
  30. insert(10, "1.0 (before 2012)");
  31. insert(20, "2.0 (05/04/2012)");
  32. insert(21, "2.4 (07/02/2012)");
  33. insert(22, "2.4 (11/26/2012)");
  34. insert(23, "2.4 (02/07/2013)");
  35. insert(24, "2.4 (02/22/2013)");
  36. insert(25, "2.4 (03/16/2013)");
  37. insert(26, "2.4 (04/03/2013)");
  38. insert(27, "2.4 (04/12/2013)");
  39. insert(28, "2.5.0 (07/12/2013)");
  40. insert(29, "2.5.0 (08/14/2013)");
  41. insert(30, "2.5.0 (08/30/2013)");
  42. insert(31, "2.5.0 (09/25/2013)");
  43. insert(32, "2.5.1 (10/11/2013)");
  44. insert(33, "2.5.2 (12/19/2013)");
  45. insert(34, "2.5.3 (01/09/2014)");
  46. insert(35, "2.5.4 (02/13/2014)");
  47. insert(36, "2.5.5 (05/30/2014)");
  48. insert(37, "2.5.5 (08/24/2014)");
  49. insert(38, "2.6.0 (09/14/2014)");
  50. insert(39, "2.6.1 (01/30/2015)");
  51. insert(40, "2.6.2 (08/06/2015)");
  52. insert(41, "2.6.2 (09/01/2015)");
  53. insert(42, "2.6.2 (10/07/2015)");
  54. insert(43, "2.6.3 (01/07/2016)");
  55. insert(44, "2.8.0 (07/07/2016)");
  56. insert(45, "2.8.0 (10/06/2016)");
  57. insert(46, "2.8.0 (11/03/2016)");
  58. insert(47, "2.9.0 (12/22/2016)");
  59. insert(48, "2.10.0 (10/19/2018)");
  60. insert(49, "2.11.0 (03/31/2019)");
  61. insert(50, "2.11.0 (10/06/2019)");
  62. insert(51, "2.12.0 (03/29/2019)");
  63. insert(52, "2.12.0 (11/30/2020)");
  64. insert(53, "2.13.alpha (10/02/2022)");
  65. insert(54, "2.13.alpha (01/29/2023)");
  66. }
  67. QString getMinCCVersion(short fileVersion) const
  68. {
  69. if (contains(fileVersion))
  70. {
  71. return value(fileVersion);
  72. }
  73. else
  74. {
  75. return "Unknown version";
  76. }
  77. }
  78. };
  79. static FileVersionToCCVersion s_fileVersionToCCVersion;
  80. QString ccApplication::GetMinCCVersionForFileVersion(short fileVersion)
  81. {
  82. return s_fileVersionToCCVersion.getMinCCVersion(fileVersion);
  83. }
  84. ccApplication::ccApplication( int &argc, char **argv, bool isCommandLine )
  85. : ccApplicationBase( argc, argv, isCommandLine, QString( "2.14.alpha (%1)" ).arg(__DATE__))
  86. {
  87. setApplicationName( "CloudCompare" );
  88. FileIO::setWriterInfo( applicationName(), versionStr() );
  89. }
  90. bool ccApplication::event(QEvent* inEvent)
  91. {
  92. #ifdef Q_OS_MAC
  93. switch ( inEvent->type() )
  94. {
  95. case QEvent::FileOpen:
  96. {
  97. MainWindow* mainWindow = MainWindow::TheInstance();
  98. if ( mainWindow == nullptr )
  99. {
  100. return false;
  101. }
  102. mainWindow->addToDB( QStringList(static_cast<QFileOpenEvent *>(inEvent)->file()) );
  103. return true;
  104. }
  105. default:
  106. break;
  107. }
  108. #endif
  109. return ccApplicationBase::event( inEvent );
  110. }