1 #pragma once
2 
3 #include <QWidget>
4 #include <memory>
5 
6 #include "engine/controls/cuecontrol.h"
7 #include "engine/controls/ratecontrol.h"
8 #include "preferences/constants.h"
9 #include "preferences/dialog/dlgpreferencepage.h"
10 #include "preferences/dialog/ui_dlgprefdeckdlg.h"
11 #include "preferences/usersettings.h"
12 #include "util/parented_ptr.h"
13 
14 class ControlProxy;
15 class ControlPotmeter;
16 class SkinLoader;
17 class PlayerManager;
18 class MixxxMainWindow;
19 class ControlObject;
20 
21 namespace {
22 constexpr bool kDefaultCloneDeckOnLoad = true;
23 }
24 
25 namespace TrackTime {
26     enum class DisplayMode {
27         ELAPSED,
28         REMAINING,
29         ELAPSED_AND_REMAINING,
30     };
31 
32     enum class DisplayFormat {
33         TRADITIONAL,
34         TRADITIONAL_COARSE,
35         SECONDS,
36         SECONDS_LONG,
37         KILO_SECONDS,
38         HECTO_SECONDS,
39     };
40 }
41 
42 enum class KeylockMode {
43     LockOriginalKey,
44     LockCurrentKey
45 };
46 
47 enum class KeyunlockMode {
48     ResetLockedKey,
49     KeepLockedKey
50 };
51 
52 class DlgPrefDeck : public DlgPreferencePage, public Ui::DlgPrefDeckDlg  {
53     Q_OBJECT
54   public:
55     DlgPrefDeck(QWidget* parent,
56             UserSettingsPointer pConfig);
57     ~DlgPrefDeck() override;
58 
59   public slots:
60     void slotUpdate() override;
61     void slotApply() override;
62     void slotResetToDefaults() override;
63 
64     void slotMoveIntroStartCheckbox(bool checked);
65     void slotRateRangeComboBox(int index);
66     void slotRateInversionCheckbox(bool invert);
67     void slotKeyLockModeSelected(QAbstractButton*);
68     void slotKeyUnlockModeSelected(QAbstractButton*);
69     void slotRateTempCoarseSpinbox(double);
70     void slotRateTempFineSpinbox(double);
71     void slotRatePermCoarseSpinbox(double);
72     void slotRatePermFineSpinbox(double);
73     void slotSetTrackTimeDisplay(QAbstractButton*);
74     void slotSetTrackTimeDisplay(double);
75     void slotDisallowTrackLoadToPlayingDeckCheckbox(bool);
76     void slotCueModeCombobox(int);
77     void slotSetTrackLoadMode(int comboboxIndex);
78     void slotCloneDeckOnLoadDoubleTapCheckbox(bool);
79     void slotRateRampingModeLinearButton(bool);
80     void slotRateRampSensitivitySlider(int);
81 
82     void slotTimeFormatChanged(double);
83 
84     void slotNumDecksChanged(double, bool initializing=false);
85     void slotNumSamplersChanged(double, bool initializing=false);
86 
87     void slotUpdateSpeedAutoReset(bool);
88     void slotUpdatePitchAutoReset(bool);
89 
90   private:
91     // Because the CueDefault list is out of order, we have to set the combo
92     // box using the user data, not the index.  Returns the index of the item
93     // that has the corresponding userData. If the userdata is not in the list,
94     // returns zero.
95     int cueDefaultIndexByData(int userData) const;
96 
97     void setRateRangeForAllDecks(int rangePercent);
98     void setRateDirectionForAllDecks(bool inverted);
99 
100     const UserSettingsPointer m_pConfig;
101 
102     const std::unique_ptr<ControlObject> m_pControlTrackTimeDisplay;
103     const std::unique_ptr<ControlObject> m_pControlTrackTimeFormat;
104 
105     const parented_ptr<ControlProxy> m_pNumDecks;
106     const parented_ptr<ControlProxy> m_pNumSamplers;
107 
108     QList<ControlProxy*> m_cueControls;
109     QList<ControlProxy*> m_rateControls;
110     QList<ControlProxy*> m_rateDirectionControls;
111     QList<ControlProxy*> m_rateRangeControls;
112     QList<ControlProxy*> m_keylockModeControls;
113     QList<ControlProxy*> m_keyunlockModeControls;
114 
115     int m_iNumConfiguredDecks;
116     int m_iNumConfiguredSamplers;
117 
118     TrackTime::DisplayMode m_timeDisplayMode;
119 
120     CueMode m_cueMode;
121 
122     bool m_bSetIntroStartAtMainCue;
123     bool m_bDisallowTrackLoadToPlayingDeck;
124     bool m_bCloneDeckOnLoadDoubleTap;
125 
126     int m_iRateRangePercent;
127     bool m_bRateDownIncreasesSpeed;
128 
129     bool m_speedAutoReset;
130     bool m_pitchAutoReset;
131     KeylockMode m_keylockMode;
132     KeyunlockMode m_keyunlockMode;
133     SeekOnLoadMode m_seekOnLoadMode;
134 
135     RateControl::RampMode m_bRateRamping;
136     int m_iRateRampSensitivity;
137     double m_dRateTempCoarse;
138     double m_dRateTempFine;
139     double m_dRatePermCoarse;
140     double m_dRatePermFine;
141 };
142