QTfrontend/ui/widget/keybinder.cpp
changeset 14900 505c8d101be3
parent 14899 4d5df8d35a95
child 14901 089f0c10ca95
equal deleted inserted replaced
14899:4d5df8d35a95 14900:505c8d101be3
    91     helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;");
    91     helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;");
    92     helpLabel->setFixedHeight(24);
    92     helpLabel->setFixedHeight(24);
    93     rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter);
    93     rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter);
    94     conflictLabel = new QLabel();
    94     conflictLabel = new QLabel();
    95     conflictLabel->setText(tr("Warning: The same key is assigned multiple times!"));
    95     conflictLabel->setText(tr("Warning: The same key is assigned multiple times!"));
    96     conflictLabel->setStyleSheet("color: #FFFFFF; background: #E31A1A; border: solid 4px #E31A1A; border-radius: 10px; padding: auto 20px;");
    96     conflictLabel->setStyleSheet("color: white; background: #E31A1A; border: solid 4px #E31A1A; border-radius: 10px; padding: auto 20px;");
    97     conflictLabel->setFixedHeight(24);
    97     conflictLabel->setFixedHeight(24);
    98     conflictLabel->setHidden(true);
    98     conflictLabel->setHidden(true);
    99     rightLayout->addWidget(conflictLabel, 0, Qt::AlignCenter);
    99     rightLayout->addWidget(conflictLabel, 0, Qt::AlignCenter);
   100 
   100 
   101     // Category list and bind table row heights
   101     // Category list and bind table row heights
   123     bool bFirstPage = true;
   123     bool bFirstPage = true;
   124     selectedBindTable = NULL;
   124     selectedBindTable = NULL;
   125     bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>();
   125     bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>();
   126     bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>();
   126     bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>();
   127 
   127 
   128     QIcon dropDownIcon = QIcon();
   128     dropDownIcon = new QIcon();
   129     QPixmap dd1 = QPixmap(":/res/dropdown.png");
   129     QPixmap dd1 = QPixmap(":/res/dropdown.png");
   130     QPixmap dd2 = QPixmap(":/res/dropdown_selected.png");
   130     QPixmap dd2 = QPixmap(":/res/dropdown_selected.png");
   131     dropDownIcon.addPixmap(dd1, QIcon::Normal);
   131     dropDownIcon->addPixmap(dd1, QIcon::Normal);
   132     dropDownIcon.addPixmap(dd2, QIcon::Selected);
   132     dropDownIcon->addPixmap(dd2, QIcon::Selected);
       
   133     conflictIcon = new QIcon();
       
   134     QPixmap kc1 = QPixmap(":/res/keyconflict.png");
       
   135     QPixmap kc2 = QPixmap(":/res/keyconflict_selected.png");
       
   136     conflictIcon->addPixmap(kc1, QIcon::Normal);
       
   137     conflictIcon->addPixmap(kc2, QIcon::Selected);
   133     QPixmap emptySpace = QPixmap(16, 16);
   138     QPixmap emptySpace = QPixmap(16, 16);
   134     emptySpace.fill(QColor(0, 0, 0, 0));
   139     emptySpace.fill(QColor(0, 0, 0, 0));
   135     QIcon emptyIcon = QIcon(emptySpace);
   140     QIcon emptyIcon = QIcon(emptySpace);
   136 
   141 
   137     for (int i = 0; i < BINDS_NUMBER; i++)
   142     for (int i = 0; i < BINDS_NUMBER; i++)
   206         QTableWidgetItem * bindCell;
   211         QTableWidgetItem * bindCell;
   207         if (cbinds[i].action != "!MULTI")
   212         if (cbinds[i].action != "!MULTI")
   208         {
   213         {
   209             bindCell = new QTableWidgetItem(comboBox->currentText());
   214             bindCell = new QTableWidgetItem(comboBox->currentText());
   210             nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
   215             nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
   211             bindCell->setIcon(dropDownIcon);
   216             bindCell->setIcon(*dropDownIcon);
   212             bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
   217             bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
   213         }
   218         }
   214         else
   219         else
   215         {
   220         {
   216             bindCell = new QTableWidgetItem(HWApplication::translate("binds (combination)", cbinds[i].strbind.toUtf8().constData()));
   221             bindCell = new QTableWidgetItem(HWApplication::translate("binds (combination)", cbinds[i].strbind.toUtf8().constData()));
   316             continue;
   321             continue;
   317         if(CBBind[i] == NULL || CBBind[compareTo] == NULL)
   322         if(CBBind[i] == NULL || CBBind[compareTo] == NULL)
   318             continue;
   323             continue;
   319         QString bind1 = CBBind[i]->currentData(Qt::UserRole + 1).toString();
   324         QString bind1 = CBBind[i]->currentData(Qt::UserRole + 1).toString();
   320         QString bind2 = CBBind[compareTo]->currentData(Qt::UserRole + 1).toString();
   325         QString bind2 = CBBind[compareTo]->currentData(Qt::UserRole + 1).toString();
   321         if(bind1 == "none" || bind2 == "none" || bind1 == "default" || bind2 == "default")
       
   322             continue;
       
   323         // TODO: For team key binds, also check collisions with global key binds
   326         // TODO: For team key binds, also check collisions with global key binds
   324         if(bind1 == bind2)
   327         if((!(bind1 == "none" || bind2 == "none" || bind1 == "default" || bind2 == "default")) && (bind1 == bind2))
   325         {
   328         {
   326             if(updateState)
   329             if(updateState)
   327             {
   330             {
   328                 p_hasConflicts = true;
   331                 p_hasConflicts = true;
   329                 conflictLabel->setHidden(false);
   332                 conflictLabel->setHidden(false);
   330             }
   333             }
       
   334             QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]);
       
   335             item->setIcon(*conflictIcon);
       
   336             item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
       
   337             item->setForeground(QBrush(Qt::white));
       
   338             item = bindComboBoxCellMappings->value(CBBind[compareTo]);
       
   339             item->setIcon(*conflictIcon);
       
   340             item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
       
   341             item->setForeground(QBrush(Qt::white));
   331             return true;
   342             return true;
       
   343         }
       
   344         else
       
   345         {
       
   346             QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]);
       
   347             item->setIcon(*dropDownIcon);
       
   348             item->setBackground(QBrush(Qt::transparent));
       
   349             item->setForeground(QBrush(QColor("#F6CB1C")));
       
   350             item = bindComboBoxCellMappings->value(CBBind[compareTo]);
       
   351             item->setIcon(*dropDownIcon);
       
   352             item->setBackground(QBrush(Qt::transparent));
       
   353             item->setForeground(QBrush(QColor("#F6CB1C")));
   332         }
   354         }
   333     }
   355     }
   334     if(updateState)
   356     if(updateState)
   335     {
   357     {
   336         p_hasConflicts = false;
   358         p_hasConflicts = false;