24 #include <algorithm> |
24 #include <algorithm> |
25 |
25 |
26 #include "teamselhelper.h" |
26 #include "teamselhelper.h" |
27 #include "hwconsts.h" |
27 #include "hwconsts.h" |
28 #include "frameTeam.h" |
28 #include "frameTeam.h" |
|
29 #include "colorwidget.h" |
29 |
30 |
30 void TeamLabel::teamButtonClicked() |
31 void TeamLabel::teamButtonClicked() |
31 { |
32 { |
32 emit teamActivated(text()); |
33 emit teamActivated(text()); |
33 } |
34 } |
34 |
35 |
35 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, FrameTeams * parent) : |
36 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, FrameTeams * parent) : |
36 QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), |
37 QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), |
37 colorButt(0) |
38 colorWidget(0) |
38 { |
39 { |
39 m_parentFrameTeams = parent; |
40 m_parentFrameTeams = parent; |
40 QPalette newPalette = palette(); |
41 QPalette newPalette = palette(); |
41 newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); |
42 newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); |
42 setPalette(newPalette); |
43 setPalette(newPalette); |
65 "}"); |
66 "}"); |
66 |
67 |
67 if(m_isPlaying) |
68 if(m_isPlaying) |
68 { |
69 { |
69 // team color |
70 // team color |
70 colorButt = new QPushButton(this); |
71 colorWidget = new ColorWidget(colorsModel, this); |
71 colorButt->setMaximumWidth(26); |
72 colorWidget->setMinimumWidth(26); |
72 colorButt->setMinimumHeight(26); |
73 colorWidget->setMaximumWidth(26); |
73 colorButt->setGeometry(0, 0, 26, 26); |
74 colorWidget->setMinimumHeight(26); |
74 |
75 colorWidget->setMaximumHeight(26); |
75 incrementTeamColor(); |
76 //colorWidget->setGeometry(0, 0, 26, 26); |
76 connect(colorButt, SIGNAL(clicked()), this, SLOT(incrementTeamColor())); |
77 connect(colorWidget, SIGNAL(colorChanged(int)), this, SLOT(onColorChanged(int))); |
77 |
78 colorWidget->setColor(m_parentFrameTeams->getNextColor()); |
78 colorButt->setContextMenuPolicy(Qt::CustomContextMenu); |
79 mainLayout.addWidget(colorWidget); |
79 connect(colorButt, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(decrementTeamColor())); |
|
80 mainLayout.addWidget(colorButt); |
|
81 |
80 |
82 phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), QImage(":/res/hh25x25grey.png"), this); |
81 phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), QImage(":/res/hh25x25grey.png"), this); |
83 connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); |
82 connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); |
84 phhoger->setHHNum(team.numHedgehogs()); |
83 phhoger->setHHNum(team.numHedgehogs()); |
85 mainLayout.addWidget(phhoger); |
84 mainLayout.addWidget(phhoger); |
97 if(m_team.isNetTeam()) |
96 if(m_team.isNetTeam()) |
98 { |
97 { |
99 butt->setEnabled(interactive); |
98 butt->setEnabled(interactive); |
100 } |
99 } |
101 |
100 |
102 colorButt->setEnabled(interactive); |
101 colorWidget->setEnabled(interactive); |
103 phhoger->setEnabled(interactive); |
102 phhoger->setEnabled(interactive); |
104 } |
103 } |
105 |
104 |
106 void TeamShowWidget::setHHNum(unsigned int num) |
105 void TeamShowWidget::setHHNum(unsigned int num) |
107 { |
106 { |
126 params.numHedgehogs=phhoger->getHedgehogsNum(); |
125 params.numHedgehogs=phhoger->getHedgehogsNum(); |
127 params.teamColor=colorButt->palette().color(QPalette::Button); |
126 params.teamColor=colorButt->palette().color(QPalette::Button); |
128 return params; |
127 return params; |
129 }*/ |
128 }*/ |
130 |
129 |
131 void TeamShowWidget::incrementTeamColor() |
130 |
|
131 void TeamShowWidget::changeTeamColor(int color) |
132 { |
132 { |
133 changeTeamColor(m_parentFrameTeams->getNextColor()); |
133 colorWidget->setColor(color); |
134 } |
|
135 void TeamShowWidget::decrementTeamColor() |
|
136 { |
|
137 const QList<QColor> & availColors = m_parentFrameTeams->availableColors; |
|
138 int idx = availColors.indexOf(m_parentFrameTeams->currentColor); |
|
139 |
|
140 idx--; |
|
141 |
|
142 if (idx < 0) |
|
143 idx = availColors.size() - 1; |
|
144 |
|
145 changeTeamColor(availColors.at(idx)); |
|
146 } |
134 } |
147 |
135 |
148 void TeamShowWidget::changeTeamColor(QColor color) |
136 void TeamShowWidget::onColorChanged(int color) |
149 { |
137 { |
150 QColor & curColor = m_parentFrameTeams->currentColor; |
138 m_team.setColor(color); |
151 curColor = color; |
|
152 |
139 |
153 colorButt->setStyleSheet(QString("QPushButton{" |
|
154 "background-color: %1;" |
|
155 "border-width: 1px;" |
|
156 "border-radius: 2px;" |
|
157 "}").arg(curColor.name())); |
|
158 |
|
159 m_team.setColor(color); |
|
160 emit teamColorChanged(m_team); |
140 emit teamColorChanged(m_team); |
161 } |
141 } |
162 |
142 |
163 HWTeam TeamShowWidget::getTeam() const |
143 HWTeam TeamShowWidget::getTeam() const |
164 { |
144 { |