Skip to content

Commit

Permalink
[更新项目配置和依赖管理]: 对项目配置和依赖管理进行了优化和更新。
Browse files Browse the repository at this point in the history
- 更新了`action.yml`文件,将Qt版本从`6.7.2`更改为`6.8.0`。
- 简化了条件判断,使用`runner.os == 'OS'`代替`startsWith(runner.os, 'OS')`。
- 添加了`dependabot.yml`文件,配置了GitHub Dependabot以自动更新GitHub Actions。
- 更新了`qmake.yml`工作流,将Windows版本从`windows-2019`更改为`windows-latest`。
- 更新了`qt.cmake`文件,更改了Qt路径以匹配新的Qt版本。
- 重构了`playlistmodel.cpp`和`playlistmodel.h`,简化了代码并移除了不必要的连接。
- 删除了Vulkan着色器文件`video_vulkan.frag`和`video_vulkan.vert`。
- 更新了`3rdparty.pri`文件,更改了第三方库的名称。
- 更新了`averror.cpp`文件,使用了`av_make_error_string`函数来获取错误信息。
- 更新了`vcpkg.json`文件,更改了内置基线的提交哈希。
  • Loading branch information
RealChuan committed Oct 9, 2024
1 parent f6f9b28 commit 3579b85
Show file tree
Hide file tree
Showing 23 changed files with 300 additions and 364 deletions.
15 changes: 7 additions & 8 deletions .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.2'
default: '6.8.0'
type: string

