LIDL Soundboard  1.9.0
A simple soundboard, yet better than EXP Soundboard forsenE
wrapperproperties.h
Go to the documentation of this file.
1 #ifndef WRAPPERPROPERTIES_H
2 #define WRAPPERPROPERTIES_H
3 
4 //#include <QDebug>
5 
6 
7 #include <QWidget>
8 #include <QPushButton>
9 #include <QListWidget>
10 #include <QHBoxLayout>
11 #include <QVBoxLayout>
12 #include <QGridLayout>
13 #include "soundwrapper.h"
14 #include <QLabel>
15 #include <QLineEdit>
16 #include <QRadioButton>
17 #include <QGroupBox>
18 #include <QCloseEvent>
19 #include <QListWidgetItem>
20 #include <QFileDialog>
21 //#include <QTreeWidget>
22 //#include <QTreeWidgetItem>
23 #include <QString>
24 
25 #include <QButtonGroup>
26 #include <QKeySequence>
27 #include <QKeyEvent>
28 #include <QSet>
29 #include <QTimer>
30 #include <QPoint>
31 #include "soundwrapper.h"
32 
33 // The class to save me from going insane
34 #include <QKeySequenceEdit>
35 #include "CustomShortcutEdit.h"
36 #include <QMessageBox>
37 #include "CustomListWidget.h"
38 #include "EnumsAndStructs.h"
39 #include <QSlider>
40 // #include "QFancySlider"
41 #include <CustomListWidgetItem.h>
42 #include <QSpinBox>
43 #include "SettingsController.h"
44 #include "Spoiler.h" // UI:SFX
45 #include <QCheckBox> // UI:SFX
46 #include <QTabWidget> // UI:SFX Tab widget
47 #include "CustomSoundFile.h" // LIDL::SoundFile methods
48 #include <QComboBox> // UI:SFX:Chorus
49 #include <QScrollArea> // UI:SFX
50 #include <QInputDialog> // Asking user for URL
51 
52 #include <QTcpSocket> // TCP Socket to check if file exist in HTTP
53 #include <QSslSocket> // SSL Socket to check if file exist in HTTPS
54 #include <QRegExp> // RegExp to find out the MIMEType of the file so user can't add retarded stuff from the internet
55 
56 #include "SliderSpin.h"
57 #include "SfxSettingsWidget.h"
58 
59 
60 
61 
62 
63 
64 
65 
66 
79 class WrapperProperties : public QWidget
80 {
81  Q_OBJECT
82 public:
100  WrapperProperties(int mainOutput,int VACOutput,SoundWrapper * sound = nullptr,QWidget *parent = nullptr);
101 
102 private:
110  explicit WrapperProperties(QWidget *parent = nullptr);
115  void closeEvent(QCloseEvent *event);
116 
118  QLabel * _soundListHint;
120  // Buttons to add and delete
121  QPushButton *_btnAdd;
122  QPushButton *_btnAddFromURL;
123  QPushButton *_btnDelete;
126  // Our layouts
127  QVBoxLayout *_vLayout;
128  QGridLayout *_gLayout;
132  // Playbackmode
133  QGroupBox *_radioGroupBox;
134  QButtonGroup *_radioGroup;
135  QHBoxLayout *_radioLayout;
136  //QRadioButton *_radioSingleton; /*!< The Singleton radio button.*/
137  QRadioButton *_radioSequential;
138  QRadioButton *_radioAuto;
139  QRadioButton *_radioCancer;
140  QRadioButton *_radioAutoLoop;
142  // Hotkey
143  QGroupBox *_shortcutGroup;
144  QGridLayout *_shortcutLayout;
147  QKeySequence *_shortcutSequence;
148  QPushButton *_shortcutResetBtn;
149  QLabel *_shortcutHint;
152  // int _shortcutVirtualKey;
153 
154  // Abort and done button
155  QPushButton *_btnDone;
156  QPushButton *_btnAbort;
161  // variables to store which output device and PTT are already set (if any)
165  /*******************************************************
166  * *
167  * VOLUME SLIDERS *
168  * *
169  *******************************************************/
172  QGroupBox* _sliderGroup;
173  QGridLayout * _sliderLayout;
174  QSlider *_sliderMain;
175  QSpinBox * _sliderMainSpin;
176  QLabel * _sliderLabelMain;
178  QSlider *_sliderVAC;
179  QSpinBox * _sliderVACSpin;
180  QLabel * _sliderLabelVAC;
181 // QLabel * _sliderHint; /*!< Hint.*/
182 
183 
184  /*******************************************************
185  * *
186  * SOUND EFFECTS *
187  * *
188  *******************************************************/
189  QButtonGroup *_sfxBtnGroup;
191  QGridLayout *_sfxLayout;
192  QTabWidget *_sfxTabWidget;
193  // DISTORTION
195  // CHORUS
197  // ECHO
199  // COMPRESSOR
201  // FLANGER
203  // GARGLE
212 template <LIDL::SFX_TYPE Type, class Param >
213 void setUpConnection(SfxSettingsWidget* widget);
214 /*
215  *
216 BASS_FX_DX8_CHORUS DX8 Chorus. Use BASS_DX8_CHORUS structure to set/get parameters.
217 BASS_FX_DX8_COMPRESSOR DX8 Compression. Use BASS_DX8_COMPRESSOR structure to set/get parameters.
218 BASS_FX_DX8_DISTORTION DX8 Distortion. Use BASS_DX8_DISTORTION structure to set/get parameters.
219 BASS_FX_DX8_ECHO DX8 Echo. Use BASS_DX8_ECHO structure to set/get parameters.
220 BASS_FX_DX8_FLANGER DX8 Flanger. Use BASS_DX8_FLANGER structure to set/get parameters.
221 BASS_FX_DX8_GARGLE DX8 Gargle. Use BASS_DX8_GARGLE structure to set/get parameters.
222 BASS_FX_DX8_I3DL2REVERB DX8 I3DL2 (Interactive 3D Audio Level 2) reverb. Use BASS_DX8_I3DL2REVERB structure to set/get parameters.
223 BASS_FX_DX8_PARAMEQ DX8 Parametric equalizer. Use BASS_DX8_PARAMEQ structure to set/get parameters.
224 BASS_FX_DX8_REVERB */
225 
226 
227 // TODO ajouter volume
228 signals:
235  void signalAddDone(std::shared_ptr<SoundWrapper> sound);
236 
243  void signalEditDone(std::shared_ptr<SoundWrapper> sound);
244 
248  void closed();
249 
250 public slots:
256  void AddSound();
257 
264  void AddSoundFromUrl();
265 
272  void AddSoundFromDrop(QString);
273 
278  void ItemWasClicked(QListWidgetItem* item);
279 
284  void RadioPressed(int id);
285 
289  void SetKeySequence(QKeySequence);
290 
291 
292 
293 
300  void SetItemMainVolume(int newValue);
301 
308  void SetItemVACVolume(int newValue);
309 
310 
311 };
312 
313 // wanna have both the type of the sfx and the parameters thinking
314 
315 template <LIDL::SFX_TYPE Type, class Param >
317 {
318  //selected item should be ok but we test it nonetheless
319  if (_selectedItem == nullptr)
320  return;
321 
322  // we disable the widget if the flag isn't set, or check the box if its enabled
323  if (!(_selectedItem->getSFX().flags & Type))
324  {
325  widget->deactivateAll();
326  widget->setCheckboxState(false);
327  }
328  else
329  widget->setCheckboxState(true);
330 
331 
332  static QMetaObject::Connection *checkboxConn;
333  static QMetaObject::Connection *sliderConn;
334  static QMetaObject::Connection *comboConn;
335  // deleting and disconnecting the connection
336  if (checkboxConn != nullptr)
337  {
338  QObject::disconnect(*checkboxConn );
339  delete checkboxConn;
340  checkboxConn = nullptr;
341  }
342  checkboxConn = new QMetaObject::Connection;
343  *checkboxConn = connect(widget, &SfxSettingsWidget::checkBoxStateChanged, this,[=](bool newState)
344  {
345  _selectedItem->SetSFXEnabled(Type, newState);
346  });
347 
348  // Populate the sliders with appropriate values :)
349  // Check limit in EnumsAndStruct
350  // starting at 0 this way we can change the order of the items in the enum
351  // Using the template of CustomListWidgetItem to get the sfx value :v: forsenE
352  for (int i= 0; i < static_cast<int>(Param::ITER_END); i++)
353  widget->setValueOfEnumParam(i, _selectedItem->getSFXValue<Param>(i) );
354 
355  // Connecting the sliders to the setters of the objects
356  // we also need a template for this :v: forsenE
357  if (sliderConn != nullptr)
358  {
359  QObject::disconnect(*sliderConn);
360  delete sliderConn;
361  sliderConn = nullptr;
362  }
363  sliderConn = new QMetaObject::Connection;
364  *sliderConn = connect(widget,&SfxSettingsWidget::sliderValueChanged,this,[=](int index, int value, int specialValue){
365  Q_UNUSED(index);
366  //qDebug() << "Special value is:" << specialValue;
367  _selectedItem->setSFX<Param>(specialValue,value);
368  });
369 
370  // Connecting the combo box changed signal
371  if (comboConn != nullptr)
372  {
373  QObject::disconnect(*comboConn);
374  delete comboConn;
375  comboConn = nullptr;
376  }
377  comboConn = new QMetaObject::Connection;
378  *comboConn = connect(widget,&SfxSettingsWidget::comboBoxValueChanged,this,[=](int whichOne,int newIndex, int specialValue){
379  Q_UNUSED(whichOne);
380  //http://bass.radio42.com/help/html/f23be39f-2720-aca0-9b58-ef3a54af2c34.htm
381  // index is equal to the value of the BASS_DX8 enum
382  // specialValue is equal to EnumsAndStructs.h value
383  qDebug() << "nigger nigger ni " << specialValue;
384  _selectedItem->setSFX<Param>(specialValue,newIndex);
385  });
386 
387 
388 }
389 
390 #endif // WRAPPERPROPERTIES_H
void setCheckboxState(bool state)
setCheckboxState Set this widget checkbox checked state.
Definition: SfxSettingsWidget.cpp:190
The CustomListWidget class : inherits QListWidget.
Definition: CustomListWidget.h:32
void sliderValueChanged(int sliderIndex, int newValue, int specialValue)
sliderValueChanged Emitted when a slider's value changed.
Definition: Spoiler.h:15
QSpinBox * _sliderMainSpin
Definition: wrapperproperties.h:175
Spoiler * _sliderSpoiler
Definition: wrapperproperties.h:170
QSpinBox * _sliderVACSpin
Definition: wrapperproperties.h:179
void setValueOfEnumParam(int enumValue, int newValue)
setValueOfEnumParam Will set the value of a widget item settings.
Definition: SfxSettingsWidget.cpp:136
QLabel * _shortcutHint
Definition: wrapperproperties.h:149
QRadioButton * _radioAutoLoop
Definition: wrapperproperties.h:140
void deactivateAll()
deactivateAll Deactivates all widgets except the checkbox.
Definition: SfxSettingsWidget.cpp:65
LIDL::Playback _playBackMode
Definition: wrapperproperties.h:160
QHBoxLayout * _radioLayout
Definition: wrapperproperties.h:135
void SetItemMainVolume(int newValue)
SetItemMainVolume Sets a sound item main volume.
Definition: wrapperproperties.cpp:669
QLabel * _soundListHint
Definition: wrapperproperties.h:118
SfxSettingsWidget * _compressorWidget
Definition: wrapperproperties.h:200
WrapperProperties(int mainOutput, int VACOutput, SoundWrapper *sound=nullptr, QWidget *parent=nullptr)
Constructor of the "Sound Entry Editor" UI.
Definition: wrapperproperties.cpp:398
CustomListWidgetItem * _selectedItem
Definition: wrapperproperties.h:124
File describing the CustomListWidgetItem class.
SfxSettingsWidget * _distortionWidget
Definition: wrapperproperties.h:194
Spoiler * _sfxSpoiler
Definition: wrapperproperties.h:190
QRadioButton * _radioCancer
Definition: wrapperproperties.h:139
QGridLayout * _shortcutLayout
Definition: wrapperproperties.h:144
CustomListWidget * _soundListDisplay
Definition: wrapperproperties.h:117
File describing the CustomListWidget class.
Code of the mainUI.
QKeySequence * _shortcutSequence
Definition: wrapperproperties.h:147
void AddSoundFromUrl()
AddSoundFromUrl method.
Definition: wrapperproperties.cpp:681
void RadioPressed(int id)
RadioPressed sets the wrapper playback mode whenever radio is pressed.
Definition: wrapperproperties.cpp:599
QGroupBox * _shortcutGroup
Definition: wrapperproperties.h:143
The CustomListWidgetItem class, inherits QListWidgetItem.
Definition: CustomListWidgetItem.h:27
void comboBoxValueChanged(int comboBoxIndex, int newIndex, int enumValue)
comboBoxValueChanged Emitted when a combo box text has changed.
QPushButton * _btnAddFromURL
Definition: wrapperproperties.h:122
QSlider * _sliderMain
Definition: wrapperproperties.h:174
QLabel * _shortcutWarning
Definition: wrapperproperties.h:150
LIDL::SFX getSFX()
getSFX
Definition: CustomListWidgetItem.cpp:94
void AddSound()
AddSound method.
Definition: wrapperproperties.cpp:546
The CustomShortcutEdit class.
Definition: CustomShortcutEdit.h:36
SfxSettingsWidget * _gargleWidget
Definition: wrapperproperties.h:204
void setUpConnection(SfxSettingsWidget *widget)
Set the connection of all the widgets (sliders,combo boxes etc), contained in the widget.
Definition: wrapperproperties.h:316
QLabel * _sliderLabelMain
Definition: wrapperproperties.h:176
QGridLayout * _sliderLayout
Definition: wrapperproperties.h:173
void SetSFXEnabled(LIDL::SFX_TYPE type, bool enabled)
SetSFXEnabled Sets (or unsets) the _sfx.flags member.
Definition: CustomListWidgetItem.cpp:106
void signalAddDone(std::shared_ptr< SoundWrapper > sound)
The signal that is sent when adding a new wrapper.
QLabel * _sliderLabelVAC
Definition: wrapperproperties.h:180
QPushButton * _btnDone
Definition: wrapperproperties.h:155
int _VACOutput
Definition: wrapperproperties.h:163
Inherits QWidget.
Definition: wrapperproperties.h:79
QRadioButton * _radioSequential
Definition: wrapperproperties.h:137
SfxSettingsWidget * _chorusWidget
Definition: wrapperproperties.h:196
QGridLayout * _gLayout
Definition: wrapperproperties.h:128
QPushButton * _btnDelete
Definition: wrapperproperties.h:123
QGroupBox * _radioGroupBox
Definition: wrapperproperties.h:133
QButtonGroup * _sfxBtnGroup
Definition: wrapperproperties.h:189
SfxSettingsWidget * _flangerWidget
Definition: wrapperproperties.h:202
QPushButton * _btnAbort
Definition: wrapperproperties.h:156
QButtonGroup * _radioGroup
Definition: wrapperproperties.h:134
void ItemWasClicked(QListWidgetItem *item)
ItemWasClicked deals with connecting every slider and spinbox to the selected sound.
Definition: wrapperproperties.cpp:628
Definition: SfxSettingsWidget.h:18
QGroupBox * _sliderGroup
Definition: wrapperproperties.h:172
QVBoxLayout * _vLayout
Definition: wrapperproperties.h:127
QSlider * _sliderVAC
Definition: wrapperproperties.h:178
QRadioButton * _radioAuto
Definition: wrapperproperties.h:138
void closeEvent(QCloseEvent *event)
Reimplemented to send a closed signal to the mainUI, so we can re-enable the widgets.
Definition: wrapperproperties.cpp:526
Inherits QObject.
Definition: soundwrapper.h:35
void closed()
This signal is emitted whenever the Sound Entry Editor window is closed.
QPushButton * _shortcutResetBtn
Definition: wrapperproperties.h:148
void setSFX(int specialValue, int value)
Definition: CustomListWidgetItem.h:230
void signalEditDone(std::shared_ptr< SoundWrapper > sound)
The signal that is sent after editing an existing wrapper.
void SetItemVACVolume(int newValue)
SetItemVACVolume Sets a sound item VAC volume.
Definition: wrapperproperties.cpp:674
SFX_TYPE flags
Definition: EnumsAndStructs.h:66
int _mainOutput
Definition: wrapperproperties.h:162
SfxSettingsWidget * _echoWidget
Definition: wrapperproperties.h:198
QGridLayout * _sfxLayout
Definition: wrapperproperties.h:191
void checkBoxStateChanged(bool newState)
checkBoxStateChanged Emitted when checkbox is toggled.
int getSFXValue(int which)
Definition: CustomListWidgetItem.h:206
Playback
The Playback enum.
Definition: EnumsAndStructs.h:27
QPushButton * _btnAdd
Definition: wrapperproperties.h:121
void AddSoundFromDrop(QString)
AddSoundFromDrop.
Definition: wrapperproperties.cpp:573
void SetKeySequence(QKeySequence)
SetKeySequence Sets the key sequence of the line edit.
Definition: wrapperproperties.cpp:619
CustomShortcutEdit * _shortcutEdit
Definition: wrapperproperties.h:146
QTabWidget * _sfxTabWidget
Definition: wrapperproperties.h:192