Chatterino
ColorProvider.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <unordered_map>
5 
6 #include <QColor>
7 
8 namespace chatterino {
9 
10 enum class ColorType {
13  Whisper,
18 };
19 
21 {
22 public:
23  static const ColorProvider &instance();
24 
36  const std::shared_ptr<QColor> color(ColorType type) const;
37 
38  void updateColor(ColorType type, QColor color);
39 
43  QSet<QColor> recentColors() const;
44 
49  const std::vector<QColor> &defaultColors() const;
50 
51 private:
52  ColorProvider();
53 
54  void initTypeColorMap();
55  void initDefaultColors();
56 
57  std::unordered_map<ColorType, std::shared_ptr<QColor>> typeColorMap_;
58  std::vector<QColor> defaultColors_;
59 };
60 } // namespace chatterino
61 
62 // Adapted from Qt example: https://doc.qt.io/qt-5/qhash.html#qhash
63 inline uint qHash(const QColor &key)
64 {
65  return qHash(key.name(QColor::HexArgb));
66 }
uint qHash(const QColor &key)
Definition: ColorProvider.hpp:63
Definition: Application.cpp:48
ColorType
Definition: ColorProvider.hpp:10
Definition: ColorProvider.hpp:20