Skip to content

Fix #6: apply config dialog changes to running projectM instance - #17

Draft
struktured wants to merge 2 commits into
masterfrom
fix/issue-6-settings-propagation
Draft

Fix #6: apply config dialog changes to running projectM instance#17
struktured wants to merge 2 commits into
masterfrom
fix/issue-6-settings-propagation

Conversation

@struktured

@struktured struktured commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Closes #6

Summary

Previously, the settings dialog wrote new values to config.inp but never pushed them to the running projectM instance. The user had to restart to see changes take effect. The reset signal was gated behind #ifdef PROJECTM_RESET_IS_THREAD_SAFE which is never defined, so it was effectively dead code.

Fix

Add applyLiveSettings() that calls projectM 4.x runtime setters after saveConfig():

  • projectm_set_fps
  • projectm_set_aspect_correction
  • projectm_set_beat_sensitivity
  • projectm_set_soft_cut_duration
  • projectm_set_preset_duration
  • projectm_set_easter_egg
  • projectm_set_window_size
  • projectm_set_mesh_size

Restart still required for

  • Texture size — needs GL context recreation
  • Preset path — playlist reload, owned by main window not projectM
  • Shuffle — playlist setting, owned by projectm_playlist
  • Font paths — projectM 4.x uses runtime font loading, not config-driven
  • Fullscreen / Menu on startup — startup-only flags

These could be wired up later but each has trickier semantics. This PR addresses the common case (timing/sensitivity tuning) which is what the original issue describes.

Test plan

  • Clean build
  • Open Settings dialog, change FPS, save → projectM updates immediately
  • Change beat sensitivity → effect visible in next preset
  • Window size change resizes the GL viewport
  • Tested locally end-to-end (open Settings, change FPS/beat sensitivity/window size, hit Save, verify changes apply without restart and persist after restart)

Previously, saving the settings dialog only wrote values to the config
file — the running projectM instance kept using the old values until
the next launch. The reset signal was gated on PROJECTM_RESET_IS_THREAD_SAFE
which is never defined.

Add applyLiveSettings() that pushes the new values via the projectM 4.x
runtime API after writing the config file. Applies:
  - FPS, aspect correction, beat sensitivity
  - Soft cut and preset durations
  - Easter egg parameter
  - Window and mesh size

Texture size, preset path, shuffle, and font paths still require restart
since they need GL context recreation or playlist reload.

Closes #6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@struktured
struktured requested a review from Copilot April 25, 2026 14:54
@struktured
struktured marked this pull request as draft April 25, 2026 14:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires the Qt Settings dialog to immediately apply supported configuration changes to the running projectM 4.x instance, rather than only writing them to config.inp and requiring an app restart.

Changes:

  • Add applyLiveSettings() and invoke it after saveConfig() on Save.
  • Apply runtime-tunable settings via projectM 4.x public C API setters (FPS, aspect correction, beat sensitivity, durations, easter egg, window/mesh size).
  • Remove the previously dead #ifdef PROJECTM_RESET_IS_THREAD_SAFE reset gate in the Save handler.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/common/qprojectmconfigdialog.hpp Declares new applyLiveSettings() helper.
src/common/qprojectmconfigdialog.cpp Implements applyLiveSettings() and calls it after saving settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/common/qprojectmconfigdialog.cpp Outdated
Comment on lines +173 to +181
projectm_set_fps(pm, _ui.maxFPSSpinBox->value());
projectm_set_aspect_correction(pm, _ui.useAspectCorrectionCheckBox->checkState() == Qt::Checked);
projectm_set_beat_sensitivity(pm, static_cast<float>(_ui.beatSensitivitySpinBox->value()));
projectm_set_soft_cut_duration(pm, _ui.smoothPresetDurationSpinBox->value());
projectm_set_preset_duration(pm, _ui.presetDurationSpinBox->value());
projectm_set_easter_egg(pm, static_cast<float>(_ui.easterEggParameterSpinBox->value()));
projectm_set_window_size(pm,
static_cast<size_t>(_ui.windowWidthSpinBox->value()),
static_cast<size_t>(_ui.windowHeightSpinBox->value()));
Comment on lines +165 to +178
if (!_qprojectMWidget || !_qprojectMWidget->qprojectM()) {
return;
}
auto *pm = _qprojectMWidget->qprojectM()->instance();
if (!pm) {
return;
}

projectm_set_fps(pm, _ui.maxFPSSpinBox->value());
projectm_set_aspect_correction(pm, _ui.useAspectCorrectionCheckBox->checkState() == Qt::Checked);
projectm_set_beat_sensitivity(pm, static_cast<float>(_ui.beatSensitivitySpinBox->value()));
projectm_set_soft_cut_duration(pm, _ui.smoothPresetDurationSpinBox->value());
projectm_set_preset_duration(pm, _ui.presetDurationSpinBox->value());
projectm_set_easter_egg(pm, static_cast<float>(_ui.easterEggParameterSpinBox->value()));
Comment thread src/common/qprojectmconfigdialog.cpp Outdated
Comment on lines +179 to +181
projectm_set_window_size(pm,
static_cast<size_t>(_ui.windowWidthSpinBox->value()),
static_cast<size_t>(_ui.windowHeightSpinBox->value()));
@struktured struktured self-assigned this Apr 25, 2026
- Hold the projectMMutex when calling projectM C API setters to avoid
  races with the render thread's paintGL.
- Resize the top-level Qt window instead of calling
  projectm_set_window_size directly. Qt's resize event flows through
  QProjectMWidget::resizeGL, which already handles devicePixelRatio
  scaling and queues the projectM update on the render thread. The
  direct call would skip DPR and desync projectM's internal size from
  the actual GL framebuffer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@struktured

Copy link
Copy Markdown
Contributor Author

@copilot review

@thedavidweng

thedavidweng commented Sep 3, 2026

Copy link
Copy Markdown

verified against the libprojectM 4.x headers, sharing results:

  • All eight setters exist in the public C API (src/api/include/projectM-4/parameters.h in libprojectM 4.2.0): projectm_set_fps, projectm_set_aspect_correction, projectm_set_beat_sensitivity, projectm_set_soft_cut_duration, projectm_set_preset_duration, projectm_set_easter_egg, projectm_set_window_size, projectm_set_mesh_size. The added include is the correct header.
  • The locked mutex (projectMMutex()) is the same one paintGL() holds, and resizeGL does defer through m_resizePending, so routing window size through the resize event (with DPR scaling) matches the existing design. All referenced widget names exist in qprojectmconfigdialog.ui with matching types.
  • The removed #ifdef PROJECTM_RESET_IS_THREAD_SAFE is referenced nowhere else in the tree, so it was indeed dead code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QT settings aren't loaded into app on save

3 participants