QTfrontend/ui/widget/teamselhelper.cpp
changeset 6745 9dce541ca16f
parent 6700 e04da46ee43c
child 6952 7f70f37bbf08
--- a/QTfrontend/ui/widget/teamselhelper.cpp	Sun Feb 26 12:56:53 2012 -0500
+++ b/QTfrontend/ui/widget/teamselhelper.cpp	Sun Feb 26 13:37:17 2012 -0500
@@ -71,8 +71,11 @@
         colorButt->setMinimumHeight(26);
         colorButt->setGeometry(0, 0, 26, 26);
 
-        changeTeamColor();
-        connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor()));
+        incrementTeamColor();
+        connect(colorButt, SIGNAL(clicked()), this, SLOT(incrementTeamColor()));
+
+        colorButt->setContextMenuPolicy(Qt::CustomContextMenu);
+        connect(colorButt, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(decrementTeamColor()));
         mainLayout.addWidget(colorButt);
 
         phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), QImage(":/res/hh25x25grey.png"), this);
@@ -124,27 +127,38 @@
   return params;
 }*/
 
+void TeamShowWidget::incrementTeamColor()
+{
+    FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
+    QColor color;
+    if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end())
+        pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
+    color=*pOurFrameTeams->currentColor;
+
+    changeTeamColor(color);
+}
+void TeamShowWidget::decrementTeamColor()
+{
+    FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
+    QColor color;
+    if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.begin())
+        pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.end()-1;
+    else --pOurFrameTeams->currentColor;
+    color=*pOurFrameTeams->currentColor;
+
+    changeTeamColor(color);
+}
+
 void TeamShowWidget::changeTeamColor(QColor color)
 {
     FrameTeams* pOurFrameTeams=dynamic_cast<FrameTeams*>(parentWidget());
-    if(!color.isValid())
+    // set according color iterator
+    pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(),
+                                           pOurFrameTeams->availableColors.end(), color);
+    if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end())
     {
-        if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end())
-        {
-            pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
-        }
-        color=*pOurFrameTeams->currentColor;
-    }
-    else
-    {
-        // set according color iterator
-        pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(),
-                                               pOurFrameTeams->availableColors.end(), color);
-        if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end())
-        {
-            // error condition
-            pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
-        }
+        // error condition
+        pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin();
     }
 
     colorButt->setStyleSheet(QString("QPushButton{"