fix #24505: text in inspector

This commit is contained in:
Marc Sabatella 2014-04-17 22:59:30 -06:00
parent d023cf118c
commit ff4b089486
9 changed files with 208 additions and 33 deletions

View file

@ -1887,8 +1887,8 @@ void Text::writeProperties(Xml& xml, bool writeText, bool writeStyle) const
{
Element::writeProperties(xml);
if (writeStyle) {
if (getProperty(P_TEXT_STYLE_TYPE) != propertyDefault(P_TEXT_STYLE_TYPE))
xml.tag("style", textStyle().name());
// if (getProperty(P_TEXT_STYLE_TYPE) != propertyDefault(P_TEXT_STYLE_TYPE))
xml.tag("style", textStyle().name());
_textStyle.writeProperties(xml, score()->textStyle(_styleIndex));
}
if (writeText)
@ -2120,6 +2120,43 @@ bool Text::setProperty(P_ID propertyId, const QVariant& v)
return rv;
}
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
QVariant Text::propertyDefault(P_ID id) const
{
int idx;
switch (type()) {
case DYNAMIC: idx = TEXT_STYLE_DYNAMICS; break;
case FIGURED_BASS: idx = TEXT_STYLE_FIGURED_BASS; break;
case FINGERING: idx = TEXT_STYLE_FINGERING; break;
case HARMONY: idx = TEXT_STYLE_HARMONY; break;
case INSTRUMENT_CHANGE: idx = TEXT_STYLE_INSTRUMENT_CHANGE; break;
// case INSTRUMENT_NAME: would need to differentiate long & short
// probably best handle this with another override
case JUMP: idx = TEXT_STYLE_REPEAT; break;
case LYRICS: idx = TEXT_STYLE_LYRIC1; break;
case MARKER: idx = TEXT_STYLE_REPEAT; break;
case REHEARSAL_MARK: idx = TEXT_STYLE_REHEARSAL_MARK; break;
case STAFF_TEXT: idx = TEXT_STYLE_STAFF; break;
case TEMPO_TEXT: idx = TEXT_STYLE_TEMPO; break;
default:
// if we cannot determine type, give up
return QVariant();
}
switch (id) {
case P_TEXT_STYLE_TYPE:
return idx;
case P_TEXT_STYLE:
return score()->textStyle(idx).name();
case P_TEXT:
return QString("");
default:
return Element::propertyDefault(id);
}
}
//---------------------------------------------------------
// paste
//---------------------------------------------------------

View file

