Skip to content

Commit

Permalink
Fix #271505: Allow user to set mode along with key signature, part 2 …
Browse files Browse the repository at this point in the history
…WIP!

Make these availble to the UI, via the Key Signature Inspector.
  • Loading branch information
Jojo-Schmitz committed Apr 28, 2018
1 parent e631485 commit cec970d
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 42 deletions.
16 changes: 16 additions & 0 deletions libmscore/keysig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,15 @@ void KeySig::undoSetShowCourtesy(bool v)
undoChangeProperty(Pid::SHOW_COURTESY, v);
}

//---------------------------------------------------------
// undoSetMode
//---------------------------------------------------------

void KeySig::undoSetMode(KeyMode v)
{
undoChangeProperty(Pid::KEYSIG_MODE, int(v));
}

//---------------------------------------------------------
// getProperty
//---------------------------------------------------------
Expand All @@ -539,6 +548,7 @@ QVariant KeySig::getProperty(Pid propertyId) const
{
switch (propertyId) {
case Pid::SHOW_COURTESY: return int(showCourtesy());
case Pid::KEYSIG_MODE: return int(mode());
default:
return Element::getProperty(propertyId);
}
Expand All @@ -556,6 +566,11 @@ bool KeySig::setProperty(Pid propertyId, const QVariant& v)
return false;
setShowCourtesy(v.toBool());
break;
case Pid::KEYSIG_MODE:
if (generated())
return false;
//setMode(v); // no known conversion from 'const QVariant' to 'Ms::KeyMode'
break;
default:
if (!Element::setProperty(propertyId, v))
return false;
Expand All @@ -574,6 +589,7 @@ QVariant KeySig::propertyDefault(Pid id) const
{
switch (id) {
case Pid::SHOW_COURTESY: return true;
case Pid::KEYSIG_MODE: return int(KeyMode::UNKNOWN);
default:
return Element::propertyDefault(id);
}
Expand Down
4 changes: 4 additions & 0 deletions libmscore/keysig.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class KeySig final : public Element {
void setShowCourtesy(bool v) { _showCourtesy = v; }
void undoSetShowCourtesy(bool v);

KeyMode mode() const { return _sig.mode(); }
void setMode(KeyMode v) { _sig.setMode(v); }
void undoSetMode(KeyMode v);

void setHideNaturals(bool hide) { _hideNaturals = hide; }

QVariant getProperty(Pid propertyId) const;
Expand Down
3 changes: 2 additions & 1 deletion libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ struct PropertyMetaData {
static constexpr PropertyMetaData propertyList[] = {
{ Pid::SUBTYPE, "subtype", false, "subtype", P_TYPE::INT },
{ Pid::SELECTED, "selected", false, "selected", P_TYPE::BOOL },
{ Pid::GENERATED, "generated", false, "generated", P_TYPE::BOOL },
{ Pid::GENERATED, "generated", false, "generated", P_TYPE::BOOL },
{ Pid::COLOR, "color", false, "color", P_TYPE::COLOR },
{ Pid::VISIBLE, "visible", false, "visible", P_TYPE::BOOL },
{ Pid::Z, "z", false, "z", P_TYPE::INT },
{ Pid::SMALL, "small", false, "small", P_TYPE::BOOL },
{ Pid::SHOW_COURTESY, "show_courtesy", false, "showCourtesy", P_TYPE::INT },
{ Pid::KEYSIG_MODE, "keysig_mode", true, "mode", P_TYPE::KEYMODE },
{ Pid::LINE_TYPE, "line_type", false, "lineType", P_TYPE::INT },
{ Pid::PITCH, "pitch", true, "pitch", P_TYPE::INT },

Expand Down
4 changes: 3 additions & 1 deletion libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ enum class Pid {
Z,
SMALL,
SHOW_COURTESY,
KEYSIG_MODE,
LINE_TYPE,
PITCH,

Expand Down Expand Up @@ -362,12 +363,13 @@ enum class P_TYPE : char {
INT_LIST,
GLISSANDO_STYLE,
BARLINE_TYPE,
HEAD_TYPE, // enum class Notehead::Type
HEAD_TYPE, // enum class Notehead::Type
HEAD_GROUP, // enum class Notehead::Group
ZERO_INT, // displayed with offset +1
FONT,
SUB_STYLE,
ALIGN,
KEYMODE // enum class KeyMode
};

extern QVariant getProperty(Pid type, XmlReader& e);
Expand Down
6 changes: 5 additions & 1 deletion mscore/inspector/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ InspectorKeySig::InspectorKeySig(QWidget* parent)
{ Pid::LEADING_SPACE, 1, s.leadingSpace, s.resetLeadingSpace },
{ Pid::SHOW_COURTESY, 0, k.showCourtesy, k.resetShowCourtesy },
// { Pid::SHOW_NATURALS, 0, k.showNaturals, k.resetShowNaturals }
{ Pid::KEYSIG_MODE, 0, k.keysigMode, k.resetKeysigMode }
};
const std::vector<InspectorPanel> ppList = {
{ s.title, s.panel },
Expand All @@ -691,8 +692,11 @@ void InspectorKeySig::setElement()
{
InspectorElementBase::setElement();
KeySig* ks = toKeySig(inspector->element());
if (ks->generated())
if (ks->generated()) {
k.showCourtesy->setEnabled(false);
k.keysigModeLabel->setEnabled(false);
k.keysigMode->setEnabled(false);
}
}

//---------------------------------------------------------
Expand Down
20 changes: 12 additions & 8 deletions mscore/inspector/inspector_hairpin.ui
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,22 @@
</property>
<item>
<property name="text">
<string>Crescendo</string>
<string notr="true">Crescendo Hairpin</string>
</property>
</item>
<item>
<property name="text">
<string>Decrescendo</string>
<string notr="true">Decrescendo Hairpin</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Crescendo Line</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Decrescendo Line</string>
</property>
</item>
</widget>
Expand Down Expand Up @@ -358,9 +368,6 @@
<property name="text">
<string>Style:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="2">
Expand Down Expand Up @@ -415,9 +422,6 @@
<property name="text">
<string>Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>fontSize</cstring>
</property>
Expand Down
154 changes: 123 additions & 31 deletions mscore/inspector/inspector_keysig.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>127</width>
<height>69</height>
<width>219</width>
<height>99</height>
</rect>
</property>
<property name="accessibleName">
Expand Down Expand Up @@ -76,35 +76,125 @@
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="showCourtesy">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="accessibleName">
<string>Show courtesy</string>
</property>
<property name="text">
<string>Show courtesy</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="resetShowCourtesy">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="accessibleName">
<string>Reset 'Show courtesy' value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../musescore.qrc">
<normaloff>:/data/icons/edit-reset.svg</normaloff>:/data/icons/edit-reset.svg</iconset>
</property>
</widget>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="3">
<widget class="QToolButton" name="resetShowCourtesy">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="accessibleName">
<string>Reset 'Show courtesy' value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../musescore.qrc">
<normaloff>:/data/icons/edit-reset.svg</normaloff>:/data/icons/edit-reset.svg</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="keysigMode">
<item>
<property name="text">
<string>Unknown</string>
</property>
</item>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Major</string>
</property>
</item>
<item>
<property name="text">
<string>Minor</string>
</property>
</item>
<item>
<property name="text">
<string>Dorian</string>
</property>
</item>
<item>
<property name="text">
<string>Phrygian</string>
</property>
</item>
<item>
<property name="text">
<string>Lydian</string>
</property>
</item>
<item>
<property name="text">
<string>Mixolydian</string>
</property>
</item>
<item>
<property name="text">
<string>Aeolian</string>
</property>
</item>
<item>
<property name="text">
<string>Ionian</string>
</property>
</item>
<item>
<property name="text">
<string>Locrian</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="resetKeysigMode">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="accessibleName">
<string>Reset 'Mode type' value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../musescore.qrc">
<normaloff>:/data/icons/edit-reset.svg</normaloff>:/data/icons/edit-reset.svg</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="keysigModeLabel">
<property name="text">
<string>Key signature mode:</string>
</property>
<property name="buddy">
<cstring>keysigMode</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="showCourtesy">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="accessibleName">
<string>Show courtesy</string>
</property>
<property name="text">
<string>Show courtesy</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand All @@ -115,6 +205,8 @@
<tabstop>title</tabstop>
<tabstop>showCourtesy</tabstop>
<tabstop>resetShowCourtesy</tabstop>
<tabstop>keysigMode</tabstop>
<tabstop>resetKeysigMode</tabstop>
</tabstops>
<resources>
<include location="../musescore.qrc"/>
Expand Down

0 comments on commit cec970d

Please sign in to comment.