Skip to content

Commit

Permalink
[更新音视频播放器均衡器设置和资源文件]
Browse files Browse the repository at this point in the history
- 更新了`action.yml`文件,将Qt版本从`6.7.0`更改为`6.7.1`,以适应新的Qt版本需求。
- 调整了`cmake/qt.cmake`文件,更新了Windows和Linux系统下Qt的路径,使其与新版本匹配。
- 新增了`equalizerdialog.cpp`和`equalizerdialog.h`文件,为播放器增加了图形界面均衡器设置功能。
- 删除了`colorspacedialog`相关的文件,因为它们已被新的均衡器设置所取代。
- 更新了`CMakeLists.txt`和`.pro`文件,添加了新的均衡器源文件,并移除了旧的色彩空间设置文件。
- 在`ffmpegplayer`和`mpvplayer`的源文件中,增加了对均衡器的支持,并更新了相关的函数和信号。
- 新增了`mediainfo`子模块,并创建了`equalizer.cpp`和`equalizer.h`文件,为均衡器设置提供了数据结构和操作接口。
- 更新了`videorender`模块,增加了对均衡器效果的处理。
- 调整了`mpvplayer`模块,增加了对mpv播放器均衡器设置的支持。
- 新增了`utils`模块中的`range.hpp`文件,为均衡器范围提供了数据结构支持。
  • Loading branch information
RealChuan committed Jun 13, 2024
1 parent 26327f2 commit 3ea6115
Show file tree
Hide file tree
Showing 40 changed files with 801 additions and 447 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
qt_ver:
description: 'qt version'
required: false
default: '6.7.0'
default: '6.7.1'
type: string

runs:
Expand Down
4 changes: 2 additions & 2 deletions cmake/qt.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if(CMAKE_HOST_WIN32)
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.7.0\\msvc2019_64")
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.7.1\\msvc2019_64")
elseif(CMAKE_HOST_APPLE)

elseif(CMAKE_HOST_LINUX)
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.7.0/gcc_64")
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.7.1/gcc_64")
endif()
4 changes: 4 additions & 0 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ defineReplace(replaceLibName) {
isEmpty(RET):RET = $$LIBRARY_NAME
return($$RET)
}

HEADERS +=

SOURCES +=
249 changes: 249 additions & 0 deletions examples/common/equalizerdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
#include "equalizerdialog.h"

#include <examples/common/slider.h>

#include <QtWidgets>

void setBlockValue(QSpinBox *spinBox, int value)
{
spinBox->blockSignals(true);
spinBox->setValue(value);
spinBox->blockSignals(false);
}

void setBlockValue(QSlider *slider, int value)
{
slider->blockSignals(true);
slider->setValue(value);
slider->blockSignals(false);
}

void init(QSlider *slider, QSpinBox *spinBox, const Media::Equalizer::EqualizerRange &equalizerRange)
{
slider->setRange(equalizerRange.min(), equalizerRange.max());
slider->setValue(equalizerRange.value());

spinBox->setKeyboardTracking(false);
spinBox->setRange(slider->minimum(), slider->maximum());
spinBox->setValue(slider->value());
}

class EqualizerDialog::EqualizerDialogPrivate
{
public:
explicit EqualizerDialogPrivate(EqualizerDialog *q)
: q_ptr(q)
{
Media::Equalizer equalizer;

contrastSlider = new Slider(q_ptr);
contrastSpinBox = new QSpinBox(q_ptr);
init(contrastSlider, contrastSpinBox, equalizer.contrastRange());

saturationSlider = new Slider(q_ptr);
saturationSpinBox = new QSpinBox(q_ptr);
init(saturationSlider, saturationSpinBox, equalizer.saturationRange());

brightnessSlider = new Slider(q_ptr);
brightnessSpinBox = new QSpinBox(q_ptr);
init(brightnessSlider, brightnessSpinBox, equalizer.brightnessRange());

gammaSlider = new Slider(q_ptr);
gammaSpinBox = new QSpinBox(q_ptr);
init(gammaSlider, gammaSpinBox, equalizer.gammaRange());

hueSlider = new Slider(q_ptr);
hueSpinBox = new QSpinBox(q_ptr);
init(hueSlider, hueSpinBox, equalizer.hueRange());

resetButton = new QToolButton(q_ptr);
resetButton->setText("Reset");
}

void setupUI() const
{
auto *layout = new QGridLayout(q_ptr);
layout->addWidget(new QLabel(QObject::tr("Contrast:"), q_ptr), 0, 0);
layout->addWidget(contrastSlider, 0, 1);
layout->addWidget(contrastSpinBox, 0, 2);
layout->addWidget(new QLabel(QObject::tr("Saturation:"), q_ptr), 1, 0);
layout->addWidget(saturationSlider, 1, 1);
layout->addWidget(saturationSpinBox, 1, 2);
layout->addWidget(new QLabel(QObject::tr("Brightness:"), q_ptr), 2, 0);
layout->addWidget(brightnessSlider, 2, 1);
layout->addWidget(brightnessSpinBox, 2, 2);
layout->addWidget(new QLabel(QObject::tr("Gamma:"), q_ptr), 3, 0);
layout->addWidget(gammaSlider, 3, 1);
layout->addWidget(gammaSpinBox, 3, 2);
layout->addWidget(new QLabel(QObject::tr("Hue:"), q_ptr), 4, 0);
layout->addWidget(hueSlider, 4, 1);
layout->addWidget(hueSpinBox, 4, 2);
layout->addWidget(resetButton, 5, 2, Qt::AlignRight);
}

EqualizerDialog *q_ptr;

Slider *contrastSlider;
QSpinBox *contrastSpinBox;

Slider *saturationSlider;
QSpinBox *saturationSpinBox;

Slider *brightnessSlider;
QSpinBox *brightnessSpinBox;

Slider *gammaSlider;
QSpinBox *gammaSpinBox;

Slider *hueSlider;
QSpinBox *hueSpinBox;

QToolButton *resetButton;
};

