diff --git a/scripts/windeploy.ps1 b/scripts/windeploy.ps1 index 3ebf6a9..e0429fb 100644 --- a/scripts/windeploy.ps1 +++ b/scripts/windeploy.ps1 @@ -1,4 +1,4 @@ -# completley written by chatgpt btw. dont bother for winslop +# completely written by chatgpt btw. dont bother for winslop Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" @@ -8,8 +8,10 @@ $QtBin = "C:\Qt\6.10.2\mingw_64\bin" $Msys2Bin = "C:\msys64\mingw64\bin" $FFmpegBin = "C:\ffmpeg\bin" $AppExe = Join-Path $BuildDir "SubWave.exe" + $StagingDir = Join-Path $env:TEMP "SubWave_staging" $ZipPath = Join-Path $ZipOutDir "SubWave.zip" +$UnpackedDir = Join-Path $ZipOutDir "SubWave_uncompressed" function Copy-Dll($src, $dst) { if (Test-Path $src) { @@ -61,7 +63,7 @@ Write-Host "`n=== windeployqt ===" -ForegroundColor Cyan & "$QtBin\windeployqt.exe" --release --no-translations --no-network --compiler-runtime $AppExe if ($LASTEXITCODE -ne 0) { Write-Error "windeployqt failed"; exit 1 } -# 2. FFmpeg - only what CMake links (avformat, avcodec, avutil, swresample) +# 2. FFmpeg Write-Host "`n=== FFmpeg DLLs ===" -ForegroundColor Cyan $ffmpegPatterns = "libavformat-*.dll","libavcodec-*.dll","libavutil-*.dll","libswresample-*.dll", "avformat-*.dll","avcodec-*.dll","avutil-*.dll","swresample-*.dll" @@ -69,7 +71,7 @@ foreach ($p in $ffmpegPatterns) { Copy-PatternFromMsys2OrFallback $p $FFmpegBin } -# 3. FFTW3 - double precision only (fftw3, not fftw3f or fftw3l) +# 3. FFTW3 Write-Host "`n=== FFTW3 ===" -ForegroundColor Cyan Copy-DllFromMsys2OrFallback "libfftw3-3.dll" $null @@ -79,104 +81,90 @@ foreach ($dll in "libgcc_s_seh-1.dll","libstdc++-6.dll","libwinpthread-1.dll") { Copy-DllFromMsys2OrFallback $dll $QtBin } -# 5. Stage into a clean copy +# 5. Stage Write-Host "`n=== Staging ===" -ForegroundColor Cyan if (Test-Path $StagingDir) { Remove-Item $StagingDir -Recurse -Force } Copy-Item $BuildDir $StagingDir -Recurse Write-Host " Staged to: $StagingDir" -# 6. Strip non-essentials from the staging copy +# 6. Strip Write-Host "`n=== Stripping ===" -ForegroundColor Cyan -# Folders to remove entirely $foldersToRemove = @( - "SubWave_autogen", - "Testing", - "tls", - "networkinformation", - ".qt", - ".qtc", - ".qtc_clangd", - "CMakeFiles", - "sqldrivers", - "position", - "sensors", - "serialport", - "scenegraph", - "virtualkeyboard", - "printsupport", - "bearer", - "networkauth", - "webengine*", - "qtwebengine*" + "SubWave_autogen","Testing","tls","networkinformation",".qt",".qtc", + ".qtc_clangd","CMakeFiles","sqldrivers","position","sensors","serialport", + "scenegraph","virtualkeyboard","printsupport","bearer","networkauth", + "webengine*","qtwebengine*" ) + foreach ($folder in $foldersToRemove) { Get-ChildItem $StagingDir -Recurse -Directory -Filter $folder | ForEach-Object { Remove-Item $_.FullName -Recurse -Force - Write-Host " Removed dir: $($_.Name)" } } -# File patterns to remove $filesToRemove = @( - "*.pdb", "*.ilk", "*.exp", "*.lib", "*.map", - "*.qm", "*.ts", - "*.cmake", "*.ninja", "build.ninja", - "CMakeCache.txt", "CMakeCache.txt.prev", - ".ninja_deps", ".ninja_log" + "*.pdb","*.ilk","*.exp","*.lib","*.map", + "*.qm","*.ts","*.cmake","*.ninja","build.ninja", + "CMakeCache.txt","CMakeCache.txt.prev", + ".ninja_deps",".ninja_log" ) + foreach ($pattern in $filesToRemove) { Get-ChildItem $StagingDir -Recurse -Filter $pattern | ForEach-Object { Remove-Item $_.FullName -Force - Write-Host " Removed: $($_.FullName.Replace($StagingDir, ''))" } } -# Remove DLLs that windeployqt pulls in but the app doesn't need +# DLL cleanup Write-Host "`n=== Removing unneeded DLLs ===" -ForegroundColor Cyan $dllsToRemove = @( - # Qt modules not in CMake "Qt6Svg.dll", - # OpenSSL - no network - "libssl-3-x64.dll", - "libcrypto-3-x64.dll", - # FFmpeg libs not linked - "avfilter-*.dll", "libavfilter-*.dll", - "avdevice-*.dll", "libavdevice-*.dll", - "swscale-*.dll", "libswscale-*.dll", - "postproc-*.dll", "libpostproc-*.dll", - # FFTW variants not linked - "libfftw3f-3.dll", - "libfftw3l-3.dll" + "libssl-3-x64.dll","libcrypto-3-x64.dll", + "avfilter-*.dll","libavfilter-*.dll", + "avdevice-*.dll","libavdevice-*.dll", + "swscale-*.dll","libswscale-*.dll", + "postproc-*.dll","libpostproc-*.dll", + "libfftw3f-3.dll","libfftw3l-3.dll" ) + foreach ($pattern in $dllsToRemove) { Get-ChildItem $StagingDir -Filter $pattern -ErrorAction SilentlyContinue | ForEach-Object { Remove-Item $_.FullName -Force - Write-Host " Removed: $($_.Name)" } } -# Remove duplicate/older FFmpeg DLLs — keep only the highest version per library +# Deduplicate FFmpeg Write-Host "`n=== Deduplicating FFmpeg DLLs ===" -ForegroundColor Cyan $ffmpegBases = @("avcodec","avformat","avutil","swresample", "libavcodec","libavformat","libavutil","libswresample") + foreach ($base in $ffmpegBases) { $matches = @(Get-ChildItem $StagingDir -Filter "$base-*.dll" -ErrorAction SilentlyContinue) if ($matches.Count -gt 1) { - # Sort by version number extracted from filename, keep the last (highest) $sorted = $matches | Sort-Object { [int]($_.Name -replace ".*-(\d+)\.dll",'$1') } $sorted | Select-Object -SkipLast 1 | ForEach-Object { Remove-Item $_.FullName -Force - Write-Host " Removed older: $($_.Name)" } } } -# 7. Zip from staging +# 6.5 NEW: Copy uncompressed output folder +Write-Host "`n=== Exporting uncompressed folder ===" -ForegroundColor Cyan +if (Test-Path $UnpackedDir) { + Remove-Item $UnpackedDir -Recurse -Force +} +Copy-Item $StagingDir $UnpackedDir -Recurse +Write-Host " Uncompressed folder at: $UnpackedDir" + +# 7. Zip Write-Host "`n=== Zipping ===" -ForegroundColor Cyan if (Test-Path $ZipPath) { Remove-Item $ZipPath -Force } Compress-Archive -Path "$StagingDir\*" -DestinationPath $ZipPath -Remove-Item $StagingDir -Recurse -Force + Write-Host " Zipped to: $ZipPath" -Write-Host "`nDone." -ForegroundColor Green +# Cleanup staging ONLY (keep uncompressed output) +Remove-Item $StagingDir -Recurse -Force + +Write-Host "`nDone." -ForegroundColor Green \ No newline at end of file diff --git a/src/gui/GradientDialog.cpp b/src/gui/GradientDialog.cpp index 8ef1ec0..d95763e 100644 --- a/src/gui/GradientDialog.cpp +++ b/src/gui/GradientDialog.cpp @@ -17,39 +17,58 @@ static QVector makePreset4(const QColor &c0, const QColor &c1, struct Preset { QString name; - QVector colors; + QVector colors; }; // Presets are defined in a Vector for simplicity of adding new ones static const QVector PRESETS = { { "Default", - { QColor("#078D70"), QColor("#26CEAA"), QColor("#98E8C1"), QColor("#FFFFFF") } }, + { QColor("#078D70"), QColor("#26CEAA"), QColor("#98E8C1"), QColor("#FFFFFF") } }, { "Pastels", - makePreset4(QColor("#92ccdd"), QColor("#c7eff0"), - QColor("#f5d5fd"), QColor("#fdc4ec"), QColor("#ffc2cb")) }, + makePreset4(QColor("#92ccdd"), QColor("#c7eff0"), + QColor("#f5d5fd"), QColor("#fdc4ec"), QColor("#ffc2cb")) }, { "Raddish", - makePreset4(QColor("#ff0000"), QColor("#b40000"), - QColor("#890000"), QColor("#540000"), QColor("#240000")) }, + makePreset4(QColor("#ff0000"), QColor("#b40000"), + QColor("#890000"), QColor("#540000"), QColor("#240000")) }, { "Blau", - makePreset4(QColor("#72c8dd"), QColor("#43b5d2"), - QColor("#14a3c7"), QColor("#1293b3"), QColor("#10829f")) }, + makePreset4(QColor("#72c8dd"), QColor("#43b5d2"), + QColor("#14a3c7"), QColor("#1293b3"), QColor("#10829f")) }, { "Turquoise", - makePreset4(QColor("#d8f2f6"), QColor("#8bd9ef"), - QColor("#3ec1d5"), QColor("#319aaa"), QColor("#25737f")) }, + makePreset4(QColor("#d8f2f6"), QColor("#8bd9ef"), + QColor("#3ec1d5"), QColor("#319aaa"), QColor("#25737f")) }, { "Aqua", - makePreset4(QColor("#2278FB"), QColor("#3A9AF0"), - QColor("#53BDE6"), QColor("#6BDFDB"), QColor("#1A5BB8")) }, + makePreset4(QColor("#2278FB"), QColor("#3A9AF0"), + QColor("#53BDE6"), QColor("#6BDFDB"), QColor("#1A5BB8")) }, { "Peaches", - makePreset4(QColor("#FFCAA6"), QColor("#FDA8A0"), - QColor("#FA879A"), QColor("#F86594"), QColor("#FFE0CC")) } + makePreset4(QColor("#FFCAA6"), QColor("#FDA8A0"), + QColor("#FA879A"), QColor("#F86594"), QColor("#FFE0CC")) } }; +static int findPresetIndex(const QVector &stops) +{ + for (int i = 0; i < PRESETS.size(); ++i) { + const auto &pc = PRESETS[i].colors; + if (pc.size() != stops.size()) + continue; + bool match = true; + for (int j = 0; j < pc.size(); ++j) { + if (pc[j].rgb() != stops[j].rgb()) { + match = false; + break; + } + } + if (match) + return i; + } + return -1; +} + GradientDialog::GradientDialog(const QVector &stops, QWidget *parent) : QDialog(parent), m_stops(stops) @@ -99,6 +118,12 @@ GradientDialog::GradientDialog(const QVector &stops, mainLay->addLayout(dialogBtns); updatePreview(); + + int presetIdx = findPresetIndex(m_stops); + if (presetIdx >= 0) { + QSignalBlocker blocker(m_presetCombo); + m_presetCombo->setCurrentIndex(presetIdx); + } } void GradientDialog::onStopClicked(int index) @@ -128,11 +153,11 @@ void GradientDialog::updatePreview() QLinearGradient grad(0, 0, pix.width(), 0); for (int i = 0; i < m_stops.size(); ++i) { qreal pos = (m_stops.size() == 1) ? 0.5 - : qreal(i) / (m_stops.size() - 1); + : qreal(i) / (m_stops.size() - 1); grad.setColorAt(pos, m_stops[i]); } p.setBrush(grad); p.drawRect(pix.rect()); p.end(); m_preview->setPixmap(pix); -} \ No newline at end of file +}