Compare commits

..

No commits in common. "5092f9bafc3b504ca39ed2889ece943aad938550" and "54c604ee9d9076c197721f1043d85fe04ae4b30d" have entirely different histories.

6 changed files with 42 additions and 99 deletions

View File

@ -1,7 +0,0 @@
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

View File

@ -7,11 +7,9 @@ jobs:
strategy: strategy:
matrix: matrix:
include: vs: ['2022']
- qt_ver: '6.8.0' msvc_arch: ['x64']
vs: '2022' qt_ver: ['6.7.3']
aqt_arch: 'win64_msvc2022_64'
msvc_arch: 'x64'
runs-on: windows-2022 runs-on: windows-2022
@ -20,9 +18,9 @@ jobs:
- name: Install Qt - name: Install Qt
uses: jurplel/install-qt-action@v4 uses: jurplel/install-qt-action@v4
with: with:
arch: ${{ matrix.aqt_arch }} arch: 'win64_msvc2019_64'
version: ${{ matrix.qt_ver }} version: ${{ matrix.qt_ver }}
modules: 'qtmultimedia qt5compat' modules: 'qtmultimedia'
- name: Build - name: Build
shell: cmd shell: cmd
run: | run: |
@ -35,16 +33,12 @@ jobs:
:: ------ dep ------ :: ------ dep ------
set CMAKE_PREFIX_PATH=%PWD%/dependencies_bin set CMAKE_PREFIX_PATH=%PWD%/dependencies_bin
mkdir dependencies_src mkdir dependencies_src
:: ===== ECM ===== :: ===== uchardet =====
git clone -q https://invent.kde.org/frameworks/extra-cmake-modules.git dependencies_src/extra-cmake-modules echo ::group::build uchardet
cmake .\dependencies_src\extra-cmake-modules -Bbuild_dependencies/extra-cmake-modules -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DBUILD_TESTING=OFF || goto :error git clone -q https://gitlab.freedesktop.org/BLumia/uchardet.git --branch msvc dependencies_src/uchardet
cmake --build build_dependencies/extra-cmake-modules --config Release --target=install || goto :error cmake .\dependencies_src\uchardet -Bbuild_dependencies/uchardet -DBUILD_BINARY=OFF -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
:: ===== Gperf (required by KCodecs) ===== cmake --build build_dependencies/uchardet --config Release --target=install -j || goto :error
choco install gperf echo ::endgroup::
:: ===== KCodecs =====
git clone -q https://invent.kde.org/frameworks/kcodecs.git dependencies_src/kcodecs
cmake .\dependencies_src\kcodecs -Bbuild_dependencies/kcodecs -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DBUILD_TESTING=OFF || goto :error
cmake --build build_dependencies/kcodecs --config Release --target=install || goto :error
:: ===== pkg-config ===== :: ===== pkg-config =====
choco install pkgconfiglite choco install pkgconfiglite
set PKG_CONFIG_PATH=%PWD%/dependencies_bin/lib/pkgconfig set PKG_CONFIG_PATH=%PWD%/dependencies_bin/lib/pkgconfig
@ -53,16 +47,16 @@ jobs:
cmake .\dependencies_src\taglib -Bbuild_dependencies/taglib -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error cmake .\dependencies_src\taglib -Bbuild_dependencies/taglib -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
cmake --build build_dependencies/taglib --config Release --target=install -j || goto :error cmake --build build_dependencies/taglib --config Release --target=install -j || goto :error
:: ------ app ------ :: ------ app ------
cmake -Bbuild . -DUSE_QTEXTCODEC=ON -DCMAKE_INSTALL_PREFIX="%PWD%\build\" || goto :error cmake -Bbuild . -DCMAKE_INSTALL_PREFIX="%PWD%\build\" || goto :error
cmake --build build --config Release -j || goto :error cmake --build build --config Release -j || goto :error
cmake --build build --config Release --target=install || goto :error cmake --build build --config Release --target=install
:: ------ pkg ------ :: ------ pkg ------
windeployqt --verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-system-d3d-compiler --no-system-dxc-compiler --multimedia --core5compat --skip-plugin-types tls,networkinformation build\bin\pmusic.exe windeployqt --verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-system-d3d-compiler --no-system-dxc-compiler --multimedia --skip-plugin-types tls,networkinformation build\bin\pmusic.exe
robocopy ./dependencies_bin/bin build/bin *.dll robocopy ./dependencies_bin/bin build/bin *.dll
if ErrorLevel 8 (exit /B 1) if ErrorLevel 8 (exit /B 1)
copy LICENSE build/bin/ copy LICENSE build/bin/
exit /B 0 exit /B 0
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: "${{ matrix.aqt_arch }}-qt${{ matrix.qt_ver }}-cmake-package" name: "windows-msvc${{ matrix.vs }}-qt${{ matrix.qt_ver }}-cmake-package"
path: build/bin/* path: build/bin/*

View File

@ -14,16 +14,10 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(USE_QTEXTCODEC "Use QTextCodec instead of QStringConverter, in case Qt is not built with ICU" OFF)
find_package(Qt6 6.6 COMPONENTS Widgets Multimedia Network LinguistTools REQUIRED) find_package(Qt6 6.6 COMPONENTS Widgets Multimedia Network LinguistTools REQUIRED)
find_package(KF6Codecs 6.1.0) find_package(uchardet)
find_package(PkgConfig) find_package(PkgConfig)
if (USE_QTEXTCODEC)
find_package(Qt6 6.6 COMPONENTS Core5Compat REQUIRED)
endif()
if (PKG_CONFIG_FOUND) if (PKG_CONFIG_FOUND)
pkg_check_modules(TagLib taglib IMPORTED_TARGET) pkg_check_modules(TagLib taglib IMPORTED_TARGET)
endif () endif ()
@ -79,18 +73,14 @@ else ()
target_link_libraries(${EXE_NAME} PRIVATE PkgConfig::TagLib) target_link_libraries(${EXE_NAME} PRIVATE PkgConfig::TagLib)
endif () endif ()
if (TARGET KF6::Codecs) if (NOT uchardet_FOUND)
target_compile_definitions(${EXE_NAME} PRIVATE HAVE_KCODECS=1) target_compile_definitions(${EXE_NAME} PRIVATE NO_UCHARDET=1)
target_link_libraries (${EXE_NAME} PRIVATE KF6::Codecs) else ()
target_link_libraries (${EXE_NAME} PRIVATE uchardet::libuchardet)
endif () endif ()
target_link_libraries(${EXE_NAME} PRIVATE Qt::Widgets Qt::Multimedia Qt::Network) target_link_libraries(${EXE_NAME} PRIVATE Qt::Widgets Qt::Multimedia Qt::Network)
if (USE_QTEXTCODEC)
target_compile_definitions(${EXE_NAME} PRIVATE USE_QTEXTCODEC=1)
target_link_libraries(${EXE_NAME} PRIVATE Qt6::Core5Compat)
endif()
# Install settings # Install settings
if (WIN32) if (WIN32)
# FIXME: try to avoid install to a "bin" subfolder under windows... # FIXME: try to avoid install to a "bin" subfolder under windows...

View File

@ -22,20 +22,12 @@ build_script:
# prepare # prepare
- mkdir 3rdparty - mkdir 3rdparty
- choco install ninja - choco install ninja
- choco install gperf
- choco install pkgconfiglite - choco install pkgconfiglite
- cd 3rdparty - cd 3rdparty
# install ECM # build uchardet
- git clone -q https://invent.kde.org/frameworks/extra-cmake-modules.git - git clone -q https://gitlab.freedesktop.org/uchardet/uchardet.git
- git rev-parse HEAD - cd uchardet
- cd extra-cmake-modules - cmake -G "Ninja" . -DCMAKE_INSTALL_PREFIX=%PACKAGE_INSTALL_ROOT% -DBUILD_BINARY=OFF
- cmake -G "Ninja" . -DCMAKE_INSTALL_PREFIX=%PACKAGE_INSTALL_ROOT% -DBUILD_TESTING=OFF
- cmake --build . --target install
- cd %APPVEYOR_BUILD_FOLDER%
# build kcodecs
- git clone -q https://invent.kde.org/frameworks/kcodecs.git
- cd kcodecs
- cmake -G "Ninja" . -DCMAKE_INSTALL_PREFIX=%PACKAGE_INSTALL_ROOT% -DBUILD_TESTING=OFF
- cmake --build . --target install - cmake --build . --target install
- cd %APPVEYOR_BUILD_FOLDER% - cd %APPVEYOR_BUILD_FOLDER%
# build taglib # build taglib

View File

@ -9,14 +9,8 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QStringConverter> #include <QStringConverter>
#ifdef HAVE_KCODECS #ifndef NO_UCHARDET
#include <KCharsets> #include <uchardet/uchardet.h>
#include <KCodecs>
#include <KEncodingProber>
#endif
#ifdef USE_QTEXTCODEC
#include <QTextCodec>
#endif #endif
Q_LOGGING_CATEGORY(lcLyrics, "pmusic.lyrics") Q_LOGGING_CATEGORY(lcLyrics, "pmusic.lyrics")
@ -50,38 +44,24 @@ bool LyricsManager::loadLyrics(QString filepath)
return false; return false;
} }
QByteArray fileContent(file.readAll()); QByteArray fileContent(file.readAll());
#ifndef NO_UCHARDET
uchardet_t handle = uchardet_new();
uchardet_handle_data(handle, fileContent.data(), fileContent.length());
uchardet_data_end(handle);
const char* encoding = uchardet_get_charset(handle);
qCDebug(lcLyrics) << "Detected encoding:" << (encoding == NULL ? "unknown" : encoding);
QStringList lines; QStringList lines;
#ifdef HAVE_KCODECS if (QStringConverter::availableCodecs().contains(QString(encoding))) {
KEncodingProber prober(KEncodingProber::Universal);
prober.feed(fileContent);
QByteArray encoding(prober.encoding());
qCDebug(lcLyrics) << "Detected encoding:" << QString(encoding) << "with confidence" << prober.confidence();
#ifdef USE_QTEXTCODEC
qCDebug(lcLyrics) << "QTextCodec is used instead of QStringConverter.";
QTextCodec *codec = QTextCodec::codecForName(encoding);
if (codec) {
lines = codec->toUnicode(fileContent).split('\n');
} else {
lines = QString(fileContent).split('\n');
qCDebug(lcLyrics) << "No codec for the detected encoding. Available codecs are:" << QTextCodec::availableCodecs();
qCDebug(lcLyrics) << "KCodecs offers these encodings:" << KCharsets::charsets()->availableEncodingNames();
}
#else // NOT USE_QTEXTCODEC
auto toUtf16 = QStringDecoder(encoding); auto toUtf16 = QStringDecoder(encoding);
// Don't use `QStringConverter::availableCodecs().contains(QString(encoding))` here, since the charset
// encoding name might not match, e.g. GB18030 (from availableCodecs) != gb18030 (from KEncodingProber)
if (toUtf16.isValid()) {
QString decodedResult = toUtf16(fileContent); QString decodedResult = toUtf16(fileContent);
lines = decodedResult.split('\n'); lines = decodedResult.split('\n');
} else { } else {
qCDebug(lcLyrics) << "No codec for the detected encoding. Available codecs are:" << QStringConverter::availableCodecs();
qCDebug(lcLyrics) << "KCodecs offers these encodings:" << KCharsets::charsets()->availableEncodingNames();
lines = QString(fileContent).split('\n'); lines = QString(fileContent).split('\n');
} }
#endif // USE_QTEXTCODEC uchardet_delete(handle);
#else // NOT HAVE_KCODECS #else
lines = QString(fileContent).split('\n'); QStringList lines = QString(fileContent).split('\n');
#endif // HAVE_KCODECS #endif
file.close(); file.close();
// parse lyrics timestamp // parse lyrics timestamp

View File

@ -46,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
m_playlistManager->setAutoLoadFilterSuffixes({ m_playlistManager->setAutoLoadFilterSuffixes({
"*.mp3", "*.wav", "*.aiff", "*.ape", "*.flac", "*.ogg", "*.oga", "*.mpga", "*.aac", "*.tta" "*.mp3", "*.wav", "*.aiff", "*.ape", "*.flac", "*.ogg", "*.oga", "*.mpga", "*.aac"
}); });
m_mediaPlayer->setAudioOutput(m_audioOutput); m_mediaPlayer->setAudioOutput(m_audioOutput);
m_mediaPlayer->setLoops(QMediaPlayer::Infinite); m_mediaPlayer->setLoops(QMediaPlayer::Infinite);
@ -438,8 +438,6 @@ void MainWindow::initConnections()
setAudioMetadataForDisplay(metadata.stringValue(QMediaMetaData::Title), setAudioMetadataForDisplay(metadata.stringValue(QMediaMetaData::Title),
metadata.stringValue(QMediaMetaData::Author), metadata.stringValue(QMediaMetaData::Author),
metadata.stringValue(QMediaMetaData::AlbumTitle)); metadata.stringValue(QMediaMetaData::AlbumTitle));
setAudioPropertyInfoForDisplay(-1, metadata.value(QMediaMetaData::AudioBitRate).toInt() / 1000,
-1, metadata.stringValue(QMediaMetaData::FileFormat));
#endif // NO_TAGLIB #endif // NO_TAGLIB
QVariant coverArt(metadata.value(QMediaMetaData::ThumbnailImage)); QVariant coverArt(metadata.value(QMediaMetaData::ThumbnailImage));
if (!coverArt.isNull()) { if (!coverArt.isNull()) {
@ -618,16 +616,12 @@ void MainWindow::on_actionHelp_triggered()
"\n\n" % "\n\n" %
tr("Based on the following free software libraries:") % tr("Based on the following free software libraries:") %
"\n\n" % "\n\n" %
QStringLiteral("- [Qt](https://www.qt.io/) %1 with the following module(s):\n").arg(QT_VERSION_STR) % QStringLiteral("- [Qt](https://www.qt.io/) %1\n").arg(QT_VERSION_STR) %
QStringLiteral(" - multimedia\n") %
#ifdef USE_QTEXTCODEC
QStringLiteral(" - core5compat\n") %
#endif
#ifndef NO_TAGLIB #ifndef NO_TAGLIB
QStringLiteral("- [TagLib](https://github.com/taglib/taglib)\n") % QStringLiteral("- [TagLib](https://github.com/taglib/taglib)\n") %
#endif // NO_TAGLIB #endif // NO_TAGLIB
#ifdef HAVE_KCODECS #ifndef NO_UCHARDET
QStringLiteral("- [KCodecs](https://invent.kde.org/frameworks/kcodecs)\n") % QStringLiteral("- [uchardet](https://www.freedesktop.org/wiki/Software/uchardet/)\n") %
#endif // NO_TAGLIB #endif // NO_TAGLIB
"\n" "\n"
"[Source Code](https://github.com/BLumia/pineapple-music)\n" "[Source Code](https://github.com/BLumia/pineapple-music)\n"