From 0452ce8e5ada7ddc20d7ec8aa3bdd1e8a93b0687 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 8 May 2009 10:58:18 +0200 Subject: Reintroduced the cancel button of ItemAmountWindow Removed the close button instead. Also, the "All" button now only puts the slider at the maximum and won't also finish the dialog, since that is quite unexpected. This reverts commit ec4656af8e2d1946ea2b1d036457c885a9e420dd. --- src/gui/itemamount.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/gui/itemamount.cpp') diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp index 32ad4706..a8389913 100644 --- a/src/gui/itemamount.cpp +++ b/src/gui/itemamount.cpp @@ -68,8 +68,6 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, if (!mMax) mMax = mItem->getQuantity(); - setCloseButton(true); - // Integer field mItemAmountTextField = new IntTextField(1); mItemAmountTextField->setRange(1, mMax); @@ -86,6 +84,7 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, Button *minusButton = new Button("-", "Minus", this); Button *plusButton = new Button("+", "Plus", this); Button *okButton = new Button(_("Ok"), "Ok", this); + Button *cancelButton = new Button(_("Cancel"), "Cancel", this); Button *addAllButton = new Button(_("All"), "All", this); minusButton->adjustSize(); @@ -101,6 +100,7 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, place = getPlacer(0, 1); place(0, 0, mItemAmountSlide, 6); place = getPlacer(0, 2); + place(4, 0, cancelButton); place(5, 0, okButton); reflowLayout(225, 0); @@ -138,7 +138,11 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) { int amount = mItemAmountTextField->getValue(); - if (event.getId() == "Plus" && amount < mMax) + if (event.getId() == "Cancel") + { + close(); + } + else if (event.getId() == "Plus" && amount < mMax) { amount++; } @@ -146,17 +150,17 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) { amount--; } + else if (event.getId() == "All") + { + amount = mMax; + } else if (event.getId() == "Slide") { amount = static_cast(mItemAmountSlide->getValue()); } - else if (event.getId() == "Ok" || event.getId() == "All") + else if (event.getId() == "Ok") { - if (event.getId() == "All") - amount = mMax; - finish(mItem, amount, mUsage); - scheduleDelete(); return; } -- cgit v1.2.3-70-g09d2