Skip to content

Commit

Permalink
Merge pull request #45 from lgolouz/lgolouz_zxtr-44
Browse files Browse the repository at this point in the history
Fixed [ZXTR-44] Implement TAP opening and playback
  • Loading branch information
lgolouz authored Aug 28, 2022
2 parents f94cbe6 + 7f72cc0 commit 8fa72bd
Show file tree
Hide file tree
Showing 36 changed files with 1,644 additions and 93 deletions.
14 changes: 13 additions & 1 deletion ZXTapeReviver.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# permission of the Author.
#*******************************************************************************

QT += quick gui quickcontrols2
QT += quick gui quickcontrols2 multimedia

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
Expand Down Expand Up @@ -78,26 +78,38 @@ DEFINES += TRANSLATION_IDS_HEADER="\\\"$${TRANSLATIONS_GENERATED_FILENAME_H}\\\"
ZXTAPEREVIVER_VERSION=\\\"$${ZXTAPEREVIVER_VERSION}\\\"

SOURCES += \
sources/actions/actionbase.cpp \
sources/actions/editsampleaction.cpp \
sources/actions/shiftwaveformaction.cpp \
sources/main.cpp \
sources/models/actionsmodel.cpp \
sources/models/dataplayermodel.cpp \
sources/models/fileworkermodel.cpp \
sources/controls/waveformcontrol.cpp \
sources/core/waveformparser.cpp \
sources/core/wavreader.cpp \
sources/models/parsersettingsmodel.cpp \
sources/models/suspiciouspointsmodel.cpp \
sources/models/waveformmodel.cpp \
sources/translations/translationmanager.cpp \
sources/translations/translations.cpp \
sources/util/enummetainfo.cpp \
sources/configuration/configurationmanager.cpp

