summaryrefslogtreecommitdiff
path: root/src/colortable.h
blob: 075171c3d159520e21be8e550606d23cde586c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef COLORTABLE_H
#define COLORTABLE_H

#include <QTableWidget>

class Settings;

// a QTableWidget to view and modify color settings
//
class ColorTable : public QTableWidget
{
public:
  ColorTable(QWidget* parent = nullptr);

  // adds colors to the table from the settings
  //
  void load(Settings& s);

  // resets the colors to their default values; commitColors() must be called
  // to save them
  //
  void resetColors();

  // commits any changes
  //
  void commitColors();

private:
  Settings* m_settings;

  void addColor(const QString& text, const QColor& defaultColor,
                std::function<QColor()> get, std::function<void(const QColor&)> commit);

  void onColorActivated();
};

#endif  // COLORTABLE_H