Add Setting for Default Autoscroll State (#7851)

Previously, the autoscroll state of the song editor and piano roll (continuous, stepped, none) was not saved. This can be an issue for users who want to permanently set their autoscroll settings, without having to change them every time they start up LMMS.

This PR adds an option in the settings window to change the default autoscroll state.
This commit is contained in:
regulus79
2025-11-30 15:11:57 -05:00
committed by GitHub
parent f0b3c2e251
commit b01980d2fb
4 changed files with 41 additions and 6 deletions

View File

@@ -90,6 +90,7 @@ void TimeLineWidget::addToolButtons( QToolBar * _tool_bar )
autoScroll->addState(embed::getIconPixmap("autoscroll_stepped_on"), tr("Stepped auto scrolling"));
autoScroll->addState(embed::getIconPixmap("autoscroll_continuous_on"), tr("Continuous auto scrolling"));
autoScroll->addState(embed::getIconPixmap("autoscroll_off"), tr("Auto scrolling disabled"));
autoScroll->changeState(static_cast<int>(m_autoScroll));
connect( autoScroll, SIGNAL(changedState(int)), this,
SLOT(toggleAutoScroll(int)));
@@ -459,4 +460,15 @@ void TimeLineWidget::contextMenuEvent(QContextMenuEvent* event)
menu.exec(event->globalPos());
}
TimeLineWidget::AutoScrollState TimeLineWidget::defaultAutoScrollState()
{
QString autoScrollState = ConfigManager::inst()->value("ui", "autoscroll");
if (autoScrollState == AutoScrollSteppedString) { return AutoScrollState::Stepped; }
else if (autoScrollState == AutoScrollContinuousString) { return AutoScrollState::Continuous; }
else if (autoScrollState == AutoScrollDisabledString) { return AutoScrollState::Disabled; }
else { return AutoScrollState::Stepped; }
}
} // namespace lmms::gui

View File

@@ -42,6 +42,7 @@
#include "SetupDialog.h"
#include "TabBar.h"
#include "TabButton.h"
#include "TimeLineWidget.h"
// Platform-specific audio-interface classes.
@@ -119,6 +120,7 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
m_openLastProject(ConfigManager::inst()->value(
"app", "openlastproject").toInt()),
m_loopMarkerMode{ConfigManager::inst()->value("app", "loopmarkermode", "dual")},
m_autoScroll(ConfigManager::inst()->value("ui", "autoscroll", "stepped")),
m_lang(ConfigManager::inst()->value(
"app", "language")),
m_saveInterval( ConfigManager::inst()->value(
@@ -268,6 +270,17 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
guiGroupLayout->addWidget(new QLabel{tr("Loop edit mode"), guiGroupBox});
guiGroupLayout->addWidget(m_loopMarkerComboBox);
m_autoScrollComboBox = new QComboBox{guiGroupBox};
m_autoScrollComboBox->addItem(tr("Disabled"), TimeLineWidget::AutoScrollDisabledString);
m_autoScrollComboBox->addItem(tr("Stepped (Scroll once the playhead goes out of view)"), TimeLineWidget::AutoScrollSteppedString);
m_autoScrollComboBox->addItem(tr("Continuous (Scroll constantly to keep the playhead in the center)"), TimeLineWidget::AutoScrollContinuousString);
m_autoScrollComboBox->setCurrentIndex(m_autoScrollComboBox->findData(m_autoScroll));
connect(m_autoScrollComboBox, qOverload<int>(&QComboBox::currentIndexChanged),
this, [this](){ m_autoScroll = m_autoScrollComboBox->currentData().toString(); });
guiGroupLayout->addWidget(new QLabel{tr("Default Autoscroll Mode"), guiGroupBox});
guiGroupLayout->addWidget(m_autoScrollComboBox);
generalControlsLayout->addWidget(guiGroupBox);
generalControlsLayout->addSpacing(10);
@@ -980,6 +993,7 @@ void SetupDialog::accept()
QString::number(m_openLastProject));
ConfigManager::inst()->setValue("app", "loopmarkermode", m_loopMarkerMode);
ConfigManager::inst()->setValue("app", "language", m_lang);
ConfigManager::inst()->setValue("ui", "autoscroll", m_autoScroll);
ConfigManager::inst()->setValue("ui", "saveinterval",
QString::number(m_saveInterval));
ConfigManager::inst()->setValue("ui", "enableautosave",