HEADERS += \
sources/actions/actionbase.h \
sources/actions/editsampleaction.h \
sources/actions/shiftwaveformaction.h \
sources/defines.h \
sources/models/actionsmodel.h \
sources/models/dataplayermodel.h \
sources/models/fileworkermodel.h \
sources/controls/waveformcontrol.h \
sources/core/waveformparser.h \
sources/core/wavreader.h \
sources/models/parsersettingsmodel.h \
sources/models/suspiciouspointsmodel.h \
sources/models/waveformmodel.h \
sources/translations/translationmanager.h \
sources/translations/translations.h \
sources/util/enummetainfo.h \
Expand Down
2 changes: 1 addition & 1 deletion qml/About.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Dialog {

Text {
id: zxTapeReviverText
text: '<b>ZX Tape Reviver</b> <i>%1</i> (c) 2020-2021 <a href="mailto:[email protected]">Leonid Golouz</a>'.arg(ConfigurationManager.zxTapeReviverVersion)
text: '<b>ZX Tape Reviver</b> <i>%1</i> (c) 2020-2022 <a href="mailto:[email protected]">Leonid Golouz</a>'.arg(ConfigurationManager.zxTapeReviverVersion)
onLinkActivated: Qt.openUrlExternally(link)
}
Text {
Expand Down
235 changes: 235 additions & 0 deletions qml/DataPlayer.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
//*******************************************************************************
// ZX Tape Reviver
//-----------------
//
// Author: Leonid Golouz
// E-mail: [email protected]
// YouTube channel: https://www.youtube.com/channel/UCz_ktTqWVekT0P4zVW8Xgcg
// YouTube channel e-mail: [email protected]
//
// Code modification and distribution of any kind is not allowed without direct
// permission of the Author.
//*******************************************************************************

import QtQuick 2.15
import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.12

import com.models.zxtapereviver 1.0
import "."

Dialog {
id: dataPlayerDialog

property int selectedChannel: 0
property var parsedChannel: undefined

visible: false
title: Translations.id_playing_parsed_data_window_header
standardButtons: StandardButton.Close
modality: Qt.WindowModal
width: 500
height: 400

Connections {
target: DataPlayerModel
function onCurrentBlockChanged() {
var cb = DataPlayerModel.currentBlock;
parsedDataView.selection.forEach(function(rowIndex) { parsedDataView.selection.deselect(rowIndex); });
parsedDataView.selection.select(cb);
}
}

TableView {
id: parsedDataView

width: parent.width
//height: parent.height * 0.9
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: progressBarItem.top
bottomMargin: 5
}

TableViewColumn {
title: Translations.id_block_number
width: rightArea.width * 0.07
role: "block"
delegate: Item {
property bool blkSelected: styleData.value.blockSelected
property int blkNumber: styleData.value.blockNumber

Rectangle {
anchors.fill: parent
border.width: 0
color: parent.blkSelected ? "#A00000FF" : "transparent"
Text {
anchors.centerIn: parent
color: parent.parent.blkSelected ? "white" : "black"
text: blkNumber + 1
}
}

// MouseArea {
// anchors.fill: parent
// onClicked: {
// WaveformParser.toggleBlockSelection(blkNumber);
// }
// }
}
}

TableViewColumn {
title: Translations.id_block_type
width: rightArea.width * 0.23
role: "blockType"
}

TableViewColumn {
title: Translations.id_block_name
width: rightArea.width * 0.3
role: "blockName"
}

TableViewColumn {
title: Translations.id_block_size
width: rightArea.width * 0.25
role: "blockSize"
}

TableViewColumn {
title: Translations.id_block_status
width: rightArea.width * 0.45
role: "blockStatus"
}

selectionMode: SelectionMode.SingleSelection
model: parsedChannel
itemDelegate: Text {
text: styleData.value
color: modelData.state === 0 ? "black" : "red"
}
}

Button {
id: playParsedData

text: DataPlayerModel.stopped ? Translations.id_play_parsed_data : Translations.id_stop_playing_parsed_data
anchors.bottom: parent.bottom
anchors.left: parent.left

onClicked: {
if (DataPlayerModel.stopped) {
DataPlayerModel.playParsedData(selectedChannel, parsedDataView.currentRow === -1 ? 0 : parsedDataView.currentRow);
} else {
DataPlayerModel.stop();
}
}
}

Item {
id: progressBarItem
anchors {
bottom:playParsedData.top
left: parent.left
right: parent.right
bottomMargin: 5
}
height: progressBarRect.height + startDurationText.height

Rectangle {
id: progressBarRect

anchors {
left: parent.left
right: parent.right
top: parent.top
}
height: textFontMetrics.height * 1.25

color: "transparent"
border.color: "black"

Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
topMargin: parent.border.width
bottomMargin: parent.border.width
leftMargin: parent.border.width
}
width: (parent.width - 2 * parent.border.width) * (DataPlayerModel.processedTime / DataPlayerModel.blockTime)
LinearGradient {
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0.0; color: "#1B94EF" }
GradientStop { position: 1.0; color: "#92C1E4" }
}
start: Qt.point(0, 0)
end: Qt.point(parent.width, 0)
}
}

Text {
id: playingRecordText
font.pixelSize: 12
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: {
var b = DataPlayerModel.blockData;
return b == undefined ? "" : (b.block.blockNumber + 1) + ": " + b.blockType + " " + b.blockName;
}
}
FontMetrics {
id: textFontMetrics
font: playingRecordText.font
}
}

function getTimeText(t) {
var bt_s = ~~(t / 1000);
var btm = ~~(bt_s / 60);
var bts = ~~(bt_s - (btm * 60));
return btm + ":" + String(bts).padStart(2, "0");
}

Text {
id: startDurationText
text: progressBarItem.getTimeText(0)
anchors {
top: progressBarRect.bottom
left: parent.left
}
}
Text {
id: endDurationText
text: progressBarItem.getTimeText(DataPlayerModel.blockTime)
anchors {
top: progressBarRect.bottom
right: parent.right
}
}
Text {
id: currentDurationText
text: progressBarItem.getTimeText(DataPlayerModel.processedTime)
anchors {
top: progressBarRect.bottom
left: parent.left
right: parent.right
}
horizontalAlignment: Text.AlignHCenter
}
}

