1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
// padthv1widget_jack.cpp
//
/****************************************************************************
Copyright (C) 2012-2017, rncbc aka Rui Nuno Capela. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1widget_jack.h"
#include "padthv1_jack.h"
#ifdef CONFIG_NSM
#include "padthv1_nsm.h"
#endif
#include <QApplication>
#include <QFileInfo>
#include <QDir>
#include <QCloseEvent>
#include <QStyleFactory>
#ifndef CONFIG_LIBDIR
#if defined(__x86_64__)
#define CONFIG_LIBDIR CONFIG_PREFIX "/lib64"
#else
#define CONFIG_LIBDIR CONFIG_PREFIX "/lib"
#endif
#endif
#if QT_VERSION < 0x050000
#define CONFIG_PLUGINSDIR CONFIG_LIBDIR "/qt4/plugins"
#else
#define CONFIG_PLUGINSDIR CONFIG_LIBDIR "/qt5/plugins"
#endif
//-------------------------------------------------------------------------
// padthv1widget_jack - impl.
//
// Constructor.
padthv1widget_jack::padthv1widget_jack ( padthv1_jack *pSynth )
: padthv1widget(), m_pSynth(pSynth)
#ifdef CONFIG_NSM
, m_pNsmClient(NULL)
#endif
{
// Special style paths...
if (QDir(CONFIG_PLUGINSDIR).exists())
QApplication::addLibraryPath(CONFIG_PLUGINSDIR);
// Custom style theme...
padthv1_config *pConfig = padthv1_config::getInstance();
if (pConfig && !pConfig->sCustomStyleTheme.isEmpty())
QApplication::setStyle(QStyleFactory::create(pConfig->sCustomStyleTheme));
// Initialize (user) interface stuff...
m_pSynthUi = new padthv1_ui(m_pSynth, false);
// May initialize the scheduler/work notifier.
openSchedNotifier();
// Initialize preset stuff...
// initPreset();
updateSample();
updateParamValues();
}
// Destructor.
padthv1widget_jack::~padthv1widget_jack (void)
{
delete m_pSynthUi;
}
// Synth engine accessor.
padthv1_ui *padthv1widget_jack::ui_instance (void) const
{
return m_pSynthUi;
}
#ifdef CONFIG_NSM
// NSM client accessors.
void padthv1widget_jack::setNsmClient ( padthv1_nsm *pNsmClient )
{
m_pNsmClient = pNsmClient;
padthv1_config *pConfig = padthv1_config::getInstance();
if (pConfig)
pConfig->bDontUseNativeDialogs = true;
}
padthv1_nsm *padthv1widget_jack::nsmClient (void) const
{
return m_pNsmClient;
}
#endif // CONFIG_NSM
// Param port method.
void padthv1widget_jack::updateParam (
padthv1::ParamIndex index, float fValue ) const
{
m_pSynthUi->setParamValue(index, fValue);
}
// Dirty flag method.
void padthv1widget_jack::updateDirtyPreset ( bool bDirtyPreset )
{
padthv1widget::updateDirtyPreset(bDirtyPreset);
#ifdef CONFIG_NSM
if (m_pNsmClient && m_pNsmClient->is_active())
m_pNsmClient->dirty(bDirtyPreset);
#endif
}
// Application close.
void padthv1widget_jack::closeEvent ( QCloseEvent *pCloseEvent )
{
#ifdef CONFIG_NSM
if (m_pNsmClient && m_pNsmClient->is_active())
padthv1widget::updateDirtyPreset(false);
#endif
// Let's be sure about that...
if (queryClose()) {
pCloseEvent->accept();
QApplication::quit();
} else {
pCloseEvent->ignore();
}
}
#ifdef CONFIG_NSM
// Optional GUI handlers.
void padthv1widget_jack::showEvent ( QShowEvent *pShowEvent )
{
QWidget::showEvent(pShowEvent);
if (m_pNsmClient)
m_pNsmClient->visible(true);
}
void padthv1widget_jack::hideEvent ( QHideEvent *pHideEvent )
{
if (m_pNsmClient)
m_pNsmClient->visible(false);
QWidget::hideEvent(pHideEvent);
}
#endif // CONFIG_NSM
// end of padthv1widget_jack.cpp
|