# HG changeset patch # User Wuzzy # Date 1557250748 -7200 # Node ID 505c8d101be3727af7b5aabaf96ce51f99a2a315 # Parent 4d5df8d35a95536de159991cdb73310cb6424f76 Frontend: Highlight key conflicts diff -r 4d5df8d35a95 -r 505c8d101be3 QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Tue May 07 18:45:14 2019 +0200 +++ b/QTfrontend/hedgewars.qrc Tue May 07 19:39:08 2019 +0200 @@ -65,6 +65,8 @@ res/dropdown.png res/dropdown_disabled.png res/dropdown_selected.png + res/keyconflict.png + res/keyconflict_selected.png res/new.png res/edit.png res/delete.png diff -r 4d5df8d35a95 -r 505c8d101be3 QTfrontend/res/keyconflict.png Binary file QTfrontend/res/keyconflict.png has changed diff -r 4d5df8d35a95 -r 505c8d101be3 QTfrontend/res/keyconflict_selected.png Binary file QTfrontend/res/keyconflict_selected.png has changed diff -r 4d5df8d35a95 -r 505c8d101be3 QTfrontend/ui/widget/keybinder.cpp --- a/QTfrontend/ui/widget/keybinder.cpp Tue May 07 18:45:14 2019 +0200 +++ b/QTfrontend/ui/widget/keybinder.cpp Tue May 07 19:39:08 2019 +0200 @@ -93,7 +93,7 @@ rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter); conflictLabel = new QLabel(); conflictLabel->setText(tr("Warning: The same key is assigned multiple times!")); - conflictLabel->setStyleSheet("color: #FFFFFF; background: #E31A1A; border: solid 4px #E31A1A; border-radius: 10px; padding: auto 20px;"); + conflictLabel->setStyleSheet("color: white; background: #E31A1A; border: solid 4px #E31A1A; border-radius: 10px; padding: auto 20px;"); conflictLabel->setFixedHeight(24); conflictLabel->setHidden(true); rightLayout->addWidget(conflictLabel, 0, Qt::AlignCenter); @@ -125,11 +125,16 @@ bindComboBoxCellMappings = new QHash(); bindCellComboBoxMappings = new QHash(); - QIcon dropDownIcon = QIcon(); + dropDownIcon = new QIcon(); QPixmap dd1 = QPixmap(":/res/dropdown.png"); QPixmap dd2 = QPixmap(":/res/dropdown_selected.png"); - dropDownIcon.addPixmap(dd1, QIcon::Normal); - dropDownIcon.addPixmap(dd2, QIcon::Selected); + dropDownIcon->addPixmap(dd1, QIcon::Normal); + dropDownIcon->addPixmap(dd2, QIcon::Selected); + conflictIcon = new QIcon(); + QPixmap kc1 = QPixmap(":/res/keyconflict.png"); + QPixmap kc2 = QPixmap(":/res/keyconflict_selected.png"); + conflictIcon->addPixmap(kc1, QIcon::Normal); + conflictIcon->addPixmap(kc2, QIcon::Selected); QPixmap emptySpace = QPixmap(16, 16); emptySpace.fill(QColor(0, 0, 0, 0)); QIcon emptyIcon = QIcon(emptySpace); @@ -208,7 +213,7 @@ { bindCell = new QTableWidgetItem(comboBox->currentText()); nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - bindCell->setIcon(dropDownIcon); + bindCell->setIcon(*dropDownIcon); bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } else @@ -318,18 +323,35 @@ continue; QString bind1 = CBBind[i]->currentData(Qt::UserRole + 1).toString(); QString bind2 = CBBind[compareTo]->currentData(Qt::UserRole + 1).toString(); - if(bind1 == "none" || bind2 == "none" || bind1 == "default" || bind2 == "default") - continue; // TODO: For team key binds, also check collisions with global key binds - if(bind1 == bind2) + if((!(bind1 == "none" || bind2 == "none" || bind1 == "default" || bind2 == "default")) && (bind1 == bind2)) { if(updateState) { p_hasConflicts = true; conflictLabel->setHidden(false); } + QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]); + item->setIcon(*conflictIcon); + item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A))); + item->setForeground(QBrush(Qt::white)); + item = bindComboBoxCellMappings->value(CBBind[compareTo]); + item->setIcon(*conflictIcon); + item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A))); + item->setForeground(QBrush(Qt::white)); return true; } + else + { + QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]); + item->setIcon(*dropDownIcon); + item->setBackground(QBrush(Qt::transparent)); + item->setForeground(QBrush(QColor("#F6CB1C"))); + item = bindComboBoxCellMappings->value(CBBind[compareTo]); + item->setIcon(*dropDownIcon); + item->setBackground(QBrush(Qt::transparent)); + item->setForeground(QBrush(QColor("#F6CB1C"))); + } } if(updateState) { diff -r 4d5df8d35a95 -r 505c8d101be3 QTfrontend/ui/widget/keybinder.h --- a/QTfrontend/ui/widget/keybinder.h Tue May 07 18:45:14 2019 +0200 +++ b/QTfrontend/ui/widget/keybinder.h Tue May 07 19:39:08 2019 +0200 @@ -56,6 +56,8 @@ QBoxLayout *bindingsPages; QComboBox * CBBind[BINDS_NUMBER]; QLabel * conflictLabel; + QIcon * dropDownIcon; + QIcon * conflictIcon; QString defaultText; bool enableSignal; bool p_hasConflicts;