onVisibleChanged: {
if (!visible) {
DataPlayerModel.stop();
}
}
}
15 changes: 15 additions & 0 deletions qml/ParserSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Dialog {
}
}
CheckBox {
id: checkForAbnormalSineCheckbox
anchors.top: grid.bottom
anchors.topMargin: 5

Expand All @@ -207,6 +208,20 @@ Dialog {
ParserSettingsModel.checkForAbnormalSine = checked;
}
}
Text {
id: sineCheckToleranceText
anchors.top: checkForAbnormalSineCheckbox.bottom
text: Translations.id_sine_check_tolerance
visible: checkForAbnormalSineCheckbox.checked
}
TextField {
anchors.top: sineCheckToleranceText.bottom
text: ParserSettingsModel.sineCheckTolerance;
onTextChanged: {
ParserSettingsModel.sineCheckTolerance = text;
}
visible: checkForAbnormalSineCheckbox.checked
}

onReset: {
ParserSettingsModel.restoreDefaultSettings();
Expand Down
9 changes: 9 additions & 0 deletions qml/Translations.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ QtObject {
property string id_file_menu_item: qsTrId("id_file_menu_item") + TranslationManager.translationChanged
property string id_open_wav_file_menu_item: qsTrId("id_open_wav_file_menu_item") + TranslationManager.translationChanged
property string id_open_waveform_file_menu_item: qsTrId("id_open_waveform_file_menu_item") + TranslationManager.translationChanged
property string id_open_tap_file_menu_item: qsTrId("id_open_tap_file_menu_item") + TranslationManager.translationChanged
property string id_save_menu_item: qsTrId("id_save_menu_item") + TranslationManager.translationChanged
property string id_save_parsed_menu_item: qsTrId("id_save_parsed_menu_item") + TranslationManager.translationChanged
property string id_left_channel_menu_item: qsTrId("id_left_channel_menu_item") + TranslationManager.translationChanged
Expand Down Expand Up @@ -58,6 +59,7 @@ QtObject {
property string id_check_for_abnormal_sine_when_parsing: qsTrId("id_check_for_abnormal_sine_when_parsing") + TranslationManager.translationChanged
property string id_please_choose_wav_file: qsTrId("id_please_choose_wav_file") + TranslationManager.translationChanged
property string id_please_choose_wfm_file: qsTrId("id_please_choose_wfm_file") + TranslationManager.translationChanged
property string id_please_choose_tap_file: qsTrId("id_please_choose_tap_file") + TranslationManager.translationChanged
property string id_wav_files: qsTrId("id_wav_files").arg(filename_wildcard + wav_file_suffix) + TranslationManager.translationChanged
property string id_wfm_files: qsTrId("id_wfm_files").arg(filename_wildcard + wfm_file_suffix) + TranslationManager.translationChanged
property string id_tap_files: qsTrId("id_tap_files").arg(filename_wildcard + tap_file_suffix) + TranslationManager.translationChanged
Expand Down Expand Up @@ -94,4 +96,11 @@ QtObject {
property string id_suspicious_point_number: qsTrId("id_suspicious_point_number") + TranslationManager.translationChanged
property string id_suspicious_point_position: qsTrId("id_suspicious_point_position") + TranslationManager.translationChanged
property string id_language_menu_item: qsTrId("id_language_menu_item") + TranslationManager.translationChanged
property string id_hotkey_tooltip: qsTrId("id_hotkey_tooltip") + TranslationManager.translationChanged
property string id_remove_action: qsTrId("id_remove_action") + TranslationManager.translationChanged //Button caption
property string id_action_name: qsTrId("id_action_name") + TranslationManager.translationChanged
property string id_sine_check_tolerance: qsTrId("id_sine_check_tolerance") + TranslationManager.translationChanged
property string id_play_parsed_data: qsTrId("id_play_parsed_data") + TranslationManager.translationChanged
property string id_stop_playing_parsed_data: qsTrId("id_stop_playing_parsed_data") + TranslationManager.translationChanged
property string id_playing_parsed_data_window_header: qsTrId("id_playing_parsed_data_window_header") + TranslationManager.translationChanged
}
Loading

0 comments on commit 8fa72bd

Please sign in to comment.