Skip to content
Merged
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
6 changes: 4 additions & 2 deletions framework/audio/main/internal/audiocommandsregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ static const std::vector<CommandInfo> s_commandInfos = {
TranslatableString::untranslatable("Use Driver Mode"),
TranslatableString::untranslatable("Use Driver Mode (developer mode)"),
InputSchema(),
Decoration(rcommand::Checkable::Yes)
Decoration(rcommand::Checkable::Yes),
Availability::Dispatch
},
CommandInfo{
AUDIO_DEV_USE_HYBRID_MODE_COMMAND,
TranslatableString::untranslatable("Use Hybrid Mode"),
TranslatableString::untranslatable("Use Hybrid Mode (developer mode)"),
InputSchema(),
Decoration(rcommand::Checkable::Yes)
Decoration(rcommand::Checkable::Yes),
Availability::Dispatch
},
};

Expand Down
12 changes: 8 additions & 4 deletions framework/dockwindow/internal/dockcommandsregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,32 @@ static const std::vector<CommandInfo> s_commandInfos = {
{ "dock_name", Arg(DataType::String, u"Dock name") },
{ "open", Arg(DataType::Boolean, u"Open") }
}),
Decoration()
Decoration(),
Availability::Dispatch
},
CommandInfo {
DOCK_TOGGLE_COMMAND,
TranslatableString("dock", "Toggle dock"),
TranslatableString("dock", "Dock: Toggle dock"),
InputSchema({ { "dock_name", Arg(DataType::String, u"Dock name") } }),
Decoration()
Decoration(),
Availability::Dispatch
},
CommandInfo {
DOCK_TOGGLE_FLOATING_COMMAND,
TranslatableString("dock", "Toggle dock floating"),
TranslatableString("dock", "Dock: Toggle dock floating"),
InputSchema({ { "dock_name", Arg(DataType::String, u"Dock name") } }),
Decoration()
Decoration(),
Availability::Dispatch
},
CommandInfo {
DOCK_RESTORE_DEFAULT_LAYOUT_COMMAND,
TranslatableString("dock", "Restore default layout"),
TranslatableString("dock", "Dock: Restore default layout"),
InputSchema(),
Decoration()
Decoration(),
Availability::All
}
};

Expand Down
12 changes: 8 additions & 4 deletions framework/dockwindow_v2/internal/dockcommandsregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,32 @@ static const std::vector<CommandInfo> s_commandInfos = {
{ "dock_name", Arg(DataType::String, u"Dock name") },
{ "open", Arg(DataType::Boolean, u"Open") }
}),
Decoration()
Decoration(),
Availability::Dispatch
},
CommandInfo {
DOCK_TOGGLE_COMMAND,
TranslatableString("dock", "Toggle dock"),
TranslatableString("dock", "Dock: Toggle dock"),
InputSchema({ { "dock_name", Arg(DataType::String, u"Dock name") } }),
Decoration()
Decoration(),
Availability::Dispatch
},
CommandInfo {
DOCK_TOGGLE_FLOATING_COMMAND,
TranslatableString("dock", "Toggle dock floating"),
TranslatableString("dock", "Dock: Toggle dock floating"),
InputSchema({ { "dock_name", Arg(DataType::String, u"Dock name") } }),
Decoration()
Decoration(),
Availability::Dispatch
},
CommandInfo {
DOCK_RESTORE_DEFAULT_LAYOUT_COMMAND,
TranslatableString("dock", "Restore default layout"),
TranslatableString("dock", "Dock: Restore default layout"),
InputSchema(),
Decoration()
Decoration(),
Availability::All
}
};

Expand Down
3 changes: 2 additions & 1 deletion framework/extensions/internal/extensionscommandsregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ static const std::vector<CommandInfo> s_commandInfos = {
TranslatableString("extensions", "Show API dump"),
TranslatableString("extensions", "Show API dump"),
InputSchema(),
Decoration()
Decoration(),
Availability::Dispatch
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ static const std::vector<CommandInfo> s_commandInfos = {
TranslatableString("musesampler", "Check"),
TranslatableString("musesampler", "Check MuseSampler"),
InputSchema(),
Decoration()
Decoration(),
Availability::All
},
CommandInfo{
MUSESAMPLER_RELOAD_COMMAND,
TranslatableString("musesampler", "Reload"),
TranslatableString("musesampler", "Reload MuseSampler"),
InputSchema(),
Decoration()
Decoration(),
Availability::All
},
};

Expand Down
10 changes: 3 additions & 7 deletions framework/shortcuts_v2/internal/shortcutscontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,14 @@ void ShortcutsController::activate(const std::string& sequence)
return;
}

LOGD() << sequence;

