QTfrontend/ui/widget/keybinder.cpp
author Wuzzy <Wuzzy2@mail.ru>
Mon, 07 Oct 2019 23:07:41 +0200
changeset 15445 88770c206c31
parent 15370 5a934f83d5eb
child 15455 1ee2736de636
permissions -rw-r--r--
Bump protocol version to 59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     1
/*
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10108
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     4
 *
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     8
 *
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    12
 * GNU General Public License for more details.
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    13
 *
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 9998
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    17
 */
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    18
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    19
#include "keybinder.h"
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    20
#include "HWApplication.h"
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    21
#include "DataManager.h"
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    22
#include <QHBoxLayout>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    23
#include <QScrollArea>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    24
#include <QTableWidget>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    25
#include <QTableWidgetItem>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    26
#include <QStandardItemModel>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    27
#include <QAbstractItemModel>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    28
#include <QListWidget>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    29
#include <QListWidgetItem>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    30
#include <QPushButton>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    31
#include <QHeaderView>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    32
#include <QComboBox>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    33
#include <QLabel>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    34
#include <QFrame>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    35
#include <QDebug>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    36
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    37
KeyBinder::KeyBinder(QWidget * parent, const QString & helpText, const QString & defaultText, const QString & resetButtonText) : QWidget(parent)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    38
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    39
    this->defaultText = defaultText;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    40
    enableSignal = false;
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
    41
    p_hasConflicts = false;
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
    42
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    43
    // Two-column tab layout
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    44
    QHBoxLayout * pageKeysLayout = new QHBoxLayout(this);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    45
    pageKeysLayout->setSpacing(0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    46
    pageKeysLayout->setContentsMargins(0, 0, 0, 0);
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
    47
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    48
    // Table for category list
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    49
    QVBoxLayout * catListContainer = new QVBoxLayout();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    50
    catListContainer->setContentsMargins(10, 10, 10, 10);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    51
    catList = new QListWidget();
15251
9be05ae1b726 Use minimum size for keybinder category list
Wuzzy <Wuzzy2@mail.ru>
parents: 15249
diff changeset
    52
    catList->setMinimumWidth(180);
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    53
    catList->setStyleSheet("QListWidget::item { font-size: 14px; } QListWidget:hover { border-color: #F6CB1C; } QListWidget::item:selected { background: #150A61; color: yellow; }");
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    54
    catList->setFocusPolicy(Qt::NoFocus);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    55
    connect(catList, SIGNAL(currentRowChanged(int)), this, SLOT(changeBindingsPage(int)));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    56
    catListContainer->addWidget(catList);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    57
    pageKeysLayout->addLayout(catListContainer);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    58
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    59
    // Reset all binds button
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    60
    if (!resetButtonText.isEmpty())
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    61
    {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    62
        QPushButton * btnResetAll = new QPushButton(resetButtonText);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    63
        catListContainer->addWidget(btnResetAll);
12236
a0ed4caa6d35 Apply minimal padding to all text buttons in frontend
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    64
        btnResetAll->setStyleSheet("padding: 5px 10px");
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    65
        btnResetAll->setFixedHeight(40);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    66
        catListContainer->setStretch(1, 0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    67
        catListContainer->setSpacing(10);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    68
        connect(btnResetAll, SIGNAL(clicked()), this, SIGNAL(resetAllBinds()));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    69
    }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    70
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    71
    // Container for pages of key bindings
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    72
    QWidget * bindingsPagesContainer = new QWidget();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    73
    QVBoxLayout * rightLayout = new QVBoxLayout(bindingsPagesContainer);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    74
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    75
    // Scroll area for key bindings
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    76
    QScrollArea * scrollArea = new QScrollArea();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    77
    scrollArea->setContentsMargins(0, 0, 0, 0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    78
    scrollArea->setWidget(bindingsPagesContainer);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    79
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    80
    scrollArea->setWidgetResizable(true);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    81
    scrollArea->setFrameShape(QFrame::NoFrame);
15249
441bdf1e6026 Fix broken stylesheet in keybinder widget
Wuzzy <Wuzzy2@mail.ru>
parents: 14901
diff changeset
    82
    scrollArea->setObjectName("keyBinderScrollArea");
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    83
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    84
    // Add key binding pages to bindings tab
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    85
    pageKeysLayout->addWidget(scrollArea);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    86
    pageKeysLayout->setStretch(1, 1);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    87
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    88
    // Custom help text
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    89
    QLabel * helpLabel = new QLabel();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    90
    helpLabel->setText(helpText);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    91
    helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;");
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    92
    helpLabel->setFixedHeight(24);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    93
    rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter);
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
    94
    conflictLabel = new QLabel();
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
    95
    conflictLabel->setText(tr("Warning: The same key is assigned multiple times!"));
14900
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
    96
    conflictLabel->setStyleSheet("color: white; background: #E31A1A; border: solid 4px #E31A1A; border-radius: 10px; padding: auto 20px;");
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
    97
    conflictLabel->setFixedHeight(24);
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
    98
    conflictLabel->setHidden(true);
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
    99
    rightLayout->addWidget(conflictLabel, 0, Qt::AlignCenter);
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   100
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   101
    // Category list and bind table row heights
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   102
    const int rowHeight = 20;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   103
    QSize catSize, headerSize;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   104
    catSize.setHeight(36);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   105
    headerSize.setHeight(24);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   106
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   107
    // Category list header
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   108
    QListWidgetItem * catListHeader = new QListWidgetItem(tr("Category"));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   109
    catListHeader->setSizeHint(headerSize);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   110
    catListHeader->setFlags(Qt::NoItemFlags);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   111
    catListHeader->setForeground(QBrush(QColor("#130F2A")));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   112
    catListHeader->setBackground(QBrush(QColor("#F6CB1C")));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   113
    catListHeader->setTextAlignment(Qt::AlignCenter);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   114
    catList->addItem(catListHeader);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   115
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   116
    // Populate
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   117
    bindingsPages = new QHBoxLayout();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   118
    bindingsPages->setContentsMargins(0, 0, 0, 0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   119
    rightLayout->addLayout(bindingsPages);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   120
    QWidget * curPage = NULL;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   121
    QVBoxLayout * curLayout = NULL;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   122
    QTableWidget * curTable = NULL;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   123
    bool bFirstPage = true;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   124
    selectedBindTable = NULL;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   125
    bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   126
    bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>();
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   127
14900
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   128
    dropDownIcon = new QIcon();
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   129
    QPixmap dd1 = QPixmap(":/res/dropdown.png");
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   130
    QPixmap dd2 = QPixmap(":/res/dropdown_selected.png");
14900
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   131
    dropDownIcon->addPixmap(dd1, QIcon::Normal);
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   132
    dropDownIcon->addPixmap(dd2, QIcon::Selected);
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   133
    conflictIcon = new QIcon();
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   134
    QPixmap kc1 = QPixmap(":/res/keyconflict.png");
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   135
    QPixmap kc2 = QPixmap(":/res/keyconflict_selected.png");
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   136
    conflictIcon->addPixmap(kc1, QIcon::Normal);
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   137
    conflictIcon->addPixmap(kc2, QIcon::Selected);
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   138
    QPixmap emptySpace = QPixmap(16, 16);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   139
    emptySpace.fill(QColor(0, 0, 0, 0));
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   140
    QIcon emptyIcon = QIcon(emptySpace);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   141
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   142
    for (int i = 0; i < BINDS_NUMBER; i++)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   143
    {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   144
        if (cbinds[i].category != NULL)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   145
        {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   146
            // Add stretch at end of previous layout
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   147
            if (curLayout != NULL) curLayout->insertStretch(-1, 1);
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
   148
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   149
            // Category list item
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   150
            QListWidgetItem * catItem = new QListWidgetItem(HWApplication::translate("binds (categories)", cbinds[i].category));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   151
            catItem->setSizeHint(catSize);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   152
            catList->addItem(catItem);
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
   153
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   154
            // Create new page
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   155
            curPage = new QWidget();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   156
            curLayout = new QVBoxLayout(curPage);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   157
            curLayout->setSpacing(2);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   158
            bindingsPages->addWidget(curPage);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   159
            if (!bFirstPage) curPage->setVisible(false);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   160
        }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   161
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   162
        // Description
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   163
        if (cbinds[i].description != NULL)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   164
        {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   165
            QLabel * desc = new QLabel(HWApplication::translate("binds (descriptions)", cbinds[i].description));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   166
            curLayout->addWidget(desc, 0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   167
            QFrame * divider = new QFrame();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   168
            divider->setFrameShape(QFrame::HLine);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   169
            divider->setFrameShadow(QFrame::Plain);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   170
            curLayout->addWidget(divider, 0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   171
        }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   172
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   173
        // New table
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   174
        if (cbinds[i].category != NULL || cbinds[i].description != NULL)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   175
        {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   176
            curTable = new QTableWidget(0, 2);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   177
            curTable->verticalHeader()->setVisible(false);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   178
            curTable->horizontalHeader()->setVisible(false);
12897
fc47fc4af6bd Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents: 12698
diff changeset
   179
            curTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   180
            curTable->verticalHeader()->setDefaultSectionSize(rowHeight);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   181
            curTable->setShowGrid(false);
15249
441bdf1e6026 Fix broken stylesheet in keybinder widget
Wuzzy <Wuzzy2@mail.ru>
parents: 14901
diff changeset
   182
            curTable->setStyleSheet("QTableWidget { border: none; background-color: transparent; } ");
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   183
            curTable->setSelectionBehavior(QAbstractItemView::SelectRows);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   184
            curTable->setSelectionMode(QAbstractItemView::SingleSelection);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   185
            curTable->setFocusPolicy(Qt::NoFocus);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   186
            connect(curTable, SIGNAL(itemSelectionChanged()), this, SLOT(bindSelectionChanged()));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   187
            connect(curTable, SIGNAL(itemClicked(QTableWidgetItem *)), this, SLOT(bindCellClicked(QTableWidgetItem *)));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   188
            curLayout->addWidget(curTable, 0);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   189
        }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   190
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   191
        // Hidden combo box
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   192
        QComboBox * comboBox;
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   193
        if (cbinds[i].action != "!MULTI")
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   194
        {
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   195
            comboBox = CBBind[i] = new QComboBox(curTable);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   196
            comboBox->setModel((QAbstractItemModel*)DataManager::instance().bindsModel());
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   197
            comboBox->setVisible(false);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   198
            comboBox->setMinimumWidth(400);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   199
            comboBox->setMaxVisibleItems(50);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   200
        }
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   201
        else
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   202
        {
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   203
            comboBox = CBBind[i] = NULL;
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   204
        }
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
   205
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   206
        // Table row
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   207
        int row = curTable->rowCount();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   208
        QTableWidgetItem * nameCell = new QTableWidgetItem(HWApplication::translate("binds", cbinds[i].name));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   209
        curTable->insertRow(row);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   210
        curTable->setItem(row, 0, nameCell);
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   211
        QTableWidgetItem * bindCell;
15370
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   212
        // Check if the bind text is bad. This was discovered after the 1.0.0,
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   213
        // so we need a little workaround.
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   214
        bool is_broken_strbind = cbinds[i].strbind == "precise + switch + toggle hedgehog tags";
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   215
                                                    // ^ should be "precise + switch + toggle team bars"
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   216
        // TODO: Remove is_broken_strbind after 1.0.0 release.
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   217
        if (cbinds[i].action != "!MULTI" && (!is_broken_strbind))
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   218
        {
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   219
            bindCell = new QTableWidgetItem(comboBox->currentText());
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   220
            nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
14900
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   221
            bindCell->setIcon(*dropDownIcon);
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   222
            bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   223
        }
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   224
        else
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   225
        {
15370
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   226
            // Apply workaround for the broken 1.0.0 strbind
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   227
            // TODO: Remove the workaround after 1.0.0 release and fix binds.cpp accordingly.
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   228
            if (is_broken_strbind)
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   229
            {
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   230
                // We simply construct the string from other strings we *do* have. :-)
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   231
                QString cellText =
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   232
                    HWApplication::translate("binds", "precise aim") + " + " +
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   233
                    HWApplication::translate("binds", "switch") + " + " +
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   234
                    HWApplication::translate("binds", "toggle team bars");
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   235
                bindCell = new QTableWidgetItem(cellText);
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   236
            }
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   237
            else
5a934f83d5eb Tempoary (!!!) workaround for incorrect key combination description in frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 15251
diff changeset
   238
                bindCell = new QTableWidgetItem(HWApplication::translate("binds (combination)", cbinds[i].strbind.toUtf8().constData()));
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   239
            nameCell->setFlags(Qt::NoItemFlags);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   240
            bindCell->setFlags(Qt::NoItemFlags);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   241
            bindCell->setIcon(emptyIcon);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   242
        }
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   243
        curTable->setItem(row, 1, bindCell);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   244
        curTable->resizeColumnsToContents();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   245
        curTable->setFixedHeight(curTable->verticalHeader()->length() + 10);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   246
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   247
        if (cbinds[i].action != "!MULTI")
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   248
        {
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   249
            // Updates the text in the table cell
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   250
            connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(bindChanged(const QString &)));
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   251
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   252
            // Map combo box and that row's cells to each other
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   253
            bindComboBoxCellMappings->insert(comboBox, bindCell);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   254
            bindCellComboBoxMappings->insert(nameCell, comboBox);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   255
            bindCellComboBoxMappings->insert(bindCell, comboBox);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   256
        }
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   257
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   258
    }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   259
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   260
    // Add stretch at end of last layout
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   261
    if (curLayout != NULL) curLayout->insertStretch(-1, 1);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   262
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   263
    // Go to first page
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   264
    catList->setCurrentItem(catList->item(1));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   265
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   266
    enableSignal = true;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   267
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   268
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   269
KeyBinder::~KeyBinder()
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   270
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   271
    delete bindComboBoxCellMappings;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   272
    delete bindCellComboBoxMappings;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   273
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   274
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   275
// Switches between different pages of key binds
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   276
void KeyBinder::changeBindingsPage(int page)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   277
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   278
    page--; // Disregard first item (the list header)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   279
    int pages = bindingsPages->count();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   280
    for (int i = 0; i < pages; i++)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   281
        bindingsPages->itemAt(i)->widget()->setVisible(false);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   282
    bindingsPages->itemAt(page)->widget()->setVisible(true);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   283
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   284
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   285
// When a key bind combobox value is changed, updates the table cell text
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   286
void KeyBinder::bindChanged(const QString & text)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   287
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   288
    bindComboBoxCellMappings->value(sender())->setText(text);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   289
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   290
    if (enableSignal)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   291
    {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   292
        for (int i = 0; i < BINDS_NUMBER; i++)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   293
        {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   294
            if (CBBind[i] == sender())
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   295
            {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   296
                emit bindUpdate(i);
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   297
                checkConflicts();
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   298
                break;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   299
            }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   300
        }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   301
    }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   302
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   303
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   304
// When a row in a key bind table is clicked, this shows the popup
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   305
void KeyBinder::bindCellClicked(QTableWidgetItem * item)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   306
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   307
    QComboBox * box = bindCellComboBoxMappings->value(item);
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   308
    if(box == NULL)
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   309
        return;
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   310
    QTableWidget * table = item->tableWidget();
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
   311
12698
f2690a0ccf19 QTfrontend: Fix flickering and bad offset of control config popup
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
   312
    box->move(
f2690a0ccf19 QTfrontend: Fix flickering and bad offset of control config popup
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
   313
        table->horizontalHeader()->sectionSize(0),
f2690a0ccf19 QTfrontend: Fix flickering and bad offset of control config popup
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
   314
        (table->verticalHeader()->defaultSectionSize() * (item->row() + 1)) - (box->height()) + 1
f2690a0ccf19 QTfrontend: Fix flickering and bad offset of control config popup
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
   315
    );
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   316
    box->showPopup();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   317
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   318
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   319
// When a new row in a bind table is *selected*, this clears selection in any other table
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   320
void KeyBinder::bindSelectionChanged()
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   321
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   322
    QTableWidget * theSender = (QTableWidget*)sender();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   323
    if (theSender != selectedBindTable)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   324
    {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   325
        if (selectedBindTable != NULL)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   326
            selectedBindTable->clearSelection();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   327
        selectedBindTable = theSender;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   328
    }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   329
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   330
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   331
// check if the given key is bound multiple times
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   332
bool KeyBinder::checkConflictsWith(int compareTo, bool updateState)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   333
{
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   334
    for(int i=0; i<BINDS_NUMBER; i++)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   335
    {
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   336
        if(i == compareTo)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   337
            continue;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   338
        if(CBBind[i] == NULL || CBBind[compareTo] == NULL)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   339
            continue;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   340
        QString bind1 = CBBind[i]->currentData(Qt::UserRole + 1).toString();
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   341
        QString bind2 = CBBind[compareTo]->currentData(Qt::UserRole + 1).toString();
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   342
        // TODO: For team key binds, also check collisions with global key binds
14900
505c8d101be3 Frontend: Highlight key conflicts
Wuzzy <Wuzzy2@mail.ru>
parents: 14899
diff changeset
   343
        if((!(bind1 == "none" || bind2 == "none" || bind1 == "default" || bind2 == "default")) && (bind1 == bind2))
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   344
        {
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   345
            if(updateState)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   346
            {
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   347
                p_hasConflicts = true;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   348
                conflictLabel->setHidden(false);
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   349
            }
14901
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   350
            QTableWidgetItem* conflictItem = bindComboBoxCellMappings->value(CBBind[i]);
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   351
            conflictItem->setIcon(*conflictIcon);
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   352
            conflictItem->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   353
            conflictItem->setForeground(QBrush(Qt::white));
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   354
            conflictItems.append(conflictItem);
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   355
            conflictItem = bindComboBoxCellMappings->value(CBBind[compareTo]);
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   356
            conflictItem->setIcon(*conflictIcon);
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   357
            conflictItem->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   358
            conflictItem->setForeground(QBrush(Qt::white));
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   359
            conflictItems.append(conflictItem);
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   360
            return true;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   361
        }
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   362
    }
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   363
    if(updateState)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   364
    {
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   365
        p_hasConflicts = false;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   366
        conflictLabel->setHidden(true);
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   367
    }
14901
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   368
    for (int c=0; c < conflictItems.size(); c++)
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   369
    {
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   370
        QTableWidgetItem* conflictItem = conflictItems[c];
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   371
        conflictItem->setIcon(*dropDownIcon);
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   372
        conflictItem->setBackground(QBrush(Qt::transparent));
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   373
        conflictItem->setForeground(QBrush(QColor("#F6CB1C")));
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   374
        conflictItem = NULL;
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   375
    }
089f0c10ca95 Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents: 14900
diff changeset
   376
    conflictItems.clear();
14899
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   377
    return false;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   378
}
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   379
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   380
// check if any key is bound multiple times and causing a conflict
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   381
bool KeyBinder::checkConflicts()
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   382
{
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   383
    bool conflict = false;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   384
    for(int i=0; i<BINDS_NUMBER; i++)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   385
    {
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   386
        conflict = checkConflictsWith(i, false);
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   387
        if(conflict)
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   388
        {
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   389
            p_hasConflicts = true;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   390
            conflictLabel->setHidden(false);
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   391
            return true;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   392
        }
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   393
    }
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   394
    p_hasConflicts = false;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   395
    conflictLabel->setHidden(true);
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   396
    return false;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   397
}
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   398
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   399
bool KeyBinder::hasConflicts()
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   400
{
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   401
    return p_hasConflicts;
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   402
}
4d5df8d35a95 Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents: 14846
diff changeset
   403
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   404
// Set a combobox's index
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   405
void KeyBinder::setBindIndex(int keyIndex, int bindIndex)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   406
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   407
    enableSignal = false;
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   408
    if(CBBind[keyIndex] != NULL)
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   409
        CBBind[keyIndex]->setCurrentIndex(bindIndex);
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   410
    enableSignal = true;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   411
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   412
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   413
// Return a combobox's selected index
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   414
int KeyBinder::bindIndex(int keyIndex)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   415
{
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   416
    if(CBBind[keyIndex] != NULL)
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   417
        return CBBind[keyIndex]->currentIndex();
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   418
    else
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   419
        return 0;
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   420
}
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   421
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   422
// Clears selection and goes to first category
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   423
void KeyBinder::resetInterface()
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   424
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   425
    enableSignal = false;
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
   426
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   427
    catList->setCurrentItem(catList->item(1));
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   428
    changeBindingsPage(1);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   429
    if (selectedBindTable != NULL)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   430
    {
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   431
        selectedBindTable->clearSelection();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   432
        selectedBindTable = NULL;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   433
    }
8434
4821897a0f10 big indentation/whitespaces cleanup
sheepluva
parents: 8346
diff changeset
   434
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   435
    // Default bind text
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   436
    DataManager::instance().bindsModel()->item(0)->setData(defaultText, Qt::DisplayRole);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   437
    for (int i = 0; i < BINDS_NUMBER; i++)
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   438
    {
14846
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   439
        if (CBBind[i] != NULL)
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   440
        {
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   441
            CBBind[i]->setModel(DataManager::instance().bindsModel());
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   442
            CBBind[i]->setCurrentIndex(0);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   443
            bindComboBoxCellMappings->value(CBBind[i])->setText(defaultText);
75b515a64202 Show key combinations in controls config menu (read-only)
Wuzzy <Wuzzy2@mail.ru>
parents: 14218
diff changeset
   444
        }
8346
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   445
    }
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   446
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   447
    enableSignal = true;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
   448
}