Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Command (or Control) F should activate the search field #25681

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/app/configs/data/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,14 @@
<key>find</key>
<std>22</std>
</SC>
<SC>
<key>req-search</key>
<std>22</std>
</SC>
<SC>
<key>req-dialog-search</key>
<std>22</std>
</SC>
<SC>
<key>zoomin</key>
<seq>Ctrl+=</seq>
Expand Down
8 changes: 8 additions & 0 deletions src/app/configs/data/shortcuts_azerty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,14 @@
<key>find</key>
<std>22</std>
</SC>
<SC>
<key>req-search</key>
<std>22</std>
</SC>
<SC>
<key>req-dialog-search</key>
<std>22</std>
</SC>
<SC>
<key>zoomin</key>
<seq>Ctrl++</seq>
Expand Down
8 changes: 8 additions & 0 deletions src/app/configs/data/shortcuts_mac.xml
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,14 @@
<key>find</key>
<std>22</std>
</SC>
<SC>
<key>req-search</key>
<std>22</std>
</SC>
<SC>
<key>req-dialog-search</key>
<std>22</std>
</SC>
<SC>
<key>zoomin</key>
<seq>Ctrl++</seq>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Item {
prv.lastNavigatedExtension = null
panel.close()
}

onSearchRequested: {
searchField.forceActiveFocus()
}
}

onSearchChanged: {
Expand Down
4 changes: 4 additions & 0 deletions src/framework/extensions/view/extensionslistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ void ExtensionsListModel::load()
updatePlugin(plugin);
});

dispatcher()->reg(this, "req-search", [this]() {
emit searchRequested();
});

endResetModel();
}

Expand Down
6 changes: 5 additions & 1 deletion src/framework/extensions/view/extensionslistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@
#include "async/asyncable.h"

#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
#include "actions/actionable.h"
#include "iinteractive.h"
#include "extensions/iextensionsconfiguration.h"
#include "extensions/iextensionsprovider.h"

