1 // Copyright (C) 2012-2019 The VPaint Developers. 2 // See the COPYRIGHT file at the top-level directory of this distribution 3 // and at https://github.com/dalboris/vpaint/blob/master/COPYRIGHT 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 #ifndef COLORSELECTOR_H 18 #define COLORSELECTOR_H 19 20 #include <QToolButton> 21 22 #include "Color.h" 23 24 class ColorSelector : public QToolButton 25 { 26 Q_OBJECT 27 28 public: 29 explicit ColorSelector(const Color & initialColor = Qt::black, QWidget *parent = 0); 30 31 // Get/Set color 32 Color color() const; 33 void setColor(const Color & newColor); 34 35 // Set icon of QToolButton to match stored color. 36 // 37 // If clients change the icon size via setIconSize(), then they 38 // must call updateIcon() afterwards. Ideally setIconSize() should be 39 // overriden call this automatically, but unfortunately setIconSize() 40 // isn't a virtual method. 41 void updateIcon(); 42 43 signals: 44 void colorChanged(const Color & newColor); 45 46 private slots: 47 void processClick_(); 48 49 private: 50 // Stored color 51 Color color_; 52 }; 53 54 #endif // COLORSELECTOR_H 55