forked from BGmot/BGShellBB10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mydonatewindow.cpp
129 lines (108 loc) · 4.03 KB
/
mydonatewindow.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* Copyright (C) 2013 BGmot <[email protected]>
*/
#include <QtGui/QPalette>
#include <QtGui/QLabel>
#include <QtGui/QRadioButton>
#include <qplatformnativeinterface_qpa.h>
#include <bps/paymentservice.h>
#include <bb/platform/PurchaseReply>
#include "qtermwidget.h"
#include "mydonatewindow.h"
#include "mysystemmenu.h"
#include "mymainwindow.h"
extern CMyMainWindow *mainWindow;
extern CMySystemMenu *SystemMenu;
CMyDonateWindow::CMyDonateWindow(QWidget *parent) :
QWidget(parent)
{
setWindowModality(Qt::ApplicationModal);
}
int CMyDonateWindow::Init(){
QRect r = QApplication::desktop()->screenGeometry(0);
int nWidth = r.width();
int nHeight = nWidth;
this->setGeometry(0, 0, nWidth, nHeight);
QBrush brush1(QColor(76, 76, 76, 255));
brush1.setStyle(Qt::SolidPattern);
QPalette palette;
palette.setBrush(QPalette::Active, QPalette::Window, brush1);
this->setAutoFillBackground(true);
QVBoxLayout *layoutGlobal = new QVBoxLayout;
this->setLayout(layoutGlobal);
QGroupBox *gb = new QGroupBox(tr("Your Thanks is appreciated"));
gb->setGeometry(10, 2, this->width()-20, this->height()-20);
gb->setAlignment(Qt::AlignHCenter);
gb->setFlat(false);
layoutGlobal->addWidget(gb);
QVBoxLayout *layoutV1 = new QVBoxLayout;
layoutV1->setContentsMargins(20, 10, 20, 20);
gb->setLayout(layoutV1);
QLabel *lblWelcome = new QLabel(tr("Receiving simple \"Thank you\" is always encouraging and inspiring. There are many ways to say thanks: "
"just an e-mail at [email protected] or if you feel like ready to spend several bucks here is your chance to say thanks this way:\n\n"));
lblWelcome->setWordWrap(true);
lblWelcome->setAlignment(Qt::AlignHCenter);
lblWelcome->setContentsMargins(10, 5, 10, 5);
layoutV1->addWidget(lblWelcome);
QWidget *wdgRadioBtns = new QWidget();
QVBoxLayout *layoutV2 = new QVBoxLayout;
layoutV2->setContentsMargins(200, 0, 20, 0);
wdgRadioBtns->setLayout(layoutV2);
rbtnOne = new QRadioButton(tr("$1"));
rbtnOne->setChecked(true);
rbtnTwo = new QRadioButton(tr("$2"));
rbtnThree = new QRadioButton(tr("$3"));
rbtnFive = new QRadioButton(tr("$5"));
rbtnTen = new QRadioButton(tr("$10 (are you sure?)"));
layoutV2->addWidget(rbtnOne);
layoutV2->addWidget(rbtnTwo);
layoutV2->addWidget(rbtnThree);
layoutV2->addWidget(rbtnFive);
layoutV2->addWidget(rbtnTen);
layoutV1->addWidget(wdgRadioBtns);
QWidget *wdgButtons = new QWidget();
QHBoxLayout *layoutH = new QHBoxLayout;
layoutH->setContentsMargins(20, 10, 20, 20);
wdgButtons->setLayout(layoutH);
layoutGlobal->addWidget(wdgButtons);
btnOk = new QToolButton(this);
btnOk->setObjectName(QString::fromUtf8("btnOk"));
btnOk->setText(QString("Thanks!"));
btnOk->setMinimumWidth(nWidth/3);
layoutH->addWidget(btnOk);
btnCancel = new QToolButton(this);
btnCancel->setObjectName(QString::fromUtf8("btnCancel"));
btnCancel->setText(QString("Next time"));
btnCancel->setMinimumWidth(nWidth/3);
layoutH->addWidget(btnCancel);
QMetaObject::connectSlotsByName(this);
return 0;
}
void CMyDonateWindow::on_btnOk_clicked(){
SystemMenu->hide();
close();
QString sku, name;
if (rbtnOne->isChecked()){
sku = QString("SKU_BG-SSH-SCP-SFTP_1");
name = QString("ThanksOne");
}else if (rbtnTwo->isChecked()){
sku = QString("SKU_BG-SSH-SCP-SFTP_2");
name = QString("ThanksTwo");
}else if (rbtnThree->isChecked()){
sku = QString("SKU_BG-SSH-SCP-SFTP_3");
name = QString("ThanksThree");
}else if (rbtnFive->isChecked()){
sku = QString("SKU_BG-SSH-SCP-SFTP_5");
name = QString("ThanksFive");
}else if (rbtnTen->isChecked()){
sku = QString("SKU_BG-SSH-SCP-SFTP_10");
name = QString("ThanksTen");
}
// Initiate purchase
const bb::platform::PurchaseReply *reply = mainWindow->paymentManager->requestPurchase(NULL, sku, name, NULL);
connect(reply, SIGNAL(finished()), mainWindow, SLOT(purchaseResponse()));
}
void CMyDonateWindow::on_btnCancel_clicked(){
SystemMenu->hide();
close();
}