color_list_widget.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * \file
  3. *
  4. * \author Mattia Basaglia
  5. *
  6. * \copyright Copyright (C) 2013-2020 Mattia Basaglia
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef COLOR_LIST_WIDGET_HPP
  23. #define COLOR_LIST_WIDGET_HPP
  24. #include "abstract_widget_list.hpp"
  25. #include "color_wheel.hpp"
  26. namespace color_widgets {
  27. class QCP_EXPORT ColorListWidget : public AbstractWidgetList
  28. {
  29. Q_OBJECT
  30. Q_PROPERTY(QList<QColor> colors READ colors WRITE setColors NOTIFY colorsChanged )
  31. Q_PROPERTY(ColorWheel::ShapeEnum wheelShape READ wheelShape WRITE setWheelShape NOTIFY wheelShapeChanged)
  32. Q_PROPERTY(ColorWheel::ColorSpaceEnum colorSpace READ colorSpace WRITE setColorSpace NOTIFY colorSpaceChanged)
  33. Q_PROPERTY(bool wheelRotating READ wheelRotating WRITE setWheelRotating NOTIFY wheelRotatingChanged)
  34. public:
  35. explicit ColorListWidget(QWidget *parent = 0);
  36. ~ColorListWidget();
  37. QList<QColor> colors() const;
  38. void setColors(const QList<QColor>& colors);
  39. void swap(int a, int b);
  40. void append();
  41. ColorWheel::ShapeEnum wheelShape() const;
  42. ColorWheel::ColorSpaceEnum colorSpace() const;
  43. bool wheelRotating() const;
  44. Q_SIGNALS:
  45. void colorsChanged(const QList<QColor>&);
  46. void wheelShapeChanged(ColorWheel::ShapeEnum shape);
  47. void colorSpaceChanged(ColorWheel::ColorSpaceEnum space);
  48. void wheelRotatingChanged(bool rotating);
  49. public Q_SLOTS:
  50. void setWheelShape(ColorWheel::ShapeEnum shape);
  51. void setColorSpace(ColorWheel::ColorSpaceEnum space);
  52. void setWheelRotating(bool rotating);
  53. private Q_SLOTS:
  54. void emit_changed();
  55. void handle_removed(int);
  56. void color_changed(int row);
  57. private:
  58. class Private;
  59. Private * const p;
  60. void append_widget(int col);
  61. };
  62. } // namespace color_widgets
  63. #endif // COLOR_LIST_WIDGET_HPP