Skip to content

Commit

Permalink
Merge pull request #700 from coding-moding/newwizardopt
Browse files Browse the repository at this point in the history
Allow disabling the New Score Wizard via an advanced setting
  • Loading branch information
Jojo-Schmitz authored Nov 19, 2024
2 parents 8ea7e88 + d449e9b commit 680897e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 42 deletions.
6 changes: 2 additions & 4 deletions global/settings/types/preferencekeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================

#ifndef PREFERENCEKEYS_H
#define PREFERENCEKEYS_H
#pragma once

//
// Defines for all preferences
Expand Down Expand Up @@ -154,6 +153,7 @@
#define PREF_UI_APP_RASTER_VERTICAL "ui/application/raster/vertical"
#define PREF_UI_APP_SHOWSTATUSBAR "ui/application/showStatusBar"
#define PREF_UI_APP_USENATIVEDIALOGS "ui/application/useNativeDialogs"
#define PREF_UI_APP_USENEWWIZARD "ui/application/useNewWizard"
#define PREF_UI_PIANO_HIGHLIGHTCOLOR "ui/piano/highlightColor"
#define PREF_UI_PIANO_SHOWPITCHHELP "ui/piano/showPitchHelp"
#define PREF_UI_SCORE_NOTE_DROPCOLOR "ui/score/note/dropColor"
Expand Down Expand Up @@ -233,5 +233,3 @@
#define PREF_UI_AVSOMR_RECOGNITION_COLOR "ui/avsomr/recognition/valid/color"
#define PREF_UI_AVSOMR_NOT_RECOGNITION_COLOR "ui/avsomr/recognition/notValid/color"
#endif

#endif // PREFERENCEKEYS_H
11 changes: 6 additions & 5 deletions mscore/exportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ ExportDialog::ExportDialog(Score* s, QWidget* parent)
// Source: https://stackoverflow.com/a/38915478
QStandardItemModel* fileTypeComboBoxModel = qobject_cast<QStandardItemModel*>(fileTypeComboBox->model());
Q_ASSERT(fileTypeComboBoxModel != nullptr);
QStandardItem* audioItem;
# ifndef USE_LAME
// Disable .mp3 option if unavailable
QStandardItem* mp3Item = fileTypeComboBoxModel->item(3);
audioItem = fileTypeComboBoxModel->item(3);
mp3Item->setFlags(audioItem->flags() & ~Qt::ItemIsEnabled);
# endif
# ifndef HAS_AUDIOFILE
// Disable .wav, .flac and .ogg options if unavailable
for (int i = 4; i < 7; i++) {
QStandardItem* audioItem = fileTypeComboBoxModel->item(i);
audioItem = fileTypeComboBoxModel->item(i);
audioItem->setFlags(audioItem->flags() & ~Qt::ItemIsEnabled);
}
# endif
Expand Down Expand Up @@ -221,7 +222,7 @@ void ExportDialog::loadScoreAndPartsList()
ExportScoreItem* scoreItem = new ExportScoreItem(cs->masterScore()->score());
listWidget->addItem(scoreItem);

