Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hurstel
CGoGN
Commits
82c66ae3
Commit
82c66ae3
authored
Sep 20, 2013
by
Pierre Kraemer
Browse files
add missing files
parent
f17551a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
SCHNApps/include/colorComboBox.h
0 → 100644
View file @
82c66ae3
#ifndef _COLORCOMBOBOX_H
#define _COLORCOMBOBOX_H
#include
<QComboBox>
class
QColor
;
class
QWidget
;
class
ColorComboBox
:
public
QComboBox
{
Q_OBJECT
Q_PROPERTY
(
QColor
color
READ
color
WRITE
setColor
USER
true
)
public:
QColor
color
()
const
;
void
setColor
(
QColor
c
);
public:
ColorComboBox
(
QWidget
*
widget
=
0
);
private:
void
populateList
();
public
slots
:
void
slotHighlight
(
int
index
);
};
#endif
SCHNApps/src/colorComboBox.cpp
0 → 100644
View file @
82c66ae3
#include
<QtGui>
#include
"colorComboBox.h"
ColorComboBox
::
ColorComboBox
(
QWidget
*
widget
)
:
QComboBox
(
widget
)
{
//connect( this, SIGNAL(highlighted(int)), this, SLOT(slotHighlight(int)) );
populateList
();
}
QColor
ColorComboBox
::
color
()
const
{
return
qvariant_cast
<
QColor
>
(
itemData
(
currentIndex
(),
Qt
::
DecorationRole
));
}
void
ColorComboBox
::
setColor
(
QColor
color
)
{
setCurrentIndex
(
findData
(
color
,
int
(
Qt
::
DecorationRole
)));
}
void
ColorComboBox
::
populateList
()
{
//QStringList colorNames = QColor::colorNames();
QStringList
colorNames
;
colorNames
<<
"red"
<<
"green"
<<
"blue"
<<
"cyan "
<<
"magenta"
<<
"yellow"
<<
"gray"
<<
"white"
<<
"black"
;
for
(
int
i
=
0
;
i
<
colorNames
.
size
();
++
i
)
{
QColor
color
(
colorNames
[
i
]);
insertItem
(
i
,
colorNames
[
i
]);
setItemData
(
i
,
color
,
Qt
::
DecorationRole
);
}
}
void
ColorComboBox
::
slotHighlight
(
int
index
)
{
const
QStringList
colorNames
=
QColor
::
colorNames
();
QColor
color
(
colorNames
.
at
(
index
));
QPalette
palette
=
this
->
palette
();
palette
.
setColor
(
QPalette
::
Highlight
,
color
);
setPalette
(
palette
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment