inspector update for KeySig

This commit is contained in:
Werner Schweer 2012-07-27 18:35:37 +02:00
parent 912c5925b0
commit fc19b8b68e
8 changed files with 136 additions and 48 deletions

View file

@ -63,8 +63,8 @@ Clef::Clef(Score* s)
{
setFlags(ELEMENT_SELECTABLE | ELEMENT_ON_STAFF | ELEMENT_MOVABLE);
_showCourtesyClef = true;
_small = false;
_showCourtesy = true;
_small = false;
_clefTypes._concertClef = CLEF_INVALID;
_clefTypes._transposingClef = CLEF_INVALID;
curClefType = CLEF_INVALID;
@ -73,7 +73,7 @@ Clef::Clef(Score* s)
Clef::Clef(const Clef& c)
: Element(c)
{
_showCourtesyClef = c._showCourtesyClef;
_showCourtesy = c._showCourtesy;
_showPreviousClef = c._showPreviousClef;
_small = c._small;
_clefTypes = c._clefTypes;
@ -385,7 +385,7 @@ void Clef::read(const QDomElement& de)
else if (tag == "transposingClefType")
_clefTypes._transposingClef = Clef::clefType(val);
else if (tag == "showCourtesyClef")
_showCourtesyClef = val.toInt();
_showCourtesy = val.toInt();
else if (!Element::readProperties(e))
domError(e);
}
@ -404,8 +404,8 @@ void Clef::write(Xml& xml) const
xml.stag(name());
xml.tag("concertClefType", clefTable[_clefTypes._concertClef].tag);
xml.tag("transposingClefType", clefTable[_clefTypes._transposingClef].tag);
if (!_showCourtesyClef)
xml.tag("showCourtesyClef", _showCourtesyClef);
if (!_showCourtesy)
xml.tag("showCourtesyClef", _showCourtesy);
Element::writeProperties(xml);
xml.etag();
}
@ -501,15 +501,6 @@ void Clef::setClefType(ClefType i)
}
}
//---------------------------------------------------------
// setShowCourtesyClef
//---------------------------------------------------------
void Clef::setShowCourtesyClef(bool v)
{
_showCourtesyClef = v;
}
//---------------------------------------------------------
// setConcertClef
//---------------------------------------------------------
@ -551,10 +542,10 @@ void Clef::spatiumChanged(qreal oldValue, qreal newValue)
}
//---------------------------------------------------------
// undoSetShowCourtesyClef
// undoSetShowCourtesy
//---------------------------------------------------------
void Clef::undoSetShowCourtesyClef(bool v)
void Clef::undoSetShowCourtesy(bool v)
{
score()->undoChangeProperty(this, P_SHOW_COURTESY, v);
}
@ -566,7 +557,7 @@ void Clef::undoSetShowCourtesyClef(bool v)
QVariant Clef::getProperty(P_ID propertyId) const
{
switch(propertyId) {
case P_SHOW_COURTESY: return showCourtesyClef();
case P_SHOW_COURTESY: return showCourtesy();
case P_SMALL: return small();
default:
return Element::getProperty(propertyId);
@ -580,7 +571,7 @@ QVariant Clef::getProperty(P_ID propertyId) const
bool Clef::setProperty(P_ID propertyId, const QVariant& v)
{
switch(propertyId) {
case P_SHOW_COURTESY: _showCourtesyClef = v.toBool(); break;
case P_SHOW_COURTESY: _showCourtesy = v.toBool(); break;
case P_SMALL: setSmall(v.toBool()); break;
default:
return Element::setProperty(propertyId, v);

View file

@ -66,17 +66,17 @@ extern const ClefInfo clefTable[];
// @@ Clef
/// Graphic representation of a clef.
//
// @P showCourtesyClef bool
// @P small bool r/o, set by layout
// @P showCourtesy bool
// @P small bool r/o, set by layout
//---------------------------------------------------------
class Clef : public Element {
Q_OBJECT
Q_PROPERTY(bool showCourtesyClef READ showCourtesyClef WRITE undoSetShowCourtesyClef)
Q_PROPERTY(bool showCourtesy READ showCourtesy WRITE undoSetShowCourtesy)
Q_PROPERTY(bool small READ small)
QList<Element*> elements;
bool _showCourtesyClef;
bool _showCourtesy;
bool _showPreviousClef; // show clef type at position tick-1
// used for first clef on staff immediatly followed
// by a different clef at same tick position
@ -114,9 +114,9 @@ class Clef : public Element {
int tick() const;
bool showCourtesyClef() const { return _showCourtesyClef; };
void setShowCourtesyClef(bool v);
void undoSetShowCourtesyClef(bool v);
bool showCourtesy() const { return _showCourtesy; };
void setShowCourtesy(bool v) { _showCourtesy = v; }
void undoSetShowCourtesy(bool v);
static ClefType clefType(const QString& s);

View file

@ -1591,7 +1591,7 @@ QList<System*> Score::layoutSystemRow(qreal rowWidth, bool isFirstSystem, bool u
showCourtesySig = true; // assume this clef change has court. sig turned on
if (s) {
c = static_cast<Clef*>(s->element(staffIdx*VOICES));
if (c && !c->showCourtesyClef())
if (c && !c->showCourtesy())
continue; // this key change has court. sig turned off
}

View file

@ -182,9 +182,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="showCourtesyClef">
<widget class="QCheckBox" name="showCourtesy">
<property name="text">
<string>showCourtesyClef</string>
<string>showCourtesy</string>
</property>
</widget>
</item>

View file

@ -2361,7 +2361,7 @@ void ClefView::setElement(Element* e)
ShowElementBase::setElement(e);
clef.clefType->setValue(c->clefType());
clef.showCourtesyClef->setChecked(c->showCourtesyClef());
clef.showCourtesy->setChecked(c->showCourtesy());
clef.small->setChecked(c->small());
clef.concertClef->setValue(int(c->concertClef()));

View file

@ -33,6 +33,7 @@
#include "libmscore/notedot.h"
#include "libmscore/hook.h"
#include "libmscore/stem.h"
#include "libmscore/keysig.h"
//---------------------------------------------------------
// showInspector
@ -121,8 +122,11 @@ void Inspector::setElement(Element* e)
case SPACER: ie = new InspectorSpacer(this); break;
case NOTE: ie = new InspectorNote(this); break;
case REST: ie = new InspectorRest(this); break;
case CLEF: ie = new InspectorClef(this); break;
case TIMESIG: ie = new InspectorTimeSig(this); break;
case KEYSIG: ie = new InspectorKeySig(this); break;
case BEAM: ie = new InspectorBeam(this); break;
case IMAGE: ie = new InspectorImage(this); break;
case LASSO: ie = new InspectorLasso(this); break;
@ -1231,11 +1235,12 @@ InspectorTimeSig::InspectorTimeSig(QWidget* parent)
iSegment = new InspectorSegment(this);
layout->addWidget(iElement);
QHBoxLayout* l = new QHBoxLayout;
showCourtesySig = new QCheckBox;
showCourtesySig->setText(tr("Show Courtesy Time Signature"));
connect(showCourtesySig, SIGNAL(toggled(bool)), SLOT(apply()));
l->addWidget(showCourtesySig);
QHBoxLayout* l = new QHBoxLayout;
showCourtesy = new QCheckBox;
showCourtesy->setText(tr("Show Courtesy Time Signature"));
connect(showCourtesy, SIGNAL(toggled(bool)), SLOT(apply()));
l->addWidget(showCourtesy);
layout->addLayout(l);
layout->addWidget(iSegment);
}
@ -1251,7 +1256,9 @@ void InspectorTimeSig::setElement(Element* e)
iElement->setElement(sig);
iSegment->setElement(segment);
showCourtesySig->setChecked(sig->showCourtesySig());
showCourtesy->blockSignals(true);
showCourtesy->setChecked(sig->showCourtesySig());
showCourtesy->blockSignals(false);
}
//---------------------------------------------------------
@ -1262,7 +1269,7 @@ void InspectorTimeSig::apply()
{
TimeSig* sig = static_cast<TimeSig*>(inspector->element());
bool val = showCourtesySig->isChecked();
bool val = showCourtesy->isChecked();
if (val != sig->showCourtesySig()) {
Score* score = sig->score();
score->startCmd();
@ -1272,6 +1279,75 @@ void InspectorTimeSig::apply()
}
}
//---------------------------------------------------------
// InspectorKeySig
//---------------------------------------------------------
InspectorKeySig::InspectorKeySig(QWidget* parent)
: InspectorBase(parent)
{
iElement = new InspectorElementElement(this);
iSegment = new InspectorSegment(this);
layout->addWidget(iElement);
QHBoxLayout* l = new QHBoxLayout;
showCourtesy = new QCheckBox;
showCourtesy->setText(tr("Show Courtesy Time Signature"));
connect(showCourtesy, SIGNAL(toggled(bool)), SLOT(apply()));
l->addWidget(showCourtesy);
layout->addLayout(l);
l = new QHBoxLayout;
showNaturals = new QCheckBox;
showNaturals->setText(tr("Show Naturals"));
connect(showNaturals, SIGNAL(toggled(bool)), SLOT(apply()));
l->addWidget(showNaturals);
layout->addLayout(l);
layout->addWidget(iSegment);
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void InspectorKeySig::setElement(Element* e)
{
KeySig* sig = static_cast<KeySig*>(e);
Segment* segment = sig->segment();
iElement->setElement(sig);
iSegment->setElement(segment);
showCourtesy->blockSignals(true);
showNaturals->blockSignals(true);
showCourtesy->setChecked(sig->showCourtesy());
showNaturals->setChecked(sig->showNaturals());
showCourtesy->blockSignals(false);
showNaturals->blockSignals(false);
}
//---------------------------------------------------------
// apply
//---------------------------------------------------------
void InspectorKeySig::apply()
{
KeySig* sig = static_cast<KeySig*>(inspector->element());
bool sc = showCourtesy->isChecked();
bool sn = showNaturals->isChecked();
if (sc != sig->showCourtesy() || sn != sig->showNaturals()) {
Score* score = sig->score();
score->startCmd();
if (sc != sig->showCourtesy())
score->undoChangeProperty(sig, P_SHOW_COURTESY, sc);
if (sn != sig->showNaturals())
score->undoChangeProperty(sig, P_SHOW_NATURALS, sn);
score->endCmd();
mscore->endCmd();
}
}
//---------------------------------------------------------
// InspectorClef
//---------------------------------------------------------
@ -1284,10 +1360,10 @@ InspectorClef::InspectorClef(QWidget* parent)
layout->addWidget(iElement);
QHBoxLayout* l = new QHBoxLayout;
showCourtesyClef = new QCheckBox;
showCourtesyClef->setText(tr("Show Courtesy Clef"));
connect(showCourtesyClef, SIGNAL(toggled(bool)), SLOT(apply()));
l->addWidget(showCourtesyClef);
showCourtesy = new QCheckBox;
showCourtesy->setText(tr("Show Courtesy Clef"));
connect(showCourtesy, SIGNAL(toggled(bool)), SLOT(apply()));
l->addWidget(showCourtesy);
layout->addLayout(l);
layout->addWidget(iSegment);
}
@ -1303,7 +1379,7 @@ void InspectorClef::setElement(Element* e)
iElement->setElement(clef);
iSegment->setElement(segment);
showCourtesyClef->setChecked(clef->showCourtesyClef());
showCourtesy->setChecked(clef->showCourtesy());
}
//---------------------------------------------------------
@ -1314,8 +1390,8 @@ void InspectorClef::apply()
{
Clef* clef = static_cast<Clef*>(inspector->element());
bool val = showCourtesyClef->isChecked();
if (val != clef->showCourtesyClef()) {
bool val = showCourtesy->isChecked();
if (val != clef->showCourtesy()) {
Score* score = clef->score();
score->startCmd();
score->undoChangeProperty(clef, P_SHOW_COURTESY, val);

View file

@ -314,7 +314,7 @@ class InspectorClef : public InspectorBase {
InspectorElementElement* iElement;
InspectorSegment* iSegment;
QCheckBox* showCourtesyClef;
QCheckBox* showCourtesy;
public slots:
virtual void apply();
@ -334,7 +334,7 @@ class InspectorTimeSig : public InspectorBase {
InspectorElementElement* iElement;
InspectorSegment* iSegment;
QCheckBox* showCourtesySig;
QCheckBox* showCourtesy;
public slots:
virtual void apply();
@ -345,6 +345,27 @@ class InspectorTimeSig : public InspectorBase {
bool dirty() const;
};
//---------------------------------------------------------
// InspectorKeySig
//---------------------------------------------------------
class InspectorKeySig : public InspectorBase {
Q_OBJECT
InspectorElementElement* iElement;
InspectorSegment* iSegment;
QCheckBox* showCourtesy;
QCheckBox* showNaturals;
public slots:
virtual void apply();
public:
InspectorKeySig(QWidget* parent);
virtual void setElement(Element*);
bool dirty() const;
};
//---------------------------------------------------------
// Inspector
//---------------------------------------------------------

View file

@ -217,7 +217,7 @@ void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup)
genPropertyMenu1(e, popup);
// if the clef is not generated (= not courtesy) add the specific menu item
if (!e->generated()) {
QAction* a = popup->addAction(static_cast<Clef*>(e)->showCourtesyClef()
QAction* a = popup->addAction(static_cast<Clef*>(e)->showCourtesy()
? QT_TRANSLATE_NOOP("Clef", "Hide courtesy clef")
: QT_TRANSLATE_NOOP("Clef", "Show courtesy clef") );
a->setData("clef-courtesy");
@ -542,7 +542,7 @@ void ScoreView::elementPropertyAction(const QString& cmd, Element* e)
else if (cmd == "smallNote")
score()->undoChangeProperty(e, P_SMALL, !static_cast<Note*>(e)->small());
else if (cmd == "clef-courtesy") {
bool show = !static_cast<Clef*>(e)->showCourtesyClef();
bool show = !static_cast<Clef*>(e)->showCourtesy();
score()->undoChangeProperty(e, P_SHOW_COURTESY, show);
}
else if (cmd == "d-props") {