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
22 import com.trolltech.qt.gui.QCheckBox;
\r
23 import com.trolltech.qt.gui.QComboBox;
\r
24 import com.trolltech.qt.gui.QGroupBox;
\r
25 import com.trolltech.qt.gui.QHBoxLayout;
\r
26 import com.trolltech.qt.gui.QLabel;
\r
27 import com.trolltech.qt.gui.QSpinBox;
\r
28 import com.trolltech.qt.gui.QTextBrowser;
\r
29 import com.trolltech.qt.gui.QVBoxLayout;
\r
30 import com.trolltech.qt.gui.QWidget;
\r
32 import cx.fbn.nevernote.Global;
\r
34 public class ConfigDebugPage extends QWidget {
\r
36 QComboBox messageCombo;
\r
37 QComboBox serverCombo;
\r
38 QCheckBox disableUploads;
\r
39 QCheckBox carriageReturnFix;
\r
40 QCheckBox enableThumbnails;
\r
41 QSpinBox databaseCache;
\r
43 public ConfigDebugPage(QWidget parent) {
\r
46 QGroupBox serverGroup = new QGroupBox(tr("Server Configuration"));
\r
47 QLabel serverLabel = new QLabel(tr("Server"));
\r
48 serverCombo = new QComboBox();
\r
49 serverCombo.addItem("www.evernote.com");
\r
50 serverCombo.addItem("sandbox.evernote.com");
\r
51 disableUploads = new QCheckBox();
\r
52 disableUploads.setText(tr("Disable uploads to server"));
\r
54 QHBoxLayout serverLayout = new QHBoxLayout();
\r
55 serverLayout.addWidget(serverLabel);
\r
56 serverLayout.addWidget(serverCombo);
\r
57 serverLayout.addWidget(disableUploads);
\r
58 serverGroup.setLayout(serverLayout);
\r
60 QLabel messageLevelLabel = new QLabel(tr("Message Level"));
\r
61 messageCombo = new QComboBox();
\r
62 messageCombo.addItem(tr("Low"),"Low");
\r
63 messageCombo.addItem(tr("Medium"),"Medium");
\r
64 messageCombo.addItem(tr("High"),"High");
\r
65 messageCombo.addItem(tr("Extreme"),"Extreme");
\r
67 QHBoxLayout messageLayout = new QHBoxLayout();
\r
68 messageLayout.addWidget(messageLevelLabel);
\r
69 messageLayout.addWidget(messageCombo);
\r
70 messageLayout.setStretch(1, 100);
\r
73 QHBoxLayout databaseCacheLayout = new QHBoxLayout();
\r
74 databaseCache = new QSpinBox();
\r
75 databaseCacheLayout.addWidget(new QLabel(tr("Database Cache (MB) - Requires restart")));
\r
76 databaseCache.setMinimum(4);
\r
77 databaseCache.setMaximum(128);
\r
78 databaseCache.setValue(new Integer(Global.databaseCache)/1024);
\r
79 databaseCacheLayout.addWidget(databaseCache);
\r
80 databaseCacheLayout.setStretch(1, 100);
\r
82 QVBoxLayout mainLayout = new QVBoxLayout();
\r
83 mainLayout.addLayout(messageLayout);
\r
84 mainLayout.addLayout(databaseCacheLayout);
\r
86 QHBoxLayout thumbnailLayout = new QHBoxLayout();
\r
87 QLabel thumbnailLabel = new QLabel(tr("Enable Thumbnails (experimental)"));
\r
88 thumbnailLayout.addWidget(thumbnailLabel);
\r
89 enableThumbnails = new QCheckBox(this);
\r
90 thumbnailLayout.addWidget(enableThumbnails);
\r
91 mainLayout.addLayout(thumbnailLayout);
\r
93 mainLayout.addWidget(serverGroup);
\r
95 QGroupBox crlfGroup = new QGroupBox(tr("Carriage Return Fix"));
\r
96 String crlfMessage = new String(tr("Note: The carriage return is a test fix. If you " +
\r
97 "enable it, it will do some modifications to the notes you view to try and" +
\r
98 " get the carriage returns to look correct. This is due to the way that " +
\r
99 "the way Evernote 3.1 Windows client is dealing with carriage returns. This fix"+
\r
100 "will try and correct this problem. This fix is not permanent unless you edit a note. If" +
\r
101 "you edit a note, this fix is PERMANENT and will be sent to Evernote on the next sync. I haven't" +
\r
102 "had any issues with this, but please be aware of this condition."));
\r
103 carriageReturnFix = new QCheckBox(this);
\r
104 QVBoxLayout crlfLayout = new QVBoxLayout();
\r
105 carriageReturnFix.setText(tr("Enable Carriage Return Fix"));
\r
106 crlfLayout.addWidget(carriageReturnFix);
\r
107 crlfGroup.setLayout(crlfLayout);
\r
109 QTextBrowser msg = new QTextBrowser(this);
\r
110 msg.setText(crlfMessage);
\r
111 crlfLayout.addWidget(msg);
\r
112 mainLayout.addWidget(crlfGroup);
\r
114 mainLayout.addStretch(1);
\r
115 setLayout(mainLayout);
\r
117 serverCombo.activated.connect(this, "serverOptionChanged()");
\r
120 //******************************************
\r
121 //* Message set/get
\r
122 //******************************************
\r
123 public void setDebugLevel(String level) {
\r
124 int i = messageCombo.findData(level);
\r
126 messageCombo.setCurrentIndex(i);
\r
128 public String getDebugLevel() {
\r
129 int i = messageCombo.currentIndex();
\r
130 return messageCombo.itemData(i).toString();
\r
132 public void setCarriageReturnFix(boolean val) {
\r
133 carriageReturnFix.setChecked(val);
\r
135 public boolean getCarriageReturnFix() {
\r
136 return carriageReturnFix.isChecked();
\r
140 //******************************************
\r
142 //******************************************
\r
143 public void setServer(String server) {
\r
144 int i = serverCombo.findText(server);
\r
146 serverCombo.setCurrentIndex(i);
\r
148 public String getServer() {
\r
149 int i = serverCombo.currentIndex();
\r
150 return serverCombo.itemText(i);
\r
152 @SuppressWarnings("unused")
\r
153 private void serverOptionChanged() {
\r
154 String text = serverCombo.currentText();
\r
155 if (text.equalsIgnoreCase("www.evernote.com"))
\r
156 disableUploads.setChecked(true);
\r
158 //*****************************************
\r
159 //* Disable uploads
\r
160 //*****************************************
\r
161 public void setDisableUploads(boolean val) {
\r
162 disableUploads.setChecked(val);
\r
164 public boolean getDisableUploads() {
\r
165 return disableUploads.isChecked();
\r
168 //****************************************
\r
170 //****************************************
\r
171 public void setEnableThumbnails(boolean val) {
\r
172 enableThumbnails.setChecked(val);
\r
175 public boolean getEnableThumbnails() {
\r
176 return enableThumbnails.isChecked();
\r
180 public String getDatabaseCacheSize() {
\r
181 return new Integer(databaseCache.value()*1024).toString();
\r