Skip to content

Commit

Permalink
Toolbar customization refinements & fixes
Browse files Browse the repository at this point in the history
- allow for the view mode / view zoom to be customised like other items

- created an icon to represent view mode / zoom - only appears in this
  context. design adapted from existing icons so (reasonable) continuity
  of look and feel

- fixed title of dialogue box

- removed text box showing workspace name from dialogue box - it's an
  edit box showing information that can never be edited - unhelpful UI

- added name of workspace being edited to the dialogue box title

- made dialogue show the proper names for customisable actions / item
  previously it was showing the internal tags/ids

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

- added tooltips to various items in dialogue box

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

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

Some "nice to do" things that could be tackled in future:

- Toolbars can be customised even when these customisation will never
  be saved. Doesn't seem like a good idea. Options:

   a. treat these in the way Advanced and Basic are treated, i.e.
      disable the customisation menu so user doesn't get to do something
      that will then never be saved

   b. make it that toolbar customisations for user workspaces are always
      saved. If (b) then would be worth adding to the dialogue the option
      to restore the Basic or Advanced default in case a user found thing
      had got messy. (Restore to default is very do-able.)

- The spacing of the zoombox is not quite right. There should be a small
  margin to the left so it matches other buttons on toolbar. Would need
  bit of work to create a new holding widget.

- The zoombox and the pageview mode could be treated as separate items. They
  are closely related, but a user might prefer to, say, drop zoom because
  they always use mouse or track pad for this.
  • Loading branch information
Obliquely committed May 17, 2019
1 parent 60546fc commit e4602ee
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 117 deletions.
7 changes: 7 additions & 0 deletions mscore/data/icons/viewOptions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion mscore/icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ static const char* iconNames[] = {
"arrow_down.svg",
"mail.svg",
"bug.svg",
"note_timewise.svg"
"note_timewise.svg",
"viewOptions.svg"
};

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion mscore/icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum class Icons : signed char { Invalid_ICON = -1,
timesig_prolatio08_ICON, timesig_prolatio10_ICON, timesig_prolatio11_ICON, edit_ICON, reset_ICON, close_ICON,
arrowUp_ICON, arrowDown_ICON,
mail_ICON, bug_ICON,
noteTimewise_ICON,
noteTimewise_ICON, viewOptions_ICON,
voice1_ICON, voice2_ICON, voice3_ICON, voice4_ICON,
ICONS
};
Expand Down
54 changes: 30 additions & 24 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ const std::list<const char*> MuseScore::_allFileOperationEntries {
"file-save-online",
"print",
"undo",
"redo"
"redo",
"",
"view-options"
};

const std::list<const char*> MuseScore::_allPlaybackControlEntries {
Expand Down Expand Up @@ -909,27 +911,29 @@ void MuseScore::populateFileOperations()
{
fileTools->clear();

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)));
}
bool leftToRightLayout = qApp->layoutDirection() == Qt::LayoutDirection::LeftToRight;

if (!leftToRightLayout)
_fileOperationEntries.reverse();

for (auto s : _fileOperationEntries) {

if (!*s)
fileTools->addSeparator();
else if (!strcmp("view-options", s))
addViewOptionsDoubleWidget();
else
fileTools->addWidget(new AccessibleToolButton(fileTools, getAction(s)));
}

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

// view-options is treated as a special case as it's not a QToolButton
// but, rather, made up of two QComboBox objects (one sub-classed).
void MuseScore::addViewOptionsDoubleWidget()
{
mag = new MagBox;
connect(mag, SIGNAL(magChanged(MagIdx)), SLOT(magChanged(MagIdx)));
fileTools->addWidget(mag);
Expand All @@ -951,6 +955,7 @@ void MuseScore::populateFileOperations()
fileTools->addWidget(viewModeCombo);
}


//---------------------------------------------------------
// populatePlaybackControls
//---------------------------------------------------------
Expand All @@ -960,14 +965,15 @@ void MuseScore::populatePlaybackControls()
transportTools->clear();

