1 /*
2  * Copyright (c) 2015-2016 Meltytech, LLC
3  * Author: Brian Matherly <code@brianmatherly.com>
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 "scopecontroller.h"
19 #include "widgets/scopes/audioloudnessscopewidget.h"
20 #include "widgets/scopes/audiopeakmeterscopewidget.h"
21 #include "widgets/scopes/audiospectrumscopewidget.h"
22 #include "widgets/scopes/audiowaveformscopewidget.h"
23 #include "widgets/scopes/videohistogramscopewidget.h"
24 #include "widgets/scopes/videorgbparadescopewidget.h"
25 #include "widgets/scopes/videorgbwaveformscopewidget.h"
26 #include "widgets/scopes/videovectorscopewidget.h"
27 #include "widgets/scopes/videowaveformscopewidget.h"
28 #include "widgets/scopes/videozoomscopewidget.h"
29 #include "docks/scopedock.h"
30 #include "settings.h"
31 #include <Logger.h>
32 #include <QMainWindow>
33 #include <QMenu>
34 
ScopeController(QMainWindow * mainWindow,QMenu * menu)35 ScopeController::ScopeController(QMainWindow* mainWindow, QMenu* menu)
36   : QObject(mainWindow)
37 {
38     LOG_DEBUG() << "begin";
39     QMenu* scopeMenu = menu->addMenu(tr("Scopes"));
40     createScopeDock<AudioLoudnessScopeWidget>(mainWindow, scopeMenu);
41     createScopeDock<AudioPeakMeterScopeWidget>(mainWindow, scopeMenu);
42     createScopeDock<AudioSpectrumScopeWidget>(mainWindow, scopeMenu);
43     createScopeDock<AudioWaveformScopeWidget>(mainWindow, scopeMenu);
44     if (!Settings.playerGPU()) {
45         createScopeDock<VideoHistogramScopeWidget>(mainWindow, scopeMenu);
46         createScopeDock<VideoRgbParadeScopeWidget>(mainWindow, scopeMenu);
47         createScopeDock<VideoRgbWaveformScopeWidget>(mainWindow, scopeMenu);
48         createScopeDock<VideoVectorScopeWidget>(mainWindow, scopeMenu);
49         createScopeDock<VideoWaveformScopeWidget>(mainWindow, scopeMenu);
50         createScopeDock<VideoZoomScopeWidget>(mainWindow, scopeMenu);
51     }
52     LOG_DEBUG() << "end";
53 }
54 
createScopeDock(QMainWindow * mainWindow,QMenu * menu)55 template<typename ScopeTYPE> void ScopeController::createScopeDock(QMainWindow* mainWindow, QMenu* menu)
56 {
57     ScopeWidget* scopeWidget = new ScopeTYPE();
58     ScopeDock* scopeDock = new ScopeDock(this, scopeWidget);
59     scopeDock->hide();
60     menu->addAction(scopeDock->toggleViewAction());
61     mainWindow->addDockWidget(Qt::RightDockWidgetArea, scopeDock);
62 }
63 
64