runs:
Expand All @@ -42,7 +42,7 @@ runs:
rm vcpkg.json
- name: Cache windows vcpkg
if: startsWith(runner.os, 'Windows')
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: C:\vcpkg\installed
Expand All @@ -51,10 +51,9 @@ runs:
${{ inputs.os_name }}-vcpkg-installed-${{ runner.os_name }}-
${{ inputs.os_name }}-vcpkg-installed-
${{ inputs.os_name }}-
save-always: true
- name: Cache macos or linux vcpkg
if: startsWith(runner.os, 'macOS') || startsWith(runner.os, 'Linux')
if: runner.os == 'macOS' || runner.os == 'Linux'
uses: actions/cache@v4
with:
path: /usr/local/share/vcpkg/installed
Expand All @@ -63,10 +62,9 @@ runs:
${{ inputs.os_name }}-vcpkg-installed-${{ runner.os_name }}-
${{ inputs.os_name }}-vcpkg-installed-
${{ inputs.os_name }}-
save-always: true
- name: Install dependencies on windows
if: startsWith(runner.os, 'Windows')
if: runner.os == 'Windows'
shell: bash
run: |
choco install ninja
Expand All @@ -77,7 +75,7 @@ runs:
|| (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on macos
if: startsWith(runner.os, 'macOS')
if: runner.os == 'macOS'
shell: bash
run: |
brew install ninja nasm python-setuptools mpv
Expand All @@ -92,7 +90,7 @@ runs:
|| (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on linux
if: startsWith(runner.os, 'Linux')
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
Expand All @@ -112,3 +110,4 @@ runs:
version: ${{ inputs.qt_ver }}
modules: ${{ inputs.qt_modules }}
cache: 'true'

12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

4 changes: 2 additions & 2 deletions .github/workflows/qmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fail-fast: false
matrix:
os:
- windows-2019
- windows-latest
- macos-latest
- ubuntu-latest

Expand All @@ -55,7 +55,7 @@ jobs:
if: startsWith(matrix.os, 'windows')
shell: pwsh
run: |
..\scripts\windows\setVsDev.ps1 -VersionRange "[16.0,17.0)" -Arch "x64"
..\scripts\windows\setVsDev.ps1
& qmake ./../.
& jom
working-directory: build
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
matrix:
os:
- windows-latest
- windows-2019
- macos-latest
- ubuntu-latest

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.2\\msvc2019_64")
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.8.0\\msvc2022_64")
elseif(CMAKE_HOST_APPLE)

elseif(CMAKE_HOST_LINUX)
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.7.2/gcc_64")
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.8.0/gcc_64")
endif()
6 changes: 4 additions & 2 deletions examples/common/playlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ QModelIndex PlaylistModel::parent(const QModelIndex &child) const

QVariant PlaylistModel::data(const QModelIndex &index, int role) const
{
if (index.isValid() && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) {
if (index.isValid() && role == Qt::DisplayRole) {
QVariant value = m_data[index];
if (!value.isValid() && index.column() == Title) {
QUrl location = m_playlist->media(index.row());
Expand Down Expand Up @@ -97,11 +97,13 @@ void PlaylistModel::beginRemoveItems(int start, int end)

void PlaylistModel::endRemoveItems()
{
endRemoveRows();
endInsertRows();
}

void PlaylistModel::changeItems(int start, int end)
{
m_data.clear();
emit dataChanged(index(start, 0), index(end, ColumnCount));
}

#include "moc_playlistmodel.cpp"
24 changes: 11 additions & 13 deletions examples/common/playlistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,24 @@ class PlaylistModel : public QAbstractItemModel
Q_OBJECT

public:
enum Column
{
Title = 0,
ColumnCount
};
enum Column { Title = 0, ColumnCount };

explicit PlaylistModel(QObject *parent = nullptr);
~PlaylistModel() override;
~PlaylistModel();

[[nodiscard]] auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
[[nodiscard]] auto columnCount(const QModelIndex &parent = QModelIndex()) const -> int override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;

[[nodiscard]] auto index(int row, int column, const QModelIndex &parent = QModelIndex()) const -> QModelIndex override;
[[nodiscard]] auto parent(const QModelIndex &child) const -> QModelIndex override;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;

[[nodiscard]] auto data(const QModelIndex &index, int role = Qt::DisplayRole) const -> QVariant override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

[[nodiscard]] auto playlist() const -> QMediaPlaylist *;
QMediaPlaylist *playlist() const;

auto setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) -> bool override;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::DisplayRole) override;

private slots:
void beginInsertItems(int start, int end);
Expand Down
21 changes: 11 additions & 10 deletions examples/common/qmediaplaylist.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "qmediaplaylist.h"
#include "qmediaplaylist_p.h"
#include "qplaylistfileparser_p.h"
#include "qplaylistfileparser.h"

#include <QCoreApplication>
#include <QFile>
#include <QList>
#include <QRandomGenerator>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qfile.h>
#include <QtCore/qlist.h>
#include <QtCore/qurl.h>
#include <QUrl>

QT_BEGIN_NAMESPACE

Expand Down Expand Up @@ -124,10 +123,12 @@ int QMediaPlaylistPrivate::prevPosition(int steps) const
\value CurrentItemInLoop The current item is played repeatedly in a loop.
\value Sequential Playback starts from the current and moves through each successive item until the last is reached and then stops.
The next item is a null item when the last one is currently playing.
\value Sequential Playback starts from the current and moves through each successive
item until the last is reached and then stops. The next item is a null item when the last one is
currently playing.
\value Loop Playback restarts at the first item after the last has finished playing.
\value Loop Playback restarts at the first item after the last has finished
playing.
\value Random Play items in random order.
*/
Expand Down
50 changes: 22 additions & 28 deletions examples/common/qmediaplaylist.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef QMEDIAPLAYLIST_H
#define QMEDIAPLAYLIST_H

#include <QtCore/qobject.h>

#include <QtMultimedia/qmediaenumdebug.h>
#include <QtMultimedia/qtmultimediaglobal.h>
#include <QObject>

QT_BEGIN_NAMESPACE

Expand All @@ -27,49 +24,49 @@ class QMediaPlaylist : public QObject
Q_ENUM(Error)

explicit QMediaPlaylist(QObject *parent = nullptr);
~QMediaPlaylist() override;
virtual ~QMediaPlaylist();

[[nodiscard]] auto playbackMode() const -> PlaybackMode;
PlaybackMode playbackMode() const;
void setPlaybackMode(PlaybackMode mode);

[[nodiscard]] auto currentIndex() const -> int;
[[nodiscard]] auto currentMedia() const -> QUrl;
int currentIndex() const;
QUrl currentMedia() const;

[[nodiscard]] auto nextIndex(int steps = 1) const -> int;
[[nodiscard]] auto previousIndex(int steps = 1) const -> int;
int nextIndex(int steps = 1) const;
int previousIndex(int steps = 1) const;

[[nodiscard]] auto media(int index) const -> QUrl;
QUrl media(int index) const;

[[nodiscard]] auto mediaCount() const -> int;
[[nodiscard]] auto isEmpty() const -> bool;
int mediaCount() const;
bool isEmpty() const;

void addMedia(const QUrl &content);
void addMedia(const QList<QUrl> &items);
auto insertMedia(int index, const QUrl &content) -> bool;
auto insertMedia(int index, const QList<QUrl> &items) -> bool;
auto moveMedia(int from, int to) -> bool;
auto removeMedia(int pos) -> bool;
auto removeMedia(int start, int end) -> bool;
bool insertMedia(int index, const QUrl &content);
bool insertMedia(int index, const QList<QUrl> &items);
bool moveMedia(int from, int to);
bool removeMedia(int pos);
bool removeMedia(int start, int end);
void clear();

void load(const QUrl &location, const char *format = nullptr);
void load(QIODevice *device, const char *format = nullptr);

auto save(const QUrl &location, const char *format = nullptr) const -> bool;
auto save(QIODevice *device, const char *format) const -> bool;
bool save(const QUrl &location, const char *format = nullptr) const;
bool save(QIODevice *device, const char *format) const;

[[nodiscard]] auto error() const -> Error;
[[nodiscard]] auto errorString() const -> QString;
Error error() const;
QString errorString() const;

public Q_SLOTS:
public slots:
void shuffle();

void next();
void previous();

void setCurrentIndex(int index);

Q_SIGNALS:
signals:
void currentIndexChanged(int index);
void playbackModeChanged(QMediaPlaylist::PlaybackMode mode);
void currentMediaChanged(const QUrl &);
Expand All @@ -90,7 +87,4 @@ public Q_SLOTS:

QT_END_NAMESPACE

Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, PlaybackMode)
Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, Error)

#endif // QMEDIAPLAYLIST_H
65 changes: 65 additions & 0 deletions examples/common/qmediaplaylist_p.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "qmediaplaylist_p.h"

QT_BEGIN_NAMESPACE

QMediaPlaylistPrivate::QMediaPlaylistPrivate() : error(QMediaPlaylist::NoError) { }

QMediaPlaylistPrivate::~QMediaPlaylistPrivate()
{
delete parser;
}

void QMediaPlaylistPrivate::loadFailed(QMediaPlaylist::Error error, const QString &errorString)
{
this->error = error;
this->errorString = errorString;

emit q_ptr->loadFailed();
}

void QMediaPlaylistPrivate::loadFinished()
{
q_ptr->addMedia(parser->playlist);

emit q_ptr->loaded();
}

bool QMediaPlaylistPrivate::checkFormat(const char *format) const
{
QLatin1String f(format);
QPlaylistFileParser::FileType type =
format ? QPlaylistFileParser::UNKNOWN : QPlaylistFileParser::M3U8;
if (format) {
if (f == QLatin1String("m3u") || f == QLatin1String("text/uri-list")
|| f == QLatin1String("audio/x-mpegurl") || f == QLatin1String("audio/mpegurl"))
type = QPlaylistFileParser::M3U;
else if (f == QLatin1String("m3u8") || f == QLatin1String("application/x-mpegURL")
|| f == QLatin1String("application/vnd.apple.mpegurl"))
type = QPlaylistFileParser::M3U8;
}

if (type == QPlaylistFileParser::UNKNOWN || type == QPlaylistFileParser::PLS) {
error = QMediaPlaylist::FormatNotSupportedError;
errorString = QMediaPlaylist::tr("This file format is not supported.");
return false;
}
return true;
}

void QMediaPlaylistPrivate::ensureParser()
{
if (parser)
return;

parser = new QPlaylistFileParser(q_ptr);
QObject::connect(parser, &QPlaylistFileParser::finished, q_ptr, [this]() { loadFinished(); });
QObject::connect(parser, &QPlaylistFileParser::error, q_ptr,
[this](QMediaPlaylist::Error err, const QString &errorMsg) {
loadFailed(err, errorMsg);
});
}

QT_END_NAMESPACE
Loading

0 comments on commit 3579b85

Please sign in to comment.