namespace muse::extensions {
class ExtensionsListModel : public QAbstractListModel, public Injectable, public async::Asyncable
class ExtensionsListModel : public QAbstractListModel, public Injectable, public async::Asyncable, public muse::actions::Actionable
{
Q_OBJECT

Inject<IInteractive> interactive = { this };
Inject<IExtensionsProvider> provider = { this };
Inject<IExtensionsConfiguration> configuration = { this };
INJECT(muse::actions::IActionsDispatcher, dispatcher)

public:
explicit ExtensionsListModel(QObject* parent = nullptr);
Expand All @@ -61,6 +64,7 @@ class ExtensionsListModel : public QAbstractListModel, public Injectable, public

signals:
void finished();
void searchRequested();

private:
enum Roles {
Expand Down
4 changes: 4 additions & 0 deletions src/framework/learn/qml/Muse/Learn/LearnPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ FocusScope {

LearnPageModel {
id: pageModel

onSearchRequested: {
searchField.forceActiveFocus()
}
}

Component.onCompleted: {
Expand Down
4 changes: 4 additions & 0 deletions src/framework/learn/view/learnpagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ void LearnPageModel::load()
learnService()->advancedPlaylistChanged().onReceive(this, [this](const Playlist& playlist) {
setAdvancedPlaylist(playlist);
});

dispatcher()->reg(this, "req-search", [this]() {
emit searchRequested();
});
}

void LearnPageModel::setSearchText(const QString& text)
Expand Down
6 changes: 5 additions & 1 deletion src/framework/learn/view/learnpagemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@
#include "async/asyncable.h"

#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
#include "actions/actionable.h"
#include "ilearnservice.h"
#include "ilearnconfiguration.h"

namespace muse::learn {
class LearnPageModel : public QObject, public Injectable, public async::Asyncable
class LearnPageModel : public QObject, public Injectable, public async::Asyncable, public muse::actions::Actionable
{
Q_OBJECT

Q_PROPERTY(QVariantList startedPlaylist READ startedPlaylist NOTIFY startedPlaylistChanged)
Q_PROPERTY(QVariantList advancedPlaylist READ advancedPlaylist NOTIFY advancedPlaylistChanged)

Inject<ILearnService> learnService = { this };
INJECT(muse::actions::IActionsDispatcher, dispatcher)
Inject<ILearnConfiguration> learnConfiguration = { this };

public:
Expand All @@ -60,6 +63,7 @@ private slots:
signals:
void startedPlaylistChanged();
void advancedPlaylistChanged();
void searchRequested();

private:
QVariantList playlistToVariantList(const Playlist& playlist) const;
Expand Down
4 changes: 4 additions & 0 deletions src/framework/shortcuts/qml/Muse/Shortcuts/ShortcutsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Item {
id: shortcutsModel

selection: shortcutsView.sourceSelection

onSearchRequested: {
topPanel.activateSearchField()
}
}

function apply() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ RowLayout {
searchField.currentText = text
}

function activateSearchField() {
searchField.forceActiveFocus()
}

FlatButton {
id: editButton

Expand Down
4 changes: 4 additions & 0 deletions src/framework/shortcuts/view/shortcutsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ void ShortcutsModel::load()
return actionText(s1.action) < actionText(s2.action);
});

dispatcher()->reg(this, "req-dialog-search", [this]() {
emit searchRequested();
});

endResetModel();
}

Expand Down
6 changes: 5 additions & 1 deletion src/framework/shortcuts/view/shortcutsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <QItemSelection>

#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
#include "actions/actionable.h"
#include "ishortcutsregister.h"
#include "ishortcutsconfiguration.h"
#include "ui/iuiactionsregister.h"
Expand All @@ -37,7 +39,7 @@
class QItemSelection;

namespace muse::shortcuts {
class ShortcutsModel : public QAbstractListModel, public Injectable, public async::Asyncable
class ShortcutsModel : public QAbstractListModel, public Injectable, public async::Asyncable, public actions::Actionable
{
Q_OBJECT

Expand All @@ -49,6 +51,7 @@ class ShortcutsModel : public QAbstractListModel, public Injectable, public asyn
Inject<IInteractive> interactive = { this };
Inject<IShortcutsConfiguration> configuration = { this };
Inject<IGlobalConfiguration> globalConfiguration = { this };
INJECT(muse::actions::IActionsDispatcher, dispatcher)

public:
explicit ShortcutsModel(QObject* parent = nullptr);
Expand Down Expand Up @@ -79,6 +82,7 @@ public slots:

signals:
void selectionChanged();
void searchRequested();

private:
const muse::ui::UiAction& action(const std::string& actionCode) const;
Expand Down
10 changes: 10 additions & 0 deletions src/framework/workspace/internal/workspaceuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ const UiActionList WorkspaceUiActions::m_actions = {
muse::shortcuts::CTX_ANY,
TranslatableString("action", "Select workspace")
),
UiAction("req-search",
muse::ui::UiCtxHomeOpened,
muse::shortcuts::CTX_ANY,
TranslatableString("action", "Search field requested")
),
UiAction("req-dialog-search",
muse::ui::UiCtxUnknown,
muse::shortcuts::CTX_ANY,
TranslatableString("action", "Dialog search field requested")
),
UiAction("configure-workspaces",
muse::ui::UiCtxAny,
muse::shortcuts::CTX_ANY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Rectangle {
familyView.scrollToGroup(groupIndex)
instrumentsView.focusInstrument(instrumentIndex)
}

onSearchRequested: {
instrumentsView.activateSearchField()
}
}

QtObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Item {
instrumentsView.positionViewAtIndex(instrumentIndex, ListView.Beginning)
}

function activateSearchField() {
searchField.forceActiveFocus()
}

StyledTextLabel {
id: instrumentsLabel

Expand Down
4 changes: 4 additions & 0 deletions src/instrumentsscene/view/instrumentlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ void InstrumentListModel::load(bool canSelectMultipleInstruments, const QString&
const InstrumentTemplate& templ = repository()->instrumentTemplate(currentInstrumentId);
init(COMMON_GENRE_ID, templ.groupId);
}

dispatcher()->reg(this, "req-dialog-search", [this]() {
emit searchRequested();
});
}

QStringList InstrumentListModel::genres() const
Expand Down
7 changes: 6 additions & 1 deletion src/instrumentsscene/view/instrumentlistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@
#include "async/asyncable.h"

#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
#include "actions/actionable.h"

#include "notation/iinstrumentsrepository.h"

#include "uicomponents/view/itemmultiselectionmodel.h"

namespace mu::instrumentsscene {
class InstrumentListModel : public QAbstractListModel, public muse::async::Asyncable
class InstrumentListModel : public QAbstractListModel, public muse::async::Asyncable, public muse::actions::Actionable
{
Q_OBJECT

INJECT(notation::IInstrumentsRepository, repository)
INJECT(muse::actions::IActionsDispatcher, dispatcher)

Q_PROPERTY(QStringList genres READ genres NOTIFY genresChanged)
Q_PROPERTY(QStringList groups READ groups NOTIFY groupsChanged)
Expand Down Expand Up @@ -86,6 +90,7 @@ public slots:
void selectionChanged();

void focusRequested(int groupIndex, int instrumentIndex);
void searchRequested();

private:
enum Roles {
Expand Down
5 changes: 5 additions & 0 deletions src/project/qml/MuseScore/Project/ScoresPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ FocusScope {

ScoresPageModel {
id: scoresPageModel

onSearchRequested: {
searchField.forceActiveFocus()
}
}

Component.onCompleted: {
tabBar.currentIndex = scoresPageModel.tabIndex
tabBar.completed = true
scoresPageModel.load()
}

Rectangle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Item {
onCurrentTemplateChanged: {
templatePreview.load(model.currentTemplatePath)
}

onSearchRequested: {
templatesView.activateSearchField()
}
}

Component.onCompleted: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Item {
searchField.clear()
}

function activateSearchField() {
searchField.forceActiveFocus()
}

StyledTextLabel {
id: title

Expand Down
7 changes: 7 additions & 0 deletions src/project/view/scorespagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ ScoresPageModel::ScoresPageModel(QObject* parent)
{
}

void ScoresPageModel::load()
{
dispatcher()->reg(this, "req-search", [this]() {
emit searchRequested();
});
}

void ScoresPageModel::createNewScore()
{
dispatcher()->dispatch("file-new");
Expand Down
5 changes: 4 additions & 1 deletion src/project/view/scorespagemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
#include "modularity/ioc.h"
#include "iprojectconfiguration.h"
#include "actions/iactionsdispatcher.h"
#include "actions/actionable.h"
#include "iinteractive.h"
#include "cloud/musescorecom/imusescorecomservice.h"

class QString;

namespace mu::project {
class ScoresPageModel : public QObject
class ScoresPageModel : public QObject, public muse::actions::Actionable
{
Q_OBJECT

Expand Down Expand Up @@ -64,10 +65,12 @@ class ScoresPageModel : public QObject
Q_INVOKABLE void openOther();
Q_INVOKABLE void openScore(const QString& scorePath, const QString& displayNameOverride);
Q_INVOKABLE void openScoreManager();
Q_INVOKABLE void load();

signals:
void tabIndexChanged();
void viewTypeChanged();
void searchRequested();
};
}

Expand Down
4 changes: 4 additions & 0 deletions src/project/view/templatesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ void TemplatesModel::load()
}
}

dispatcher()->reg(this, "req-dialog-search", [this]() {
emit searchRequested();
});

loadAllCategories();
}

Expand Down
Loading