File: colorframe.h

package info (click to toggle)
meshlab 2022.02%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 47,348 kB
  • sloc: cpp: 536,635; ansic: 27,783; sh: 539; makefile: 36
file content (49 lines) | stat: -rw-r--r-- 1,098 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef COLORFRAME_H_
#define COLORFRAME_H_

#include <QFrame>
#include <QColorDialog>

/*
 *A simple widget that displays a color and allows the
 * user to choose a new one with a QColorDialog
 */ 
class Colorframe : public QFrame
{
	Q_OBJECT
	
public:
	Colorframe(QWidget * parent, Qt::WindowFlags flags = 0) : QFrame(parent, flags){} 

	virtual void mousePressEvent ( QMouseEvent *)
	{
		QPalette palette = Colorframe::palette();
		QColor temp = palette.color(QPalette::Normal, QPalette::Window);
		temp = QColorDialog::getColor(temp);
		if (temp.isValid()){
			setColor(temp);
			update();
		}
	}

	QColor getColor(){return Colorframe::palette().color(QPalette::Normal, QPalette::Window);}
	
public slots:

	void setColor(QColor c)
	{
		QPalette palette = Colorframe::palette();
		palette.setColor(QPalette::Normal, QPalette::Window, c);
		palette.setColor(QPalette::Disabled, QPalette::Window, c);
		palette.setColor(QPalette::Inactive, QPalette::Window, c);
		setPalette(palette);
		update();
		emit colorChanged(c);
	}
	
signals:
	void colorChanged(QColor c);
	
};

#endif /*COLORFRAME_H_*/