forked from ahmidou/SpliceMaya
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FabricSpliceBaseDialog.cpp
62 lines (52 loc) · 1.63 KB
/
FabricSpliceBaseDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "FabricSpliceBaseDialog.h"
#include "FabricSpliceButtonWidget.h"
FabricSpliceBaseDialog::FabricSpliceBaseDialog(QWidget * parent)
: QDialog(parent)
{
mCallback = NULL;
mCallbackUD = NULL;
mSucceeded = false;
setLayout(new QVBoxLayout());
setModal(true);
}
void FabricSpliceBaseDialog::setupButtons()
{
QWidget * buttons = new QWidget(this);
layout()->addWidget(buttons);
buttons->setLayout(new QHBoxLayout());
buttons->layout()->setContentsMargins(0, 0, 0, 0);
FabricSpliceButtonWidget * cancelButton = new FabricSpliceButtonWidget("Cancel", buttons);
buttons->layout()->addWidget(cancelButton);
FabricSpliceButtonWidget * okButton = new FabricSpliceButtonWidget("OK", buttons);
buttons->layout()->addWidget(okButton);
// callbacks
okButton->setCallback(onOkPressed, this);
cancelButton->setCallback(onCancelPressed, this);
okButton->setDefault(true);
}
void FabricSpliceBaseDialog::onOkPressed(void * userData)
{
FabricSpliceBaseDialog * dialog = (FabricSpliceBaseDialog *)userData;
dialog->mSucceeded = true;
if(dialog->mCallback != NULL)
(*dialog->mCallback)(dialog->mCallbackUD);
dialog->close();
}
void FabricSpliceBaseDialog::onCancelPressed(void * userData)
{
FabricSpliceBaseDialog * dialog = (FabricSpliceBaseDialog *)userData;
dialog->close();
}
void FabricSpliceBaseDialog::setCallback(FabricSpliceBaseDialog::callback func, void * userData)
{
mCallback = func;
mCallbackUD = userData;
}
std::string FabricSpliceBaseDialog::getStdStringFromQString(QString input)
{
#ifdef _WIN32
return input.toLocal8Bit().constData();
#else
return input.toUtf8().constData();
#endif
}