summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-14 17:41:23 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-14 17:41:23 +0300
commit606f836e9d1c17801ed4564a300cdbaa26097383 (patch)
tree1caf3bfcc5224ea32ec7c2ce18627cf48313cad7 /src
parent0bea9cbee260faff6db5c4d440edfad78bdb6cf2 (diff)
downloadmv-606f836e9d1c17801ed4564a300cdbaa26097383.tar.gz
mv-606f836e9d1c17801ed4564a300cdbaa26097383.tar.bz2
mv-606f836e9d1c17801ed4564a300cdbaa26097383.tar.xz
mv-606f836e9d1c17801ed4564a300cdbaa26097383.zip
Use CREATEWIDGET macro in actions.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp21
-rw-r--r--src/gui/widgets/createwidget.h6
2 files changed, 18 insertions, 9 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 713e80a9f..dd6e57eae 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -59,6 +59,8 @@
#include "gui/windows/skilldialog.h"
#include "gui/windows/whoisonline.h"
+#include "gui/widgets/createwidget.h"
+
#include "gui/widgets/tabs/chat/chattab.h"
#include "input/inputactionoperators.h"
@@ -142,15 +144,17 @@ static int uploadUpdate(void *ptr,
}
else
{
- // TRANSLATORS: file uploaded message
- (new OkDialog(_("File uploaded"), str,
+ CREATEWIDGET0(OkDialog,
+ // TRANSLATORS: file uploaded message
+ _("File uploaded"),
+ str,
// TRANSLATORS: ok dialog button
_("OK"),
DialogType::OK,
Modal_true,
ShowCenter_false,
nullptr,
- 260))->postInit();
+ 260);
}
}
}
@@ -391,8 +395,8 @@ impHandler0(quit)
}
else if (!quitDialog)
{
- quitDialog = new QuitDialog(&quitDialog);
- quitDialog->postInit();
+ CREATEWIDGET(quitDialog, QuitDialog,
+ &quitDialog);
quitDialog->requestMoveToTop();
return true;
}
@@ -716,8 +720,8 @@ impHandler(talk)
}
else if (being->getType() == ActorType::Player)
{
- BuySellDialog *const dialog = new BuySellDialog(being->getName());
- dialog->postInit();
+ CREATEWIDGET0(BuySellDialog,
+ being->getName());
}
return true;
}
@@ -1418,8 +1422,7 @@ impHandler0(testSdlFont)
impHandler0(createItems)
{
- BuyDialog *const dialog = new BuyDialog();
- dialog->postInit();
+ BuyDialog *const dialog = CREATEWIDGETR0(BuyDialog);
const ItemDB::ItemInfos &items = ItemDB::getItemInfos();
FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items)
{
diff --git a/src/gui/widgets/createwidget.h b/src/gui/widgets/createwidget.h
index 9c72b95f5..70722a9e3 100644
--- a/src/gui/widgets/createwidget.h
+++ b/src/gui/widgets/createwidget.h
@@ -25,6 +25,9 @@
var = new type(__VA_ARGS__); \
var->postInit()
+#define CREATEWIDGET0(type, ...) \
+ (new type(__VA_ARGS__))->postInit()
+
#define CREATEWIDGET1(var, type) \
var = new type; \
var->postInit()
@@ -32,4 +35,7 @@
#define CREATEWIDGET2(type, ...) \
static_cast<type*>(Widget::callPostInit(new type(__VA_ARGS__)))
+#define CREATEWIDGETR0(type) \
+ static_cast<type*>(Widget::callPostInit(new type))
+
#endif // GUI_WIDGETS_CREATEWIDGET_H