2 * This file is part of NeverNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
5 * This file may be licensed under the terms of of the
\r
6 * GNU General Public License Version 2 (the ``GPL'').
\r
8 * Software distributed under the License is distributed
\r
9 * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
\r
10 * express or implied. See the GPL for the specific language
\r
11 * governing rights and limitations.
\r
13 * You should have received a copy of the GPL along with this
\r
14 * program. If not, go to http://www.gnu.org/licenses/gpl.html
\r
15 * or write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
20 package cx.fbn.nevernote.dialog;
\r
23 import java.text.SimpleDateFormat;
\r
25 import com.evernote.edam.type.UserAttributes;
\r
26 import com.trolltech.qt.gui.QDialog;
\r
27 import com.trolltech.qt.gui.QGridLayout;
\r
28 import com.trolltech.qt.gui.QGroupBox;
\r
29 import com.trolltech.qt.gui.QHBoxLayout;
\r
30 import com.trolltech.qt.gui.QLabel;
\r
31 import com.trolltech.qt.gui.QPushButton;
\r
33 import cx.fbn.nevernote.Global;
\r
35 public class AccountDialog extends QDialog {
\r
37 private final QPushButton ok;
\r
40 public AccountDialog() {
\r
41 setWindowTitle("Account Information");
\r
42 QGridLayout grid = new QGridLayout();
\r
45 if (Global.isPremium())
\r
46 premium = new QLabel("Premium");
\r
48 premium = new QLabel("Free");
\r
50 Long uploadAmt = Global.getUploadAmount();
\r
51 Long uploadLimit = Global.getUploadLimit();
\r
52 Long uploadLimitEnd = Global.getUploadLimitEnd();
\r
54 if (uploadLimit > 0)
\r
55 pct = uploadAmt*100 / uploadLimit;
\r
58 String unit = " Bytes";
\r
60 if (uploadAmt > 0) {
\r
61 uploadAmt = uploadAmt/1024;
\r
64 if (uploadAmt >= 1024) {
\r
65 uploadAmt = uploadAmt / 1024;
\r
68 if (uploadLimit > 0)
\r
69 uploadLimit = uploadLimit/1024/1024;
\r
72 String fmt = Global.getDateFormat() + " " + Global.getTimeFormat();
\r
73 String dateTimeFormat = new String(fmt);
\r
74 SimpleDateFormat simple = new SimpleDateFormat(dateTimeFormat);
\r
75 StringBuilder endDate = new StringBuilder(simple.format(uploadLimitEnd));
\r
77 QGridLayout textGrid = new QGridLayout();
\r
78 QGroupBox limitGroup = new QGroupBox(tr("Account:"));
\r
79 textGrid.addWidget(new QLabel("Account Type:"), 1,1);
\r
80 textGrid.addWidget(premium, 1, 2);
\r
81 textGrid.addWidget(new QLabel("Limit:"), 2,1);
\r
82 textGrid.addWidget(new QLabel(uploadLimit.toString() +" MB"),2,2);
\r
83 textGrid.addWidget(new QLabel("Uploaded In This Period:"), 3,1);
\r
84 textGrid.addWidget(new QLabel(uploadAmt.toString()+unit +" ("+pct+"%)"),3,2);
\r
85 textGrid.addWidget(new QLabel("Current Cycle Ends:"), 4,1);
\r
86 textGrid.addWidget(new QLabel(endDate.toString()),4,2);
\r
87 limitGroup.setLayout(textGrid);
\r
89 grid.addWidget(limitGroup, 1, 1);
\r
91 UserAttributes attrib = Global.getUserAttributes();
\r
92 QGridLayout attribGrid = new QGridLayout();
\r
93 QGroupBox attribGroup = new QGroupBox(tr("User Attributes"));
\r
94 attribGrid.addWidget(new QLabel(tr("Incoming Email:")), 1,1);
\r
95 String server = Global.getServer();
\r
96 if (server.startsWith("www."))
\r
97 server = server.substring(4);
\r
98 attribGrid.addWidget(new QLabel(attrib.getIncomingEmailAddress()+"@"+Global.getServer()), 1,2);
\r
99 attribGroup.setLayout(attribGrid);
\r
100 grid.addWidget(attribGroup, 2,1);
\r
103 QHBoxLayout buttonLayout = new QHBoxLayout();
\r
104 ok = new QPushButton("OK");
\r
105 ok.clicked.connect(this, "okPushed()");
\r
106 buttonLayout.addStretch();
\r
107 buttonLayout.addWidget(ok);
\r
108 buttonLayout.addStretch();
\r
109 grid.addLayout(buttonLayout,3,1);
\r
112 @SuppressWarnings("unused")
\r
113 private void okPushed() {
\r
118 public QPushButton getOkButton() {
\r