for (const auto s : _playbackControlEntries) {
if (!*s)
if (!*s) {
transportTools->addSeparator();
}
else {
if (QString(s) == "repeat") {
QAction* repeatAction = getAction("repeat");
repeatAction->setChecked(preferences.getBool(PREF_APP_PLAYBACK_PLAYREPEATS));
QWidget* w = new AccessibleToolButton(transportTools, repeatAction);
transportTools->addWidget(w);
QAction* repeatAction = getAction("repeat");
repeatAction->setChecked(preferences.getBool(PREF_APP_PLAYBACK_PLAYREPEATS));
QWidget* w = new AccessibleToolButton(transportTools, repeatAction);
transportTools->addWidget(w);
}
else if (QString(s) == "play") {
_playButton = new AccessibleToolButton(transportTools, getAction("play"));
Expand Down
2 changes: 2 additions & 0 deletions mscore/musescore.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
std::list<const char*>* fileOperationEntries() { return &_fileOperationEntries; }
void setFileOperationEntries(std::list<const char*> l) { _fileOperationEntries = l; }
void populateFileOperations();
void addViewOptionsDoubleWidget();

static const std::list<const char*>& allPlaybackControlEntries() { return _allPlaybackControlEntries; }
std::list<const char*>* playbackControlEntries() { return &_playbackControlEntries; }
Expand Down Expand Up @@ -882,6 +883,7 @@ MasterSynthesizer* synthesizerFactory();
Driver* driverFactory(Seq*, QString driver);

extern QAction* getAction(const char*);
extern QString getShortcutText(const char*);
extern Shortcut* midiActionMap[128];
extern void loadTranslation(QString fileName, QString localeName);
extern void setMscoreLocale(QString localeName);
Expand Down
1 change: 1 addition & 0 deletions mscore/musescore.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
<file>data/icons/mail.svg</file>
<file>data/icons/bug.svg</file>
<file>data/icons/note_timewise.svg</file>
<file>data/icons/viewOptions.svg</file>
<file>data/icons/mixer-slider-handle.svg</file>
<file>data/icons/mixer-mute-off.svg</file>
<file>data/icons/mixer-mute-on.svg</file>
Expand Down
21 changes: 21 additions & 0 deletions mscore/shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ Shortcut Shortcut::_sc[] = {
Icons::redo_ICON,
Qt::ApplicationShortcut
},
{
MsWidget::MAIN_WINDOW,
STATE_NORMAL,
"view-options",
QT_TRANSLATE_NOOP("action","View Options"),
0,
0,
Icons::viewOptions_ICON,
},
{
MsWidget::SCORE_TAB,
STATE_NORMAL | STATE_NOTE_ENTRY | STATE_EDIT | STATE_TEXT_EDIT | STATE_LYRICS_EDIT
Expand Down Expand Up @@ -3880,6 +3889,18 @@ QAction* getAction(const char* id)
return s ? s->action() : 0;
}


//---------------------------------------------------------
// getShortcutText
// returns description for shortcut
//---------------------------------------------------------

QString getShortcutText(const char* id)
{
Shortcut* shortcut = Shortcut::getShortcut(id);
return shortcut ? shortcut->text() : "";
}

//---------------------------------------------------------
// aAction
//---------------------------------------------------------
Expand Down
91 changes: 60 additions & 31 deletions mscore/toolbarEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ ToolbarEditor::ToolbarEditor(QWidget* parent)
void ToolbarEditor::init()
{
QString name = Workspace::currentWorkspace->name();
bool writable = !Workspace::currentWorkspace->readOnly();
if (!writable) {
name += " " + tr("(not changeable)");
}
add->setEnabled(writable);
remove->setEnabled(writable);
up->setEnabled(writable);
down->setEnabled(writable);
workspaceName->setText(name);
QString mainTitle = tr("Customize Toolbars");
setWindowTitle(mainTitle + " (" + name + ")");

// defensive - don't expect to be here if workspace is not customizable
bool canBeCustomized = !Workspace::currentWorkspace->readOnly();

add->setEnabled(canBeCustomized);
remove->setEnabled(canBeCustomized);
up->setEnabled(canBeCustomized);
down->setEnabled(canBeCustomized);

// Syncs the editor with the current toolbars
new_toolbars->at(0) = mscore->noteInputMenuEntries();
Expand Down Expand Up @@ -113,38 +114,52 @@ void ToolbarEditor::accepted()
void ToolbarEditor::populateLists(const std::list<const char*>& all, std::list<const char*>* current)
{
actionList->clear();
availableList->clear();
for (auto i : *current) {
QAction* a = getAction(i);
for (auto currentId : *current) {
QString shortcutText = getShortcutText(currentId);
QAction* action = getAction(currentId);
QListWidgetItem* item;
QString actionName = QString(i);
if (a)
item = new QListWidgetItem(a->icon(), actionName);
else if (actionName.isEmpty())

if (action)
item = new QListWidgetItem(action->icon(), shortcutText);
else if (QString(currentId).isEmpty())
item = new QListWidgetItem(tr("Separator"));
else
item = new QListWidgetItem(actionName);
item->setData(Qt::UserRole, QVariant::fromValue((void*)i));
item = new QListWidgetItem(shortcutText);

item->setData(Qt::UserRole, QVariant::fromValue((void*)currentId));
actionList->addItem(item);
}
for (auto i : all) {

refreshAvailableList(all, current);
}


void ToolbarEditor::refreshAvailableList(const std::list<const char*>& all, std::list<const char*>* current)
{
availableList->clear();

for (auto id : all) {
bool found = false;
for (auto k : *current) {
if (strcmp(k, i) == 0) {

for (auto allId : *current) {
if (strcmp(allId, id) == 0) {
found = true;
break;
}
}

if (!found) {
QAction* a = getAction(i);
QString shortcutText = getShortcutText(id);
QAction* action = getAction(id);
QListWidgetItem* item = 0;
QString actionName = QString(i);
if (a)
item = new QListWidgetItem(a->icon(), actionName);
else if (!actionName.isEmpty())
item = new QListWidgetItem(QString(i));
if (item) {
item->setData(Qt::UserRole, QVariant::fromValue((void*)i));

if (action)
item = new QListWidgetItem(action->icon(), shortcutText);
else if (!QString(id).isEmpty())
item = new QListWidgetItem(shortcutText);

if (item) {
item->setData(Qt::UserRole, QVariant::fromValue((void*)id));
availableList->addItem(item);
}
}
Expand Down Expand Up @@ -198,10 +213,24 @@ void ToolbarEditor::removeAction()
int cr = actionList->currentRow();
if (cr == -1)
return;

QListWidgetItem* item = actionList->takeItem(cr);
if (!isSpacer(item))
availableList->addItem(item);
updateNewToolbar(toolbarList->currentRow());

if (isSpacer(item))
return;

int currentRow = toolbarList->currentRow();
switch (currentRow) {
case 0:
refreshAvailableList(MuseScore::allNoteInputMenuEntries(), new_toolbars->at(currentRow));
break;
case 1:
refreshAvailableList(MuseScore::allFileOperationEntries(), new_toolbars->at(currentRow));
break;
case 2:
refreshAvailableList(MuseScore::allPlaybackControlEntries(), new_toolbars->at(currentRow));
}
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mscore/toolbarEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ToolbarEditor : public QDialog, public Ui::ToolbarEditor {
void updateNewToolbar(int toolbar_to_update);

void populateLists(const std::list<const char*>&, std::list<const char*>*);
void refreshAvailableList(const std::list<const char*>&, std::list<const char*>*);
bool isSpacer(QListWidgetItem*) const;

virtual void hideEvent(QHideEvent*);
Expand Down
Loading

0 comments on commit e4602ee

Please sign in to comment.