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 
24 #include <unistd.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 
28 #include <QDesktopServices>
29 #include <QMessageBox>
30 #include <QUrl>
31 //#include <QDebug>
32 
33 #include "app.h"
34 #include "globals.h"
35 #include "gconfig.h"
36 #include "icons.h"
37 #include "aboutbox_impl.h"
38 
39 // Whether to open the pdf or the html
40 //#define MUSE_USE_PDF_HELP_FILE
41 
42 namespace MusEGui {
43 
44 //---------------------------------------------------------
45 //   startHelpBrowser
46 //---------------------------------------------------------
47 
startHelpBrowser()48 void MusE::startHelpBrowser()
49 {
50     QWidget* w = QApplication::widgetAt (QCursor::pos());
51 //    qDebug() << "Debug F1 help: Widget at mouse position:" << w << w->objectName();
52 
53     // setting object name for action toolbutton doesn't work, use a workaround
54     QToolButton* tb = nullptr;
55     if (w && strcmp(w->metaObject()->className(), "QToolButton") == 0) {
56         tb = dynamic_cast<QToolButton*>(w);
57 //        qDebug() << "Debug F1 help: Tool button action:" << tb << tb->defaultAction()->objectName();
58     }
59 
60     QString museManual;
61 
62     if (w && w->objectName() == "PartCanvas")
63         museManual = QString("https://github.com/muse-sequencer/muse/wiki/usage-of-the-editors");
64     else if (w && w->objectName() == "Pianoroll")
65         museManual = QString("https://github.com/muse-sequencer/muse/wiki/usage-of-the-editors");
66     else if (w && w->objectName() == "DrumCanvas")
67         museManual = QString("https://github.com/muse-sequencer/muse/wiki/usage-of-the-editors");
68     else if (w && w->objectName() == "WaveCanvas")
69         museManual = QString("https://github.com/muse-sequencer/muse/wiki/usage-of-the-editors");
70     else if (w && w->objectName() == "TrackList")
71         museManual = QString("https://github.com/muse-sequencer/muse/wiki/Documentation#tracks-and-parts");
72     else if (w && w->objectName() == "EffectRack")
73         museManual = QString("https://github.com/muse-sequencer/muse/wiki/understanding-the-effects-rack");
74     else if (w && w->objectName() == "SoloButton")
75         museManual = QString("https://github.com/muse-sequencer/muse/wiki/Documentation#track-soloing");
76     else if (w && (w->objectName() == "InputRouteButton" || w->objectName() == "OutputRouteButton"))
77         museManual = QString("https://github.com/muse-sequencer/muse/wiki/Documentation#routes");
78     else if (w && (w->objectName() == "AudioAutoType"))
79         museManual = QString("https://github.com/muse-sequencer/muse/wiki/Documentation#audio-automation");
80 
81     else if (w && tb && tb->defaultAction()->objectName() == "PanicButton")
82         museManual = QString("https://github.com/muse-sequencer/muse/wiki/Documentation#panic-local-off-reset-instrument-and-init-instrument");
83     else if (w && tb && tb->defaultAction()->objectName() == "MetronomeButton")
84         museManual = QString("https://github.com/muse-sequencer/muse/wiki/metronome");
85 
86     else
87         museManual = QString("https://github.com/muse-sequencer/muse/wiki/Documentation");
88 
89     launchBrowser(museManual);
90 }
91 
92 //---------------------------------------------------------
93 //   startHelpBrowser
94 //---------------------------------------------------------
95 
startHomepageBrowser()96 void MusE::startHomepageBrowser()
97       {
98       QString museHome = QString("https://muse-sequencer.github.io");
99       launchBrowser(museHome);
100       }
101 
102 //---------------------------------------------------------
103 //   startBugBrowser
104 //---------------------------------------------------------
105 
startBugBrowser()106 void MusE::startBugBrowser()
107       {
108       QString museBugPage("https://github.com/muse-sequencer/muse/issues");
109       launchBrowser(museBugPage);
110       }
111 
112 //---------------------------------------------------------
113 //   about
114 //---------------------------------------------------------
115 
about()116 void MusE::about()
117       {
118       MusEGui::AboutBoxImpl ab;
119       ab.show();
120       ab.exec();
121       }
122 
123 //---------------------------------------------------------
124 //   aboutQt
125 //---------------------------------------------------------
126 
aboutQt()127 void MusE::aboutQt()
128       {
129       QMessageBox::aboutQt(this, QString("MusE"));
130       }
131 
132 //---------------------------------------------------------
133 //   launchBrowser
134 //---------------------------------------------------------
135 
launchBrowser(QString & whereTo)136 void MusE::launchBrowser(QString &whereTo)
137       {
138       if (! QDesktopServices::openUrl(QUrl(whereTo)))
139             {
140             QMessageBox::information(this, tr("Unable to launch browser"),
141                                      tr("Error launching default browser"),
142                                      QMessageBox::Ok);
143             printf("Unable to launch browser\n");
144             }
145       }
146 
147 } // namespace MusEGui
148