save and restore window width+height
This commit is contained in:
parent
5875776442
commit
dfb17a7459
@ -1,17 +1,15 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import math
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
from numpy.lib import math
|
|
||||||
from utils import FFTAnalyser
|
from utils import FFTAnalyser
|
||||||
|
|
||||||
|
|
||||||
class AudioVisualizer(QtWidgets.QWidget):
|
class AudioVisualizer(QtWidgets.QWidget):
|
||||||
"""Audio Visualizer component"""
|
"""Audio Visualizer component"""
|
||||||
|
|
||||||
def __init__(self, media_player, x_resolution):
|
def __init__(self, media_player):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.media_player = media_player
|
self.media_player = media_player
|
||||||
self.x_resolution = x_resolution
|
self.x_resolution = 100
|
||||||
self.fft_analyser = FFTAnalyser(self.media_player, self.x_resolution)
|
self.fft_analyser = FFTAnalyser(self.media_player, self.x_resolution)
|
||||||
self.fft_analyser.calculatedVisual.connect(self.set_amplitudes)
|
self.fft_analyser.calculatedVisual.connect(self.set_amplitudes)
|
||||||
self.fft_analyser.calculatedVisualRs.connect(self.set_rs)
|
self.fft_analyser.calculatedVisualRs.connect(self.set_rs)
|
||||||
@ -28,6 +26,10 @@ class AudioVisualizer(QtWidgets.QWidget):
|
|||||||
np.log10(self.min_freq), np.log10(self.max_freq), self.x_resolution
|
np.log10(self.min_freq), np.log10(self.max_freq), self.x_resolution
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_x_resolution(self):
|
||||||
|
"""Returns the resolution for the graphics plot"""
|
||||||
|
return self.x_resolution
|
||||||
|
|
||||||
def get_frequency_ticks(self):
|
def get_frequency_ticks(self):
|
||||||
"""Returns frequency ticks for x-axis display
|
"""Returns frequency ticks for x-axis display
|
||||||
|
|
||||||
|
|||||||
12
main.py
12
main.py
@ -162,10 +162,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.config.read(self.cfg_file)
|
self.config.read(self.cfg_file)
|
||||||
self.player: QMediaPlayer = QMediaPlayer() # Audio player object
|
self.player: QMediaPlayer = QMediaPlayer() # Audio player object
|
||||||
self.probe: QAudioProbe = QAudioProbe() # Gets audio data
|
self.probe: QAudioProbe = QAudioProbe() # Gets audio data
|
||||||
self.analyzer_x_resolution = 100
|
self.audio_visualizer: AudioVisualizer = AudioVisualizer(self.player)
|
||||||
self.audio_visualizer: AudioVisualizer = AudioVisualizer(
|
|
||||||
self.player, self.analyzer_x_resolution
|
|
||||||
)
|
|
||||||
self.timer = QTimer(self) # Audio timing things
|
self.timer = QTimer(self) # Audio timing things
|
||||||
self.clipboard = clipboard
|
self.clipboard = clipboard
|
||||||
self.tableView.load_qapp(self)
|
self.tableView.load_qapp(self)
|
||||||
@ -192,7 +189,9 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
# Adjust to leave room for playback controls
|
# Adjust to leave room for playback controls
|
||||||
self.PlotWidget.setFixedHeight(225)
|
self.PlotWidget.setFixedHeight(225)
|
||||||
# x range
|
# x range
|
||||||
self.PlotWidget.setXRange(0, self.analyzer_x_resolution, padding=0)
|
self.PlotWidget.setXRange(
|
||||||
|
0, self.audio_visualizer.get_x_resolution(), padding=0
|
||||||
|
)
|
||||||
# y axis range for decibals (-96db to 0db)
|
# y axis range for decibals (-96db to 0db)
|
||||||
self.PlotWidget.setYRange(-96, 0, padding=0)
|
self.PlotWidget.setYRange(-96, 0, padding=0)
|
||||||
# Logarithmic x-axis for frequency display
|
# Logarithmic x-axis for frequency display
|
||||||
@ -298,6 +297,9 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
column_widths_as_string = ",".join(list_of_column_widths)
|
column_widths_as_string = ",".join(list_of_column_widths)
|
||||||
self.config["table"]["column_widths"] = column_widths_as_string
|
self.config["table"]["column_widths"] = column_widths_as_string
|
||||||
self.config["settings"]["volume"] = str(self.current_volume)
|
self.config["settings"]["volume"] = str(self.current_volume)
|
||||||
|
self.config["settings"]["window_size"] = (
|
||||||
|
str(self.width()) + "," + str(self.height())
|
||||||
|
)
|
||||||
|
|
||||||
# Save the config
|
# Save the config
|
||||||
with open(self.cfg_file, "w") as configfile:
|
with open(self.cfg_file, "w") as configfile:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user