30 void TeamLabel::teamButtonClicked() |
30 void TeamLabel::teamButtonClicked() |
31 { |
31 { |
32 emit teamActivated(text()); |
32 emit teamActivated(text()); |
33 } |
33 } |
34 |
34 |
35 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) : |
35 TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, FrameTeams * parent) : |
36 QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), |
36 QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), |
37 colorButt(0) |
37 colorButt(0) |
38 { |
38 { |
|
39 m_parentFrameTeams = parent; |
39 QPalette newPalette = palette(); |
40 QPalette newPalette = palette(); |
40 newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); |
41 newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); |
41 setPalette(newPalette); |
42 setPalette(newPalette); |
42 setAutoFillBackground(true); |
43 setAutoFillBackground(true); |
43 |
44 |
127 return params; |
128 return params; |
128 }*/ |
129 }*/ |
129 |
130 |
130 void TeamShowWidget::incrementTeamColor() |
131 void TeamShowWidget::incrementTeamColor() |
131 { |
132 { |
132 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
133 changeTeamColor(m_parentFrameTeams->getNextColor()); |
133 QColor color; |
|
134 if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) |
|
135 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
|
136 color=*pOurFrameTeams->currentColor; |
|
137 |
|
138 changeTeamColor(color); |
|
139 } |
134 } |
140 void TeamShowWidget::decrementTeamColor() |
135 void TeamShowWidget::decrementTeamColor() |
141 { |
136 { |
142 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
137 const QList<QColor> & availColors = m_parentFrameTeams->availableColors; |
143 QColor color; |
138 int idx = availColors.indexOf(m_parentFrameTeams->currentColor); |
144 if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.begin()) |
|
145 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.end()-1; |
|
146 else --pOurFrameTeams->currentColor; |
|
147 color=*pOurFrameTeams->currentColor; |
|
148 |
139 |
149 changeTeamColor(color); |
140 idx--; |
|
141 |
|
142 if (idx < 0) |
|
143 idx = availColors.size() - 1; |
|
144 |
|
145 changeTeamColor(availColors.at(idx)); |
150 } |
146 } |
151 |
147 |
152 void TeamShowWidget::changeTeamColor(QColor color) |
148 void TeamShowWidget::changeTeamColor(QColor color) |
153 { |
149 { |
154 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
150 QColor & curColor = m_parentFrameTeams->currentColor; |
155 // set according color iterator |
151 curColor = color; |
156 pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), |
|
157 pOurFrameTeams->availableColors.end(), color); |
|
158 if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) |
|
159 { |
|
160 // error condition |
|
161 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
|
162 } |
|
163 |
152 |
164 colorButt->setStyleSheet(QString("QPushButton{" |
153 colorButt->setStyleSheet(QString("QPushButton{" |
165 "background-color: %1;" |
154 "background-color: %1;" |
166 "border-width: 1px;" |
155 "border-width: 1px;" |
167 "border-radius: 2px;" |
156 "border-radius: 2px;" |
168 "}").arg(pOurFrameTeams->currentColor->name())); |
157 "}").arg(curColor.name())); |
169 |
158 |
170 m_team.setColor(color); |
159 m_team.setColor(color); |
171 emit teamColorChanged(m_team); |
160 emit teamColorChanged(m_team); |
172 } |
161 } |
173 |
162 |