author | Anton Malmygin <antonc27@mail.ru> |
Wed, 15 May 2019 00:24:53 +0200 | |
changeset 14959 | 5cd4edd71d22 |
parent 14901 | 089f0c10ca95 |
permissions | -rw-r--r-- |
8346 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
8346 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
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 | 17 |
*/ |
18 |
||
19 |
#ifndef _KEY_BINDER_H |
|
20 |
#define _KEY_BINDER_H |
|
21 |
||
22 |
#include <QWidget> |
|
23 |
#include <QHash> |
|
24 |
||
25 |
#include "binds.h" |
|
26 |
||
27 |
class QListWidget; |
|
28 |
class QTableWidgetItem; |
|
29 |
class QTableWidget; |
|
30 |
class QBoxLayout; |
|
31 |
class QComboBox; |
|
14899
4d5df8d35a95
Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents:
11046
diff
changeset
|
32 |
class QLabel; |
8346 | 33 |
|
34 |
// USAGE NOTE: Every time the widget comes into view, you must call resetInterface() |
|
35 |
||
36 |
class KeyBinder : public QWidget |
|
37 |
{ |
|
38 |
Q_OBJECT |
|
39 |
||
40 |
public: |
|
41 |
KeyBinder(QWidget * parent = NULL, const QString & helpText = QString(), const QString & defaultText = QString(), const QString & resetButtonText = QString()); |
|
42 |
~KeyBinder(); |
|
43 |
||
44 |
void setBindIndex(int keyIndex, int bindIndex); |
|
45 |
int bindIndex(int keyIndex); |
|
46 |
void resetInterface(); |
|
14899
4d5df8d35a95
Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents:
11046
diff
changeset
|
47 |
bool hasConflicts(); |
4d5df8d35a95
Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents:
11046
diff
changeset
|
48 |
bool checkConflicts(); |
4d5df8d35a95
Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents:
11046
diff
changeset
|
49 |
bool checkConflictsWith(int bind, bool updateState); |
8346 | 50 |
|
51 |
private: |
|
52 |
QHash<QObject *, QTableWidgetItem *> * bindComboBoxCellMappings; |
|
53 |
QHash<QTableWidgetItem *, QComboBox *> * bindCellComboBoxMappings; |
|
54 |
QTableWidget * selectedBindTable; |
|
55 |
QListWidget * catList; |
|
56 |
QBoxLayout *bindingsPages; |
|
57 |
QComboBox * CBBind[BINDS_NUMBER]; |
|
14899
4d5df8d35a95
Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents:
11046
diff
changeset
|
58 |
QLabel * conflictLabel; |
14900 | 59 |
QIcon * dropDownIcon; |
60 |
QIcon * conflictIcon; |
|
8346 | 61 |
QString defaultText; |
62 |
bool enableSignal; |
|
14901
089f0c10ca95
Frontend: Optimize control conflict handling a bit
Wuzzy <Wuzzy2@mail.ru>
parents:
14900
diff
changeset
|
63 |
QList<QTableWidgetItem*> conflictItems; |
14899
4d5df8d35a95
Display a warning when the same key is used multiple times
Wuzzy <Wuzzy2@mail.ru>
parents:
11046
diff
changeset
|
64 |
bool p_hasConflicts; |
8346 | 65 |
|
66 |
signals: |
|
67 |
void bindUpdate(int bindID); |
|
68 |
void resetAllBinds(); |
|
69 |
||
70 |
private slots: |
|
71 |
void changeBindingsPage(int page); |
|
72 |
void bindChanged(const QString &); |
|
73 |
void bindCellClicked(QTableWidgetItem * item); |
|
74 |
void bindSelectionChanged(); |
|
75 |
}; |
|
76 |
||
77 |
#endif // _KEY_BINDER_H |