2 * This file is part of NixNote/NeighborNote
\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
21 //**********************************************
\r
22 //**********************************************
\r
23 //* This dialog is the debugging information
\r
24 //* page used in the Edit/Preferences dialog
\r
25 //**********************************************
\r
26 //**********************************************
\r
28 package cx.fbn.nevernote.dialog;
\r
30 import com.trolltech.qt.gui.QCheckBox;
\r
31 import com.trolltech.qt.gui.QComboBox;
\r
32 import com.trolltech.qt.gui.QGroupBox;
\r
33 import com.trolltech.qt.gui.QHBoxLayout;
\r
34 import com.trolltech.qt.gui.QLabel;
\r
35 import com.trolltech.qt.gui.QSpinBox;
\r
36 import com.trolltech.qt.gui.QTextBrowser;
\r
37 import com.trolltech.qt.gui.QVBoxLayout;
\r
38 import com.trolltech.qt.gui.QWidget;
\r
40 import cx.fbn.nevernote.Global;
\r
42 public class ConfigDebugPage extends QWidget {
\r
44 QComboBox messageCombo;
\r
45 QComboBox serverCombo;
\r
46 QCheckBox disableUploads;
\r
47 QCheckBox carriageReturnFix;
\r
48 QCheckBox htmlEntitiesFix;
\r
49 QCheckBox enableThumbnails;
\r
50 QSpinBox databaseCache;
\r
51 QCheckBox reloadSharedNotebooks;
\r
53 public ConfigDebugPage(QWidget parent) {
\r
56 QGroupBox serverGroup = new QGroupBox(tr("Server Configuration"));
\r
57 QLabel serverLabel = new QLabel(tr("Server"));
\r
58 serverCombo = new QComboBox();
\r
59 serverCombo.addItem("www.evernote.com");
\r
60 serverCombo.addItem("sandbox.evernote.com");
\r
61 disableUploads = new QCheckBox();
\r
62 disableUploads.setText(tr("Disable uploads to server"));
\r
64 QHBoxLayout serverLayout = new QHBoxLayout();
\r
65 serverLayout.addWidget(serverLabel);
\r
66 serverLayout.addWidget(serverCombo);
\r
67 serverLayout.addWidget(disableUploads);
\r
68 serverGroup.setLayout(serverLayout);
\r
70 QLabel messageLevelLabel = new QLabel(tr("Message Level"));
\r
71 messageCombo = new QComboBox();
\r
72 messageCombo.addItem(tr("Low"),"Low");
\r
73 messageCombo.addItem(tr("Medium"),"Medium");
\r
74 messageCombo.addItem(tr("High"),"High");
\r
75 messageCombo.addItem(tr("Extreme"),"Extreme");
\r
77 QHBoxLayout messageLayout = new QHBoxLayout();
\r
78 messageLayout.addWidget(messageLevelLabel);
\r
79 messageLayout.addWidget(messageCombo);
\r
80 messageLayout.setStretch(1, 100);
\r
83 QHBoxLayout databaseCacheLayout = new QHBoxLayout();
\r
84 databaseCache = new QSpinBox();
\r
85 databaseCacheLayout.addWidget(new QLabel(tr("Database Cache (MB) - Requires restart")));
\r
86 databaseCache.setMinimum(4);
\r
87 databaseCache.setMaximum(128);
\r
88 databaseCache.setValue(new Integer(Global.databaseCache)/1024);
\r
89 databaseCacheLayout.addWidget(databaseCache);
\r
90 databaseCacheLayout.setStretch(1, 100);
\r
92 QVBoxLayout mainLayout = new QVBoxLayout();
\r
93 mainLayout.addLayout(messageLayout);
\r
94 mainLayout.addLayout(databaseCacheLayout);
\r
96 QHBoxLayout thumbnailLayout = new QHBoxLayout();
\r
97 QLabel thumbnailLabel = new QLabel(tr("Enable Thumbnails (experimental)"));
\r
98 thumbnailLayout.addWidget(thumbnailLabel);
\r
99 enableThumbnails = new QCheckBox(this);
\r
100 thumbnailLayout.addWidget(enableThumbnails);
\r
101 mainLayout.addLayout(thumbnailLayout);
\r
103 mainLayout.addWidget(serverGroup);
\r
105 QGroupBox crlfGroup = new QGroupBox(tr("Carriage Return Fix"));
\r
106 String crlfMessage = new String(tr("Note: The carriage return is a test fix. If you " +
\r
107 "enable it, it will do some modifications to the notes you view to try and" +
\r
108 " get the carriage returns to look correct. This is due to the way that " +
\r
109 "the way Evernote 3.1 Windows client is dealing with carriage returns. This fix"+
\r
110 "will try and correct this problem. This fix is not permanent unless you edit a note. If" +
\r
111 "you edit a note, this fix is PERMANENT and will be sent to Evernote on the next sync. I haven't" +
\r
112 "had any issues with this, but please be aware of this condition."));
\r
113 carriageReturnFix = new QCheckBox(this);
\r
114 QVBoxLayout crlfLayout = new QVBoxLayout();
\r
115 carriageReturnFix.setText(tr("Enable Carriage Return Fix"));
\r
116 crlfLayout.addWidget(carriageReturnFix);
\r
117 crlfGroup.setLayout(crlfLayout);
\r
119 QGroupBox htmlGroup = new QGroupBox(tr("Android Note Fix"));
\r
120 String entitiesMessage = new String(tr("Note: This is an experimental fix to correct Unicode" +
\r
121 " notes created on Android Evernote clients."));
\r
122 htmlEntitiesFix = new QCheckBox(this);
\r
123 QVBoxLayout htmlLayout = new QVBoxLayout();
\r
124 htmlEntitiesFix.setText(tr("Enable Android Fix"));
\r
125 htmlLayout.addWidget(htmlEntitiesFix);
\r
126 htmlGroup.setLayout(htmlLayout);
\r
128 reloadSharedNotebooks = new QCheckBox(tr("Shared Notebooks"));
\r
129 QGroupBox refresh = new QGroupBox(tr("Special Refresh (WARNING - This can cause unsynchronized data loss)."));
\r
130 QVBoxLayout refreshLayout = new QVBoxLayout();
\r
131 refreshLayout.addWidget(reloadSharedNotebooks);
\r
132 refresh.setLayout(refreshLayout);
\r
135 QTextBrowser msg = new QTextBrowser(this);
\r
136 QTextBrowser htmlMsg = new QTextBrowser(this);
\r
137 msg.setText(crlfMessage);
\r
138 htmlMsg.setText(entitiesMessage);
\r
139 crlfLayout.addWidget(msg);
\r
140 mainLayout.addWidget(crlfGroup);
\r
141 htmlLayout.addWidget(htmlMsg);
\r
142 mainLayout.addWidget(htmlGroup);
\r
143 mainLayout.addWidget(refresh);
\r
145 mainLayout.addStretch(1);
\r
146 setLayout(mainLayout);
\r
148 serverCombo.activated.connect(this, "serverOptionChanged()");
\r
151 //******************************************
\r
152 //* Message set/get
\r
153 //******************************************
\r
154 public void setDebugLevel(String level) {
\r
155 int i = messageCombo.findData(level);
\r
157 messageCombo.setCurrentIndex(i);
\r
159 public String getDebugLevel() {
\r
160 int i = messageCombo.currentIndex();
\r
161 return messageCombo.itemData(i).toString();
\r
165 //******************************************
\r
166 //* Experimental fixes
\r
167 //******************************************
\r
168 public void setHtmlEntitiesFix(boolean val) {
\r
169 htmlEntitiesFix.setChecked(val);
\r
171 public boolean getHtmlEntitiesFix() {
\r
172 return htmlEntitiesFix.isChecked();
\r
174 public void setCarriageReturnFix(boolean val) {
\r
175 carriageReturnFix.setChecked(val);
\r
177 public boolean getCarriageReturnFix() {
\r
178 return carriageReturnFix.isChecked();
\r
182 //******************************************
\r
184 //******************************************
\r
185 public void setServer(String server) {
\r
186 int i = serverCombo.findText(server);
\r
188 serverCombo.setCurrentIndex(i);
\r
190 public String getServer() {
\r
191 int i = serverCombo.currentIndex();
\r
192 return serverCombo.itemText(i);
\r
194 @SuppressWarnings("unused")
\r
195 private void serverOptionChanged() {
\r
196 String text = serverCombo.currentText();
\r
197 if (text.equalsIgnoreCase("www.evernote.com"))
\r
198 disableUploads.setChecked(true);
\r
200 //*****************************************
\r
201 //* Disable uploads
\r
202 //*****************************************
\r
203 public void setDisableUploads(boolean val) {
\r
204 disableUploads.setChecked(val);
\r
206 public boolean getDisableUploads() {
\r
207 return disableUploads.isChecked();
\r
210 //****************************************
\r
212 //****************************************
\r
213 public void setEnableThumbnails(boolean val) {
\r
214 enableThumbnails.setChecked(val);
\r
217 public boolean getEnableThumbnails() {
\r
218 return enableThumbnails.isChecked();
\r
222 public String getDatabaseCacheSize() {
\r
223 return new Integer(databaseCache.value()*1024).toString();
\r
227 //***************************************
\r
228 //* Special refreshes
\r
229 //***************************************
\r
230 public boolean reloadSharedNotebooksClicked() {
\r
231 return reloadSharedNotebooks.isChecked();
\r