QTfrontend/ui/widget/keybinder.h
author Vittorio Giovara <vittorio.giovara@gmail.com>
Sat, 07 Nov 2015 17:33:43 +0100
changeset 11318 78d8255349d3
parent 11046 47a8c19ecb60
child 14899 4d5df8d35a95
permissions -rw-r--r--
Add markdown extension to README so github can render it more nicely Keep a link to the standard README file too.
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
#ifndef _KEY_BINDER_H
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    20
#define _KEY_BINDER_H
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    21
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    22
#include <QWidget>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    23
#include <QHash>
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    24
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    25
#include "binds.h"
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    26
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    27
class QListWidget;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    28
class QTableWidgetItem;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    29
class QTableWidget;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    30
class QBoxLayout;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    31
class QComboBox;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    32
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    33
// USAGE NOTE: Every time the widget comes into view, you must call resetInterface()
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    34
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    35
class KeyBinder : public QWidget
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    36
{
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    37
    Q_OBJECT
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    38
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    39
    public:
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    40
        KeyBinder(QWidget * parent = NULL, const QString & helpText = QString(), const QString & defaultText = QString(), const QString & resetButtonText = QString());
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    41
        ~KeyBinder();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    42
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    43
        void setBindIndex(int keyIndex, int bindIndex);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    44
        int bindIndex(int keyIndex);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    45
        void resetInterface();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    46
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    47
    private:
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    48
        QHash<QObject *, QTableWidgetItem *> * bindComboBoxCellMappings;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    49
        QHash<QTableWidgetItem *, QComboBox *> * bindCellComboBoxMappings;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    50
        QTableWidget * selectedBindTable;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    51
        QListWidget * catList;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    52
        QBoxLayout *bindingsPages;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    53
        QComboBox * CBBind[BINDS_NUMBER];
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    54
        QString defaultText;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    55
        bool enableSignal;
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    56
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    57
    signals:
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    58
        void bindUpdate(int bindID);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    59
        void resetAllBinds();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    60
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    61
    private slots:
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    62
        void changeBindingsPage(int page);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    63
        void bindChanged(const QString &);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    64
        void bindCellClicked(QTableWidgetItem * item);
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    65
        void bindSelectionChanged();
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    66
};
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    67
3443e0de2c9d GCI2012: Advanced Keyboard Configuration
dag10
parents:
diff changeset
    68
#endif // _KEY_BINDER_H