summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/gui/setup_keyboard.cpp24
-rw-r--r--src/gui/setup_keyboard.h7
3 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 552ab31c..edec977c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@
* src/keyboardconfig.cpp, src/keyboardconfig.h: Minor cleanup.
* src/gui/buy.cpp, src/gui/sell.cpp: Buy/sell fixed minimum quantity.
+ * src/gui/setup_keyboard.cpp, src/gui/setup_keyboard.h: fixed bug - reverts
+ unassigned key.
2007-08-17 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 3cce3483..3c8c8163 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -70,7 +70,8 @@ class KeyListModel : public gcn::ListModel
Setup_Keyboard::Setup_Keyboard():
mKeyListModel(new KeyListModel()),
- mKeyList(new ListBox(mKeyListModel))
+ mKeyList(new ListBox(mKeyListModel)),
+ mKeySetting(false)
{
keyboard.setSetupKeyboard(this);
setOpaque(false);
@@ -108,6 +109,8 @@ Setup_Keyboard::~Setup_Keyboard()
void Setup_Keyboard::apply()
{
+ keyUnresolved();
+
if (keyboard.hasConflicts())
{
new OkDialog("Key Conflict(s) Detected.",
@@ -119,8 +122,11 @@ void Setup_Keyboard::apply()
void Setup_Keyboard::cancel()
{
+ keyUnresolved();
+
keyboard.retrieve();
keyboard.setEnabled(true);
+
refreshKeys();
}
@@ -128,13 +134,16 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
{
if (event.getSource() == mKeyList)
{
- mAssignKeyButton->setEnabled(true);
+ if (!mKeySetting) {
+ mAssignKeyButton->setEnabled(true);
+ }
}
else if (event.getId() == "assign")
{
- int i(mKeyList->getSelected());
+ mKeySetting = true;
mAssignKeyButton->setEnabled(false);
keyboard.setEnabled(false);
+ int i(mKeyList->getSelected());
keyboard.setNewKeyIndex(i);
mKeyListModel->setElementAt(i, keyboard.getKeyCaption(i) + ": ?");
}
@@ -156,6 +165,7 @@ void Setup_Keyboard::refreshAssignedKey(int index)
void Setup_Keyboard::newKeyCallback(int index)
{
+ mKeySetting = false;
refreshAssignedKey(index);
mAssignKeyButton->setEnabled(true);
}
@@ -167,3 +177,11 @@ void Setup_Keyboard::refreshKeys()
refreshAssignedKey(i);
}
}
+
+void Setup_Keyboard::keyUnresolved()
+{
+ if (mKeySetting) {
+ newKeyCallback(keyboard.getNewKeyIndex());
+ keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE);
+ }
+}
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index ccc2558f..b72e8746 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -66,12 +66,19 @@ class Setup_Keyboard : public SetupTab, public gcn::ActionListener
*/
void refreshKeys();
+ /**
+ * If a key function is unresolved, then this reverts it.
+ */
+ void keyUnresolved();
+
private:
class KeyListModel *mKeyListModel;
gcn::ListBox *mKeyList;
gcn::Button *mAssignKeyButton;
gcn::Button *mMakeDefaultButton;
+
+ bool mKeySetting; /**< flag to check if key being set. */
};
#endif