Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
82c66ae3
Commit
82c66ae3
authored
Sep 20, 2013
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing files
parent
f17551a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
SCHNApps/include/colorComboBox.h
SCHNApps/include/colorComboBox.h
+28
-0
SCHNApps/src/colorComboBox.cpp
SCHNApps/src/colorComboBox.cpp
+52
-0
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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