PageRenderTime 63ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/ResInsight-2018.01.1/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp

https://bitbucket.org/terraai/resinsight
C++ | 179 lines | 95 code | 40 blank | 44 comment | 3 complexity | 5f2925dff84175cb97dbfcc971316aa1 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  1. /////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2016- Statoil ASA
  4. //
  5. // ResInsight 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. // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
  11. // WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. // FITNESS FOR A PARTICULAR PURPOSE.
  13. //
  14. // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
  15. // for more details.
  16. //
  17. /////////////////////////////////////////////////////////////////////////////////
  18. #include "RicHelpFeatures.h"
  19. #include "RiaBaseDefs.h"
  20. #include "RiaApplication.h"
  21. #include "RiuMainWindow.h"
  22. #include "cafAboutDialog.h"
  23. #include "cafViewer.h"
  24. #include <QAction>
  25. #include <QDesktopServices>
  26. #include <QErrorMessage>
  27. #include <QUrl>
  28. CAF_CMD_SOURCE_INIT(RicHelpAboutFeature, "RicHelpAboutFeature");
  29. CAF_CMD_SOURCE_INIT(RicHelpCommandLineFeature, "RicHelpCommandLineFeature");
  30. CAF_CMD_SOURCE_INIT(RicHelpOpenUsersGuideFeature, "RicHelpOpenUsersGuideFeature");
  31. //--------------------------------------------------------------------------------------------------
  32. ///
  33. //--------------------------------------------------------------------------------------------------
  34. bool RicHelpAboutFeature::isCommandEnabled()
  35. {
  36. return true;
  37. }
  38. //--------------------------------------------------------------------------------------------------
  39. ///
  40. //--------------------------------------------------------------------------------------------------
  41. void RicHelpAboutFeature::onActionTriggered(bool isChecked)
  42. {
  43. this->disableModelChangeContribution();
  44. caf::AboutDialog dlg(NULL);
  45. dlg.setApplicationName(RI_APPLICATION_NAME);
  46. dlg.setApplicationVersion(RiaApplication::getVersionStringApp(true));
  47. dlg.setCopyright("Copyright Statoil ASA, Ceetron Solutions AS, Ceetron AS");
  48. dlg.showQtVersion(false);
  49. #ifdef _DEBUG
  50. dlg.setIsDebugBuild(true);
  51. #endif
  52. dlg.addVersionEntry(" ", "ResInsight is made available under the GNU General Public License v. 3");
  53. dlg.addVersionEntry(" ", "See http://www.gnu.org/licenses/gpl.html");
  54. dlg.addVersionEntry(" ", " ");
  55. QStringList activeFeatures;
  56. #ifdef USE_ODB_API
  57. activeFeatures += " Geomech";
  58. #endif
  59. #ifdef USE_HDF5
  60. activeFeatures += " Souring";
  61. #endif
  62. #ifdef USE_PROTOTYPE_FEATURE_FRACTURES
  63. activeFeatures += " Fractures";
  64. #endif
  65. if (!activeFeatures.isEmpty())
  66. {
  67. dlg.addVersionEntry(" ", "Features");
  68. for (auto feature : activeFeatures)
  69. {
  70. dlg.addVersionEntry(" ", feature);
  71. }
  72. }
  73. dlg.addVersionEntry(" ", " ");
  74. dlg.addVersionEntry(" ", "Technical Information");
  75. dlg.addVersionEntry(" ", QString(" Qt ") + qVersion());
  76. dlg.addVersionEntry(" ", QString(" ") + caf::AboutDialog::versionStringForcurrentOpenGLContext());
  77. dlg.addVersionEntry(" ", caf::Viewer::isShadersSupported() ? " Hardware OpenGL" : " Software OpenGL");
  78. dlg.create();
  79. dlg.resize(300, 200);
  80. dlg.exec();
  81. }
  82. //--------------------------------------------------------------------------------------------------
  83. ///
  84. //--------------------------------------------------------------------------------------------------
  85. void RicHelpAboutFeature::setupActionLook(QAction* actionToSetup)
  86. {
  87. actionToSetup->setText("&About");
  88. }
  89. //--------------------------------------------------------------------------------------------------
  90. ///
  91. //--------------------------------------------------------------------------------------------------
  92. bool RicHelpCommandLineFeature::isCommandEnabled()
  93. {
  94. return true;
  95. }
  96. //--------------------------------------------------------------------------------------------------
  97. ///
  98. //--------------------------------------------------------------------------------------------------
  99. void RicHelpCommandLineFeature::onActionTriggered(bool isChecked)
  100. {
  101. this->disableModelChangeContribution();
  102. RiaApplication* app = RiaApplication::instance();
  103. QString text = app->commandLineParameterHelp();
  104. app->showFormattedTextInMessageBox(text);
  105. }
  106. //--------------------------------------------------------------------------------------------------
  107. ///
  108. //--------------------------------------------------------------------------------------------------
  109. void RicHelpCommandLineFeature::setupActionLook(QAction* actionToSetup)
  110. {
  111. actionToSetup->setText("&Command Line Help");
  112. }
  113. //--------------------------------------------------------------------------------------------------
  114. ///
  115. //--------------------------------------------------------------------------------------------------
  116. bool RicHelpOpenUsersGuideFeature::isCommandEnabled()
  117. {
  118. return true;
  119. }
  120. //--------------------------------------------------------------------------------------------------
  121. ///
  122. //--------------------------------------------------------------------------------------------------
  123. void RicHelpOpenUsersGuideFeature::onActionTriggered(bool isChecked)
  124. {
  125. this->disableModelChangeContribution();
  126. QString usersGuideUrl = "http://resinsight.org/docs/home";
  127. if (!QDesktopServices::openUrl(usersGuideUrl))
  128. {
  129. QErrorMessage* errorHandler = QErrorMessage::qtHandler();
  130. errorHandler->showMessage("Failed open browser with the following url\n\n" + usersGuideUrl);
  131. }
  132. }
  133. //--------------------------------------------------------------------------------------------------
  134. ///
  135. //--------------------------------------------------------------------------------------------------
  136. void RicHelpOpenUsersGuideFeature::setupActionLook(QAction* actionToSetup)
  137. {
  138. actionToSetup->setText("&Users Guide");
  139. }