swatch.cpp
Go to the documentation of this file.
1 
22 #include "swatch.hpp"
23 
24 #include <cmath>
25 #include <QPainter>
26 #include <QMouseEvent>
27 #include <QKeyEvent>
28 #include <QApplication>
29 #include <QDrag>
30 #include <QMimeData>
31 #include <QDropEvent>
32 #include <QDragEnterEvent>
33 #include <QStyleOption>
34 #include <QToolTip>
35 
36 namespace color_widgets {
37 
39 {
40 public:
42  int selected;
43  QSize color_size;
45  QPen border;
48  bool readonly;
49 
50  QPoint drag_pos;
51  int drag_index;
52  int drop_index;
53  QColor drop_color;
55 
57 
58  Private(Swatch* owner)
59  : selected(-1),
60  color_size(16,16),
61  size_policy(Hint),
62  border(Qt::black, 1),
63  forced_rows(0),
64  forced_columns(0),
65  readonly(false),
66  drag_index(-1),
67  drop_index(-1),
68  drop_overwrite(false),
69  owner(owner)
70  {}
71 
75  QSize rowcols()
76  {
77  int count = palette.count();
78  if ( count == 0 )
79  return QSize();
80 
81  if ( forced_rows )
82  return QSize(std::ceil( float(count) / forced_rows ), forced_rows);
83 
84  int columns = palette.columns();
85 
86  if ( forced_columns )
87  columns = forced_columns;
88  else if ( columns == 0 )
89  columns = qMin(palette.count(), owner->width() / color_size.width());
90 
91  int rows = std::ceil( float(count) / columns );
92 
93  return QSize(columns, rows);
94  }
95 
99  void dropEvent(QDropEvent* event)
100  {
101  // Find the output location
102  drop_index = owner->indexAt(event->pos());
103  if ( drop_index == -1 )
104  drop_index = palette.count();
105 
106  // Gather up the color
107  if ( event->mimeData()->hasColor() )
108  {
109  drop_color = event->mimeData()->colorData().value<QColor>();
110  drop_color.setAlpha(255);
111  }
112  else if ( event->mimeData()->hasText() )
113  {
114  drop_color = QColor(event->mimeData()->text());
115  }
116 
117  drop_overwrite = false;
118  QRectF drop_rect = indexRect(drop_index);
119  if ( drop_index < palette.count() && drop_rect.isValid() )
120  {
121  // 1 column => vertical style
122  if ( palette.columns() == 1 || forced_columns == 1 )
123  {
124  // Dragged to the last quarter of the size of the square, add after
125  if ( event->posF().y() >= drop_rect.top() + drop_rect.height() * 3.0 / 4 )
126  drop_index++;
127  // Dragged to the middle of the square, overwrite existing color
128  else if ( event->posF().x() > drop_rect.top() + drop_rect.height() / 4 &&
129  ( event->dropAction() != Qt::MoveAction || event->source() != owner ) )
130  drop_overwrite = true;
131  }
132  else
133  {
134  // Dragged to the last quarter of the size of the square, add after
135  if ( event->posF().x() >= drop_rect.left() + drop_rect.width() * 3.0 / 4 )
136  drop_index++;
137  // Dragged to the middle of the square, overwrite existing color
138  else if ( event->posF().x() > drop_rect.left() + drop_rect.width() / 4 &&
139  ( event->dropAction() != Qt::MoveAction || event->source() != owner ) )
140  drop_overwrite = true;
141  }
142  }
143 
144  owner->update();
145  }
146 
150  void clearDrop()
151  {
152  drop_index = -1;
153  drop_color = QColor();
154  drop_overwrite = false;
155 
156  owner->update();
157  }
158 
163  {
164  QSize rowcols = this->rowcols();
165  if ( !rowcols.isValid() )
166  return QSizeF();
167  return actualColorSize(rowcols);
168  }
169 
174  QSizeF actualColorSize(const QSize& rowcols)
175  {
176  return QSizeF (float(owner->width()) / rowcols.width(),
177  float(owner->height()) / rowcols.height());
178  }
179 
180 
186  QRectF indexRect(int index, const QSize& rowcols, const QSizeF& color_size)
187  {
188  if ( index == -1 )
189  return QRectF();
190 
191  return QRectF(
192  index % rowcols.width() * color_size.width(),
193  index / rowcols.width() * color_size.height(),
194  color_size.width(),
195  color_size.height()
196  );
197  }
201  QRectF indexRect(int index)
202  {
203  QSize rc = rowcols();
204  if ( index == -1 || !rc.isValid() )
205  return QRectF();
206  return indexRect(index, rc, actualColorSize(rc));
207  }
208 };
209 
210 Swatch::Swatch(QWidget* parent)
211  : QWidget(parent), p(new Private(this))
212 {
214  connect(&p->palette, &ColorPalette::columnsChanged, this, (void(QWidget::*)())&QWidget::update);
215  connect(&p->palette, &ColorPalette::colorsUpdated, this, (void(QWidget::*)())&QWidget::update);
216  connect(&p->palette, &ColorPalette::colorChanged, [this](int index){
217  if ( index == p->selected )
218  emit colorSelected( p->palette.colorAt(index) );
219  });
220  connect(&p->palette, &ColorPalette::colorRemoved, [this](int index){
221  if ( index == p->selected )
222  clearSelection();
223  });
224  setFocusPolicy(Qt::StrongFocus);
225  setAcceptDrops(true);
226  setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
227  setAttribute(Qt::WA_Hover, true);
228 }
229 
231 {
232  delete p;
233 }
234 
235 QSize Swatch::sizeHint() const
236 {
237  QSize rowcols = p->rowcols();
238 
239  if ( !p->color_size.isValid() || !rowcols.isValid() )
240  return QSize();
241 
242  return QSize(
243  p->color_size.width() * rowcols.width(),
244  p->color_size.height() * rowcols.height()
245  );
246 }
247 
249 {
250  if ( p->size_policy != Hint )
251  return sizeHint();
252  return QSize();
253 }
254 
255 const ColorPalette& Swatch::palette() const
256 {
257  return p->palette;
258 }
259 
261 {
262  return p->palette;
263 }
264 
265 int Swatch::selected() const
266 {
267  return p->selected;
268 }
269 
270 QColor Swatch::selectedColor() const
271 {
272  return p->palette.colorAt(p->selected);
273 }
274 
275 int Swatch::indexAt(const QPoint& pt)
276 {
277  QSize rowcols = p->rowcols();
278  if ( rowcols.isEmpty() )
279  return -1;
280 
281  QSizeF color_size = p->actualColorSize(rowcols);
282 
283  QPoint point(
284  qBound<int>(0, pt.x() / color_size.width(), rowcols.width() - 1),
285  qBound<int>(0, pt.y() / color_size.height(), rowcols.height() - 1)
286  );
287 
288  int index = point.y() * rowcols.width() + point.x();
289  if ( index >= p->palette.count() )
290  return -1;
291  return index;
292 }
293 
294 QColor Swatch::colorAt(const QPoint& pt)
295 {
296  return p->palette.colorAt(indexAt(pt));
297 }
298 
300 {
301  clearSelection();
302  p->palette = palette;
303  update();
304  emit paletteChanged(p->palette);
305 }
306 
308 {
309  if ( selected < 0 || selected >= p->palette.count() )
310  selected = -1;
311 
312  if ( selected != p->selected )
313  {
314  emit selectedChanged( p->selected = selected );
315  if ( selected != -1 )
317  update();
318  }
319 }
320 
322 {
323  setSelected(-1);
324 }
325 
326 void Swatch::paintEvent(QPaintEvent* )
327 {
328  QSize rowcols = p->rowcols();
329  if ( rowcols.isEmpty() )
330  return;
331 
332  QSizeF color_size = p->actualColorSize(rowcols);
333  QPainter painter(this);
334 
335  QStyleOptionFrame panel;
336  panel.initFrom(this);
337  panel.lineWidth = 1;
338  panel.midLineWidth = 0;
339  panel.state |= QStyle::State_Sunken;
340  style()->drawPrimitive(QStyle::PE_Frame, &panel, &painter, this);
341  QRect r = style()->subElementRect(QStyle::SE_FrameContents, &panel, this);
342  painter.setClipRect(r);
343 
344  int count = p->palette.count();
345  painter.setPen(p->border);
346  for ( int y = 0, i = 0; i < count; y++ )
347  {
348  for ( int x = 0; x < rowcols.width() && i < count; x++, i++ )
349  {
350  painter.setBrush(p->palette.colorAt(i));
351  painter.drawRect(p->indexRect(i, rowcols, color_size));
352  }
353  }
354 
355  painter.setClipping(false);
356 
357  if ( p->drop_index != -1 )
358  {
359  QRectF drop_area = p->indexRect(p->drop_index, rowcols, color_size);
360  if ( p->drop_overwrite )
361  {
362  painter.setBrush(p->drop_color);
363  painter.setPen(QPen(Qt::gray));
364  painter.drawRect(drop_area);
365  }
366  else if ( rowcols.width() == 1 )
367  {
368  // 1 column => vertical style
369  painter.setPen(QPen(p->drop_color, 2));
370  painter.setBrush(Qt::transparent);
371  painter.drawLine(drop_area.topLeft(), drop_area.topRight());
372  }
373  else
374  {
375  painter.setPen(QPen(p->drop_color, 2));
376  painter.setBrush(Qt::transparent);
377  painter.drawLine(drop_area.topLeft(), drop_area.bottomLeft());
378  // Draw also on the previous line when the first item of a line is selected
379  if ( p->drop_index % rowcols.width() == 0 && p->drop_index != 0 )
380  {
381  drop_area = p->indexRect(p->drop_index-1, rowcols, color_size);
382  drop_area.translate(color_size.width(), 0);
383  painter.drawLine(drop_area.topLeft(), drop_area.bottomLeft());
384  }
385  }
386  }
387 
388  if ( p->selected != -1 )
389  {
390  QRectF rect = p->indexRect(p->selected, rowcols, color_size);
391  painter.setBrush(Qt::transparent);
392  painter.setPen(QPen(Qt::darkGray, 2));
393  painter.drawRect(rect);
394  painter.setPen(QPen(Qt::gray, 2, Qt::DotLine));
395  painter.drawRect(rect);
396  }
397 }
398 
399 void Swatch::keyPressEvent(QKeyEvent* event)
400 {
401  if ( p->palette.count() == 0 )
402  QWidget::keyPressEvent(event);
403 
404  int selected = p->selected;
405  int count = p->palette.count();
406  QSize rowcols = p->rowcols();
407  int columns = rowcols.width();
408  int rows = rowcols.height();
409  switch ( event->key() )
410  {
411  default:
412  QWidget::keyPressEvent(event);
413  return;
414 
415  case Qt::Key_Left:
416  if ( selected == -1 )
417  selected = count - 1;
418  else if ( selected > 0 )
419  selected--;
420  break;
421 
422  case Qt::Key_Right:
423  if ( selected == -1 )
424  selected = 0;
425  else if ( selected < count - 1 )
426  selected++;
427  break;
428 
429  case Qt::Key_Up:
430  if ( selected == -1 )
431  selected = count - 1;
432  else if ( selected >= columns )
433  selected -= columns;
434  break;
435 
436  case Qt::Key_Down:
437  if ( selected == -1 )
438  selected = 0;
439  else if ( selected < count - columns )
440  selected += columns;
441  break;
442 
443  case Qt::Key_Home:
444  if ( event->modifiers() & Qt::ControlModifier )
445  selected = 0;
446  else
447  selected -= selected % columns;
448  break;
449 
450  case Qt::Key_End:
451  if ( event->modifiers() & Qt::ControlModifier )
452  selected = count - 1;
453  else
454  selected += columns - (selected % columns) - 1;
455  break;
456 
457  case Qt::Key_Delete:
458  removeSelected();
459  return;
460 
461  case Qt::Key_Backspace:
462  if (selected != -1 && !p->readonly )
463  {
464  p->palette.eraseColor(selected);
465  if ( p->palette.count() == 0 )
466  selected = -1;
467  else
468  selected = qMax(selected - 1, 0);
469  }
470  break;
471 
472  case Qt::Key_PageUp:
473  if ( selected == -1 )
474  selected = 0;
475  else
476  selected = selected % columns;
477  break;
478  case Qt::Key_PageDown:
479  if ( selected == -1 )
480  {
481  selected = count - 1;
482  }
483  else
484  {
485  selected = columns * (rows-1) + selected % columns;
486  if ( selected >= count )
487  selected -= columns;
488  }
489  break;
490  }
491  setSelected(selected);
492 }
493 
495 {
496  if (p->selected != -1 && !p->readonly )
497  {
498  int selected = p->selected;
500  setSelected(qMin(selected, p->palette.count() - 1));
501  }
502 }
503 
504 void Swatch::mousePressEvent(QMouseEvent *event)
505 {
506  if ( event->button() == Qt::LeftButton )
507  {
508  setSelected(indexAt(event->pos()));
509  p->drag_pos = event->pos();
510  p->drag_index = indexAt(event->pos());
511  }
512  else if ( event->button() == Qt::RightButton )
513  {
514  int index = indexAt(event->pos());
515  if ( index != -1 )
516  emit rightClicked(index);
517  }
518 }
519 
520 void Swatch::mouseMoveEvent(QMouseEvent *event)
521 {
522  if ( p->drag_index != -1 && (event->buttons() & Qt::LeftButton) &&
523  (p->drag_pos - event->pos()).manhattanLength() >= QApplication::startDragDistance() )
524  {
525  QColor color = p->palette.colorAt(p->drag_index);
526 
527  QPixmap preview(24,24);
528  preview.fill(color);
529 
530  QMimeData *mimedata = new QMimeData;
531  mimedata->setColorData(color);
532  mimedata->setText(p->palette.nameAt(p->drag_index));
533 
534  QDrag *drag = new QDrag(this);
535  drag->setMimeData(mimedata);
536  drag->setPixmap(preview);
537  Qt::DropActions actions = Qt::CopyAction;
538  if ( !p->readonly )
539  actions |= Qt::MoveAction;
540  drag->exec(actions);
541  }
542 }
543 
545 {
546  if ( event->button() == Qt::LeftButton )
547  {
548  p->drag_index = -1;
549  }
550 }
551 
553 {
554  if ( event->button() == Qt::LeftButton )
555  {
556  int index = indexAt(event->pos());
557  if ( index != -1 )
558  emit doubleClicked(index);
559  }
560 }
561 
562 void Swatch::wheelEvent(QWheelEvent* event)
563 {
564  if ( event->delta() > 0 )
565  p->selected = qMin(p->selected + 1, p->palette.count() - 1);
566  else if ( p->selected == -1 )
567  p->selected = p->palette.count() - 1;
568  else if ( p->selected > 0 )
569  p->selected--;
571 }
572 
573 void Swatch::dragEnterEvent(QDragEnterEvent *event)
574 {
575  if ( p->readonly )
576  return;
577 
578  p->dropEvent(event);
579 
580  if ( p->drop_color.isValid() && p->drop_index != -1 )
581  {
582  if ( event->proposedAction() == Qt::MoveAction && event->source() == this )
583  event->setDropAction(Qt::MoveAction);
584  else
585  event->setDropAction(Qt::CopyAction);
586 
587  event->accept();
588  }
589 }
590 
591 void Swatch::dragMoveEvent(QDragMoveEvent* event)
592 {
593  if ( p->readonly )
594  return;
595  p->dropEvent(event);
596 }
597 
598 void Swatch::dragLeaveEvent(QDragLeaveEvent *)
599 {
600  p->clearDrop();
601 }
602 
603 void Swatch::dropEvent(QDropEvent *event)
604 {
605  if ( p->readonly )
606  return;
607 
608  QString name;
609 
610  // Gather up the color
611  if ( event->mimeData()->hasColor() && event->mimeData()->hasText() )
612  name = event->mimeData()->text();
613 
614  // Not a color, discard
615  if ( !p->drop_color.isValid() || p->drop_index == -1 )
616  return;
617 
618  p->dropEvent(event);
619 
620  // Move unto self
621  if ( event->dropAction() == Qt::MoveAction && event->source() == this )
622  {
623  // Not moved => noop
624  if ( p->drop_index != p->drag_index && p->drop_index != p->drag_index + 1 )
625  {
626  // Erase the old color
628  if ( p->drop_index > p->drag_index )
629  p->drop_index--;
630  p->selected = p->drop_index;
631  // Insert the dropped color
633  }
634  }
635  // Move into a color cell
636  else if ( p->drop_overwrite )
637  {
639  }
640  // Insert the dropped color
641  else
642  {
644  }
645 
646  // Finalize
647  event->accept();
648  p->drag_index = -1;
649  p->clearDrop();
650 }
651 
653 {
654  if ( p->selected >= p->palette.count() )
655  clearSelection();
656 
657  if ( p->size_policy == Minimum )
658  setMinimumSize(sizeHint());
659  else if ( p->size_policy == Fixed )
660  setFixedSize(sizeHint());
661 
662  update();
663 }
664 
665 QSize Swatch::colorSize() const
666 {
667  return p->color_size;
668 }
669 
670 void Swatch::setColorSize(const QSize& colorSize)
671 {
672  if ( p->color_size != colorSize )
673  emit colorSizeChanged(p->color_size = colorSize);
674 }
675 
677 {
678  return p->size_policy;
679 }
680 
682 {
683  if ( p->size_policy != colorSizePolicy )
684  {
685  setMinimumSize(0,0);
686  setFixedSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX);
687  paletteModified();
688  emit colorSizePolicyChanged(p->size_policy = colorSizePolicy);
689  }
690 }
691 
692 int Swatch::forcedColumns() const
693 {
694  return p->forced_columns;
695 }
696 
697 int Swatch::forcedRows() const
698 {
699  return p->forced_rows;
700 }
701 
703 {
704  if ( forcedColumns <= 0 )
705  forcedColumns = 0;
706 
707  if ( forcedColumns != p->forced_columns )
708  {
709  emit forcedColumnsChanged(p->forced_columns = forcedColumns);
710  emit forcedRowsChanged(p->forced_rows = 0);
711  }
712 }
713 
715 {
716  if ( forcedRows <= 0 )
717  forcedRows = 0;
718 
719  if ( forcedRows != p->forced_rows )
720  {
722  emit forcedRowsChanged(p->forced_rows = forcedRows);
723  }
724 }
725 
726 bool Swatch::readOnly() const
727 {
728  return p->readonly;
729 }
730 
732 {
733  if ( readOnly != p->readonly )
734  {
735  emit readOnlyChanged(p->readonly = readOnly);
736  setAcceptDrops(!p->readonly);
737  }
738 }
739 
740 bool Swatch::event(QEvent* event)
741 {
742  if(event->type() == QEvent::ToolTip)
743  {
744  QHelpEvent* help_ev = static_cast<QHelpEvent*>(event);
745  int index = indexAt(help_ev->pos());
746  if ( index != -1 )
747  {
748  QColor color = p->palette.colorAt(index);
749  QString name = p->palette.nameAt(index);
750  QString message = color.name();
751  if ( !name.isEmpty() )
752  message = tr("%1 (%2)").arg(name).arg(message);
753  message = "<tt style='background-color:"+color.name()+";color:"+color.name()+";'>MM</tt> "+message.toHtmlEscaped();
754  QToolTip::showText(help_ev->globalPos(), message, this,
755  p->indexRect(index).toRect());
756  event->accept();
757  }
758  else
759  {
760  QToolTip::hideText();
761  event->ignore();
762  }
763  return true;
764  }
765 
766  return QWidget::event(event);
767 }
768 
769 QPen Swatch::border() const
770 {
771  return p->border;
772 }
773 
774 void Swatch::setBorder(const QPen& border)
775 {
776  if ( border != p->border )
777  {
778  p->border = border;
779  emit borderChanged(border);
780  update();
781  }
782 }
783 
784 } // namespace color_widgets
QPoint drag_pos
Point used to keep track of dragging.
Definition: swatch.cpp:50
void forcedRowsChanged(int forcedRows)
void colorsChanged(const QVector< QPair< QColor, QString > > &)
Emitted when all the colors have changed.
void setPalette(const ColorPalette &palette)
Definition: swatch.cpp:299
QSize rowcols()
Number of rows/columns in the palette.
Definition: swatch.cpp:75
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:573
void setColorSize(const QSize &colorSize)
Definition: swatch.cpp:670
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:544
bool drop_overwrite
Whether the drop will overwrite an existing color.
Definition: swatch.cpp:54
A widget drawing a palette.
Definition: swatch.hpp:34
int drop_index
Index for a requested drop.
Definition: swatch.cpp:52
void colorSelected(const QColor &color)
QRectF indexRect(int index, const QSize &rowcols, const QSizeF &color_size)
Rectangle corresponding to the color at the given index.
Definition: swatch.cpp:186
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:562
void readOnlyChanged(bool readOnly)
void colorSizeChanged(const QSize &colorSize)
int indexAt(const QPoint &p)
Color index at the given position within the widget.
Definition: swatch.cpp:275
void selectedChanged(int selected)
void forcedColumnsChanged(int forcedColumns)
int forcedRows() const
bool event(QEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:740
void removeSelected()
Remove the currently seleceted color.
Definition: swatch.cpp:494
void setForcedColumns(int forcedColumns)
Definition: swatch.cpp:702
QSizeF actualColorSize(const QSize &rowcols)
Actual size of a color square.
Definition: swatch.cpp:174
QSize color_size
Preferred size for the color squares.
Definition: swatch.cpp:43
void paletteModified()
Connected to the internal palette object to keep eveything consistent.
Definition: swatch.cpp:652
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:520
void colorSizePolicyChanged(ColorSizePolicy colorSizePolicy)
int selected() const
QColor colorAt(const QPoint &p)
Color at the given position within the widget.
Definition: swatch.cpp:294
void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:598
void paletteChanged(const ColorPalette &palette)
QSize colorSize() const
void rightClicked(int index)
QPen border() const
QSize sizeHint() const Q_DECL_OVERRIDE
Definition: swatch.cpp:235
void setColorAt(int index, const QColor &color)
Change the color at the given index.
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:326
void eraseColor(int index)
Remove the color at the given index.
void setSelected(int selected)
Definition: swatch.cpp:307
void setReadOnly(bool readOnly)
Definition: swatch.cpp:731
const char * name
int columns
Number of colors to display in a row, if 0 unspecified.
void clearDrop()
Clears drop properties.
Definition: swatch.cpp:150
QRectF indexRect(int index)
Rectangle corresponding to the color at the given index.
Definition: swatch.cpp:201
void borderChanged(const QPen &border)
void colorRemoved(int index)
Emitted when the color at the given index has been removed.
QColor selectedColor() const
Color at the currently selected index.
Definition: swatch.cpp:270
QSize minimumSizeHint() const Q_DECL_OVERRIDE
Definition: swatch.cpp:248
Q_INVOKABLE QColor colorAt(int index) const
Color at the given index.
void colorChanged(int index)
Emitted when the color or the name at the given index has been modified.
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:603
QSizeF actualColorSize()
Actual size of a color square.
Definition: swatch.cpp:162
void setColorSizePolicy(ColorSizePolicy colorSizePolicy)
Definition: swatch.cpp:681
int selected
Current selection index (-1 for no selection)
Definition: swatch.cpp:42
int forcedColumns() const
void insertColor(int index, const QColor &color, const QString &name=QString())
Insert a color in an arbitrary location.
void dropEvent(QDropEvent *event)
Sets the drop properties.
Definition: swatch.cpp:99
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:552
void setForcedRows(int forcedRows)
Definition: swatch.cpp:714
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:504
QColor drop_color
Dropped color.
Definition: swatch.cpp:53
Q_INVOKABLE QString nameAt(int index) const
Color name at the given index.
bool readOnly() const
ColorSizePolicy size_policy
Definition: swatch.cpp:44
int count
Number of colors.
void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:591
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE
Definition: swatch.cpp:399
enum MQTTReasonCodes rc
Definition: test10.c:1112
The size is just a hint.
Definition: swatch.hpp:93
int drag_index
Index used by drags.
Definition: swatch.cpp:51
Swatch(QWidget *parent=0)
Definition: swatch.cpp:210
ColorPalette palette
Palette with colors and related metadata.
Definition: swatch.cpp:41
bool readonly
Whether the palette can be modified via user interaction.
Definition: swatch.cpp:48
const ColorPalette & palette() const
void setBorder(const QPen &border)
Definition: swatch.cpp:774
Must be exactly as specified.
Definition: swatch.hpp:95
void doubleClicked(int index)
void colorsUpdated(const QVector< QPair< QColor, QString >> &)
Emitted when the colors have been modified with a simple operation (set, append etc.)
ColorSizePolicy colorSizePolicy() const
Can expand but not contract.
Definition: swatch.hpp:94


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:48