EqualizerDialog::EqualizerDialog(QWidget *parent)
: QDialog(parent)
, d_ptr(new EqualizerDialogPrivate(this))
{
d_ptr->setupUI();
buildConnect();
resize(400, 250);
}

EqualizerDialog::~EqualizerDialog() = default;

void EqualizerDialog::setEqualizer(const Media::Equalizer &equalizer)
{
setBlockValue(d_ptr->contrastSlider, equalizer.contrastRange().value());
setBlockValue(d_ptr->contrastSpinBox, equalizer.contrastRange().value());

setBlockValue(d_ptr->saturationSlider, equalizer.saturationRange().value());
setBlockValue(d_ptr->saturationSpinBox, equalizer.saturationRange().value());

setBlockValue(d_ptr->brightnessSlider, equalizer.brightnessRange().value());
setBlockValue(d_ptr->brightnessSpinBox, equalizer.brightnessRange().value());

setBlockValue(d_ptr->gammaSlider, equalizer.gammaRange().value());
setBlockValue(d_ptr->gammaSpinBox, equalizer.gammaRange().value());

setBlockValue(d_ptr->hueSlider, equalizer.hueRange().value());
setBlockValue(d_ptr->hueSpinBox, equalizer.hueRange().value());
}

Media::Equalizer EqualizerDialog::equalizer() const
{
Media::Equalizer equalizer;
equalizer.contrastRange().setValue(d_ptr->contrastSlider->value());
equalizer.saturationRange().setValue(d_ptr->saturationSlider->value());
equalizer.brightnessRange().setValue(d_ptr->brightnessSlider->value());
equalizer.gammaRange().setValue(d_ptr->gammaSlider->value());
equalizer.hueRange().setValue(d_ptr->hueSlider->value());
return equalizer;
}

void EqualizerDialog::onContrastSliderChanged(int value)
{
setBlockValue(d_ptr->contrastSpinBox, value);
emit equalizerChanged();
}

void EqualizerDialog::onSaturationSliderChanged(int value)
{
setBlockValue(d_ptr->saturationSpinBox, value);
emit equalizerChanged();
}

void EqualizerDialog::onBrightnessSliderChanged(int value)
{
setBlockValue(d_ptr->brightnessSpinBox, value);
emit equalizerChanged();
}

void EqualizerDialog::onContrastSpinBoxChanged(int value)
{
setBlockValue(d_ptr->contrastSlider, value);
emit equalizerChanged();
}

void EqualizerDialog::onSaturationSpinBoxChanged(int value)
{
setBlockValue(d_ptr->saturationSlider, value);
emit equalizerChanged();
}

void EqualizerDialog::onBrightnessSpinBoxChanged(int value)
{
setBlockValue(d_ptr->brightnessSlider, value);
emit equalizerChanged();
}

void EqualizerDialog::onGammaSliderChanged(int value)
{
setBlockValue(d_ptr->gammaSpinBox, value);
emit equalizerChanged();
}

void EqualizerDialog::onGammaSpinBoxChanged(int value)
{
setBlockValue(d_ptr->gammaSlider, value);
emit equalizerChanged();
}

void EqualizerDialog::onHueSliderChanged(int value)
{
setBlockValue(d_ptr->hueSpinBox, value);
emit equalizerChanged();
}

void EqualizerDialog::onHueSpinBoxChanged(int value)
{
setBlockValue(d_ptr->hueSlider, value);
emit equalizerChanged();
}

