Skip to content

Commit

Permalink
[Update_Qt_Version_and_Introduce_Equalizer]: 更新Qt版本至6.7.1并引入均衡器功能
Browse files Browse the repository at this point in the history
- 更新`action.yml`文件,将Qt版本默认值设置为6.7.1
- 修改`cmake/qt.cmake`文件,更新Qt安装路径以匹配新版本
- 删除原有的`colorspacedialog`相关代码,并添加新的`equalizerdialog`模块
- 调整`CMakeLists.txt`和`.pro`文件,增加`mediaconfig`库的引用
- 重构`videorender`和`mpvplayer`模块,使用`Equalizer`代替旧的色彩空间调整功能
- 对`mpvplayer`模块进行了功能增强,增加了调整视频播放色彩效果的API
  • Loading branch information
RealChuan committed Jun 14, 2024
1 parent 26327f2 commit b4518fb
Show file tree
Hide file tree
Showing 42 changed files with 807 additions and 449 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 +=
251 changes: 251 additions & 0 deletions examples/common/equalizerdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
#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 MediaConfig::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)
{
MediaConfig::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 MediaConfig::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());
}

MediaConfig::Equalizer EqualizerDialog::equalizer() const
{
MediaConfig::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 <mediaconfig/equalizer.hpp>

#include <QDialog>

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

void setEqualizer(const MediaConfig::Equalizer &equalizer);
[[nodiscard]] auto equalizer() const -> MediaConfig::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
mediaconfig
thirdparty
dump
utils
Expand Down
Loading

0 comments on commit b4518fb

Please sign in to comment.