ColorChooser.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* ColorChooser.h - declaration and definition of ColorChooser class.
  2. *
  3. * Copyright (c) 2019 CYBERDEViLNL <cyberdevilnl/at/protonmail/dot/ch>
  4. *
  5. * This file is part of LMMS - https://lmms.io
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with this program (see COPYING); if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. * Boston, MA 02110-1301 USA.
  21. *
  22. */
  23. #include <QColorDialog>
  24. #include <QApplication>
  25. #include <QKeyEvent>
  26. class ColorChooser: public QColorDialog
  27. {
  28. public:
  29. ColorChooser(const QColor &initial, QWidget *parent): QColorDialog(initial, parent) {};
  30. ColorChooser(QWidget *parent): QColorDialog(parent) {};
  31. protected:
  32. // Forward key events to the parent to prevent stuck notes when the dialog gets focus
  33. void keyReleaseEvent(QKeyEvent *event) override
  34. {
  35. QKeyEvent ke(*event);
  36. QApplication::sendEvent(parentWidget(), &ke);
  37. }
  38. };