Skip to content

Commit

Permalink
implement 'reset text to style' in inspector for text elements
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Feb 27, 2015
1 parent 40e15ef commit 6b554a9
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 58 deletions.
1 change: 1 addition & 0 deletions mscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ add_executable ( ${ExecutableName}
inspector/inspectorBase.cpp inspector/inspectorBeam.cpp masterpalette.cpp
inspector/inspectorGroupElement.cpp dragdrop.cpp inspector/inspectorImage.cpp
inspector/inspectorFret.cpp
inspector/inspectorText.cpp
waveview.cpp helpBrowser.cpp inspector/inspectorLasso.cpp
editelement.cpp inspector/inspectorVolta.cpp inspector/inspectorOttava.cpp enableplayforwidget.cpp
inspector/inspectorTrill.cpp
Expand Down
42 changes: 1 addition & 41 deletions mscore/inspector/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "inspectorNote.h"
#include "inspectorAmbitus.h"
#include "inspectorFret.h"
#include "inspectorText.h"
#include "musescore.h"
#include "scoreview.h"

Expand Down Expand Up @@ -668,47 +669,6 @@ void InspectorClef::valueChanged(int idx)
InspectorBase::valueChanged(idx);
}

//---------------------------------------------------------
// InspectorText
//---------------------------------------------------------

InspectorText::InspectorText(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
t.setupUi(addWidget());

iList = {
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::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() & TextStyleHidden::IN_LISTS) )
t.style->addItem(qApp->translate("TextStyle",ts.at(i).name().toLatin1().data()), i);
}
t.style->blockSignals(false);
InspectorBase::setElement();
}

//---------------------------------------------------------
// InspectorTempoText
//---------------------------------------------------------
Expand Down
17 changes: 1 addition & 16 deletions mscore/inspector/inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include "ui_inspector_tempotext.h"
#include "ui_inspector_dynamic.h"
#include "ui_inspector_slur.h"
#include "ui_inspector_text.h"
#include "ui_inspector_empty.h"
#include "ui_inspector_text.h"

namespace Ms {

Expand Down Expand Up @@ -228,21 +228,6 @@ 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
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion mscore/inspector/inspectorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ void InspectorBase::valueChanged(int idx, bool reset)
inspector->setInspectorEdit(true);
checkDifferentValues(ii);
score->endCmd();
mscore->endCmd();
inspector->setInspectorEdit(false);
postInit();
}
Expand Down
74 changes: 74 additions & 0 deletions mscore/inspector/inspectorText.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENSE.GPL
//=============================================================================

#include "inspectorText.h"
#include "libmscore/score.h"

namespace Ms {

//---------------------------------------------------------
// InspectorText
//---------------------------------------------------------

InspectorText::InspectorText(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
t.setupUi(addWidget());

iList = {
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle }
};
mapSignals();
connect(t.resetToStyle, SIGNAL(clicked()), SLOT(resetToStyle()));
}

//---------------------------------------------------------
// 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() & TextStyleHidden::IN_LISTS) )
t.style->addItem(qApp->translate("TextStyle",ts.at(i).name().toLatin1().data()), i);
}
t.style->blockSignals(false);
InspectorBase::setElement();
}

//---------------------------------------------------------
// resetToStyle
//---------------------------------------------------------

void InspectorText::resetToStyle()
{
Text* text = static_cast<Text*>(inspector->element());
Score* score = text->score();
score->startCmd();
text->undoChangeProperty(P_ID::TEXT, text->plainText());
score->endCmd();
}

}

43 changes: 43 additions & 0 deletions mscore/inspector/inspectorText.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2011 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENSE.GPL
//=============================================================================

#ifndef __INSPECTOR_TEXT_H__
#define __INSPECTOR_TEXT_H__

#include "inspector.h"
#include "inspectorBase.h"
#include "ui_inspector_text.h"

namespace Ms {

//---------------------------------------------------------
// InspectorText
//---------------------------------------------------------

class InspectorText : public InspectorBase {
Q_OBJECT

UiInspectorElement e;
Ui::InspectorText t;

private slots:
void resetToStyle();

public:
InspectorText(QWidget* parent);
virtual void setElement() override;
};

}

#endif

7 changes: 7 additions & 0 deletions mscore/inspector/inspector_text.ui
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="resetToStyle">
<property name="text">
<string>Reset Text to Style</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down

0 comments on commit 6b554a9

Please sign in to comment.