implemented the ability to open the staff/system text properties dialog

via the context menu
This commit is contained in:
Roman Pudashkin 2021-07-15 12:40:54 +02:00
parent 3b97275a64
commit 279083d7e5
7 changed files with 64 additions and 4 deletions

View file

@ -174,7 +174,7 @@ void TextSettingsModel::insertSpecialCharacters()
void TextSettingsModel::showStaffTextProperties()
{
dispatcher()->dispatch("st-props");
dispatcher()->dispatch("staff-text-properties");
}
PropertyItem* TextSettingsModel::fontFamily() const

View file

@ -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); });

View file

@ -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…"),

View file

@ -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 {

View file

@ -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;
};

View file

@ -29,6 +29,8 @@
#include <QSignalMapper>
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();
}
}

View file

@ -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];