added temporary solution for determinate shortcuts context
This commit is contained in:
parent
256b1ca094
commit
af0aa347b1
5 changed files with 38 additions and 9 deletions
|
@ -20,10 +20,12 @@
|
|||
|
||||
using namespace mu::context;
|
||||
using namespace mu::domain::notation;
|
||||
using namespace mu::shortcuts;
|
||||
|
||||
void GlobalContext::setCurrentNotation(const std::shared_ptr<domain::notation::INotation>& notation)
|
||||
{
|
||||
m_notation = notation;
|
||||
updateShortcutContext();
|
||||
m_notationChanged.notify();
|
||||
}
|
||||
|
||||
|
@ -45,6 +47,7 @@ bool GlobalContext::isPlaying() const
|
|||
void GlobalContext::setIsPlaying(bool arg)
|
||||
{
|
||||
m_isPlaying = arg;
|
||||
updateShortcutContext();
|
||||
m_isPlayingChanged.notify();
|
||||
}
|
||||
|
||||
|
@ -52,3 +55,20 @@ mu::async::Notification GlobalContext::isPlayingChanged() const
|
|||
{
|
||||
return m_isPlayingChanged;
|
||||
}
|
||||
|
||||
ShortcutContext GlobalContext::currentShortcutContext() const
|
||||
{
|
||||
//! TODO Temporary solution, it does not correctly determine the current context for shortcuts
|
||||
if (isPlaying()) {
|
||||
return ShortcutContext::Playing;
|
||||
} else if (currentNotation()) {
|
||||
return ShortcutContext::NotationActive;
|
||||
}
|
||||
return ShortcutContext::Undefined;
|
||||
}
|
||||
|
||||
void GlobalContext::updateShortcutContext()
|
||||
{
|
||||
ShortcutContext ctx = currentShortcutContext();
|
||||
shortcutsController()->setActiveContext(ctx);
|
||||
}
|
||||
|
|
|
@ -22,10 +22,16 @@
|
|||
#include <map>
|
||||
#include "../iglobalcontext.h"
|
||||
|
||||
#include "modularity/ioc.h"
|
||||
#include "shortcuts/ishortcutscontroller.h"
|
||||
#include "shortcuts/shortcutstypes.h"
|
||||
|
||||
namespace mu {
|
||||
namespace context {
|
||||
class GlobalContext : public IGlobalContext
|
||||
{
|
||||
INJECT(context, shortcuts::IShortcutsController, shortcutsController)
|
||||
|
||||
public:
|
||||
GlobalContext() = default;
|
||||
|
||||
|
@ -39,6 +45,9 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
shortcuts::ShortcutContext currentShortcutContext() const;
|
||||
void updateShortcutContext();
|
||||
|
||||
std::shared_ptr<domain::notation::INotation> m_notation;
|
||||
async::Notification m_notationChanged;
|
||||
|
||||
|
|
|
@ -33,23 +33,23 @@ const std::vector<Action> NotationActions::m_actions = {
|
|||
),
|
||||
Action("domain/notation/note-input",
|
||||
QT_TRANSLATE_NOOP("action", "Note Input"),
|
||||
ShortcutContext::NotationViewFocused
|
||||
ShortcutContext::NotationActive
|
||||
),
|
||||
Action("domain/notation/pad-note-4",
|
||||
QT_TRANSLATE_NOOP("action", "4th"),
|
||||
ShortcutContext::NotationViewFocused
|
||||
ShortcutContext::NotationActive
|
||||
),
|
||||
Action("domain/notation/pad-note-8",
|
||||
QT_TRANSLATE_NOOP("action", "8th"),
|
||||
ShortcutContext::NotationViewFocused
|
||||
ShortcutContext::NotationActive
|
||||
),
|
||||
Action("domain/notation/pad-note-16",
|
||||
QT_TRANSLATE_NOOP("action", "16th"),
|
||||
ShortcutContext::NotationViewFocused
|
||||
ShortcutContext::NotationActive
|
||||
),
|
||||
Action("domain/notation/put-note", // args: QPoint pos, bool replace, bool insert
|
||||
QT_TRANSLATE_NOOP("action", "Put Note"),
|
||||
ShortcutContext::NotationViewFocused
|
||||
ShortcutContext::NotationActive
|
||||
)
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ static const std::map<std::string, std::string> m_actionsMap = {
|
|||
{ "note-input", "domain/notation/note-input" },
|
||||
{ "pad-note-4", "domain/notation/pad-note-4" },
|
||||
{ "pad-note-8", "domain/notation/pad-note-8" },
|
||||
{ "pad-note-16", "domain/notation/pad-note-16" },
|
||||
{ "pad-note-16", "domain/notation/pad-note-16" }
|
||||
};
|
||||
|
||||
void ShortcutsRegister::load()
|
||||
|
@ -71,7 +71,7 @@ void ShortcutsRegister::expandStandartKeys(std::list<Shortcut>& shortcuts) const
|
|||
|
||||
const QKeySequence& first = kslist.first();
|
||||
sc.sequence = first.toString().toStdString();
|
||||
LOGD() << "for standart key: " << sc.standartKey << ", sequence: " << sc.sequence;
|
||||
//LOGD() << "for standart key: " << sc.standartKey << ", sequence: " << sc.sequence;
|
||||
|
||||
//! NOTE If the keyBindings contains more than one result,
|
||||
//! these can be considered alternative shortcuts on the same platform for the given key.
|
||||
|
@ -79,7 +79,7 @@ void ShortcutsRegister::expandStandartKeys(std::list<Shortcut>& shortcuts) const
|
|||
const QKeySequence& seq = kslist.at(i);
|
||||
Shortcut esc = sc;
|
||||
esc.sequence = seq.toString().toStdString();
|
||||
LOGD() << "for standart key: " << esc.standartKey << ", alternative sequence: " << esc.sequence;
|
||||
//LOGD() << "for standart key: " << esc.standartKey << ", alternative sequence: " << esc.sequence;
|
||||
expanded.push_back(esc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ struct Shortcut
|
|||
enum class ShortcutContext {
|
||||
Undefined = 0,
|
||||
Any,
|
||||
NotationViewFocused,
|
||||
NotationActive,
|
||||
Playing
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue