Better looking player audio + global layout
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ Data
|
||||
.ipynb_checkpoints
|
||||
*.ipynb
|
||||
wav_converter.py
|
||||
*.txt
|
||||
|
||||
@@ -12,7 +12,7 @@ class AudioPlayer(object):
|
||||
is managed internally.
|
||||
"""
|
||||
|
||||
__time_step = 1000 # Milliseconds.
|
||||
__time_step = 500 # Milliseconds.
|
||||
__delay_load_audio = 250 # Milliseconds
|
||||
|
||||
def __init__(self, play, pause, stop, volume, audio_progress):
|
||||
@@ -34,6 +34,7 @@ class AudioPlayer(object):
|
||||
|
||||
|
||||
def __set_volume(self):
|
||||
if mixer.get_init():
|
||||
mixer.music.set_volume(self.__volume.value() / self.__volume.maximum())
|
||||
|
||||
def __reset_audio_widget(self):
|
||||
@@ -60,7 +61,7 @@ class AudioPlayer(object):
|
||||
mixer.Sound(self.__audio_file).get_length() * 1000
|
||||
)
|
||||
|
||||
def set_audio_player(self, fname):
|
||||
def set_audio_player(self, fname = ""):
|
||||
if self.__load_timer.isActive():
|
||||
self.__load_timer.stop()
|
||||
self.fname = fname
|
||||
|
||||
32
main.py
32
main.py
@@ -3,7 +3,8 @@ import os
|
||||
from pandas import read_csv
|
||||
from PyQt5.QtWidgets import (QMainWindow,
|
||||
QApplication,
|
||||
QMessageBox,)
|
||||
QMessageBox,
|
||||
qApp,)
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5 import uic
|
||||
from PyQt5.QtCore import QFileInfo, QSize
|
||||
@@ -20,22 +21,24 @@ class MyApp(QMainWindow, Ui_MainWindow):
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
self.show()
|
||||
self.actionExit.triggered.connect(qApp.quit)
|
||||
self.db_version = None
|
||||
self.load_db()
|
||||
self.display_signals()
|
||||
self.search_bar.textChanged.connect(self.display_signals)
|
||||
self.result_list.itemSelectionChanged.connect(self.display_specs)
|
||||
self.result_list.currentItemChanged.connect(self.display_specs)
|
||||
self.play.setIcon(qta.icon('fa5.play-circle',
|
||||
color = "#999999",
|
||||
color_disabled = '#000000'))
|
||||
color = "#4facf1",
|
||||
color_disabled = '#7a7a7a'))
|
||||
self.play.setIconSize(self.play.size())
|
||||
self.pause.setIcon(qta.icon('fa5.pause-circle',
|
||||
color = "#999999",
|
||||
color_disabled = '#000000'))
|
||||
color = "#4facf1",
|
||||
color_disabled = '#7a7a7a'))
|
||||
self.pause.setIconSize(self.pause.size())
|
||||
self.stop.setIcon(qta.icon('fa5.stop-circle',
|
||||
color = "#999999",
|
||||
color_disabled = '#000000'))
|
||||
color = "#4facf1",
|
||||
color_disabled = '#7a7a7a'))
|
||||
self.stop.setIconSize(self.stop.size())
|
||||
self.audio_widget = AudioPlayer(self.play,
|
||||
self.pause,
|
||||
@@ -89,13 +92,22 @@ class MyApp(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def display_specs(self):
|
||||
self.display_spectrogram()
|
||||
self.audio_widget.set_audio_player(self.result_list.currentItem().text())
|
||||
item = self.result_list.currentItem()
|
||||
if item:
|
||||
self.audio_widget.set_audio_player(item.text())
|
||||
else:
|
||||
self.audio_widget.set_audio_player()
|
||||
|
||||
def display_spectrogram(self):
|
||||
spectrogram_name = self.result_list.currentItem().text()
|
||||
default_pic = os.path.join("icons_imgs", "image_not_found.png")
|
||||
item = self.result_list.currentItem()
|
||||
if item:
|
||||
spectrogram_name = item.text()
|
||||
path_spectr = os.path.join("Data", "Spectra", spectrogram_name + ".jpg")
|
||||
if not QFileInfo(path_spectr).exists():
|
||||
path_spectr = os.path.join("icons_imgs", "image_not_found.png")
|
||||
path_spectr = default_pic
|
||||
else:
|
||||
path_spectr = default_pic
|
||||
self.spectrogram.setPixmap(QPixmap(path_spectr))
|
||||
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ QProgressBar::chunk {
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #1d5eff, stop:0.5 #4177ff, stop:1 #1d5eff);
|
||||
border-radius: 3px;
|
||||
}
|
||||
/*
|
||||
|
||||
QAbstractScrollArea::corner {
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
||||
*/
|
||||
|
||||
QScrollBar:vertical, QScrollBar:horizontal{
|
||||
background-color:#343434;
|
||||
border-radius: 5px;
|
||||
@@ -111,15 +111,9 @@ QScrollBar::sub-page:horizontal{
|
||||
}</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -314,14 +308,55 @@ QTabBar::tab:!selected {
|
||||
<attribute name="title">
|
||||
<string>Main</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>110</y>
|
||||
<width>161</width>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Filters</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>153</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget {
|
||||
background-color:rgb(52,52,52);
|
||||
border: 1px solid gray;
|
||||
border-radius: 8px;
|
||||
}
|
||||
QProgressBar {
|
||||
border: 2px #7a7a7a;
|
||||
border-radius: 3px;
|
||||
background-color: #7a7a7a;
|
||||
}
|
||||
|
||||
QProgressBar::chunk {
|
||||
/*background-color: #1d5eff;*/
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #1d5eff, stop:0.5 #4177ff, stop:1 #1d5eff);
|
||||
border-radius: 3px;
|
||||
}
|
||||
QLabel, QPushButton, QSlider {
|
||||
border: 0px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
@@ -333,12 +368,17 @@ QTabBar::tab:!selected {
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton {
|
||||
<string notr="true">
|
||||
QWidget {
|
||||
border: 0px;
|
||||
}
|
||||
QPushButton {
|
||||
/*background-color: #1d5eff;*/
|
||||
border: 1px solid gray;
|
||||
border: 0px solid gray;
|
||||
border-color: #1d5eff;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
/*
|
||||
QPushButton:disabled {
|
||||
background-color: #7a7a7a;
|
||||
@@ -518,7 +558,7 @@ QSlider::handle:horizontal {
|
||||
<item>
|
||||
<widget class="QLabel" name="spectrogram">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -526,12 +566,18 @@ QSlider::handle:horizontal {
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>153</width>
|
||||
<height>100</height>
|
||||
<height>350</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Signal waterfall</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>icons_imgs/image_not_found.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -539,14 +585,6 @@ QSlider::handle:horizontal {
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Filters</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user