1 |
// qsamplerInstrumentListForm.ui.h |
2 |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
5 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
7 |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
9 |
as published by the Free Software Foundation; either version 2 |
10 |
of the License, or (at your option) any later version. |
11 |
|
12 |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License along |
18 |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
21 |
*****************************************************************************/ |
22 |
|
23 |
#include "qsamplerInstrument.h" |
24 |
|
25 |
#include "qsamplerMainForm.h" |
26 |
#include "qsamplerOptions.h" |
27 |
|
28 |
#include <qapplication.h> |
29 |
#include <qcombobox.h> |
30 |
#include <qtooltip.h> |
31 |
|
32 |
|
33 |
// Kind of constructor. |
34 |
void qsamplerInstrumentListForm::init (void) |
35 |
{ |
36 |
// Setup toolbar widgets. |
37 |
m_pMapComboBox = new QComboBox(InstrumentToolbar); |
38 |
m_pMapComboBox->setMinimumWidth(120); |
39 |
m_pMapComboBox->setEnabled(false); |
40 |
QToolTip::add(m_pMapComboBox, tr("Instrument Map")); |
41 |
|
42 |
InstrumentToolbar->addSeparator(); |
43 |
// InstrumentList->newGroupAction()->addTo(InstrumentToolbar); |
44 |
InstrumentList->newItemAction()->addTo(InstrumentToolbar); |
45 |
InstrumentList->editItemAction()->addTo(InstrumentToolbar); |
46 |
InstrumentList->deleteAction()->addTo(InstrumentToolbar); |
47 |
InstrumentToolbar->addSeparator(); |
48 |
InstrumentList->refreshAction()->addTo(InstrumentToolbar); |
49 |
|
50 |
QObject::connect(m_pMapComboBox, |
51 |
SIGNAL(activated(int)), |
52 |
SLOT(activateMap(int))); |
53 |
} |
54 |
|
55 |
|
56 |
// Kind of destructor. |
57 |
void qsamplerInstrumentListForm::destroy (void) |
58 |
{ |
59 |
delete m_pMapComboBox; |
60 |
} |
61 |
|
62 |
|
63 |
// Notify our parent that we're emerging. |
64 |
void qsamplerInstrumentListForm::showEvent ( QShowEvent *pShowEvent ) |
65 |
{ |
66 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
67 |
if (pMainForm) |
68 |
pMainForm->stabilizeForm(); |
69 |
|
70 |
QWidget::showEvent(pShowEvent); |
71 |
} |
72 |
|
73 |
|
74 |
// Notify our parent that we're closing. |
75 |
void qsamplerInstrumentListForm::hideEvent ( QHideEvent *pHideEvent ) |
76 |
{ |
77 |
QWidget::hideEvent(pHideEvent); |
78 |
|
79 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
80 |
if (pMainForm) |
81 |
pMainForm->stabilizeForm(); |
82 |
} |
83 |
|
84 |
|
85 |
// Refresh all instrument list and views. |
86 |
void qsamplerInstrumentListForm::refreshInstruments (void) |
87 |
{ |
88 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
89 |
if (pMainForm == NULL) |
90 |
return; |
91 |
|
92 |
qsamplerOptions *pOptions = pMainForm->options(); |
93 |
if (pOptions == NULL) |
94 |
return; |
95 |
|
96 |
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
97 |
|
98 |
// Get/save current map selection... |
99 |
int iMap = m_pMapComboBox->currentItem(); |
100 |
if (iMap < 0 || m_pMapComboBox->count() < 2) |
101 |
iMap = pOptions->iMidiMap + 1; |
102 |
|
103 |
// Populate maps list. |
104 |
m_pMapComboBox->clear(); |
105 |
m_pMapComboBox->insertItem(tr("(All)")); |
106 |
m_pMapComboBox->insertStringList(qsamplerInstrument::getMapNames()); |
107 |
|
108 |
// Adjust to saved selection... |
109 |
if (iMap < 0 || iMap >= m_pMapComboBox->count()) |
110 |
iMap = 0; |
111 |
m_pMapComboBox->setCurrentItem(iMap); |
112 |
m_pMapComboBox->setEnabled(m_pMapComboBox->count() > 1); |
113 |
|
114 |
QApplication::restoreOverrideCursor(); |
115 |
|
116 |
activateMap(iMap); |
117 |
} |
118 |
|
119 |
|
120 |
// Refresh instrument maps selector. |
121 |
void qsamplerInstrumentListForm::activateMap ( int iMap ) |
122 |
{ |
123 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
124 |
if (pMainForm == NULL) |
125 |
return; |
126 |
|
127 |
qsamplerOptions *pOptions = pMainForm->options(); |
128 |
if (pOptions == NULL) |
129 |
return; |
130 |
|
131 |
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
132 |
|
133 |
int iMidiMap = iMap - 1; |
134 |
if (iMidiMap >= 0) |
135 |
pOptions->iMidiMap = iMidiMap; |
136 |
|
137 |
InstrumentList->setMidiMap(iMidiMap); |
138 |
InstrumentList->refresh(); |
139 |
|
140 |
QApplication::restoreOverrideCursor(); |
141 |
} |
142 |
|
143 |
|
144 |
// end of qsamplerInstrumentListForm.ui.h |