PlayerSelectionDialog.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * PlayerSelectionDialog.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include <QDialog>
  12. #include <QVBoxLayout>
  13. #include "../lib/constants/EntityIdentifiers.h"
  14. class QCheckBox;
  15. class MainWindow;
  16. /// Dialog shown when a hero cannot be placed as NEUTRAL.
  17. /// Allows the user to select a valid player via checkboxes,
  18. /// or using the existing keyboard shortcuts from MainWindow's player QActions.
  19. class PlayerSelectionDialog : public QDialog
  20. {
  21. Q_OBJECT
  22. public:
  23. explicit PlayerSelectionDialog(MainWindow * mainWindow = nullptr);
  24. PlayerColor getSelectedPlayer() const;
  25. private slots:
  26. void onCheckboxToggled(bool checked);
  27. private:
  28. std::vector<QCheckBox *> checkboxes;
  29. PlayerColor selectedPlayer;
  30. QFont font;
  31. QVBoxLayout mainLayout;
  32. QVBoxLayout checkboxLayout;
  33. bool defaultCheckedSet = false;
  34. void setupDialogComponents();
  35. void addCheckbox(QAction * checkboxAction, PlayerColor player, bool isEnabled);
  36. };