Add signals and slots. Add emit values changes in QRangeSlider. Update preview dialog.
This commit is contained in:
parent
5d670d62b1
commit
3e9206be2f
@ -9,12 +9,16 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>782</width>
|
<width>779</width>
|
||||||
<height>356</height>
|
<height>356</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>MagicPodcast - preview podcast</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../../resources.qrc">
|
||||||
|
<normaloff>:/icons/src/gui/images/icons/preview.png</normaloff>:/icons/src/gui/images/icons/preview.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
@ -37,7 +41,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="left_range"/>
|
<widget class="QLineEdit" name="left_range">
|
||||||
|
<property name="inputMethodHints">
|
||||||
|
<set>Qt::ImhPreferNumbers|Qt::ImhTime</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="right_label">
|
<widget class="QLabel" name="right_label">
|
||||||
@ -47,12 +55,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="right_range"/>
|
<widget class="QLineEdit" name="right_range">
|
||||||
|
<property name="inputMethodHints">
|
||||||
|
<set>Qt::ImhPreferNumbers|Qt::ImhTime</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="create_preview_button">
|
<widget class="QPushButton" name="create_preview_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>utwórz podgląd</string>
|
<string>Utwórz podgląd</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -70,14 +82,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="play_button">
|
<widget class="QPushButton" name="play_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>start</string>
|
<string>Start</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="stop_button">
|
<widget class="QPushButton" name="stop_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>stop</string>
|
<string>Stop</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -85,6 +97,8 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../../resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
from pydub.utils import mediainfo
|
from pydub.utils import mediainfo
|
||||||
|
|
||||||
# import resources_rc
|
# import resources_rc
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QPixmap
|
from PyQt5.QtGui import QPixmap
|
||||||
from PyQt5.QtWidgets import QMainWindow, QLabel, QFileDialog, QDialog, QDialogButtonBox, QVBoxLayout, QApplication
|
from PyQt5.QtWidgets import QMainWindow, QLabel, QFileDialog, QDialog, QDialogButtonBox, QVBoxLayout, QApplication
|
||||||
|
|
||||||
@ -24,11 +24,8 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
MainWindow Class
|
MainWindow Class
|
||||||
"""
|
"""
|
||||||
signal = pyqtSignal()
|
|
||||||
slot = pyqtSlot()
|
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|
||||||
super(MainWindow, self).__init__(parent=parent)
|
super(MainWindow, self).__init__(parent=parent)
|
||||||
self.connected_channels_status = False
|
self.connected_channels_status = False
|
||||||
self.translator = Translator()
|
self.translator = Translator()
|
||||||
@ -40,12 +37,18 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
|||||||
self.setup_detail()
|
self.setup_detail()
|
||||||
self.retranslateUi(self.window())
|
self.retranslateUi(self.window())
|
||||||
self.aresample = "8000"
|
self.aresample = "8000"
|
||||||
# self.test_data()
|
|
||||||
self.dialog = self.create_custom_dialog(title='Process generowania podcastu', msg='Sprawdzanie poprawności danych')
|
|
||||||
self.image_extensions = ['.jpg', '.png']
|
self.image_extensions = ['.jpg', '.png']
|
||||||
self.audio_extensions = ['.mp3', '.wav']
|
self.audio_extensions = ['.mp3', '.wav']
|
||||||
|
|
||||||
self.progress_bar.setValue(0)
|
self.progress_bar.setValue(0)
|
||||||
|
|
||||||
|
self.dialog = self.create_custom_dialog(
|
||||||
|
title='Process generowania podcastu',
|
||||||
|
msg='Sprawdzanie poprawności danych'
|
||||||
|
)
|
||||||
|
self.test_data()
|
||||||
|
|
||||||
def setup_logic(self):
|
def setup_logic(self):
|
||||||
"""Connect ui elements with methods."""
|
"""Connect ui elements with methods."""
|
||||||
self.action_settings.triggered.connect(self.open_setting_dialog)
|
self.action_settings.triggered.connect(self.open_setting_dialog)
|
||||||
@ -60,6 +63,7 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
|||||||
self.check_box_connected_channels.setChecked(True)
|
self.check_box_connected_channels.setChecked(True)
|
||||||
self.connected_channels_status = self.check_box_connected_channels.checkState()
|
self.connected_channels_status = self.check_box_connected_channels.checkState()
|
||||||
self.check_box_connected_channels.stateChanged.connect(self.channels_connected)
|
self.check_box_connected_channels.stateChanged.connect(self.channels_connected)
|
||||||
|
self.threshold_slider.valueChanged.connect(self.update_lcd_threshold)
|
||||||
|
|
||||||
def on_progress_change(self, value):
|
def on_progress_change(self, value):
|
||||||
"""Update progress bar value"""
|
"""Update progress bar value"""
|
||||||
@ -101,8 +105,6 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
|||||||
self.preview_label_avatar_4.setPixmap(scaled_pixmap4)
|
self.preview_label_avatar_4.setPixmap(scaled_pixmap4)
|
||||||
self.preview_label_avatar_4.setProperty('path', './src/gui/images/right.png')
|
self.preview_label_avatar_4.setProperty('path', './src/gui/images/right.png')
|
||||||
|
|
||||||
self.threshold_slider.valueChanged.connect(self.update_lcd_threshold)
|
|
||||||
|
|
||||||
def update_lcd_threshold(self, event):
|
def update_lcd_threshold(self, event):
|
||||||
"""Set threshold value from slider to lcd."""
|
"""Set threshold value from slider to lcd."""
|
||||||
self.threshold_lcd.display(event)
|
self.threshold_lcd.display(event)
|
||||||
@ -245,6 +247,13 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
|||||||
|
|
||||||
if not all(self.check_file(x, self.audio_extensions) for x in audio_files):
|
if not all(self.check_file(x, self.audio_extensions) for x in audio_files):
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
self.line_edit_audio_1.setProperty(
|
||||||
|
'duration', mediainfo(self.line_edit_audio_1.text())['duration'])
|
||||||
|
|
||||||
|
self.line_edit_audio_2.setProperty(
|
||||||
|
'duration', mediainfo(self.line_edit_audio_2.text())['duration'])
|
||||||
|
|
||||||
audio_1 = float(self.line_edit_audio_1.property('duration'))
|
audio_1 = float(self.line_edit_audio_1.property('duration'))
|
||||||
print(audio_1)
|
print(audio_1)
|
||||||
audio_2 = float(self.line_edit_audio_2.property('duration'))
|
audio_2 = float(self.line_edit_audio_2.property('duration'))
|
||||||
@ -259,6 +268,9 @@ class MainWindow(QMainWindow, QApplication, Ui_MainWindow):
|
|||||||
if not all(self.check_file(x, self.audio_extensions) for x in audio_files):
|
if not all(self.check_file(x, self.audio_extensions) for x in audio_files):
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
self.line_edit_audio_1.setProperty(
|
||||||
|
'duration', mediainfo(self.line_edit_audio_1.text())['duration'])
|
||||||
|
|
||||||
end_time = float(self.line_edit_audio_1.property('duration'))
|
end_time = float(self.line_edit_audio_1.property('duration'))
|
||||||
print(f"[*] File duration audio_2: {end_time}")
|
print(f"[*] File duration audio_2: {end_time}")
|
||||||
preview_dialog = PreviewDialog(parent=self, start_time=0, end_time=end_time)
|
preview_dialog = PreviewDialog(parent=self, start_time=0, end_time=end_time)
|
||||||
|
@ -13,10 +13,11 @@ class PreviewDialog(QDialog, Ui_PreviewDialog):
|
|||||||
"""
|
"""
|
||||||
Dialog to show preview of podcast.
|
Dialog to show preview of podcast.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, parent=None, start_time=0, end_time=15):
|
def __init__(self, parent=None, start_time=0, end_time=15):
|
||||||
super(PreviewDialog, self).__init__(parent=parent)
|
super(PreviewDialog, self).__init__(parent=parent)
|
||||||
self.setupUi(self)
|
|
||||||
|
|
||||||
|
self.setupUi(self)
|
||||||
self.mediaPlayer = QMediaPlayer(parent=self, flags=QMediaPlayer.VideoSurface)
|
self.mediaPlayer = QMediaPlayer(parent=self, flags=QMediaPlayer.VideoSurface)
|
||||||
|
|
||||||
self.video_widget = QVideoWidget()
|
self.video_widget = QVideoWidget()
|
||||||
@ -24,8 +25,21 @@ class PreviewDialog(QDialog, Ui_PreviewDialog):
|
|||||||
self.v_layout_1.addWidget(self.video_widget)
|
self.v_layout_1.addWidget(self.video_widget)
|
||||||
self.v_layout_1.addWidget(self.range_slider)
|
self.v_layout_1.addWidget(self.range_slider)
|
||||||
|
|
||||||
|
self.range_slider.setRangeLimit(minimum=int(start_time), maximum=int(end_time))
|
||||||
self.range_slider.setRange(start=int(start_time), end=int(end_time))
|
self.range_slider.setRange(start=int(start_time), end=int(end_time))
|
||||||
|
|
||||||
|
self.range_slider.c.range_changed.connect(self.update_line_edit_values)
|
||||||
|
|
||||||
|
self.left_range.setText(str(self.range_slider.first_position))
|
||||||
|
self.right_range.setText(str(self.range_slider.second_position))
|
||||||
|
|
||||||
|
def update_line_edit_values(self, x, y):
|
||||||
|
"""Update values."""
|
||||||
|
if x == 1:
|
||||||
|
self.left_range.setText(str(y))
|
||||||
|
elif x == 2:
|
||||||
|
self.right_range.setText(str(y))
|
||||||
|
|
||||||
def get_audio_files(self):
|
def get_audio_files(self):
|
||||||
"""Load time of audio files"""
|
"""Load time of audio files"""
|
||||||
audio_files = []
|
audio_files = []
|
||||||
@ -56,7 +70,6 @@ class PreviewDialog(QDialog, Ui_PreviewDialog):
|
|||||||
|
|
||||||
def media_state_changed(self, state):
|
def media_state_changed(self, state):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param state:
|
:param state:
|
||||||
"""
|
"""
|
||||||
if self.mediaPlayer.state() == QMediaPlayer.PlayingState:
|
if self.mediaPlayer.state() == QMediaPlayer.PlayingState:
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
from PyQt5.QtCore import Qt, QRect, QSize
|
from PyQt5.QtCore import Qt, QRect, QSize, pyqtSignal, QObject
|
||||||
from PyQt5.QtGui import QPaintEvent, QPainter, QPalette, QBrush, QMouseEvent
|
from PyQt5.QtGui import QPaintEvent, QPainter, QPalette, QBrush, QMouseEvent
|
||||||
from PyQt5.QtWidgets import QApplication, QAbstractSlider, QSizePolicy, QSlider, QStyle, QStyleOptionSlider
|
from PyQt5.QtWidgets import QApplication, QAbstractSlider, QSizePolicy, QSlider, QStyle, QStyleOptionSlider
|
||||||
|
|
||||||
|
|
||||||
|
class Communicate(QObject):
|
||||||
|
range_changed = pyqtSignal(int, int)
|
||||||
|
|
||||||
|
|
||||||
class QRangeSlider(QAbstractSlider):
|
class QRangeSlider(QAbstractSlider):
|
||||||
"""
|
"""
|
||||||
QRangeSlider
|
QRangeSlider
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.c = Communicate()
|
||||||
self.first_position = 1
|
self.first_position = 1
|
||||||
self.second_position = 8
|
self.second_position = 8
|
||||||
|
|
||||||
@ -23,6 +29,10 @@ class QRangeSlider(QAbstractSlider):
|
|||||||
self.setSizePolicy(
|
self.setSizePolicy(
|
||||||
QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed, QSizePolicy.Slider)
|
QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed, QSizePolicy.Slider)
|
||||||
)
|
)
|
||||||
|
self.c.range_changed.connect(self.handle_emit)
|
||||||
|
|
||||||
|
def handle_emit(self, x, y):
|
||||||
|
print(x, y)
|
||||||
|
|
||||||
def setRangeLimit(self, minimum: int, maximum: int):
|
def setRangeLimit(self, minimum: int, maximum: int):
|
||||||
"""Set new range limit."""
|
"""Set new range limit."""
|
||||||
@ -126,13 +136,16 @@ class QRangeSlider(QAbstractSlider):
|
|||||||
if self._first_sc == QStyle.SC_SliderHandle:
|
if self._first_sc == QStyle.SC_SliderHandle:
|
||||||
if pos <= self.second_position:
|
if pos <= self.second_position:
|
||||||
self.first_position = pos
|
self.first_position = pos
|
||||||
|
self.c.range_changed.emit(1, pos)
|
||||||
self.update()
|
self.update()
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._second_sc == QStyle.SC_SliderHandle:
|
if self._second_sc == QStyle.SC_SliderHandle:
|
||||||
if pos >= self.first_position:
|
if pos >= self.first_position:
|
||||||
self.second_position = pos
|
self.second_position = pos
|
||||||
|
self.c.range_changed.emit(2, pos)
|
||||||
self.update()
|
self.update()
|
||||||
|
return
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
""" Override sizeHint """
|
""" Override sizeHint """
|
||||||
|
@ -15,7 +15,10 @@ class Ui_PreviewDialog(object):
|
|||||||
def setupUi(self, PreviewDialog):
|
def setupUi(self, PreviewDialog):
|
||||||
PreviewDialog.setObjectName("PreviewDialog")
|
PreviewDialog.setObjectName("PreviewDialog")
|
||||||
PreviewDialog.setWindowModality(QtCore.Qt.NonModal)
|
PreviewDialog.setWindowModality(QtCore.Qt.NonModal)
|
||||||
PreviewDialog.resize(782, 356)
|
PreviewDialog.resize(779, 356)
|
||||||
|
icon = QtGui.QIcon()
|
||||||
|
icon.addPixmap(QtGui.QPixmap(":/icons/src/gui/images/icons/preview.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
PreviewDialog.setWindowIcon(icon)
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout(PreviewDialog)
|
self.verticalLayout = QtWidgets.QVBoxLayout(PreviewDialog)
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.v_layout_1 = QtWidgets.QVBoxLayout()
|
self.v_layout_1 = QtWidgets.QVBoxLayout()
|
||||||
@ -32,12 +35,14 @@ class Ui_PreviewDialog(object):
|
|||||||
self.left_label.setObjectName("left_label")
|
self.left_label.setObjectName("left_label")
|
||||||
self.h_layout_range_values.addWidget(self.left_label)
|
self.h_layout_range_values.addWidget(self.left_label)
|
||||||
self.left_range = QtWidgets.QLineEdit(PreviewDialog)
|
self.left_range = QtWidgets.QLineEdit(PreviewDialog)
|
||||||
|
self.left_range.setInputMethodHints(QtCore.Qt.ImhPreferNumbers|QtCore.Qt.ImhTime)
|
||||||
self.left_range.setObjectName("left_range")
|
self.left_range.setObjectName("left_range")
|
||||||
self.h_layout_range_values.addWidget(self.left_range)
|
self.h_layout_range_values.addWidget(self.left_range)
|
||||||
self.right_label = QtWidgets.QLabel(PreviewDialog)
|
self.right_label = QtWidgets.QLabel(PreviewDialog)
|
||||||
self.right_label.setObjectName("right_label")
|
self.right_label.setObjectName("right_label")
|
||||||
self.h_layout_range_values.addWidget(self.right_label)
|
self.h_layout_range_values.addWidget(self.right_label)
|
||||||
self.right_range = QtWidgets.QLineEdit(PreviewDialog)
|
self.right_range = QtWidgets.QLineEdit(PreviewDialog)
|
||||||
|
self.right_range.setInputMethodHints(QtCore.Qt.ImhPreferNumbers|QtCore.Qt.ImhTime)
|
||||||
self.right_range.setObjectName("right_range")
|
self.right_range.setObjectName("right_range")
|
||||||
self.h_layout_range_values.addWidget(self.right_range)
|
self.h_layout_range_values.addWidget(self.right_range)
|
||||||
self.create_preview_button = QtWidgets.QPushButton(PreviewDialog)
|
self.create_preview_button = QtWidgets.QPushButton(PreviewDialog)
|
||||||
@ -64,12 +69,13 @@ class Ui_PreviewDialog(object):
|
|||||||
|
|
||||||
def retranslateUi(self, PreviewDialog):
|
def retranslateUi(self, PreviewDialog):
|
||||||
_translate = QtCore.QCoreApplication.translate
|
_translate = QtCore.QCoreApplication.translate
|
||||||
PreviewDialog.setWindowTitle(_translate("PreviewDialog", "Dialog"))
|
PreviewDialog.setWindowTitle(_translate("PreviewDialog", "MagicPodcast - preview podcast"))
|
||||||
self.left_label.setText(_translate("PreviewDialog", "Czas rozpoczęcia:"))
|
self.left_label.setText(_translate("PreviewDialog", "Czas rozpoczęcia:"))
|
||||||
self.right_label.setText(_translate("PreviewDialog", "Czas zakończenia:"))
|
self.right_label.setText(_translate("PreviewDialog", "Czas zakończenia:"))
|
||||||
self.create_preview_button.setText(_translate("PreviewDialog", "utwórz podgląd"))
|
self.create_preview_button.setText(_translate("PreviewDialog", "Utwórz podgląd"))
|
||||||
self.play_button.setText(_translate("PreviewDialog", "start"))
|
self.play_button.setText(_translate("PreviewDialog", "Start"))
|
||||||
self.stop_button.setText(_translate("PreviewDialog", "stop"))
|
self.stop_button.setText(_translate("PreviewDialog", "Stop"))
|
||||||
|
import resources_rc
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user