From 413711d073ced7664800a875445197d81797fd06 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sat, 7 Sep 2024 00:48:09 +0800 Subject: [PATCH] chore(CI): github action msvc windows build --- .github/workflows/windows.yml | 56 +++++++++++++++++++++++++++++++++++ mainwindow.cpp | 9 ++++-- 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..7561f0d --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,56 @@ +name: Windows CI + +on: [push, pull_request, workflow_dispatch] + +jobs: + msvc-cmake-build: + + strategy: + matrix: + vs: ['2022'] + msvc_arch: ['x64'] + qt_ver: ['6.7.2'] + + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + - name: Install Qt + uses: jurplel/install-qt-action@v4 + with: + arch: 'win64_msvc2019_64' + version: ${{ matrix.qt_ver }} + modules: 'qtmultimedia' + - name: Build + shell: cmd + run: | + :: ------ env ------ + set PWD=%cd% + set VS=${{ matrix.vs }} + set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" + if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" + call %VCVARS% ${{ matrix.msvc_arch }} + :: ------ dep ------ + set CMAKE_PREFIX_PATH=%PWD%/dependencies_bin + mkdir dependencies_src + :: ===== pkg-config ===== + choco install pkgconfiglite + set PKG_CONFIG_PATH=%PWD%/dependencies_bin/lib/pkgconfig + :: ===== taglib ===== + git clone --recurse-submodules -q https://github.com/taglib/taglib.git dependencies_src/taglib + 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 || goto :error + :: ------ app ------ + cmake -Bbuild . -DCMAKE_INSTALL_PREFIX="%PWD%\build\" || goto :error + cmake --build build --config Release || goto :error + cmake --build build --config Release --target=install + :: ------ pkg ------ + 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 + if ErrorLevel 8 (exit /B 1) + copy LICENSE build/bin/ + exit /B 0 + - uses: actions/upload-artifact@v4 + with: + name: "windows-msvc${{ matrix.vs }}-qt${{ matrix.qt_ver }}-cmake-package" + path: build/bin/* diff --git a/mainwindow.cpp b/mainwindow.cpp index 87008f9..1d136fa 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -35,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent) "*.mp3", "*.wav", "*.aiff", "*.ape", "*.flac", "*.ogg", "*.oga", "*.mpga" }); m_mediaPlayer->setAudioOutput(m_audioOutput); + m_mediaPlayer->setLoops(QMediaPlayer::Infinite); ui->playlistView->setModel(m_playlistManager->model()); this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint); @@ -157,7 +158,6 @@ void MainWindow::mousePressEvent(QMouseEvent *event) void MainWindow::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::LeftButton && m_clickedOnWindow) { - qDebug() << "??" << event << event->flags() << event->isBeginEvent() << event->isEndEvent(); window()->windowHandle()->startSystemMove(); event->accept(); } @@ -168,7 +168,6 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) void MainWindow::mouseReleaseEvent(QMouseEvent *event) { m_clickedOnWindow = false; - qDebug() << "?"; return QMainWindow::mouseReleaseEvent(event); } @@ -402,7 +401,8 @@ void MainWindow::initConnections() // do nothing break; case MainWindow::CurrentItemInLoop: - m_mediaPlayer->play(); + // also do nothing + // as long as we did `setLoops(Infinite)`, we won't even get there break; case MainWindow::Sequential: on_nextBtn_clicked(); @@ -414,12 +414,15 @@ void MainWindow::initConnections() connect(this, &MainWindow::playbackModeChanged, this, [=](){ switch (m_playbackMode) { case MainWindow::CurrentItemOnce: + m_mediaPlayer->setLoops(QMediaPlayer::Once); ui->playbackModeBtn->setIcon(QIcon(":/icons/icons/media-repeat-single.png")); break; case MainWindow::CurrentItemInLoop: + m_mediaPlayer->setLoops(QMediaPlayer::Infinite); ui->playbackModeBtn->setIcon(QIcon(":/icons/icons/media-playlist-repeat-song.png")); break; case MainWindow::Sequential: + m_mediaPlayer->setLoops(QMediaPlayer::Once); ui->playbackModeBtn->setIcon(QIcon(":/icons/icons/media-playlist-repeat.png")); break; }