Skip to content

Commit

Permalink
fixed fixed updating scores after resettings style values to default
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPudashkin authored and vpereverzev committed Dec 29, 2020
1 parent aa8461f commit 5988206
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 47 deletions.
46 changes: 22 additions & 24 deletions mscore/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ void EditStyle::showEvent(QShowEvent* ev)
scrollArea->setWidgetResizable(true);
hasShown = true; // so that it only happens once
}
loadValuesFromStyle(cs->style());
setValues();
pageList->setFocus();
cs->startCmd();
buttonApplyToAllParts->setEnabled(!cs->isMaster());
Expand All @@ -990,11 +990,6 @@ void EditStyle::buttonClicked(QAbstractButton* b)
switch (buttonBox->standardButton(b)) {
case QDialogButtonBox::Ok:
done(1);

if (needResetStyle) {
resetStyle(cs);
}

cs->endCmd();
break;
case QDialogButtonBox::Cancel:
Expand Down Expand Up @@ -1039,7 +1034,9 @@ void EditStyle::on_buttonTogglePagelist_clicked()
void EditStyle::on_resetStylesButton_clicked()
{
needResetStyle = true;
loadValuesFromStyle(MScore::defaultStyle());
resetStyle(cs);
cs->update();
setValues();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1169,15 +1166,16 @@ QVariant EditStyle::getValue(Sid idx)
// setValues
//---------------------------------------------------------

void EditStyle::loadValuesFromStyle(const MStyle& sourceStyle)
void EditStyle::setValues()
{
const MStyle& lstyle = cs->style();
for (const StyleWidget& sw : styleWidgets) {
if (sw.widget)
sw.widget->blockSignals(true);
QVariant val = sourceStyle.value(sw.idx);
QVariant val = lstyle.value(sw.idx);
const char* type = MStyle::valueType(sw.idx);
if (sw.reset)
sw.reset->setEnabled(!sourceStyle.isDefault(sw.idx));
sw.reset->setEnabled(!lstyle.isDefault(sw.idx));

if (!strcmp("Ms::Spatium", type)) {
if (sw.showPercent)
Expand Down Expand Up @@ -1274,7 +1272,7 @@ void EditStyle::loadValuesFromStyle(const MStyle& sourceStyle)

//TODO: convert the rest:

QString unit(sourceStyle.value(Sid::swingUnit).toString());
QString unit(lstyle.value(Sid::swingUnit).toString());

if (unit == TDuration(TDuration::DurationType::V_EIGHTH).name()) {
swingEighth->setChecked(true);
Expand All @@ -1288,9 +1286,9 @@ void EditStyle::loadValuesFromStyle(const MStyle& sourceStyle)
swingOff->setChecked(true);
swingBox->setEnabled(false);
}
QString s(sourceStyle.value(Sid::chordDescriptionFile).toString());
QString s(lstyle.value(Sid::chordDescriptionFile).toString());
chordDescriptionFile->setText(s);
QString cstyle(sourceStyle.value(Sid::chordStyle).toString());
QString cstyle(lstyle.value(Sid::chordStyle).toString());
if (cstyle == "std") {
chordsStandard->setChecked(true);
chordDescriptionGroup->setEnabled(false);
Expand All @@ -1307,15 +1305,15 @@ void EditStyle::loadValuesFromStyle(const MStyle& sourceStyle)

// figured bass
for (int i = 0; i < comboFBFont->count(); i++)
if (comboFBFont->itemText(i) == sourceStyle.value(Sid::figuredBassFontFamily).toString()) {
if (comboFBFont->itemText(i) == lstyle.value(Sid::figuredBassFontFamily).toString()) {
comboFBFont->setCurrentIndex(i);
break;
}
doubleSpinFBSize->setValue(sourceStyle.value(Sid::figuredBassFontSize).toDouble());
doubleSpinFBVertPos->setValue(sourceStyle.value(Sid::figuredBassYOffset).toDouble());
spinFBLineHeight->setValue(sourceStyle.value(Sid::figuredBassLineHeight).toDouble() * 100.0);
doubleSpinFBSize->setValue(lstyle.value(Sid::figuredBassFontSize).toDouble());
doubleSpinFBVertPos->setValue(lstyle.value(Sid::figuredBassYOffset).toDouble());
spinFBLineHeight->setValue(lstyle.value(Sid::figuredBassLineHeight).toDouble() * 100.0);

QString mfont(sourceStyle.value(Sid::MusicalSymbolFont).toString());
QString mfont(lstyle.value(Sid::MusicalSymbolFont).toString());
int idx = 0;
for (const auto& i : ScoreFont::scoreFonts()) {
if (i.name().toLower() == mfont.toLower()) {
Expand All @@ -1334,14 +1332,14 @@ void EditStyle::loadValuesFromStyle(const MStyle& sourceStyle)
musicalTextFont->addItem("Gonville Text", "Gootville Text");
musicalTextFont->addItem("MuseJazz Text", "MuseJazz Text");
musicalTextFont->addItem("Petaluma Text", "Petaluma Text");
QString tfont(sourceStyle.value(Sid::MusicalTextFont).toString());
QString tfont(lstyle.value(Sid::MusicalTextFont).toString());
idx = musicalTextFont->findData(tfont);
musicalTextFont->setCurrentIndex(idx);
musicalTextFont->blockSignals(false);

toggleHeaderOddEven(sourceStyle.value(Sid::headerOddEven).toBool());
toggleFooterOddEven(sourceStyle.value(Sid::footerOddEven).toBool());
disableVerticalSpread->setChecked(!sourceStyle.value(Sid::enableVerticalSpread).toBool());
toggleHeaderOddEven(lstyle.value(Sid::headerOddEven).toBool());
toggleFooterOddEven(lstyle.value(Sid::footerOddEven).toBool());
disableVerticalSpread->setChecked(!lstyle.value(Sid::enableVerticalSpread).toBool());
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1625,7 +1623,7 @@ void EditStyle::valueChanged(int i)
cs->undo(new ChangeStyleVal(cs, idx, val));
cs->update();
if (setValue)
loadValuesFromStyle(cs->style());
setValues();
const StyleWidget& sw = styleWidget(idx);
if (sw.reset)
sw.reset->setEnabled(!cs->style().isDefault(idx));
Expand All @@ -1639,7 +1637,7 @@ void EditStyle::resetStyleValue(int i)
{
Sid idx = (Sid)i;
cs->undo(new ChangeStyleVal(cs, idx, MScore::defaultStyle().value(idx)));
loadValuesFromStyle(cs->style());
setValues();
cs->update();
}

Expand Down
2 changes: 1 addition & 1 deletion mscore/editstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class EditStyle : public QDialog, private Ui::EditStyleBase {
virtual void showEvent(QShowEvent*);
virtual void hideEvent(QHideEvent*);
QVariant getValue(Sid idx);
void loadValuesFromStyle(const MStyle& sourceStyle);
void setValues();

void resetStyle(Score* score);
void applyToAllParts();
Expand Down
14 changes: 7 additions & 7 deletions mscore/editstyle.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12372,13 +12372,6 @@ By default, they will be placed such as that their right end are at the same lev
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="resetStylesButton">
<property name="text">
<string>Reset All Styles to Default</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonTogglePagelist">
<property name="maximumSize">
Expand All @@ -12395,6 +12388,13 @@ By default, they will be placed such as that their right end are at the same lev
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetStylesButton">
<property name="text">
<string>Reset All Styles to Default</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
Expand Down
2 changes: 1 addition & 1 deletion mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void MuseScore::askAboutApplyingEdwinIfNeed(const QString& fileSuffix)
QPushButton* yesButton = dialog.addButton(QObject::tr("Apply Edwin"), QMessageBox::YesRole);
dialog.setDefaultButton(noButton);

QCheckBox askAgainCheckbox(QObject::tr("Remember my choise and don't ask again"));
QCheckBox askAgainCheckbox(QObject::tr("Remember my choice and don't ask again"));
dialog.setCheckBox(&askAgainCheckbox);

QObject::connect(&askAgainCheckbox, &QCheckBox::stateChanged, [this](int state) {
Expand Down
11 changes: 2 additions & 9 deletions mscore/pagesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ void PageSettings::setScore(Score* s)
updateValues();
updatePreview();
_changeFlag = false;
_needResetStyle = false;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -268,8 +267,8 @@ void PageSettings::orientationClicked()

void PageSettings::on_resetPageStyleButton_clicked()
{
_needResetStyle = true;
_changeFlag = true;
preview->score()->style().resetStyles(preview->score(), pageStyles());
updatePreview();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -324,12 +323,6 @@ void PageSettings::apply()

void PageSettings::applyToScore(Score* s)
{

if (_needResetStyle) {
s->style().resetStyles(s, pageStyles());
return;
}

double f = mmUnit ? 1.0/INCH : 1.0;
double f1 = mmUnit ? DPMM : DPI;

Expand Down
3 changes: 0 additions & 3 deletions mscore/pagesettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class PageSettings : public AbstractDialog, private Ui::PageSettingsBase {
bool _changeFlag = false;
Score* cs = nullptr;
Score* clonedScore = nullptr;
bool _needResetStyle = false;

// std::unique_ptr<Score> clonedScoreForNavigator;

virtual void hideEvent(QHideEvent*);
void updateValues();
Expand Down
8 changes: 7 additions & 1 deletion mscore/prefsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,12 @@ void PreferenceDialog::start()
new BoolPreferenceItem(PREF_EXPORT_PNG_USETRANSPARENCY, pngTransparent),
new BoolPreferenceItem(PREF_IMPORT_MUSICXML_IMPORTBREAKS, importBreaks),
new BoolPreferenceItem(PREF_IMPORT_MUSICXML_IMPORTLAYOUT, importLayout),
new BoolPreferenceItem(PREF_MIGRATION_APPLY_EDWIN_FOR_XML_FILES, applyDefaultTypeFaceToImportedScores),
new BoolPreferenceItem(PREF_MIGRATION_APPLY_EDWIN_FOR_XML_FILES, applyDefaultTypeFaceToImportedScores,
[this]() { preferences.setPreference(PREF_MIGRATION_APPLY_EDWIN_FOR_XML_FILES, applyDefaultTypeFaceToImportedScores->isChecked()); }, // apply function
[this]() {
bool value = preferences.getBool(PREF_MIGRATION_DO_NOT_ASK_ME_AGAIN_XML) && preferences.getBool(PREF_MIGRATION_APPLY_EDWIN_FOR_XML_FILES);
applyDefaultTypeFaceToImportedScores->setChecked(value);
}), // update function
#ifdef AVSOMR
new BoolPreferenceItem(PREF_IMPORT_AVSOMR_USELOCAL, useLocalAvsOmr, [&](){ updateUseLocalAvsOmr(); }),
#endif
Expand Down Expand Up @@ -376,6 +381,7 @@ void PreferenceDialog::start()
new BoolPreferenceItem(PREF_MIGRATION_DO_NOT_ASK_ME_AGAIN, scoreMigrationEnabled,
[this]() { preferences.setPreference(PREF_MIGRATION_DO_NOT_ASK_ME_AGAIN, !scoreMigrationEnabled->isChecked()); }, // apply function
[this]() { scoreMigrationEnabled->setChecked(!preferences.getBool(PREF_MIGRATION_DO_NOT_ASK_ME_AGAIN)); }), // update function
new BoolPreferenceItem(PREF_MIGRATION_DO_NOT_ASK_ME_AGAIN_XML),
new StringPreferenceItem(PREF_UI_APP_LANGUAGE, language, [&](){ languageApply(); }, [&](){ languageUpdate(); }),
new CustomPreferenceItem(PREF_APP_STARTUP_SESSIONSTART, lastSession,
[this]() { // apply function
Expand Down
2 changes: 1 addition & 1 deletion mscore/prefsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3386,7 +3386,7 @@ Adjusting latency can help synchronize your MIDI hardware with MuseScore's inter
<item>
<widget class="QCheckBox" name="applyDefaultTypeFaceToImportedScores">
<property name="text">
<string>Apply default typeface to imported scores</string>
<string>Apply default typeface (Edwin) to imported scores</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 5988206

Please sign in to comment.