right-click colour selection to scroll backwards through colours (bit hackish, subclassing + right click handling would be better than custom menu item signal)
authornemo
Sun, 26 Feb 2012 13:37:17 -0500
changeset 6745 9dce541ca16f
parent 6744 7a4db08d291d
child 6746 e13058484d72
right-click colour selection to scroll backwards through colours (bit hackish, subclassing + right click handling would be better than custom menu item signal)
QTfrontend/ui/widget/teamselhelper.cpp
QTfrontend/ui/widget/teamselhelper.h
--- 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{"
--- a/QTfrontend/ui/widget/teamselhelper.h	Sun Feb 26 12:56:53 2012 -0500
+++ b/QTfrontend/ui/widget/teamselhelper.h	Sun Feb 26 13:37:17 2012 -0500
@@ -48,6 +48,8 @@
         Q_OBJECT
 
     public slots:
+        void incrementTeamColor();
+        void decrementTeamColor();
         void changeTeamColor(QColor color=QColor());
         void hhNumChanged();