Skip to content

Commit

Permalink
replaygain2: provide browse button to set path to rsgain command
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Nov 9, 2022
1 parent d8ae8a0 commit ebd75b3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
11 changes: 10 additions & 1 deletion plugins/replaygain2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
This plugin is based on the original ReplayGain plugin by Philipp Wolfer and Sophist.
'''
PLUGIN_VERSION = "1.0"
PLUGIN_VERSION = "1.1"
PLUGIN_API_VERSIONS = ["2.0"]
PLUGIN_LICENSE = "GPL-2.0"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.html"
Expand All @@ -39,6 +39,8 @@
import shutil
import os

from PyQt5.QtWidgets import QFileDialog

from picard import log
from picard.formats.vorbis import OggOpusFile
from picard.album import Album
Expand Down Expand Up @@ -357,6 +359,7 @@ def __init__(self, parent=None):
N_("Write standard ReplayGain tags"),
N_("Write R128_*_GAIN tags")
])
self.ui.rsgain_command_browse.clicked.connect(self.rsgain_command_browse)

def load(self):
self.ui.rsgain_command.setText(self.config.setting["rsgain_command"])
Expand All @@ -380,6 +383,12 @@ def save(self):
self.config.setting["opus_mode"] = self.ui.opus_mode.currentIndex()
self.config.setting["opus_m23"] = self.ui.opus_m23.isChecked()

def rsgain_command_browse(self):
path, _filter = QFileDialog.getOpenFileName(self, "", self.ui.rsgain_command.text())
if path:
path = os.path.normpath(path)
self.ui.rsgain_command.setText(path)


register_track_action(ScanTracks())
register_album_action(ScanAlbums())
Expand Down
11 changes: 9 additions & 2 deletions plugins/replaygain2/ui_options_replaygain2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'ui_options_replaygain2.ui'
# Form implementation generated from reading ui file 'plugins/replaygain2/ui_options_replaygain2.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
Expand Down Expand Up @@ -37,9 +37,15 @@ def setupUi(self, ReplayGain2OptionsPage):
self.label.setFont(font)
self.label.setObjectName("label")
self.vboxlayout1.addWidget(self.label)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.rsgain_command = QtWidgets.QLineEdit(self.replay_gain)
self.rsgain_command.setObjectName("rsgain_command")
self.vboxlayout1.addWidget(self.rsgain_command)
self.horizontalLayout.addWidget(self.rsgain_command)
self.rsgain_command_browse = QtWidgets.QToolButton(self.replay_gain)
self.rsgain_command_browse.setObjectName("rsgain_command_browse")
self.horizontalLayout.addWidget(self.rsgain_command_browse)
self.vboxlayout1.addLayout(self.horizontalLayout)
self.label_6 = QtWidgets.QLabel(self.replay_gain)
self.label_6.setOpenExternalLinks(True)
self.label_6.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
Expand Down Expand Up @@ -143,6 +149,7 @@ def retranslateUi(self, ReplayGain2OptionsPage):
self.replay_gain.setTitle(_translate("ReplayGain2OptionsPage", "ReplayGain 2.0 Settings"))
self.label.setText(_translate("ReplayGain2OptionsPage", "Path to rsgain:"))
self.rsgain_command.setText(_translate("ReplayGain2OptionsPage", "rsgain"))
self.rsgain_command_browse.setText(_translate("ReplayGain2OptionsPage", "Browse..."))
self.label_6.setText(_translate("ReplayGain2OptionsPage", "<a href=\"https://github.com/complexlogic/rsgain\">Download rsgain</a>"))
self.album_tags.setText(_translate("ReplayGain2OptionsPage", "Calculate album gain/peak"))
self.true_peak.setWhatsThis(_translate("ReplayGain2OptionsPage", "Use more accurate true peak calculations (trade for performance)"))
Expand Down
21 changes: 16 additions & 5 deletions plugins/replaygain2/ui_options_replaygain2.ui
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,22 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="rsgain_command">
<property name="text">
<string>rsgain</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="rsgain_command">
<property name="text">
<string>rsgain</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="rsgain_command_browse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_6">
Expand Down

0 comments on commit ebd75b3

Please sign in to comment.