[4777] | 1 | /* |
---|
[2581] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | This program is distributed in the hope that it will be useful, |
---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | GNU General Public License for more details. |
---|
| 15 | |
---|
| 16 | You should have received a copy of the GNU General Public License |
---|
| 17 | along with this program; if not, write to the Free Software Foundation, |
---|
[4777] | 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
[2581] | 19 | |
---|
| 20 | |
---|
| 21 | ### File Specific: |
---|
| 22 | main-programmer: Benjamin Grauer |
---|
| 23 | |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | |
---|
[7636] | 27 | #include "gui_control.h" |
---|
[7484] | 28 | |
---|
[7534] | 29 | #include <QtGui/QLayout> |
---|
[7598] | 30 | #include "globals.h" |
---|
[7481] | 31 | #include "debug.h" |
---|
[7547] | 32 | #include "qt_gui_elements.h" |
---|
[7484] | 33 | |
---|
[7636] | 34 | #include "lib/event/key_mapper.h" |
---|
| 35 | #include "lib/event/key_names.h" |
---|
| 36 | |
---|
[7481] | 37 | namespace OrxGui |
---|
[2018] | 38 | { |
---|
[7481] | 39 | /** |
---|
[7636] | 40 | * Creates the Control-Option-Frame |
---|
[7481] | 41 | */ |
---|
[7636] | 42 | GuiControl::GuiControl(OrxGui::Gui* gui) |
---|
| 43 | : Element(CONFIG_SECTION_CONTROL, gui), QGroupBox() |
---|
[4064] | 44 | { |
---|
[7484] | 45 | QGridLayout* layout = new QGridLayout(this); |
---|
[7493] | 46 | |
---|
[7484] | 47 | { |
---|
[7637] | 48 | //QLabel* keyLabel = new QLabel; |
---|
[7484] | 49 | |
---|
[7637] | 50 | const KeyMapper::KeyMapping* map = KeyMapper::getKeyMapping(); |
---|
| 51 | unsigned int i = 0; |
---|
| 52 | while(!map->pName.empty()) |
---|
| 53 | { |
---|
| 54 | QLabel* label = new QLabel(QString().fromStdString(map->pName)); |
---|
| 55 | layout->addWidget(label, i, 0); |
---|
[7493] | 56 | |
---|
[7637] | 57 | GuiControlInput* input = new GuiControlInput(map->pName, this, "test"); |
---|
| 58 | layout->addWidget(input, i, 1); |
---|
[7493] | 59 | |
---|
[7637] | 60 | ++map; |
---|
| 61 | ++i; |
---|
| 62 | } |
---|
[7484] | 63 | |
---|
[7636] | 64 | } |
---|
[4064] | 65 | |
---|
[7598] | 66 | |
---|
[4064] | 67 | } |
---|
[2018] | 68 | |
---|
[7481] | 69 | /** |
---|
[7636] | 70 | * Destructs the Control-stuff |
---|
[7481] | 71 | */ |
---|
[7636] | 72 | GuiControl::~GuiControl() |
---|
[7481] | 73 | { |
---|
| 74 | // nothing to do here. |
---|
| 75 | } |
---|
[3423] | 76 | |
---|
[7637] | 77 | GuiControlInput::GuiControlInput(const std::string& name, SaveableGroup* group, const std::string& defaultValue) |
---|
| 78 | : QPushButton(QString().fromStdString(name)), Saveable(name, group, defaultValue) |
---|
| 79 | { |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | void GuiControlInput::load() |
---|
| 83 | { |
---|
| 84 | Saveable::load(); |
---|
| 85 | this->setText(QString().fromStdString(this->value().getString())); |
---|
| 86 | } |
---|
| 87 | void GuiControlInput::save() |
---|
| 88 | { |
---|
| 89 | this->value() = this->text().toStdString(); |
---|
| 90 | Saveable::save(); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | |
---|
[3624] | 94 | } |
---|