Skip to content

Commit

Permalink
Merge pull request #12 from lgolouz/develop
Browse files Browse the repository at this point in the history
[Release #1] ZXTapeReviver
  • Loading branch information
lgolouz authored Sep 27, 2020
2 parents 34cc242 + 5474fcf commit 02413fa
Show file tree
Hide file tree
Showing 15 changed files with 534 additions and 84 deletions.
6 changes: 4 additions & 2 deletions ZXTapeReviver.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ SOURCES += \
sources/models/fileworkermodel.cpp \
sources/controls/waveformcontrol.cpp \
sources/core/waveformparser.cpp \
sources/core/wavreader.cpp
sources/core/wavreader.cpp \
sources/models/suspiciouspointsmodel.cpp

HEADERS += \
sources/defines.h \
sources/models/fileworkermodel.h \
sources/controls/waveformcontrol.h \
sources/core/waveformparser.h \
sources/core/wavreader.h
sources/core/wavreader.h \
sources/models/suspiciouspointsmodel.h

RESOURCES += qml/qml.qrc

Expand Down
61 changes: 61 additions & 0 deletions qml/GoToAddress.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//*******************************************************************************
// ZX Tape Reviver
//-----------------
//
// Author: Leonid Golouz
// E-mail: [email protected]
//*******************************************************************************

import QtQuick 2.3
import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.3

Dialog {
id: gotoAddressDialog

signal gotoAddress(int adr);

visible: false
title: "Go to address..."
standardButtons: StandardButton.Ok | StandardButton.Cancel
modality: Qt.WindowModal
width: 200
height: 120

Text {
id: textWithField
text: "Please enter address:"
}

TextField {
id: textField
anchors.top: textWithField.bottom
width: parent.width
}

CheckBox {
id: hexCheckbox

anchors.top: textField.bottom
anchors.topMargin: 3
checked: true
text: "Hexadecimal"
}

Text {
id: conversionField

function convertAddress(adr) {
return hexCheckbox.checked ? parseInt(adr, 16) : "0x" + parseInt(adr, 10).toString(16).toUpperCase();
}

text: "(" + convertAddress(textField.text) + ")"
anchors.left: hexCheckbox.right
anchors.leftMargin: 3
anchors.top: hexCheckbox.top
}

onAccepted: {
gotoAddress(parseInt(textField.text, hexCheckbox.checked ? 16 : 10));
}
}
126 changes: 88 additions & 38 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ApplicationWindow {
id: mainWindow

readonly property int mainAreaWidth: width * 0.75
property ListModel suspiciousPoints: ListModel { }
property var suspiciousPoints: SuspiciousPointsModel.suspiciousPoints

visible: true
width: 1600
Expand All @@ -31,26 +31,20 @@ ApplicationWindow {
return wfWidth * wfXScale / 2;
}

function addSuspiciousPoint(idx) {
console.log("Adding suspicious point: " + idx);
for (var i = 0; i < suspiciousPoints.count; ++i) {
var p = suspiciousPoints.get(i).idx;
if (p === idx) {
return;
}
else if (p > idx) {
suspiciousPoints.insert(i, {idx: idx});
return;
}
}

suspiciousPoints.append({idx: idx});
}

function getSelectedWaveform() {
return channelsComboBox.currentIndex == 0 ? waveformControlCh0 : waveformControlCh1;
}

function restoreWaveformView() {
waveformControlCh0.xScaleFactor = 1;
waveformControlCh0.yScaleFactor = 80000;
waveformControlCh0.wavePos = 0;

waveformControlCh1.xScaleFactor = 1;
waveformControlCh1.yScaleFactor = 80000;
waveformControlCh1.wavePos = 0;
}

menuBar: MenuBar {
Menu {
title: "File"
Expand All @@ -59,6 +53,16 @@ ApplicationWindow {
text: "Open WAV file..."
onTriggered: {
console.log("Opening WAV file");
openFileDialog.isWavOpening = true;
openFileDialog.open();
}
}

MenuItem {
text: "Open Waveform file..."
onTriggered: {
console.log("Opening Waveform file");
openFileDialog.isWavOpening = false;
openFileDialog.open();
}
}
Expand Down Expand Up @@ -116,15 +120,9 @@ ApplicationWindow {
title: "Waveform"

MenuItem {
text: "Restore"
text: "Restore view"
onTriggered: {
waveformControlCh0.xScaleFactor = 1;
waveformControlCh0.yScaleFactor = 80000;
waveformControlCh0.wavePos = 0;

waveformControlCh1.xScaleFactor = 1;
waveformControlCh1.yScaleFactor = 80000;
waveformControlCh1.wavePos = 0;
restoreWaveformView();
}
}

Expand All @@ -137,15 +135,27 @@ ApplicationWindow {
FileDialog {
id: openFileDialog

property bool isWavOpening: true

title: "Please choose WAV file"
selectMultiple: false
sidebarVisible: true
defaultSuffix: "wav"
nameFilters: [ "WAV files (*.wav)" ]
defaultSuffix: isWavOpening ? "wav" : "wfm"
nameFilters: isWavOpening ? [ "WAV files (*.wav)" ] : [ "Waveform files (*.wfm)" ]

onAccepted: {
console.log("Selected WAV file: " + openFileDialog.fileUrl);
console.log("Open WAV file result: " + FileWorkerModel.openWavFileByUrl(openFileDialog.fileUrl));
var filetype = isWavOpening ? "WAV" : "Waveform";
console.log("Selected %1 file: ".arg(filetype) + openFileDialog.fileUrl);
var res = (isWavOpening
? FileWorkerModel.openWavFileByUrl(openFileDialog.fileUrl)
: FileWorkerModel.openWaveformFileByUrl(openFileDialog.fileUrl));
console.log("Open %1 file result: ".arg(filetype) + res);
if (res === 0) {
if (isWavOpening) {
SuspiciousPointsModel.clearSuspiciousPoints();
}
restoreWaveformView();
}
}

onRejected: {
Expand Down Expand Up @@ -174,9 +184,11 @@ ApplicationWindow {
else {
waveformControlCh1.saveTap(saveFileDialog.fileUrl);
}
console.log("Tap saved: " + saveFileDialog.fileUrl)
}
else {
//wavReader.saveWaveform();
FileWorkerModel.saveWaveformFileByUrl(saveFileDialog.fileUrl);
console.log("Waveform saved: " + saveFileDialog.fileUrl);
}
}
}
Expand Down Expand Up @@ -215,7 +227,7 @@ ApplicationWindow {
height: parent.height - parent.height / 2 - parent.spacerHeight / 2

onDoubleClick: {
addSuspiciousPoint(idx);
SuspiciousPointsModel.addSuspiciousPoint(idx);
}
}

Expand All @@ -232,7 +244,7 @@ ApplicationWindow {
height: waveformControlCh0.height

onDoubleClick: {
addSuspiciousPoint(idx);
SuspiciousPointsModel.addSuspiciousPoint(idx);
}
}

Expand Down Expand Up @@ -430,6 +442,23 @@ ApplicationWindow {
}
}

Button {
id: gotoAddressButton

text: "Goto address..."
anchors {
top: shiftWaveform.bottom
topMargin: 5
right: parent.right
rightMargin: 5
}
width: hZoomOutButton.width

onClicked: {
gotoAddressDialogLoader.item.open();
}
}

Button {
id: selectionModeToggleButton

Expand Down Expand Up @@ -525,7 +554,7 @@ ApplicationWindow {
idx = 0;
}

waveformControlCh0.wavePos = waveformControlCh1.wavePos = idx ;
waveformControlCh0.wavePos = waveformControlCh1.wavePos = idx;
}
}
}
Expand Down Expand Up @@ -617,11 +646,11 @@ ApplicationWindow {
text: "Goto Suspicious point"

onClicked: {
if (suspiciousPointsView.currentRow < 0 || suspiciousPointsView.currentRow >= suspiciousPoints.count) {
if (suspiciousPointsView.currentRow < 0 || suspiciousPointsView.currentRow >= SuspiciousPointsModel.size) {
return;
}

var idx = suspiciousPoints.get(suspiciousPointsView.currentRow).idx - getWaveShiftIndex(waveformControlCh0.width, waveformControlCh0.xScaleFactor);
var idx = SuspiciousPointsModel.getSuspiciousPoint(suspiciousPointsView.currentRow) - getWaveShiftIndex(waveformControlCh0.width, waveformControlCh0.xScaleFactor);
if (idx < 0) {
idx = 0;
}
Expand All @@ -645,9 +674,9 @@ ApplicationWindow {
text: "Remove Suspicious point"

onClicked: {
if (suspiciousPointsView.currentRow >= 0 && suspiciousPointsView.currentRow < suspiciousPoints.count) {
console.log("Removing suspicious point: " + suspiciousPoints.get(suspiciousPointsView.currentRow).idx);
suspiciousPoints.remove(suspiciousPointsView.currentRow);
if (suspiciousPointsView.currentRow >= 0 && suspiciousPointsView.currentRow < SuspiciousPointsModel.size) {
console.log("Removing suspicious point: " + SuspiciousPointsModel.getSuspiciousPoint(suspiciousPointsView.currentRow));
SuspiciousPointsModel.removeSuspiciousPoint(suspiciousPointsView.currentRow);
}
}
}
Expand Down Expand Up @@ -680,4 +709,25 @@ ApplicationWindow {
}
}
}

Loader {
id: gotoAddressDialogLoader
source: "GoToAddress.qml"
}

Connections {
target: gotoAddressDialogLoader.item
function onGotoAddress(adr) {
console.log("Goto address: " + adr);
var pos = WaveformParser.getPositionByAddress(channelsComboBox.currentIndex, parsedDataView.currentRow, adr);
if (pos !== 0) {
var idx = pos - getWaveShiftIndex(waveformControlCh0.width, waveformControlCh0.xScaleFactor);
if (idx < 0) {
idx = 0;
}

waveformControlCh0.wavePos = waveformControlCh1.wavePos = idx;
}
}
}
}
1 change: 1 addition & 0 deletions qml/qml.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>GoToAddress.qml</file>
</qresource>
</RCC>
2 changes: 1 addition & 1 deletion sources/controls/waveformcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void WaveformControl::repairWaveform()
{
if (!m_isWaveformRepaired) {
//mWavReader.repairWaveform(m_channelNumber);
mWavReader.normalizeWaveform(0);
mWavReader.normalizeWaveform2(m_channelNumber);
update();
m_isWaveformRepaired = true;
emit isWaveformRepairedChanged();
Expand Down
Loading

0 comments on commit 02413fa

Please sign in to comment.