ShortcutList allowedShortcuts;
const ShortcutList& commandShortcuts = commandShortcutsRegister()->shortcutsForSequence(sequence);
SC_LOG() << "commandShortcuts: " << commandShortcuts.size();
for (const Shortcut& sc : commandShortcuts) {
const Command& command = Command(sc.command);
if (commandsState()->commandState(command).enabled) {
if (commandsState()->commandState(sc.command).enabled) {
allowedShortcuts.push_back(sc);
}
}
SC_LOG() << "allowedShortcuts: " << allowedShortcuts.size();
SC_LOG() << sequence << ": allowedShortcuts: " << allowedShortcuts.size() << ": " << allowedShortcuts;

Shortcut selectedShortcut;
if (allowedShortcuts.size() == 1) {
Expand All @@ -73,7 +69,7 @@ void ShortcutsController::activate(const std::string& sequence)
}
SC_LOG() << "selectedShortcut: " << selectedShortcut.command;
if (selectedShortcut.isValid()) {
commandDispatcher()->dispatch(Command(selectedShortcut.command));
commandDispatcher()->dispatch(selectedShortcut.command);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ static QKeySequence translateToCurrentKeyboardLayout(const QKeySequence& sequenc
};

ShortcutList shortcuts = commandShortcutsRegister()->shortcuts();
const ShortcutList& actionsShortcuts = shortcutsRegister()->shortcuts();

shortcuts.insert(shortcuts.end(), actionsShortcuts.begin(), actionsShortcuts.end());

for (const Shortcut& sc : shortcuts) {
for (const std::string& seq : sc.sequences) {
Expand Down
21 changes: 21 additions & 0 deletions framework/shortcuts_v2/shortcutstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "global/stringutils.h"
#include "rcommand/commandtypes.h"

#include "global/logstream.h"

namespace muse::shortcuts {
struct Shortcut
{
Expand Down Expand Up @@ -126,3 +128,22 @@ inline bool canShortcutsConflict(const std::string& scope1, const std::string& s
return scope1 == scope2;
}
}

inline muse::logger::Stream& operator<<(muse::logger::Stream& s, const muse::shortcuts::Shortcut& sc)
{
s << "{" << sc.scope << ", " << sc.command.toString() << ", " << sc.sequencesAsString() << "}";
return s;
}

inline muse::logger::Stream& operator<<(muse::logger::Stream& s, const std::vector<muse::shortcuts::Shortcut>& v)
{
s << '[';
for (size_t i = 0; i < v.size(); ++i) {
s << v.at(i);
if (i < v.size() - 1) {
s << ',';
}
}
s << ']';
return s;
}
6 changes: 5 additions & 1 deletion framework/stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ if (NOT MUSE_MODULE_NETWORK)
endif()

if (NOT MUSE_MODULE_SHORTCUTS)
add_subdirectory(shortcuts)
if (MUSE_MODULE_SHORTCUTS_V2)
add_subdirectory(shortcuts_v2)
else()
add_subdirectory(shortcuts)
endif()
endif()

if (NOT MUSE_MODULE_TOURS)
Expand Down
36 changes: 36 additions & 0 deletions framework/stubs/shortcuts_v2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-License-Identifier: GPL-3.0-only
# MuseScore-CLA-applies
#
# MuseScore Studio
# Music Composition & Notation
#
# Copyright (C) 2021 MuseScore Limited and others
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

muse_create_module(muse_shortcuts ALIAS muse::shortcuts STUB)

target_sources(muse_shortcuts PRIVATE
shortcutsstubmodule.cpp
shortcutsstubmodule.h
shortcutsregisterstub.cpp
shortcutsregisterstub.h
shortcutscontrollerstub.cpp
shortcutscontrollerstub.h
shortcutsconfigurationstub.cpp
shortcutsconfigurationstub.h
)

if (MUSE_MODULE_SHORTCUTS_QML)
add_subdirectory(qml/Muse/Shortcuts)
endif()
13 changes: 13 additions & 0 deletions framework/stubs/shortcuts_v2/qml/Muse/Shortcuts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
muse_create_qml_module(muse_shortcuts_qml ALIAS muse::shortcuts_qml FOR muse_shortcuts STUB)

qt_add_qml_module(muse_shortcuts_qml
URI Muse.Shortcuts
VERSION 1.0
QML_FILES
Shortcuts.qml
IMPORTS
TARGET muse_ui_qml
TARGET muse_uicomponents_qml
)

fixup_qml_module_dependencies(muse_shortcuts_qml)
25 changes: 25 additions & 0 deletions framework/stubs/shortcuts_v2/qml/Muse/Shortcuts/Shortcuts.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import QtQuick

QtObject { }
78 changes: 78 additions & 0 deletions framework/stubs/shortcuts_v2/shortcutsconfigurationstub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "shortcutsconfigurationstub.h"

using namespace muse;
using namespace muse::shortcuts;

QString ShortcutsConfigurationStub::currentKeyboardLayout() const
{
return QString();
}

void ShortcutsConfigurationStub::setCurrentKeyboardLayout(const QString&)
{
}

io::path_t ShortcutsConfigurationStub::shortcutsUserAppDataPath() const
{
return io::path_t();
}

io::path_t ShortcutsConfigurationStub::shortcutsAppDataPath() const
{
return io::path_t();
}

std::string ShortcutsConfigurationStub::defaultShortcutsName() const
{
return "shortcuts";
}

std::vector<std::string> ShortcutsConfigurationStub::availableShortcutsPresets() const
{
return {};
}

std::string ShortcutsConfigurationStub::currentShortcutsPresetName() const
{
return std::string();
}

void ShortcutsConfigurationStub::setCurrentShortcutsPresetName(const std::string&)
{
}

muse::async::Channel<std::string> ShortcutsConfigurationStub::currentShortcutsPresetNameChanged() const
{
return {};
}

io::path_t ShortcutsConfigurationStub::commandShortcutsUserAppDataPath(const std::string&) const
{
return io::path_t();
}

io::path_t ShortcutsConfigurationStub::commandShortcutsAppDataPath(const std::string&) const
{
return io::path_t();
}
Loading