Skip to content

Commit

Permalink
inspector updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Mar 6, 2013
1 parent ebb1cf1 commit 10ca5f9
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 127 deletions.
2 changes: 1 addition & 1 deletion mscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ QT4_WRAP_UI (ui_headers
inspector_group_element.ui inspector_image.ui stem.ui inspector_lasso.ui
inspector_volta.ui inspector_ottava.ui inspector_trill.ui inspector_hairpin.ui
box.ui pluginManager.ui inspector_jump.ui inspector_marker.ui inspector_glissando.ui
inspector_clef.ui
inspector_clef.ui inspector_timesig.ui inspector_keysig.ui
${SCRIPT_UI}
)

Expand Down
147 changes: 39 additions & 108 deletions mscore/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,54 +1196,26 @@ InspectorRest::InspectorRest(QWidget* parent)
InspectorTimeSig::InspectorTimeSig(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);
layout->addWidget(iSegment);
}

//---------------------------------------------------------
// setElement
//---------------------------------------------------------

void InspectorTimeSig::setElement()
{
TimeSig* sig = static_cast<TimeSig*>(inspector->element());
Segment* segment = sig->segment();

iElement->setElement(sig);
iSegment->setElement(segment);
showCourtesy->blockSignals(true);
showCourtesy->setChecked(sig->showCourtesySig());
showCourtesy->blockSignals(false);
}

//---------------------------------------------------------
// apply
//---------------------------------------------------------

void InspectorTimeSig::apply()
{
TimeSig* sig = static_cast<TimeSig*>(inspector->element());
QWidget* w1 = new QWidget;
e.setupUi(w1);
layout->addWidget(w1);
QWidget* w2 = new QWidget;
s.setupUi(w2);
layout->addWidget(w2);
QWidget* w3 = new QWidget;
t.setupUi(w3);
layout->addWidget(w3);

bool val = showCourtesy->isChecked();
if (val != sig->showCourtesySig()) {
mscore->getInspector()->setInspectorEdit(true); // this edit is coming from within the inspector itself:
// do not set element values again
Score* score = sig->score();
score->startCmd();
score->undoChangeProperty(sig, P_SHOW_COURTESY, val);
score->endCmd();
mscore->endCmd();
}
iList = {
{ P_COLOR, 0, false, e.color, e.resetColor },
{ P_VISIBLE, 0, false, e.visible, e.resetVisible },
{ P_USER_OFF, 0, false, e.offsetX, e.resetX },
{ P_USER_OFF, 1, false, e.offsetY, e.resetY },
{ P_LEADING_SPACE, 0, true, s.leadingSpace, s.resetLeadingSpace },
{ P_TRAILING_SPACE, 0, true, s.trailingSpace, s.resetTrailingSpace },
{ P_SHOW_COURTESY, 0, false, t.showCourtesy, t.resetShowCourtesy }
};
mapSignals();
}

//---------------------------------------------------------
Expand All @@ -1253,68 +1225,27 @@ void InspectorTimeSig::apply()
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()
{
KeySig* sig = static_cast<KeySig*>(inspector->element());
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());
QWidget* w1 = new QWidget;
e.setupUi(w1);
layout->addWidget(w1);
QWidget* w2 = new QWidget;
s.setupUi(w2);
layout->addWidget(w2);
QWidget* w3 = new QWidget;
k.setupUi(w3);
layout->addWidget(w3);

bool sc = showCourtesy->isChecked();
bool sn = showNaturals->isChecked();
if (sc != sig->showCourtesy() || sn != sig->showNaturals()) {
mscore->getInspector()->setInspectorEdit(true); // this edit is coming from within the inspector itself:
// do not set element values again
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();
}
iList = {
{ P_COLOR, 0, false, e.color, e.resetColor },
{ P_VISIBLE, 0, false, e.visible, e.resetVisible },
{ P_USER_OFF, 0, false, e.offsetX, e.resetX },
{ P_USER_OFF, 1, false, e.offsetY, e.resetY },
{ P_LEADING_SPACE, 0, true, s.leadingSpace, s.resetLeadingSpace },
{ P_TRAILING_SPACE, 0, true, s.trailingSpace, s.resetTrailingSpace },
{ P_SHOW_COURTESY, 0, false, k.showCourtesy, k.resetShowCourtesy },
{ P_SHOW_NATURALS, 0, false, k.showNaturals, k.resetShowNaturals }
};
mapSignals();
}

//---------------------------------------------------------
Expand Down
25 changes: 8 additions & 17 deletions mscore/inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "ui_inspector_chord.h"
#include "ui_inspector_rest.h"
#include "ui_inspector_clef.h"
#include "ui_inspector_timesig.h"
#include "ui_inspector_keysig.h"
#include "ui_inspector_volta.h"

class Element;
Expand Down Expand Up @@ -298,17 +300,12 @@ class InspectorClef : public InspectorBase {
class InspectorTimeSig : public InspectorBase {
Q_OBJECT

InspectorElementElement* iElement;
InspectorSegment* iSegment;
QCheckBox* showCourtesy;

public slots:
virtual void apply();
Ui::InspectorElement e;
Ui::InspectorSegment s;
Ui::InspectorTimeSig t;

public:
InspectorTimeSig(QWidget* parent);
virtual void setElement();
bool dirty() const;
};

//---------------------------------------------------------
Expand All @@ -318,18 +315,12 @@ class InspectorTimeSig : public InspectorBase {
class InspectorKeySig : public InspectorBase {
Q_OBJECT

InspectorElementElement* iElement;
InspectorSegment* iSegment;
QCheckBox* showCourtesy;
QCheckBox* showNaturals;

public slots:
virtual void apply();
Ui::InspectorElement e;
Ui::InspectorSegment s;
Ui::InspectorKeySig k;

public:
InspectorKeySig(QWidget* parent);
virtual void setElement();
bool dirty() const;
};

//---------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion mscore/inspectorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ void InspectorBase::resetClicked(int i)
static_cast<QCheckBox*>(w)->setChecked(def.toBool());
else if (qobject_cast<QLineEdit*>(w))
static_cast<QLineEdit*>(w)->setText(def.toString());
else if (qobject_cast<Awl::ColorLabel*>(w))
else if (qobject_cast<Awl::ColorLabel*>(w)) {
static_cast<Awl::ColorLabel*>(w)->setColor(def.value<QColor>());
valueChanged(i);
}
else {
qDebug("not supported widget");
abort();
Expand Down
107 changes: 107 additions & 0 deletions mscore/inspector_keysig.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InspectorKeySig</class>
<widget class="QWidget" name="InspectorKeySig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>206</width>
<height>97</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="elementName">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Key Signature</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="2">
<widget class="QToolButton" name="resetShowCourtesy">
<property name="toolTip">
<string>reset value</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="musescore.qrc">
<normaloff>:/data/icons-dark/resetproperty.png</normaloff>:/data/icons-dark/resetproperty.png</iconset>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="showCourtesy">
<property name="text">
<string>show courtesy</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="resetShowNaturals">
<property name="toolTip">
<string>reset value</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="musescore.qrc">
<normaloff>:/data/icons-dark/resetproperty.png</normaloff>:/data/icons-dark/resetproperty.png</iconset>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="showNaturals">
<property name="text">
<string>show naturals</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="musescore.qrc"/>
</resources>
<connections/>
</ui>
Loading

0 comments on commit 10ca5f9

Please sign in to comment.