summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/windows/maileditwindow.cpp15
-rw-r--r--src/gui/windows/maileditwindow.h6
-rw-r--r--src/gui/windows/mailviewwindow.cpp18
-rw-r--r--src/gui/windows/mailviewwindow.h1
-rw-r--r--src/gui/windows/mailwindow.cpp2
5 files changed, 40 insertions, 2 deletions
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index d6f91e394..2d65e73e6 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -179,3 +179,18 @@ void MailEditWindow::addItem(const Item *const item, const int amount)
Equipm_false,
Equipped_false);
}
+
+void MailEditWindow::setSubject(const std::string &str)
+{
+ mSubjectField->setText(str);
+}
+
+void MailEditWindow::setTo(const std::string &str)
+{
+ mToField->setText(str);
+}
+
+void MailEditWindow::setMessage(const std::string &str)
+{
+ mMessageField->setText(str);
+}
diff --git a/src/gui/windows/maileditwindow.h b/src/gui/windows/maileditwindow.h
index b1838817c..997106c9a 100644
--- a/src/gui/windows/maileditwindow.h
+++ b/src/gui/windows/maileditwindow.h
@@ -50,6 +50,12 @@ class MailEditWindow final : public Window,
void addItem(const Item *const item, const int amount);
+ void setSubject(const std::string &str);
+
+ void setTo(const std::string &str);
+
+ void setMessage(const std::string &str);
+
private:
Button *mSendButton;
Button *mCloseButton;
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 13961dfde..380e04f3f 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -26,6 +26,7 @@
#include "gui/mailmessage.h"
+#include "gui/windows/maileditwindow.h"
#include "gui/windows/mailwindow.h"
#include "gui/widgets/button.h"
@@ -61,6 +62,8 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
mCloseButton(new Button(this, _("Close"), "close", this)),
mPrevButton(new Button(this, "<", "prev", this)),
mNextButton(new Button(this, ">", "next", this)),
+ // TRANSLATORS: mail view window button
+ mReplyButton(new Button(this, _("Reply"), "reply", this)),
// TRANSLATORS: mail view window label
mTimeLabel(new Label(this, strprintf("%s %s", _("Time:"),
message->strTime.c_str()))),
@@ -136,7 +139,8 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) :
placer2(0, 0, mPrevButton);
placer2(1, 0, mNextButton);
- placer2(2, 0, mCloseButton);
+ placer2(3, 0, mReplyButton);
+ placer2(4, 0, mCloseButton);
loadWindowState();
enableVisibleSound(true);
@@ -176,4 +180,16 @@ void MailViewWindow::action(const ActionEvent &event)
if (mMessage)
mailWindow->viewPrev(mMessage->id);
}
+ else if (eventId == "reply")
+ {
+ if (!mMessage)
+ return;
+ if (mailEditWindow)
+ mailEditWindow->scheduleDelete();
+ mailEditWindow = new MailEditWindow;
+ mailEditWindow->setTo(mMessage->sender);
+ mailEditWindow->setSubject("Re:" + mMessage->title);
+ mailEditWindow->setMessage(">" + mMessage->text);
+ scheduleDelete();
+ }
}
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
index 77e1fb2cb..62d2daa67 100644
--- a/src/gui/windows/mailviewwindow.h
+++ b/src/gui/windows/mailviewwindow.h
@@ -52,6 +52,7 @@ class MailViewWindow final : public Window,
Button *mCloseButton;
Button *mPrevButton;
Button *mNextButton;
+ Button *mReplyButton;
Label *mTimeLabel;
Label *mMoneyLabel;
Label *mFromLabel;
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index e01bab225..2ed6f4def 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -121,7 +121,7 @@ void MailWindow::action(const ActionEvent &event)
else if (eventId == "new")
{
if (!mailEditWindow)
- mailEditWindow = new MailEditWindow();
+ mailEditWindow = new MailEditWindow;
}
else if (eventId == "open")
{