69 colorButt = new QPushButton(this); |
69 colorButt = new QPushButton(this); |
70 colorButt->setMaximumWidth(26); |
70 colorButt->setMaximumWidth(26); |
71 colorButt->setMinimumHeight(26); |
71 colorButt->setMinimumHeight(26); |
72 colorButt->setGeometry(0, 0, 26, 26); |
72 colorButt->setGeometry(0, 0, 26, 26); |
73 |
73 |
74 changeTeamColor(); |
74 incrementTeamColor(); |
75 connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor())); |
75 connect(colorButt, SIGNAL(clicked()), this, SLOT(incrementTeamColor())); |
|
76 |
|
77 colorButt->setContextMenuPolicy(Qt::CustomContextMenu); |
|
78 connect(colorButt, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(decrementTeamColor())); |
76 mainLayout.addWidget(colorButt); |
79 mainLayout.addWidget(colorButt); |
77 |
80 |
78 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); |
79 connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); |
82 connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); |
80 phhoger->setHHNum(team.numHedgehogs()); |
83 phhoger->setHHNum(team.numHedgehogs()); |
122 params.numHedgehogs=phhoger->getHedgehogsNum(); |
125 params.numHedgehogs=phhoger->getHedgehogsNum(); |
123 params.teamColor=colorButt->palette().color(QPalette::Button); |
126 params.teamColor=colorButt->palette().color(QPalette::Button); |
124 return params; |
127 return params; |
125 }*/ |
128 }*/ |
126 |
129 |
|
130 void TeamShowWidget::incrementTeamColor() |
|
131 { |
|
132 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
|
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 } |
|
140 void TeamShowWidget::decrementTeamColor() |
|
141 { |
|
142 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
|
143 QColor color; |
|
144 if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.begin()) |
|
145 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.end()-1; |
|
146 else --pOurFrameTeams->currentColor; |
|
147 color=*pOurFrameTeams->currentColor; |
|
148 |
|
149 changeTeamColor(color); |
|
150 } |
|
151 |
127 void TeamShowWidget::changeTeamColor(QColor color) |
152 void TeamShowWidget::changeTeamColor(QColor color) |
128 { |
153 { |
129 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
154 FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget()); |
130 if(!color.isValid()) |
155 // set according color iterator |
|
156 pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), |
|
157 pOurFrameTeams->availableColors.end(), color); |
|
158 if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) |
131 { |
159 { |
132 if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) |
160 // error condition |
133 { |
161 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
134 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
|
135 } |
|
136 color=*pOurFrameTeams->currentColor; |
|
137 } |
|
138 else |
|
139 { |
|
140 // set according color iterator |
|
141 pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), |
|
142 pOurFrameTeams->availableColors.end(), color); |
|
143 if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) |
|
144 { |
|
145 // error condition |
|
146 pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); |
|
147 } |
|
148 } |
162 } |
149 |
163 |
150 colorButt->setStyleSheet(QString("QPushButton{" |
164 colorButt->setStyleSheet(QString("QPushButton{" |
151 "background-color: %1;" |
165 "background-color: %1;" |
152 "border-width: 1px;" |
166 "border-width: 1px;" |