OSDN Git Service

- Added the ability to do special refreshes for debugging. - Added the ability to...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigDebugPage.java
1 /*\r
2  * This file is part of NeverNote \r
3  * Copyright 2009 Randy Baumgarte\r
4  * \r
5  * This file may be licensed under the terms of of the\r
6  * GNU General Public License Version 2 (the ``GPL'').\r
7  *\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
12  *\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
17  *\r
18 */\r
19 \r
20 \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
27 \r
28 package cx.fbn.nevernote.dialog;\r
29 \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
39 \r
40 import cx.fbn.nevernote.Global;\r
41 \r
42 public class ConfigDebugPage extends QWidget {\r
43         \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
52         \r
53         public ConfigDebugPage(QWidget parent) {\r
54                 super(parent);\r
55                 // Server settings\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
63 \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
69 \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
76                 \r
77                 QHBoxLayout messageLayout = new QHBoxLayout();\r
78                 messageLayout.addWidget(messageLevelLabel);\r
79                 messageLayout.addWidget(messageCombo);\r
80                 messageLayout.setStretch(1, 100);\r
81                 \r
82                 \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
91                 \r
92                 QVBoxLayout mainLayout = new QVBoxLayout();\r
93                 mainLayout.addLayout(messageLayout);\r
94                 mainLayout.addLayout(databaseCacheLayout);\r
95                 \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
102                 \r
103                 mainLayout.addWidget(serverGroup);\r
104                 \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
118 \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
127                 \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
133                 \r
134                 \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
144 \r
145                 mainLayout.addStretch(1);\r
146                 setLayout(mainLayout);\r
147                 \r
148                 serverCombo.activated.connect(this, "serverOptionChanged()");\r
149         }\r
150         \r
151         //******************************************\r
152         //* Message set/get\r
153         //******************************************\r
154         public void setDebugLevel(String level) {\r
155                 int i = messageCombo.findData(level);\r
156                 if (i>0)\r
157                         messageCombo.setCurrentIndex(i);\r
158         }\r
159         public String getDebugLevel() {\r
160                 int i = messageCombo.currentIndex();\r
161                 return messageCombo.itemData(i).toString();\r
162         }\r
163 \r
164 \r
165         //******************************************\r
166         //* Experimental fixes\r
167         //******************************************\r
168         public void setHtmlEntitiesFix(boolean val) {\r
169                 htmlEntitiesFix.setChecked(val);\r
170         }\r
171         public boolean getHtmlEntitiesFix() {\r
172                 return htmlEntitiesFix.isChecked();\r
173         }\r
174         public void setCarriageReturnFix(boolean val) {\r
175                 carriageReturnFix.setChecked(val);\r
176         }\r
177         public boolean getCarriageReturnFix() {\r
178                 return carriageReturnFix.isChecked();\r
179         }\r
180 \r
181         \r
182         //******************************************\r
183         //* Server set/get\r
184         //******************************************\r
185         public void setServer(String server) {\r
186                 int i = serverCombo.findText(server);\r
187                 if (i>0)\r
188                         serverCombo.setCurrentIndex(i);\r
189         }\r
190         public String getServer() {\r
191                 int i = serverCombo.currentIndex();\r
192                 return serverCombo.itemText(i);\r
193         }\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
199         }\r
200         //*****************************************\r
201         //* Disable uploads \r
202         //*****************************************\r
203         public void setDisableUploads(boolean val) {\r
204                 disableUploads.setChecked(val);\r
205         }\r
206         public boolean getDisableUploads() {\r
207                 return disableUploads.isChecked();\r
208         }\r
209         \r
210         //****************************************\r
211         //* Thumbnails\r
212         //****************************************\r
213         public void setEnableThumbnails(boolean val) {\r
214                 enableThumbnails.setChecked(val);\r
215         }\r
216         \r
217         public boolean getEnableThumbnails() {\r
218                 return enableThumbnails.isChecked();\r
219         }\r
220 \r
221         \r
222         public String getDatabaseCacheSize() {\r
223                 return new Integer(databaseCache.value()*1024).toString();\r
224         }\r
225 \r
226         \r
227         //***************************************\r
228         //* Special refreshes\r
229         //***************************************\r
230         public boolean reloadSharedNotebooksClicked() {\r
231                 return reloadSharedNotebooks.isChecked();\r
232         }\r
233 \r
234 }\r