PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/muse-2.0/muse/help.cpp

#
C++ | 112 lines | 58 code | 17 blank | 37 comment | 5 complexity | fe2b9b85943afc8324815f0c73850a08 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. //=========================================================
  2. // MusE
  3. // Linux Music Editor
  4. // $Id: help.cpp,v 1.7.2.4 2009/07/05 23:06:21 terminator356 Exp $
  5. //
  6. // (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
  7. //
  8. // This program is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU General Public License
  10. // as published by the Free Software Foundation; version 2 of
  11. // the License, or (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program; if not, write to the Free Software
  20. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. //
  22. //=========================================================
  23. #include <unistd.h>
  24. #include <stdlib.h>
  25. #include <QDesktopServices>
  26. #include <QMessageBox>
  27. #include <QUrl>
  28. #include "app.h"
  29. #include "globals.h"
  30. #include "gconfig.h"
  31. #include "icons.h"
  32. #include "aboutbox_impl.h"
  33. namespace MusEGui {
  34. //---------------------------------------------------------
  35. // startHelpBrowser
  36. //---------------------------------------------------------
  37. void MusE::startHelpBrowser()
  38. {
  39. QString lang(getenv("LANG"));
  40. QString museHelp = DOCDIR + QString("/html/index_") + lang + QString(".html");
  41. if (access(museHelp.toLatin1(), R_OK) != 0) {
  42. museHelp = DOCDIR + QString("/html/index.html");
  43. if (access(museHelp.toLatin1(), R_OK) != 0) {
  44. QString info(tr("no help found at: "));
  45. info += museHelp;
  46. QMessageBox::critical(this, tr("MusE: Open Help"), info);
  47. return;
  48. }
  49. }
  50. launchBrowser(museHelp);
  51. }
  52. //---------------------------------------------------------
  53. // startHelpBrowser
  54. //---------------------------------------------------------
  55. void MusE::startHomepageBrowser()
  56. {
  57. QString museHome = QString("http://www.muse-sequencer.org");
  58. launchBrowser(museHome);
  59. }
  60. //---------------------------------------------------------
  61. // startBugBrowser
  62. //---------------------------------------------------------
  63. void MusE::startBugBrowser()
  64. {
  65. QString museBugPage("http://www.muse-sequencer.org/index.php/Report_a_bug");
  66. launchBrowser(museBugPage);
  67. }
  68. //---------------------------------------------------------
  69. // about
  70. //---------------------------------------------------------
  71. void MusE::about()
  72. {
  73. MusEGui::AboutBoxImpl ab;
  74. ab.show();
  75. ab.exec();
  76. }
  77. //---------------------------------------------------------
  78. // aboutQt
  79. //---------------------------------------------------------
  80. void MusE::aboutQt()
  81. {
  82. QMessageBox::aboutQt(this, QString("MusE"));
  83. }
  84. void MusE::launchBrowser(QString &whereTo)
  85. {
  86. if (! QDesktopServices::openUrl(QUrl(whereTo)))
  87. {
  88. QMessageBox::information(this, tr("Unable to launch help"),
  89. tr("For some reason MusE has to launch the default\n"
  90. "browser on your machine."),
  91. QMessageBox::Ok, QMessageBox::Ok);
  92. printf("Unable to launch help\n");
  93. }
  94. }
  95. } // namespace MusEGui