@ -292,6 +292,7 @@ class Text : public Element {
QVariant getProperty(P_ID propertyId) const;
bool setProperty(P_ID propertyId, const QVariant& v);
virtual QVariant propertyDefault(P_ID id) const;
virtual bool acceptDrop(MuseScoreView*, const QPointF&, Element*) const override;
virtual Element* drop(const DropData&) override;

View file

@ -226,7 +226,10 @@ void Inspector::setElements(const QList<Element*>& l)
ie = new InspectorAmbitus(this);
break;
default:
ie = new InspectorElement(this);
if (_element->isText())
ie = new InspectorText(this);
else
ie = new InspectorElement(this);
break;
}
}
@ -535,6 +538,47 @@ void InspectorClef::valueChanged(int idx)
InspectorBase::valueChanged(idx);
}
//---------------------------------------------------------
// InspectorText
//---------------------------------------------------------
InspectorText::InspectorText(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
t.setupUi(addWidget());
iList = {
{ P_COLOR, 0, 0, e.color, e.resetColor },
{ P_VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle }
};
mapSignals();
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void InspectorText::setElement()
{
Element* e = inspector->element();
Score* score = e->score();
t.style->blockSignals(true);
t.style->clear();
const QList<TextStyle>& ts = score->style()->textStyles();
int n = ts.size();
for (int i = 0; i < n; ++i) {
if (!(ts.at(i).hidden() & TextStyle::HIDE_IN_LISTS) )
t.style->addItem(ts.at(i).name(), i);
}
t.style->blockSignals(false);
InspectorBase::setElement();
}
//---------------------------------------------------------
// InspectorTempoText
//---------------------------------------------------------
@ -544,17 +588,40 @@ InspectorTempoText::InspectorTempoText(QWidget* parent)
{
e.setupUi(addWidget());
t.setupUi(addWidget());
tt.setupUi(addWidget());
iList = {
{ P_COLOR, 0, 0, e.color, e.resetColor },
{ P_VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_TEMPO, 0, 0, t.tempo, t.resetTempo },
{ P_TEMPO_FOLLOW_TEXT, 0, 0, t.followText, t.resetFollowText }
{ P_COLOR, 0, 0, e.color, e.resetColor },
{ P_VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle },
{ P_TEMPO, 0, 0, tt.tempo, tt.resetTempo },
{ P_TEMPO_FOLLOW_TEXT, 0, 0, tt.followText, tt.resetFollowText }
};
mapSignals();
connect(t.followText, SIGNAL(toggled(bool)), t.tempo, SLOT(setDisabled(bool)));
connect(tt.followText, SIGNAL(toggled(bool)), tt.tempo, SLOT(setDisabled(bool)));
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void InspectorTempoText::setElement()
{
Element* e = inspector->element();
Score* score = e->score();
t.style->blockSignals(true);
t.style->clear();
const QList<TextStyle>& ts = score->style()->textStyles();
int n = ts.size();
for (int i = 0; i < n; ++i) {
if (!(ts.at(i).hidden() & TextStyle::HIDE_IN_LISTS) )
t.style->addItem(ts.at(i).name(), i);
}
t.style->blockSignals(false);
InspectorBase::setElement();
}
//---------------------------------------------------------
@ -563,7 +630,7 @@ InspectorTempoText::InspectorTempoText(QWidget* parent)
void InspectorTempoText::postInit()
{
t.tempo->setDisabled(t.followText->isChecked());
tt.tempo->setDisabled(tt.followText->isChecked());
}
//---------------------------------------------------------
@ -578,13 +645,13 @@ InspectorDynamic::InspectorDynamic(QWidget* parent)
d.setupUi(addWidget());
iList = {
{ P_COLOR, 0, 0, e.color, e.resetColor },
{ P_VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_TEXT_STYLE, 0, 0, t.style, t.resetStyle },
{ P_DYNAMIC_RANGE, 0, 0, d.dynRange, d.resetDynRange },
{ P_VELOCITY, 0, 0, d.velocity, d.resetVelocity }
{ P_COLOR, 0, 0, e.color, e.resetColor },
{ P_VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle },
{ P_DYNAMIC_RANGE, 0, 0, d.dynRange, d.resetDynRange },
{ P_VELOCITY, 0, 0, d.velocity, d.resetVelocity }
};
mapSignals();
}

View file

@ -206,6 +206,21 @@ class InspectorAccidental : public InspectorBase {
InspectorAccidental(QWidget* parent);
};
//---------------------------------------------------------
// InspectorText
//---------------------------------------------------------
class InspectorText : public InspectorBase {
Q_OBJECT
UiInspectorElement e;
Ui::InspectorText t;
public:
InspectorText(QWidget* parent);
virtual void setElement() override;
};
//---------------------------------------------------------
// InspectorTempoText
//---------------------------------------------------------
@ -214,10 +229,12 @@ class InspectorTempoText : public InspectorBase {
Q_OBJECT
UiInspectorElement e;
Ui::InspectorTempoText t;
Ui::InspectorText t;
Ui::InspectorTempoText tt;
public:
InspectorTempoText(QWidget* parent);
virtual void setElement() override;
virtual void postInit();
};

View file

@ -390,6 +390,8 @@ void InspectorBase::resetClicked(int i)
for (int i = 0; i < ii.parent; ++i)
e = e->parent();
QVariant def = e->propertyDefault(id);
if (!def.isValid())
return;
QWidget* w = ii.w;
blockSignals = true;

View file

@ -25,19 +25,42 @@ InspectorJump::InspectorJump(QWidget* parent)
: InspectorBase(parent)
{
b.setupUi(addWidget());
t.setupUi(addWidget());
j.setupUi(addWidget());
iList = {
{ P_COLOR, 0, false, b.color, b.resetColor },
{ P_VISIBLE, 0, false, b.visible, b.resetVisible },
{ P_USER_OFF, 0, false, b.offsetX, b.resetX },
{ P_USER_OFF, 1, false, b.offsetY, b.resetY },
{ P_JUMP_TO, 0, false, j.jumpTo, j.resetJumpTo },
{ P_PLAY_UNTIL, 0, false, j.playUntil, j.resetPlayUntil },
{ P_CONTINUE_AT, 0, false, j.continueAt, j.resetContinueAt }
{ P_COLOR, 0, false, b.color, b.resetColor },
{ P_VISIBLE, 0, false, b.visible, b.resetVisible },
{ P_USER_OFF, 0, false, b.offsetX, b.resetX },
{ P_USER_OFF, 1, false, b.offsetY, b.resetY },
{ P_TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle },
{ P_JUMP_TO, 0, false, j.jumpTo, j.resetJumpTo },
{ P_PLAY_UNTIL, 0, false, j.playUntil, j.resetPlayUntil },
{ P_CONTINUE_AT, 0, false, j.continueAt, j.resetContinueAt }
};
mapSignals();
}
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void InspectorJump::setElement()
{
Element* e = inspector->element();
Score* score = e->score();
t.style->blockSignals(true);
t.style->clear();
const QList<TextStyle>& ts = score->style()->textStyles();
int n = ts.size();
for (int i = 0; i < n; ++i) {
if (!(ts.at(i).hidden() & TextStyle::HIDE_IN_LISTS) )
t.style->addItem(ts.at(i).name(), i);
}
t.style->blockSignals(false);
InspectorBase::setElement();
}
}

