Skip to content

Commit

Permalink
Toolbar customization refinements & fixes
Browse files Browse the repository at this point in the history
- make ToolbarEditor dialog show the proper names for customisable
  actions / item as previously it was showing the internal tags/ids

- allow for the view mode & page zoom dropdowns to be customised
  like all other toolbar items

- re-ordered the available and chosen lists in the dialogue box to make
  more sense - most specific is now at the right and not in the middle

- Customize Toolbars menu is greyed out / disabled when toolbars are
  not customisable, i.e. because we're in advanced or basic mode or
  because although workspace is editable the toolbars are not

- available actions now maintain STANDARD order when items are removed
  from the current toolbar

- improved the spacing of view mode and page zoom dropdowns on the toolbar
  • Loading branch information
Obliquely committed Aug 30, 2020
1 parent d0a08e7 commit 22d5834
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 167 deletions.
94 changes: 60 additions & 34 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ const std::list<const char*> MuseScore::_allFileOperationEntries {
"file-save-online",
"print",
"undo",
"redo"
"redo",
"",
"zoom-options",
"view-mode"
};

const std::list<const char*> MuseScore::_allPlaybackControlEntries {
Expand Down Expand Up @@ -1006,46 +1009,63 @@ bool MuseScore::isInstalledExtension(QString extensionId)

void MuseScore::populateFileOperations()
{
// Save the current zoom and view-mode combobox states. if any.
const auto magState = mag ? std::make_pair(mag->currentIndex(), mag->currentText()) : std::make_pair(-1, QString());
const auto viewModeComboIndex = viewModeCombo ? viewModeCombo->currentIndex() : -1;
fileTools->clear();

fileTools->clear();
bool leftToRightLayout = qApp->layoutDirection() == Qt::LayoutDirection::LeftToRight;

if (qApp->layoutDirection() == Qt::LayoutDirection::LeftToRight) {
for (auto s : _fileOperationEntries) {
if (!*s) {
fileTools->addSeparator();
} else {
fileTools->addWidget(new AccessibleToolButton(fileTools, getAction(s)));
}
}
} else {
_fileOperationEntries.reverse();
for (auto s : _fileOperationEntries) {
if (!*s) {
fileTools->addSeparator();
} else {
fileTools->addWidget(new AccessibleToolButton(fileTools, getAction(s)));
if (!leftToRightLayout)
_fileOperationEntries.reverse();


for (auto s : _fileOperationEntries) {

if (!*s)
fileTools->addSeparator();
else if (!strcmp("view-mode", s))
addViewModeWidget();
else if (!strcmp("zoom-options", s))
addZoomOptionsWidget();
else
fileTools->addWidget(new AccessibleToolButton(fileTools, getAction(s)));
}
}
_fileOperationEntries.reverse();
}

// Currently not customizable in ToolbarEditor
fileTools->addSeparator();
mag = new MagBox;
if (!leftToRightLayout)
_fileOperationEntries.reverse();
}

// Restore the saved zoom combobox index and text, if any.
if (magState.first != -1) {
// zoom-options is treated as a special case as it's not a QToolButton
// but, rather, a MagBox (a sub-class of QComboBox)
void MuseScore::addZoomOptionsWidget()
{
// Save the current zoom state, if any.
const auto magState = mag ? std::make_pair(mag->currentIndex(), mag->currentText()) : std::make_pair(-1, QString());
QWidget* spacer1 = new QWidget();
spacer1->setMinimumWidth(1);
spacer1->setMaximumWidth(1);
fileTools->addWidget(spacer1);
mag = new MagBox;

// Restore the saved zoom combobox index and text, if any.
if (magState.first != -1) {
mag->setCurrentIndex(magState.first);
mag->setCurrentText(magState.second);
}

connect(mag, SIGNAL(magChanged(MagIdx)), SLOT(magChanged(MagIdx)));
fileTools->addWidget(mag);

viewModeCombo = new QComboBox(this);
}

connect(mag, SIGNAL(magChanged(MagIdx)), SLOT(magChanged(MagIdx)));
fileTools->addWidget(mag);
QWidget* spacer2 = new QWidget();
spacer2->setMinimumWidth(1);
spacer2->setMaximumWidth(1);
fileTools->addWidget(spacer2);
}

// view-mode is treated as a special case as it's not a QToolButton
// but, rather, a QComboBox
void MuseScore::addViewModeWidget()
{
// Save the current view-mode combobox state, if any.
const auto viewModeComboIndex = viewModeCombo ? viewModeCombo->currentIndex() : -1;
viewModeCombo = new QComboBox(this);
#if defined(Q_OS_MAC)
viewModeCombo->setFocusPolicy(Qt::StrongFocus);
#else
Expand Down Expand Up @@ -4690,6 +4710,12 @@ void MuseScore::changeState(ScoreState val)
getAction("split-measure")->setEnabled(cs && cs->masterScore()->excerpts().size() == 0);
}

// currentWorkspace can be nullptr in some contexts, so check to avoid crash
Workspace* currentWorkspace = WorkspacesManager::currentWorkspace();
if (currentWorkspace) {
getAction("edit-toolbars")->setEnabled(currentWorkspace->canCustomizeToolbars());
}

// disabling top level menu entries does not
// work for MAC

Expand Down
2 changes: 2 additions & 0 deletions mscore/musescore.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ public slots:
std::list<const char*>* fileOperationEntries() { return &_fileOperationEntries; }
void setFileOperationEntries(std::list<const char*> l) { _fileOperationEntries = l; }
void populateFileOperations();
void addViewModeWidget();
void addZoomOptionsWidget();

static const std::list<const char*>& allPlaybackControlEntries() { return _allPlaybackControlEntries; }
std::list<const char*>* playbackControlEntries() { return &_playbackControlEntries; }
Expand Down
Loading

0 comments on commit 22d5834

Please sign in to comment.