summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-26 17:42:49 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-26 17:42:49 +0300
commit19c49d794657f87cf07790b3fad6dae09f8005df (patch)
tree69c211cd5e88e7c42211ee232a42b6fe104c8425 /src/gui/windows
parente72b6ef50fbfe22d3c856e06db00d55643a4c148 (diff)
downloadmanaverse-19c49d794657f87cf07790b3fad6dae09f8005df.tar.gz
manaverse-19c49d794657f87cf07790b3fad6dae09f8005df.tar.bz2
manaverse-19c49d794657f87cf07790b3fad6dae09f8005df.tar.xz
manaverse-19c49d794657f87cf07790b3fad6dae09f8005df.zip
Show/hide get attach button in mail view window based on attached items and money.
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/mailviewwindow.cpp34
-rw-r--r--src/gui/windows/mailviewwindow.h2
2 files changed, 21 insertions, 15 deletions
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 6a55f6a2e..2f6c1c28b 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -60,8 +60,8 @@ MailViewWindow::MailViewWindow(const MailMessage *const message,
Window(_("View mail"), Modal_false, nullptr, "mailview.xml"),
ActionListener(),
mMessage(message),
- // TRANSLATORS: mail view window button
- mGetAttachButton(nullptr),
+ // TRANSLATORS: mail view attach button
+ mGetAttachButton(new Button(this, _("Get attach"), "attach", this)),
// TRANSLATORS: mail view window button
mCloseButton(new Button(this, _("Close"), "close", this)),
mPrevButton(new Button(this, "<", "prev", this)),
@@ -121,20 +121,9 @@ MailViewWindow::MailViewWindow(const MailMessage *const message,
placer(0, n++, mMessageLabel);
placer(0, n++, mItemScrollArea);
- logger->log("sizes: %d, %d",
- mItemContainer->getWidth(),
- mItemContainer->getHeight());
+ placer(0, n++, mGetAttachButton);
+ updateAttachButton();
- if (message->money != 0 ||
- message->itemId != 0)
- {
- mGetAttachButton = new Button(this,
- // TRANSLATORS: mail view attach button
- _("Get attach"),
- "attach",
- this);
- placer(0, n++, mGetAttachButton);
- }
ContainerPlacer placer2;
placer2 = getPlacer(0, n);
@@ -198,7 +187,22 @@ Inventory *MailViewWindow::getInventory() const
return mInventory;
}
+void MailViewWindow::updateAttachButton()
+{
+ if (mMessage->money != 0 ||
+ mMessage->itemId != 0 ||
+ mInventory->getLastUsedSlot() != -1)
+ {
+ mGetAttachButton->setVisible(Visible_true);
+ }
+ else
+ {
+ mGetAttachButton->setVisible(Visible_false);
+ }
+}
+
void MailViewWindow::updateItems()
{
mItemContainer->updateMatrix();
+ updateAttachButton();
}
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
index a9d19e57e..9f09bb9a7 100644
--- a/src/gui/windows/mailviewwindow.h
+++ b/src/gui/windows/mailviewwindow.h
@@ -52,6 +52,8 @@ class MailViewWindow final : public Window,
void updateItems();
private:
+ void updateAttachButton();
+
const MailMessage *mMessage;
Button *mGetAttachButton;
Button *mCloseButton;