for (Excerpt* e : cs->masterScore()->excerpts()) {
for (Excerpt*& e : cs->masterScore()->excerpts()) {
Score* s = e->partScore();
ExportScoreItem* item = new ExportScoreItem(s);
item->setChecked(s == cs);
Expand Down Expand Up @@ -527,13 +528,13 @@ void ExportDialog::accept()
// Export the selected scores as separate files, appending the part names to the filename
SaveReplacePolicy replacePolicy = SaveReplacePolicy::NO_CHOICE;

for (Score* score : scores) {
for (Score*& score : scores) {
QString definitiveFilename = QString("%1/%2%3.%4")
.arg(fileinfo.absolutePath(),
fileinfo.completeBaseName(),
score->isMaster() ? "" : "-" + mscore->saveFilename(score->title()),
suffix);
if (saveFormat != "png" && saveFormat != "svg" && QFileInfo(definitiveFilename).exists()) {
if (saveFormat != "png" && saveFormat != "svg" && QFileInfo::exists(definitiveFilename)) {
// Png and Svg export functions change the filename, so they
// are responsible for asking the user about overwriting.
switch (replacePolicy) {
Expand Down
7 changes: 4 additions & 3 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,9 @@ MasterScore* MuseScore::getNewFile()
newWizard->updateValues();
newWizard->restart();
}
if (newWizard->exec() != QDialog::Accepted)
return 0;
if(preferences.getBool(PREF_UI_APP_USENEWWIZARD))
if (newWizard->exec() != QDialog::Accepted)
return 0;
int measures = newWizard->measures();
Fraction timesig = newWizard->timesig();
TimeSigType timesigType = newWizard->timesigType();
Expand All @@ -654,7 +655,7 @@ MasterScore* MuseScore::getNewFile()
QString tp = newWizard->templatePath();

QList<Excerpt*> excerpts;
if (!newWizard->emptyScore()) {
if (!preferences.getBool(PREF_UI_APP_USENEWWIZARD) || !newWizard->emptyScore()) {
MasterScore* tscore = new MasterScore(MScore::defaultStyle());
tscore->setCreated(true);
Score::FileError rv = Ms::readScore(tscore, tp, false);
Expand Down
1 change: 1 addition & 0 deletions mscore/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ void Preferences::init(bool storeInMemoryOnly)
#else // don't use system native file dialog, this is causing issues on some Linuxes
{PREF_UI_APP_USENATIVEDIALOGS, new BoolPreference(false)},
#endif
{PREF_UI_APP_USENEWWIZARD, new BoolPreference(true)},
{PREF_UI_PIANO_HIGHLIGHTCOLOR, new ColorPreference(QColor(0x0065BF))},
{PREF_UI_PIANO_SHOWPITCHHELP, new BoolPreference(true)},
{PREF_UI_SCORE_NOTE_DROPCOLOR, new ColorPreference(QColor(0x0065BF))},
Expand Down
69 changes: 39 additions & 30 deletions mscore/prefsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@
//=============================================================================

#include "musescore.h"
#include "timeline.h"
#include "pathlistdialog.h"
#include "preferences.h"
#include "prefsdialog.h"
#include "resourceManager.h"
#include "seq.h"
#include "shortcutcapturedialog.h"
#include "scoreview.h"
#include "shortcut.h"
#include "shortcutcapturedialog.h"
#include "timeline.h"
#include "workspace.h"

#include "audio/drivers/pa.h"
#ifdef USE_PORTMIDI
#include "audio/drivers/pm.h"
#endif

#include "pathlistdialog.h"
#include "resourceManager.h"

#ifdef AVSOMR
#include "avsomr/avsomrlocal.h"
#endif
Expand Down Expand Up @@ -246,7 +245,11 @@ PreferenceDialog::PreferenceDialog(QWidget* parent)
recordButtons->addButton(recordEditMode, RMIDI_NOTE_EDIT_MODE);
recordButtons->addButton(recordRealtimeAdvance, RMIDI_REALTIME_ADVANCE);

#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(recordButtons, QOverload<int>::of(&QButtonGroup::idClicked), this, &PreferenceDialog::recordButtonClicked);
#else
connect(recordButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &PreferenceDialog::recordButtonClicked);
#endif
connect(midiRemoteControlClear, &QToolButton::clicked, this, &PreferenceDialog::midiRemoteControlClearClicked);
connect(portaudioDriver, &QGroupBox::toggled, this, &PreferenceDialog::exclusiveAudioDriver);
connect(pulseaudioDriver, &QGroupBox::toggled, this, &PreferenceDialog::exclusiveAudioDriver);
Expand Down Expand Up @@ -501,23 +504,25 @@ void PreferenceDialog::start()
audioRelatedWidgets = std::vector<PreferenceItem*>{
new BoolPreferenceItem(PREF_IO_ALSA_USEALSAAUDIO, alsaDriver, doNothing),
new BoolPreferenceItem(PREF_IO_JACK_USEJACKAUDIO, useJackAudio, doNothing),
#ifdef USE_PORTAUDIO
new BoolPreferenceItem(PREF_IO_PORTAUDIO_USEPORTAUDIO, portaudioDriver, doNothing),
#endif
new BoolPreferenceItem(PREF_IO_PULSEAUDIO_USEPULSEAUDIO, pulseaudioDriver, doNothing),
new BoolPreferenceItem(PREF_IO_JACK_USEJACKMIDI, useJackMidi, doNothing),
new BoolPreferenceItem(PREF_IO_JACK_USEJACKTRANSPORT, useJackTransport, doNothing),
new BoolPreferenceItem(PREF_IO_JACK_TIMEBASEMASTER, becomeTimebaseMaster, doNothing),
new BoolPreferenceItem(PREF_IO_JACK_REMEMBERLASTCONNECTIONS, rememberLastMidiConnections, doNothing),
#ifdef USE_ALSA
#ifdef USE_ALSA
new StringPreferenceItem(PREF_IO_ALSA_DEVICE, alsaDevice, doNothing),
new IntPreferenceItem(PREF_IO_ALSA_SAMPLERATE, alsaSampleRate, doNothing),
new IntPreferenceItem(PREF_IO_ALSA_PERIODSIZE, alsaPeriodSize, doNothing),
new IntPreferenceItem(PREF_IO_ALSA_FRAGMENTS, alsaFragments, doNothing),
#endif
#ifdef USE_PORTAUDIO
#endif
#ifdef USE_PORTAUDIO
new IntPreferenceItem(PREF_IO_PORTAUDIO_DEVICE, portaudioApi, doNothing, doNothing),
new IntPreferenceItem(PREF_IO_PORTAUDIO_DEVICE, portaudioDevice, doNothing, doNothing),
#endif
#ifdef USE_PORTMIDI
#endif
#ifdef USE_PORTMIDI
new StringPreferenceItem(PREF_IO_PORTMIDI_INPUTDEVICE, portMidiInput, doNothing, doNothing),
new StringPreferenceItem(PREF_IO_PORTMIDI_OUTPUTDEVICE, portMidiOutput, doNothing, doNothing),
new IntPreferenceItem(PREF_IO_PORTMIDI_OUTPUTLATENCYMILLISECONDS, portMidiOutputLatencyMilliseconds),
Expand Down Expand Up @@ -593,7 +598,7 @@ void PreferenceDialog::hideEvent(QHideEvent* ev)

void PreferenceDialog::recordButtonClicked(int val)
{
for (QAbstractButton* b : recordButtons->buttons()) {
for (QAbstractButton*& b : recordButtons->buttons()) {
b->setChecked(recordButtons->id(b) == val);
}
mscore->setMidiRecordId(val);
Expand Down Expand Up @@ -795,7 +800,7 @@ bool ShortcutItem::operator<(const QTreeWidgetItem& item) const
void PreferenceDialog::updateSCListView()
{
shortcutList->clear();
for (Shortcut* s : localShortcuts) {
for (Shortcut*& s : localShortcuts) {
if (!s)
continue;
ShortcutItem* newItem = new ShortcutItem;
Expand All @@ -805,7 +810,7 @@ void PreferenceDialog::updateSCListView()
newItem->setText(1, s->keysToString());
newItem->setData(0, Qt::UserRole, s->key());
QString accessibleInfo = tr("Action: %1; Shortcut: %2")
.arg(newItem->text(0)).arg(newItem->text(1).isEmpty()
.arg(newItem->text(0), newItem->text(1).isEmpty()
? tr("No shortcut defined") : newItem->text(1));
newItem->setData(0, Qt::AccessibleTextRole, accessibleInfo);
newItem->setData(1, Qt::AccessibleTextRole, accessibleInfo);
Expand Down Expand Up @@ -925,7 +930,7 @@ void PreferenceDialog::filterAdvancedPreferences(const QString& query)
void PreferenceDialog::resetAdvancedPreferenceToDefault()
{
preferences.setReturnDefaultValuesMode(true);
for (QTreeWidgetItem* item : advancedWidget->selectedItems()) {
for (QTreeWidgetItem*& item : advancedWidget->selectedItems()) {
PreferenceItem* pref = static_cast<PreferenceItem*>(item);
pref->setDefaultValue();
}
Expand Down Expand Up @@ -1170,7 +1175,7 @@ void PreferenceDialog::updateCharsetListGP()
std::sort(charsets.begin(), charsets.end());
int idx = 0;
importCharsetListGP->clear();
for (QByteArray charset : charsets) {
for (QByteArray& charset : charsets) {
importCharsetListGP->addItem(charset);
if (charset == preferences.getString(PREF_IMPORT_GUITARPRO_CHARSET))
importCharsetListGP->setCurrentIndex(idx);
Expand All @@ -1188,7 +1193,7 @@ void PreferenceDialog::updateCharsetListOve()
std::sort(charsets.begin(), charsets.end());
int idx = 0;
importCharsetListOve->clear();
for (QByteArray charset : charsets) {
for (QByteArray& charset : charsets) {
importCharsetListOve->addItem(charset);
if (charset == preferences.getString(PREF_IMPORT_OVERTURE_CHARSET))
importCharsetListOve->setCurrentIndex(idx);
Expand Down Expand Up @@ -1230,9 +1235,9 @@ void PreferenceDialog::applyPageVertical()
const auto cv = mscore->currentScoreView();
preferences.setPreference(PREF_UI_CANVAS_SCROLL_VERTICALORIENTATION, pageVertical->isChecked());
MScore::setVerticalOrientation(pageVertical->isChecked());
for (Score* s : mscore->scores()) {
for (Score* s : qAsConst(mscore->scores())) {
s->doLayout();
for (Score* ss : s->scoreList())
for (Score*& ss : s->scoreList())
ss->doLayout();
}
if (cv)
Expand Down Expand Up @@ -1375,7 +1380,7 @@ void PreferenceDialog::apply()
buttonBox->repaint();

std::vector<QString> changedAdvancedProperties = advancedWidget->save();
for (auto x : changedAdvancedProperties)
for (auto& x : changedAdvancedProperties)
if (x.startsWith("ui"))
uiStyleThemeChanged = true;

Expand Down Expand Up @@ -1426,35 +1431,39 @@ void PreferenceDialog::apply()
else if (
(wasJack != nowJack)
|| (preferences.getBool(PREF_IO_ALSA_USEALSAAUDIO) != alsaDriver->isChecked())
#ifdef USE_PORTAUDIO
|| (preferences.getBool(PREF_IO_PORTAUDIO_USEPORTAUDIO) != portaudioDriver->isChecked())
#endif
|| (preferences.getBool(PREF_IO_PULSEAUDIO_USEPULSEAUDIO) != pulseaudioDriver->isChecked())
#ifdef USE_ALSA
#ifdef USE_ALSA
|| (preferences.getString(PREF_IO_ALSA_DEVICE) != alsaDevice->text())
|| (preferences.getInt(PREF_IO_ALSA_SAMPLERATE) != alsaSampleRate->currentData().toInt())
|| (preferences.getInt(PREF_IO_ALSA_PERIODSIZE) != alsaPeriodSize->currentData().toInt())
|| (preferences.getInt(PREF_IO_ALSA_FRAGMENTS) != alsaFragments->value())
#endif
#endif
) {
preferences.setPreference(PREF_IO_ALSA_USEALSAAUDIO, alsaDriver->isChecked());
#ifdef USE_PORTAUDIO
preferences.setPreference(PREF_IO_PORTAUDIO_USEPORTAUDIO, portaudioDriver->isChecked());
#endif
preferences.setPreference(PREF_IO_PULSEAUDIO_USEPULSEAUDIO, pulseaudioDriver->isChecked());
#ifdef USE_ALSA
#ifdef USE_ALSA
preferences.setPreference(PREF_IO_ALSA_DEVICE, alsaDevice->text());
preferences.setPreference(PREF_IO_ALSA_SAMPLERATE, alsaSampleRate->currentData().toInt());
preferences.setPreference(PREF_IO_ALSA_PERIODSIZE, alsaPeriodSize->currentData().toInt());
preferences.setPreference(PREF_IO_ALSA_FRAGMENTS, alsaFragments->value());
#endif
#endif

restartAudioEngine();
}
#ifdef USE_PORTAUDIO
#ifdef USE_PORTAUDIO
if (portAudioIsUsed && !noSeq) {
Portaudio* audio = static_cast<Portaudio*>(seq->driver());
preferences.setPreference(PREF_IO_PORTAUDIO_DEVICE, audio->deviceIndex(portaudioApi->currentIndex(), portaudioDevice->currentIndex()));
}
#endif
#endif

#ifdef USE_PORTMIDI
#ifdef USE_PORTMIDI
preferences.setPreference(PREF_IO_PORTMIDI_INPUTDEVICE, portMidiInput->currentText());
preferences.setPreference(PREF_IO_PORTMIDI_OUTPUTDEVICE, portMidiOutput->currentText());
preferences.setPreference(PREF_IO_PORTMIDI_OUTPUTLATENCYMILLISECONDS, portMidiOutputLatencyMilliseconds->value());
Expand All @@ -1465,12 +1474,12 @@ void PreferenceDialog::apply()
msgBox.setText(tr("Warning: You used the same CoreMIDI IAC bus for input and output. This will cause problematic loopback, whereby MuseScore's output MIDI messages will be sent back to MuseScore as input, causing confusion. To avoid this problem, access Audio MIDI Setup via Spotlight to create a dedicated virtual port for MuseScore's MIDI output, restart MuseScore, return to Preferences, and select your new virtual port for MuseScore's MIDI output. Other programs may then use that dedicated virtual port to receive MuseScore's MIDI output."));
msgBox.exec();
}
#endif
#endif
}

if (shortcutsChanged) {
shortcutsChanged = false;
for(const Shortcut* s : localShortcuts) {
for(Shortcut*& s : localShortcuts) {
Shortcut* os = Shortcut::getShortcut(s->key());
if (os) {
if (!os->compareKeys(*s))
Expand All @@ -1488,7 +1497,7 @@ void PreferenceDialog::apply()
}

emit preferencesChanged(false, uiStyleThemeChanged);
uiStyleThemeChanged = false;
//uiStyleThemeChanged = false;
preferences.save();
mscore->startAutoSave();

Expand Down Expand Up @@ -1890,7 +1899,7 @@ void PreferenceDialog::updateShortestNote()

void PreferenceDialog::applyShortestNote()
{
int ticks = MScore::division / 4;
int ticks;
switch (shortestNote->currentIndex()) {
case 0: ticks = MScore::division; break;
case 1: ticks = MScore::division / 2; break;
Expand Down
4 changes: 4 additions & 0 deletions mscore/seq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,17 @@ void Seq::setScoreView(ScoreView* v)

void Seq::CachedPreferences::update()
{
#ifdef USE_PORTMIDI
portMidiOutputLatencyMilliseconds = preferences.getInt(PREF_IO_PORTMIDI_OUTPUTLATENCYMILLISECONDS);
#endif
jackTimeBaseMaster = preferences.getBool(PREF_IO_JACK_TIMEBASEMASTER);
useJackTransport = preferences.getBool(PREF_IO_JACK_USEJACKTRANSPORT);
useJackMidi = preferences.getBool(PREF_IO_JACK_USEJACKMIDI);
useJackAudio = preferences.getBool(PREF_IO_JACK_USEJACKAUDIO);
useAlsaAudio = preferences.getBool(PREF_IO_ALSA_USEALSAAUDIO);
#ifdef USE_PORTAUDIO
usePortAudio = preferences.getBool(PREF_IO_PORTAUDIO_USEPORTAUDIO);
#endif
usePulseAudio = preferences.getBool(PREF_IO_PULSEAUDIO_USEPULSEAUDIO);
}

Expand Down

0 comments on commit 680897e

Please sign in to comment.