-
Notifications
You must be signed in to change notification settings - Fork 28
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
Draft: More dynamic keyboard layout mapping #89
Draft: More dynamic keyboard layout mapping #89
Conversation
Interesting that AppVeyor's compilation fails, as I can compile everything just fine on my end? Last attempted compile command from AppVeyor vs same command from my local build.
|
It's looking promising, I would suggest a few things.
|
QtCreator insists on replacing all tabs of lines I touch with spaces, I gotta figure out how to turn that off for a project. I noticed that after committing, unfortunately.
👍
They were needed for the |
You are surely right about As |
I plan to add the missing keys in the custom layout section, the wiring between the custom layout settings and custom map and the saving/loading of the key settings over the next few days whenever I have time. |
As I avoid using Qt as much as possible except for gui, it would be better to hold keys in utf8 auto it = std::find_if(selectedLayoutMapping.begin(), selectedLayoutMapping.end(),
[key](const std::pair<std::string, JamKey>& t) -> bool {
return (QKeySequence(key).matches(QKeySequence(t.first)) == QKeySequence::ExactMatch);
});
if (it != selectedLayoutMapping.end()) {
return it.second;
}
else {
throw std::invalid_argument("Unmapped key");
}
Compiling works fine in my environment, so I don't know why Appveyor causes errors... |
That sounds like a good idea. I fixed the offset from the current octave being calculated wrong and replaced the - return (QKeySequence(key).matches(QKeySequence(t.first)) == QKeySequence::ExactMatch);
+ return (QKeySequence(key).matches(QKeySequence(QString(t.first))) == QKeySequence::ExactMatch); - return it.second;
+ return (*it).second; or + return it->second; |
Thank you for telling me the fix! |
I implemented custom layout saving and loading today. With that, the main goal of the PR has been reached and it can be reviewed. I think it would be better to move everything into a separate LayoutHandler class instead of defining and redefining these mapping and small helper maps all over the GUI, I'll consider doing that when I have more time again. 🙁 |
Adds keyboard layout mapping to Configuration. Also touches up the configuration dialog abit. Not much more yet: Neither saving or loading the changed custom layout nor actually using it is implemented yet, this is just to showcase the direction I'm heading in. REBASE: configuration.hpp: reverted map-include removal gui/configuration_dialog.hpp: reverted map-include removal
· Indention should be fixed. · Fixed General configuration dialog tab not being displayed first anymore. · Removed `jam_handler` from configuration.hpp, replaced with `enum class JamKey : int;` at the start of the header instead. · Moved map definitions to implementation side.
As suggested by rerrahkr. The code that was suggested to access convert the std::string to Qt::Key needed some changes though: return it.second; to return (*it).second; and return (QKeySequence(key).matches(QKeySequence(t.first)) == QKeySequence::ExactMatch); to return (QKeySequence(key).matches(QKeySequence(QString::fromStdString(t.first))) == QKeySequence::ExactMatch); Then it worked without any problems.
· Custom layout will be saved and loaded · Custom layout can be reset (to QWERTY) REBASE: Fixed merge conflicts.
It pulls the default values from the QWERTY layout, so the values in the UI can be dropped.
01d2859
to
477aad4
Compare
I rebased the PR on the current HEAD and hopefully solved all merge conflicts. Let's see if AppVeyor can build it now 🙂 |
It works well, thanks for your contribution! |
Closes #70
This is a draft PR. It's not yet feature-completeThis PR is now feature-complete, but some feedback and tips on the design and how to structure everything would be appreciated, as I'm still very much a beginner at C++ and Qt!The goal:
Current state:
std::map
s for all currently supported layouts as well as a custom one have been added.Problems / Feedback points:
mainwindow.cpp
andpattern_editor_panel.cpp
.I think this needs to be moved into a separate class with a method declaration like this?:
Let me know what you think so far!