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

Pieces Coloring Permutation + Keyboard Input with QKeyEvents #119

Merged
merged 36 commits into from
Feb 20, 2024

Conversation

Necktschnagge
Copy link
Owner

@Necktschnagge Necktschnagge commented Feb 4, 2024

Conclusion

Features and Fixes

  • use event filters instead of grabKeyboard() for in-game keyboard input
  • use dynamically created color vector with up to 11 colors
    • dynamically created menu actions for color selection
    • color selection by keyboard input
    • show selected piece color in status bar

Details

dependencies:

feature requests:

  • Add MenuBar->Input->KeyCapture->{ ON AUTO OFF } (only valid as long as we grabKeyboard())

manual tests prior to merge:

  • Whenever game is stopped, Color select Actions are removed from Menubar.
  • Selected color is shown in StatusBar

TODOs:

  • Remove the color selection Menu Actions in *.ui

Acquired Knowledge:

Qt - informative:

design decisions:

  • Disadvantages of grabKeyboard() on the level of MainWindow

    • It prevents the QKeyEvents from proccessing in children of QMainWindow roughly said.
      • void MainWindow::keyPressEvent(QKeyEvent* e) eats the QKeyEvents.
      • In consequence, arrow keys stop working in mainMenu -> requires a "is focus on main menu" - check to turn on / off grabKeyboard()
  • Can we use the grabKeyboard on just the ui elements outside menubar-> SVG, ListView, TreeView in our case?

    • causes need for new inheriting classes providing the void keyPressEvent(QKeyEvent* e);
    • there are better options, see below
  • How to check for keyboard input when focus is on one of a certain list of widgets?

    • create a class e.g. class controlKeyEventAgent inheriting from QObject that has a member function
bool eventFilter(QObject* object, QEvent* event) override;
    • Install event filters on all UI elements where QKeyEvents should be caught using
ui->graphicsView->installEventFilter(&controlKeyEventAgent);

@Necktschnagge Necktschnagge self-assigned this Feb 4, 2024
@Necktschnagge Necktschnagge force-pushed the feature-pieces-coloring branch from a79c029 to e4e64b7 Compare February 4, 2024 18:50
@Necktschnagge Necktschnagge added this to the First Release milestone Feb 4, 2024
* prototype dynamically created menu items

* remove unused

* color pixmap minor

* function signatur does not matter (?)

* try to fix Qt5 Builds

* dynamically create color menu, use QSignalMapper, connect all signals and slots

* fix clang compile

* fix clang

* remove debug code

* developer menu-> enable all menu bar items

* review
@Necktschnagge
Copy link
Owner Author

Necktschnagge commented Feb 16, 2024

moved away

r0ost3r and others added 3 commits February 16, 2024 22:17
* fix error: mappedInt is not a member of QSignalMapper

* experimental: type trait check for member function existance

* try fix gcc, clang

* try fix gcc, clang

* type traits stuff

* try fix a gcc warning

* try fix error

* try fix gcc

* try fix a check

* try another implementation

* try to use new implementation

* test for negation in static assert

* remove the static_assert and use the obtained pointer.

* Delete src/custom_traits.cpp

* review

* review: renaming, doc-comments

* review

---------

Co-authored-by: Daniel Wehmeyer <r0ost3r@users.noreply.github.com>
Co-authored-by: Maximilian Starke <maximilian.starke@medionmail.com>
@Necktschnagge Necktschnagge mentioned this pull request Feb 16, 2024
19 tasks
@@ -234,6 +235,14 @@
<string>&amp;Highlight generated target cells</string>
</property>
</action>
<action name="actionEnableAllMenuBarItems">
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs some DEBUG / DEVELOP mode.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Necktschnagge
Copy link
Owner Author

Necktschnagge commented Feb 18, 2024

Broken by last commit:

  • Solver Mode: String output in listview does not match the colors anymore. Use the color vector there too -> fixed
  • Solver Mode: keyboard input does not work anymore. ->fixed

src/mainwindow.h Outdated Show resolved Hide resolved
src/mainwindow.h Outdated Show resolved Hide resolved
src/mainwindow.cpp Outdated Show resolved Hide resolved
src/mainwindow.cpp Outdated Show resolved Hide resolved
src/mainwindow.cpp Outdated Show resolved Hide resolved
src/mainwindow.cpp Outdated Show resolved Hide resolved
@Necktschnagge
Copy link
Owner Author

Necktschnagge commented Feb 19, 2024

color selection via main menu: permutation missing -> fixed in 6ab36ec

@Necktschnagge Necktschnagge changed the title Pieces Coloring (Consistency and Structure redesign) Pieces Coloring Permutation + Keyboard Input with QKeyEvents Feb 19, 2024
@Necktschnagge Necktschnagge linked an issue Feb 19, 2024 that may be closed by this pull request
@Necktschnagge Necktschnagge merged commit 13e2397 into main Feb 20, 2024
12 checks passed
@Necktschnagge Necktschnagge deleted the feature-pieces-coloring branch February 20, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Piece Coloring in GUI is not yet correct
2 participants