void EqualizerDialog::onReset()
{
setEqualizer({});
emit equalizerChanged();
}

void EqualizerDialog::buildConnect()
{
connect(d_ptr->contrastSlider,
&Slider::valueChanged,
this,
&EqualizerDialog::onContrastSliderChanged);
connect(d_ptr->contrastSpinBox,
&QSpinBox::valueChanged,
this,
&EqualizerDialog::onContrastSpinBoxChanged);

connect(d_ptr->saturationSlider,
&Slider::valueChanged,
this,
&EqualizerDialog::onSaturationSliderChanged);
connect(d_ptr->saturationSpinBox,
&QSpinBox::valueChanged,
this,
&EqualizerDialog::onSaturationSpinBoxChanged);

connect(d_ptr->brightnessSlider,
&Slider::valueChanged,
this,
&EqualizerDialog::onBrightnessSliderChanged);
connect(d_ptr->brightnessSpinBox,
&QSpinBox::valueChanged,
this,
&EqualizerDialog::onBrightnessSpinBoxChanged);

connect(d_ptr->gammaSlider, &Slider::valueChanged, this, &EqualizerDialog::onGammaSliderChanged);
connect(d_ptr->gammaSpinBox,
&QSpinBox::valueChanged,
this,
&EqualizerDialog::onGammaSpinBoxChanged);

connect(d_ptr->hueSlider, &Slider::valueChanged, this, &EqualizerDialog::onHueSliderChanged);
connect(d_ptr->hueSpinBox, &QSpinBox::valueChanged, this, &EqualizerDialog::onHueSpinBoxChanged);

connect(d_ptr->resetButton, &QToolButton::clicked, this, &EqualizerDialog::onReset);
}
46 changes: 46 additions & 0 deletions examples/common/equalizerdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef EQUALIZERDIALOG_H
#define EQUALIZERDIALOG_H

#include <mediainfo/equalizer.h>

#include <QDialog>

class EqualizerDialog : public QDialog
{
Q_OBJECT
public:
explicit EqualizerDialog(QWidget *parent = nullptr);
~EqualizerDialog() override;

void setEqualizer(const Media::Equalizer &equalizer);
[[nodiscard]] auto equalizer() const -> Media::Equalizer;

signals:
void equalizerChanged();

private slots:
void onContrastSliderChanged(int value);
void onContrastSpinBoxChanged(int value);

void onSaturationSliderChanged(int value);
void onSaturationSpinBoxChanged(int value);

void onBrightnessSliderChanged(int value);
void onBrightnessSpinBoxChanged(int value);

void onGammaSliderChanged(int value);
void onGammaSpinBoxChanged(int value);

void onHueSliderChanged(int value);
void onHueSpinBoxChanged(int value);

void onReset();

private:
void buildConnect();

class EqualizerDialogPrivate;
QScopedPointer<EqualizerDialogPrivate> d_ptr;
};

#endif // EQUALIZERDIALOG_H
13 changes: 13 additions & 0 deletions examples/common/playlistview.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#include "playlistview.hpp"

#include <QFileInfo>
#include <QUrl>

auto isPlaylist(const QUrl &url) -> bool // Check for ".m3u" playlists.
{
if (!url.isLocalFile()) {
return false;
}
const QFileInfo fileInfo(url.toLocalFile());
return fileInfo.exists()
&& (fileInfo.suffix().compare(QLatin1String("m3u"), Qt::CaseInsensitive) == 0);
}

PlayListView::PlayListView(QWidget *parent)
: QListView(parent)
{
Expand Down
2 changes: 2 additions & 0 deletions examples/common/playlistview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <QListView>

auto isPlaylist(const QUrl &url) -> bool;

class PlayListView : public QListView
{
public:
Expand Down
5 changes: 3 additions & 2 deletions examples/ffmpegplayer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(PROJECT_SOURCES
../common/controlwidget.cc
../common/controlwidget.hpp
../common/equalizerdialog.cpp
../common/equalizerdialog.h
../common/openwebmediadialog.cc
../common/openwebmediadialog.hpp
../common/playlistmodel.cpp
Expand All @@ -16,8 +18,6 @@ set(PROJECT_SOURCES
../common/slider.h
../common/titlewidget.cc
../common/titlewidget.hpp
colorspacedialog.cc
colorspacedialog.hpp
main.cpp
mainwindow.cpp
mainwindow.h)
Expand All @@ -26,6 +26,7 @@ qt_add_executable(FfmpegPlayer MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_link_libraries(
FfmpegPlayer
PRIVATE ffmpeg
mediainfo
thirdparty
dump
utils
Expand Down
Loading

0 comments on commit 3ea6115

Please sign in to comment.