]> Shamusworld >> Repos - wozmaker/blob - src/navwidget.cpp
Flesh out the disk settings dialog.
[wozmaker] / src / navwidget.cpp
1 //
2 // navwidget.cpp: A2R disk image navigation widget
3 //
4 // Part of the WOZ Maker Project
5 // by James Hammons
6 // (C) 2018 Underground Software
7 // See the README and GPLv3 files for licensing and warranty information
8 //
9
10 #include "navwidget.h"
11 #include "fileio.h"
12 #include "global.h"
13
14
15 NavWidget::NavWidget(void): QWidget()
16 {
17         label = new QLabel;
18
19         QToolButton * pb1 = new QToolButton;
20         QToolButton * pb2 = new QToolButton;
21         QToolButton * pb3 = new QToolButton;
22         QToolButton * pb4 = new QToolButton;
23         QToolButton * pb5 = new QToolButton;
24         QToolButton * pb6 = new QToolButton;
25         QToolButton * pb7 = new QToolButton;
26         QToolButton * pb8 = new QToolButton;
27
28         QSpinBox * sb1 = new QSpinBox;
29         QSpinBox * sb2 = new QSpinBox;
30         QSpinBox * sb3 = new QSpinBox;
31         QSpinBox * sb4 = new QSpinBox;
32         QSpinBox * sb5 = new QSpinBox;
33
34         QSpinBox * sb6 = new QSpinBox;
35 /*      QSpinBox * sb6 = new QSpinBox;
36         QSpinBox * sb7 = new QSpinBox;
37         QSpinBox * sb8 = new QSpinBox;
38         QSpinBox * sb9 = new QSpinBox;
39         QSpinBox * sb10 = new QSpinBox;//*/
40 #if 0
41         pb1->setIcon(QIcon(":/res/layer-add.png"));
42         pb2->setIcon(QIcon(":/res/layer-delete.png"));
43         pb3->setIcon(QIcon(":/res/layer-edit.png"));
44         pb4->setIcon(QIcon(":/res/block-import.png"));
45 #endif
46         pb1->setText("-");
47         pb2->setText("+");
48         pb3->setText("Sync");
49         pb4->setText("<<");
50         pb5->setText("Man. Sync");
51         pb6->setText("0 All");
52         pb7->setText("Synth");
53         pb8->setText("Synth2");
54
55         pb1->setToolTip(tr("Previous track"));
56         pb2->setToolTip(tr("Next track"));
57         pb3->setToolTip(tr("Init sync"));
58         pb4->setToolTip(tr("Step back"));
59         pb5->setToolTip(tr("Manual sync"));
60         pb6->setToolTip(tr("Reset to zero"));
61         pb7->setToolTip(tr("Synthesize waveform"));
62         pb8->setToolTip(tr("Synthesize waveform 2"));
63
64         sb1->setMaximum(80000);
65         sb2->setMaximum(80000);
66         sb3->setMaximum(80000);
67         sb4->setMaximum(80000);
68         sb5->setMaximum(80000);
69
70         sb6->setMaximum(80000);
71 /*      sb6->setMaximum(2000000);
72         sb7->setMaximum(2000000);
73         sb8->setMaximum(2000000);
74         sb9->setMaximum(2000000);
75         sb10->setMaximum(2000000);//*/
76
77         QHBoxLayout * hbox1 = new QHBoxLayout;
78         QHBoxLayout * hbox2 = new QHBoxLayout;
79         QHBoxLayout * hbox3 = new QHBoxLayout;
80         QHBoxLayout * hbox4 = new QHBoxLayout;
81         hbox1->addWidget(pb1);
82         hbox1->addWidget(pb2);
83         hbox1->addWidget(pb3);
84         hbox1->addWidget(pb4);
85         hbox1->addStretch();
86
87         hbox2->addWidget(pb5);
88         hbox2->addWidget(pb6);
89         hbox2->addWidget(pb7);
90         hbox2->addStretch();
91
92         hbox3->addWidget(sb1);
93         hbox3->addWidget(sb2);
94         hbox3->addWidget(sb3);
95         hbox3->addWidget(sb4);
96         hbox3->addWidget(sb5);
97         hbox3->addStretch();
98
99         hbox4->addWidget(sb6);
100         hbox4->addWidget(pb8);
101 /*      hbox4->addWidget(sb6);
102         hbox4->addWidget(sb7);
103         hbox4->addWidget(sb8);
104         hbox4->addWidget(sb9);
105         hbox4->addWidget(sb10);
106         hbox4->addStretch();//*/
107
108         QVBoxLayout * mainLayout = new QVBoxLayout;
109         mainLayout->addWidget(label);
110         mainLayout->addStretch();
111         mainLayout->addLayout(hbox4);
112         mainLayout->addLayout(hbox3);
113         mainLayout->addLayout(hbox1);
114         mainLayout->addLayout(hbox2);
115
116         setLayout(mainLayout);
117
118         connect(pb1, SIGNAL(clicked()), this, SLOT(HandlePrevTrack()));
119         connect(pb2, SIGNAL(clicked()), this, SLOT(HandleNextTrack()));
120         connect(pb3, SIGNAL(clicked()), this, SLOT(HandleInitSync()));
121         connect(pb4, SIGNAL(clicked()), this, SLOT(HandleStepBack()));
122         connect(pb5, SIGNAL(clicked()), this, SLOT(HandleManualSync()));
123         connect(pb6, SIGNAL(clicked()), this, SLOT(HandleZeroAll()));
124         connect(pb7, SIGNAL(clicked()), this, SLOT(HandleSynthesize()));
125         connect(pb8, SIGNAL(clicked()), this, SLOT(HandleSynthesize2()));
126
127         connect(sb1, SIGNAL(valueChanged(int)), this, SLOT(HandleSync1(int)));
128         connect(sb2, SIGNAL(valueChanged(int)), this, SLOT(HandleSync2(int)));
129         connect(sb3, SIGNAL(valueChanged(int)), this, SLOT(HandleSync3(int)));
130         connect(sb4, SIGNAL(valueChanged(int)), this, SLOT(HandleSync4(int)));
131         connect(sb5, SIGNAL(valueChanged(int)), this, SLOT(HandleSync5(int)));
132
133         connect(sb6, SIGNAL(valueChanged(int)), this, SLOT(HandleWaveSync(int)));
134 /*      connect(sb6, SIGNAL(valueChanged(int)), this, SLOT(HandleRatio1(int)));
135         connect(sb7, SIGNAL(valueChanged(int)), this, SLOT(HandleRatio2(int)));
136         connect(sb8, SIGNAL(valueChanged(int)), this, SLOT(HandleRatio3(int)));
137         connect(sb9, SIGNAL(valueChanged(int)), this, SLOT(HandleRatio4(int)));
138         connect(sb10, SIGNAL(valueChanged(int)), this, SLOT(HandleRatio5(int)));//*/
139 }
140
141
142 NavWidget::~NavWidget()
143 {
144 }
145
146
147 void NavWidget::ShowInfo(void)
148 {
149         QString s;
150         s += QString("Track No.: %1<br>").arg((double)Global::trackNum / 4.0, 0, 'f', 2);
151         s += QString("Stream No.: %1<br>").arg(Global::streamNum);
152         s += QString("Nibbles: %1<br>").arg(Global::nibbleCount);
153         s += QString("Bloops: %1<br>").arg(Global::bloops);
154
155         label->setText(s);
156 }
157
158
159 void NavWidget::HandlePrevTrack(void)
160 {
161         if (Global::trackNum == 0)
162                 return;
163
164         Global::trackNum--;
165         ShowInfo();
166         emit(UpdateWaveform());
167 }
168
169
170 void NavWidget::HandleNextTrack(void)
171 {
172         if (Global::trackNum == (35 * 4))
173                 return;
174
175         Global::trackNum++;
176         ShowInfo();
177         emit(UpdateWaveform());
178 }
179
180
181 void NavWidget::HandleInitSync(void)
182 {
183         emit(InitSync());
184 }
185
186
187 void NavWidget::HandleStepBack(void)
188 {
189         emit(StepBack());
190 }
191
192
193 void NavWidget::HandleManualSync(void)
194 {
195         emit(ManualSync());
196 }
197
198
199 void NavWidget::HandleZeroAll(void)
200 {
201         emit(ZeroAll());
202 }
203
204
205 void NavWidget::HandleSynthesize(void)
206 {
207         emit(Synthesize());
208 }
209
210
211 void NavWidget::HandleSynthesize2(void)
212 {
213         emit(Synthesize2());
214 }
215
216
217 void NavWidget::HandleSync1(int num)
218 {
219         emit(Sync(0, num));
220 }
221
222
223 void NavWidget::HandleSync2(int num)
224 {
225         emit(Sync(1, num));
226 }
227
228
229 void NavWidget::HandleSync3(int num)
230 {
231         emit(Sync(2, num));
232 }
233
234
235 void NavWidget::HandleSync4(int num)
236 {
237         emit(Sync(3, num));
238 }
239
240
241 void NavWidget::HandleSync5(int num)
242 {
243         emit(Sync(4, num));
244 }
245
246
247 void NavWidget::HandleWaveSync(int num)
248 {
249         emit(WaveSync(num));
250 }
251