View file

@ -28,10 +28,12 @@ class InspectorJump : public InspectorBase {
Q_OBJECT
UiInspectorElement b;
Ui::InspectorText t;
Ui::InspectorJump j;
public:
InspectorJump(QWidget* parent);
virtual void setElement() override;
};

View file

@ -25,18 +25,42 @@ InspectorMarker::InspectorMarker(QWidget* parent)
: InspectorBase(parent)
{
b.setupUi(addWidget());
t.setupUi(addWidget());
m.setupUi(addWidget());
iList = {
{ P_COLOR, 0, false, b.color, b.resetColor },
{ P_VISIBLE, 0, false, b.visible, b.resetVisible },
{ P_USER_OFF, 0, false, b.offsetX, b.resetX },
{ P_USER_OFF, 1, false, b.offsetY, b.resetY },
{ P_MARKER_TYPE, 0, false, m.markerType, m.resetMarkerType },
{ P_LABEL, 0, false, m.jumpLabel, m.resetJumpLabel },
{ P_COLOR, 0, false, b.color, b.resetColor },
{ P_VISIBLE, 0, false, b.visible, b.resetVisible },
{ P_USER_OFF, 0, false, b.offsetX, b.resetX },
{ P_USER_OFF, 1, false, b.offsetY, b.resetY },
{ P_TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle },
{ P_MARKER_TYPE, 0, false, m.markerType, m.resetMarkerType },
{ P_LABEL, 0, false, m.jumpLabel, m.resetJumpLabel }
};
mapSignals();
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void InspectorMarker::setElement()
{
Element* e = inspector->element();
Score* score = e->score();
t.style->blockSignals(true);
t.style->clear();
const QList<TextStyle>& ts = score->style()->textStyles();
int n = ts.size();
for (int i = 0; i < n; ++i) {
if (!(ts.at(i).hidden() & TextStyle::HIDE_IN_LISTS) )
t.style->addItem(ts.at(i).name(), i);
}
t.style->blockSignals(false);
InspectorBase::setElement();
}
}

View file

@ -29,10 +29,12 @@ class InspectorMarker : public InspectorBase {
Q_OBJECT
UiInspectorElement b;
Ui::InspectorText t;
Ui::InspectorMarker m;
public:
InspectorMarker(QWidget* parent);
virtual void setElement() override;
};