diff --git a/src/inspector/models/text/textsettingsmodel.cpp b/src/inspector/models/text/textsettingsmodel.cpp index 15b94e87d5..26b4ae85d6 100644 --- a/src/inspector/models/text/textsettingsmodel.cpp +++ b/src/inspector/models/text/textsettingsmodel.cpp @@ -174,7 +174,7 @@ void TextSettingsModel::insertSpecialCharacters() void TextSettingsModel::showStaffTextProperties() { - dispatcher()->dispatch("st-props"); + dispatcher()->dispatch("staff-text-properties"); } PropertyItem* TextSettingsModel::fontFamily() const diff --git a/src/notation/internal/notationactioncontroller.cpp b/src/notation/internal/notationactioncontroller.cpp index d6ff5dfb30..d6afd70c6f 100644 --- a/src/notation/internal/notationactioncontroller.cpp +++ b/src/notation/internal/notationactioncontroller.cpp @@ -194,7 +194,8 @@ void NotationActionController::init() dispatcher()->reg(this, "edit-info", this, &NotationActionController::openScoreProperties); dispatcher()->reg(this, "transpose", this, &NotationActionController::openTransposeDialog); dispatcher()->reg(this, "parts", this, &NotationActionController::openPartsDialog); - dispatcher()->reg(this, "st-props", this, &NotationActionController::openStaffTextPropertiesDialog); + dispatcher()->reg(this, "staff-text-properties", this, &NotationActionController::openStaffTextPropertiesDialog); + dispatcher()->reg(this, "system-text-properties", this, &NotationActionController::openStaffTextPropertiesDialog); dispatcher()->reg(this, "voice-x12", [this]() { swapVoices(0, 1); }); dispatcher()->reg(this, "voice-x13", [this]() { swapVoices(0, 2); }); diff --git a/src/notation/internal/notationuiactions.cpp b/src/notation/internal/notationuiactions.cpp index 18711e5194..d0156ac920 100644 --- a/src/notation/internal/notationuiactions.cpp +++ b/src/notation/internal/notationuiactions.cpp @@ -340,6 +340,16 @@ const UiActionList NotationUiActions::m_actions = { mu::context::UiCtxNotationOpened, QT_TRANSLATE_NOOP("action", "Staff/Part Properties") ), + UiAction("staff-text-properties", + mu::context::UiCtxNotationOpened, + QT_TRANSLATE_NOOP("action", "Staff Text Properties…"), + QT_TRANSLATE_NOOP("action", "Staff text properties") + ), + UiAction("system-text-properties", + mu::context::UiCtxNotationOpened, + QT_TRANSLATE_NOOP("action", "System Text Properties…"), + QT_TRANSLATE_NOOP("action", "System text properties") + ), UiAction("add-remove-breaks", mu::context::UiCtxNotationOpened, QT_TRANSLATE_NOOP("action", "Add/Remove System Breaks…"), diff --git a/src/notation/view/notationcontextmenu.cpp b/src/notation/view/notationcontextmenu.cpp index e8b690990a..b52db694f8 100644 --- a/src/notation/view/notationcontextmenu.cpp +++ b/src/notation/view/notationcontextmenu.cpp @@ -33,6 +33,10 @@ MenuItemList NotationContextMenu::items(const ElementType& elementType) const return measureItems(); case ElementType::PAGE: return pageItems(); + case ElementType::STAFF_TEXT: + return staffTextItems(); + case ElementType::SYSTEM_TEXT: + return systemTextItems(); default: break; } @@ -72,6 +76,24 @@ MenuItemList NotationContextMenu::measureItems() const return items; } +MenuItemList NotationContextMenu::staffTextItems() const +{ + MenuItemList items = elementItems(); + items << makeSeparator(); + items << makeMenuItem("staff-text-properties"); + + return items; +} + +MenuItemList NotationContextMenu::systemTextItems() const +{ + MenuItemList items = elementItems(); + items << makeSeparator(); + items << makeMenuItem("system-text-properties"); + + return items; +} + MenuItemList NotationContextMenu::selectItems() const { MenuItemList items { diff --git a/src/notation/view/notationcontextmenu.h b/src/notation/view/notationcontextmenu.h index ce25222835..fcaf5c3c04 100644 --- a/src/notation/view/notationcontextmenu.h +++ b/src/notation/view/notationcontextmenu.h @@ -37,6 +37,8 @@ private: ui::MenuItemList pageItems() const; ui::MenuItemList defaultCopyPasteItems() const; ui::MenuItemList measureItems() const; + ui::MenuItemList staffTextItems() const; + ui::MenuItemList systemTextItems() const; ui::MenuItemList selectItems() const; ui::MenuItemList elementItems() const; }; diff --git a/src/notation/view/widgets/stafftextpropertiesdialog.cpp b/src/notation/view/widgets/stafftextpropertiesdialog.cpp index 973b4d083d..be18af831c 100644 --- a/src/notation/view/widgets/stafftextpropertiesdialog.cpp +++ b/src/notation/view/widgets/stafftextpropertiesdialog.cpp @@ -29,6 +29,8 @@ #include +using namespace mu::notation; + static const QString STAFF_TEXT_PROPERTIES_DIALOG_NAME("StaffTextPropertiesDialog"); namespace Ms { @@ -59,8 +61,16 @@ StaffTextPropertiesDialog::StaffTextPropertiesDialog(QWidget* parent) setObjectName(STAFF_TEXT_PROPERTIES_DIALOG_NAME); setupUi(this); - //! FIXME - StaffTextBase* st = new StaffText(); + const INotationPtr notation = globalContext()->currentNotation(); + const INotationSelectionPtr selection = notation ? notation->interaction()->selection() : nullptr; + Element* selectedElement = selection ? selection->element() : nullptr; + StaffTextBase* st = selectedElement && selectedElement->isStaffTextBase() ? Ms::toStaffTextBase(selectedElement) : nullptr; + + if (!st) { + return; + } + + m_originStaffText = st; if (st->systemFlag()) { setWindowTitle(tr("System Text Properties")); @@ -507,5 +517,14 @@ void StaffTextPropertiesDialog::saveValues() } else { m_staffText->setCapo(0); } + + Score* score = m_originStaffText->score(); + StaffTextBase* nt = toStaffTextBase(m_staffText->clone()); + nt->setScore(score); + score->undoChangeElement(m_originStaffText, nt); + score->masterScore()->updateChannel(); + score->updateCapo(); + score->updateSwing(); + score->setPlaylistDirty(); } } diff --git a/src/notation/view/widgets/stafftextpropertiesdialog.h b/src/notation/view/widgets/stafftextpropertiesdialog.h index 67c0738fd3..463beb7333 100644 --- a/src/notation/view/widgets/stafftextpropertiesdialog.h +++ b/src/notation/view/widgets/stafftextpropertiesdialog.h @@ -24,6 +24,9 @@ #include "ui_stafftextpropertiesdialog.h" +#include "modularity/ioc.h" +#include "context/iglobalcontext.h" + class QPushButton; class QToolButton; class QComboBox; @@ -36,6 +39,8 @@ class StaffTextPropertiesDialog : public QDialog, public Ui::StaffTextProperties { Q_OBJECT + INJECT(Ms, mu::context::IGlobalContext, globalContext) + public: StaffTextPropertiesDialog(QWidget* parent = nullptr); StaffTextPropertiesDialog(const StaffTextPropertiesDialog& other); @@ -53,6 +58,7 @@ private slots: private: void saveChannel(int channel); + StaffTextBase* m_originStaffText = nullptr; StaffTextBase* m_staffText = nullptr; QToolButton* m_vb[4][4]; QComboBox* m_channelCombo[4];