Skip to content

Commit

Permalink
fix #276461: Custom text styles in previous versions of MS changed to…
Browse files Browse the repository at this point in the history
… User-1, User-2 etc.
  • Loading branch information
mattmcclinch committed Nov 2, 2018
1 parent c864dda commit 97a17e2
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 55 deletions.
3 changes: 3 additions & 0 deletions libmscore/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ void readTextStyle206(MStyle* style, XmlReader& e)
qDebug("unhandled substyle <%s>", qPrintable(name));
return;
}
int idx = int(ss) - int(Tid::USER1);
Sid sid[6] = { Sid::user1Name, Sid::user2Name, Sid::user3Name, Sid::user4Name, Sid::user5Name, Sid::user6Name };
style->set(sid[idx], name);
}

for (const auto& i : *textStyle(ss)) {
Expand Down
6 changes: 6 additions & 0 deletions libmscore/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ static const StyleType styleTypes[] {
{ Sid::figuredBassFontItalic, "figuredBassFontItalic", false },
{ Sid::figuredBassFontUnderline, "figuredBassFontUnderline", false },

{ Sid::user1Name, "user1Name", "" },
{ Sid::user1FontFace, "user1FontFace", "FreeSerif" },
{ Sid::user1FontSize, "user1FontSize", 10.0 },
{ Sid::user1FontBold, "user1FontBold", false },
Expand All @@ -864,6 +865,7 @@ static const StyleType styleTypes[] {
{ Sid::user1FrameFgColor, "user1FrameFgColor", QColor(0, 0, 0, 255) },
{ Sid::user1FrameBgColor, "user1FrameBgColor", QColor(255, 255, 255, 0) },

{ Sid::user2Name, "user2Name", "" },
{ Sid::user2FontFace, "user2FontFace", "FreeSerif" },
{ Sid::user2FontSize, "user2FontSize", 10.0 },
{ Sid::user2FontBold, "user2FontBold", false },
Expand All @@ -879,6 +881,7 @@ static const StyleType styleTypes[] {
{ Sid::user2FrameFgColor, "user2FrameFgColor", QColor(0, 0, 0, 255) },
{ Sid::user2FrameBgColor, "user2FrameBgColor", QColor(255, 255, 255, 0) },

{ Sid::user3Name, "user3Name", "" },
{ Sid::user3FontFace, "user3FontFace", "FreeSerif" },
{ Sid::user3FontSize, "user3FontSize", 10.0 },
{ Sid::user3FontBold, "user3FontBold", false },
Expand All @@ -894,6 +897,7 @@ static const StyleType styleTypes[] {
{ Sid::user3FrameFgColor, "user3FrameFgColor", QColor(0, 0, 0, 255) },
{ Sid::user3FrameBgColor, "user3FrameBgColor", QColor(255, 255, 255, 0) },

{ Sid::user4Name, "user4Name", "" },
{ Sid::user4FontFace, "user4FontFace", "FreeSerif" },
{ Sid::user4FontSize, "user4FontSize", 10.0 },
{ Sid::user4FontBold, "user4FontBold", false },
Expand All @@ -909,6 +913,7 @@ static const StyleType styleTypes[] {
{ Sid::user4FrameFgColor, "user4FrameFgColor", QColor(0, 0, 0, 255) },
{ Sid::user4FrameBgColor, "user4FrameBgColor", QColor(255, 255, 255, 0) },

{ Sid::user5Name, "user5Name", "" },
{ Sid::user5FontFace, "user5FontFace", "FreeSerif" },
{ Sid::user5FontSize, "user5FontSize", 10.0 },
{ Sid::user5FontBold, "user5FontBold", false },
Expand All @@ -924,6 +929,7 @@ static const StyleType styleTypes[] {
{ Sid::user5FrameFgColor, "user5FrameFgColor", QColor(0, 0, 0, 255) },
{ Sid::user5FrameBgColor, "user5FrameBgColor", QColor(255, 255, 255, 0) },

{ Sid::user6Name, "user6Name", "" },
{ Sid::user6FontFace, "user6FontFace", "FreeSerif" },
{ Sid::user6FontSize, "user6FontSize", 10.0 },
{ Sid::user6FontBold, "user6FontBold", false },
Expand Down
6 changes: 6 additions & 0 deletions libmscore/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ enum class Sid {
figuredBassFontItalic,
figuredBassFontUnderline,

user1Name,
user1FontFace,
user1FontSize,
user1FontBold,
Expand All @@ -846,6 +847,7 @@ enum class Sid {
user1FrameFgColor,
user1FrameBgColor,

user2Name,
user2FontFace,
user2FontSize,
user2FontBold,
Expand All @@ -861,6 +863,7 @@ enum class Sid {
user2FrameFgColor,
user2FrameBgColor,

user3Name,
user3FontFace,
user3FontSize,
user3FontBold,
Expand All @@ -876,6 +879,7 @@ enum class Sid {
user3FrameFgColor,
user3FrameBgColor,

user4Name,
user4FontFace,
user4FontSize,
user4FontBold,
Expand All @@ -891,6 +895,7 @@ enum class Sid {
user4FrameFgColor,
user4FrameBgColor,

user5Name,
user5FontFace,
user5FontSize,
user5FontBold,
Expand All @@ -906,6 +911,7 @@ enum class Sid {
user5FrameFgColor,
user5FrameBgColor,

user6Name,
user6FontFace,
user6FontSize,
user6FontBold,
Expand Down
54 changes: 48 additions & 6 deletions mscore/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,18 +614,32 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
Tid::TRANSLATOR,
Tid::HEADER,
Tid::FOOTER,
Tid::USER1,
Tid::USER2,
Tid::USER3,
Tid::USER4,
Tid::USER5,
Tid::USER6
} )
{
QListWidgetItem* item = new QListWidgetItem(textStyleUserName(ss));
item->setData(Qt::UserRole, int(ss));
textStyles->addItem(item);
}
struct {
Sid sid;
Tid tid;
} userStyles[] = {
{ Sid::user1Name, Tid::USER1 },
{ Sid::user2Name, Tid::USER2 },
{ Sid::user3Name, Tid::USER3 },
{ Sid::user4Name, Tid::USER4 },
{ Sid::user5Name, Tid::USER5 },
{ Sid::user6Name, Tid::USER6 }
};
for (auto user : userStyles)
{
QString name = s->styleSt(user.sid);
if (name == "")
name = textStyleUserName(user.tid);
QListWidgetItem* item = new QListWidgetItem(name);
item->setData(Qt::UserRole, int(user.tid));
textStyles->addItem(item);
}

// font face
resetTextStyleFontFace->setIcon(*icons[int(Icons::reset_ICON)]);
Expand Down Expand Up @@ -732,6 +746,7 @@ EditStyle::EditStyle(Score* s, QWidget* parent)
[=](){ textStyleValueChanged(Pid::FRAME_BG_COLOR, textStyleFrameBackground->color()); }
);

connect(styleName, SIGNAL(editingFinished()), SLOT(renameUserStyle()));
connect(textStyles, SIGNAL(currentRowChanged(int)), SLOT(textStyleChanged(int)));
textStyles->setCurrentRow(0);
MuseScore::restoreGeometry(this);
Expand Down Expand Up @@ -1366,6 +1381,19 @@ void EditStyle::textStyleChanged(int row)
break;
}
}
if (int(tid) >= int(Tid::USER1)) {
int idx = int(tid) - int(Tid::USER1);
Sid sid[] = { Sid::user1Name, Sid::user2Name, Sid::user3Name, Sid::user4Name, Sid::user5Name, Sid::user6Name };
QString name = cs->styleSt(sid[idx]);
if (name == "")
name = textStyleUserName(tid);
styleName->setText(name);
styleName->setEnabled(true);
}
else {
styleName->setText(textStyleUserName(tid));
styleName->setEnabled(false);
}
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1405,5 +1433,19 @@ void EditStyle::resetTextStyle(Pid pid)
textStyleChanged(textStyles->currentRow()); // update GUI
cs->update();
}

void EditStyle::renameUserStyle() {
int row = textStyles->currentRow();
Tid tid = Tid(textStyles->item(row)->data(Qt::UserRole).toInt());
int idx = int(tid) - int(Tid::USER1);
Sid sid[] = { Sid::user1Name, Sid::user2Name, Sid::user3Name, Sid::user4Name, Sid::user5Name, Sid::user6Name };
QString name = styleName->text();
cs->undoChangeStyleVal(sid[idx], name);
if (name == "")
name = textStyleUserName(tid);
textStyles->item(row)->setText(name);
cs->update();
}

}

1 change: 1 addition & 0 deletions mscore/editstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class EditStyle : public QDialog, private Ui::EditStyleBase {
void resetTextStyle(Pid);
void textStyleValueChanged(Pid, QVariant);
void on_comboFBFont_currentIndexChanged(int index);
void renameUserStyle();

public:
static const int PAGE_NOTE = 6;
Expand Down
Loading

0 comments on commit 97a17e2

Please sign in to comment.