OSDN Git Service

Updated comments in some of the code.
[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         \r
52         public ConfigDebugPage(QWidget parent) {\r
53                 super(parent);\r
54                 // Server settings\r
55                 QGroupBox serverGroup =  new QGroupBox(tr("Server Configuration"));\r
56                 QLabel serverLabel = new QLabel(tr("Server"));\r
57                 serverCombo = new QComboBox();\r
58                 serverCombo.addItem("www.evernote.com");\r
59                 serverCombo.addItem("sandbox.evernote.com");\r
60                 disableUploads = new QCheckBox();\r
61                 disableUploads.setText(tr("Disable uploads to server"));\r
62 \r
63                 QHBoxLayout serverLayout = new QHBoxLayout();\r
64                 serverLayout.addWidget(serverLabel);\r
65                 serverLayout.addWidget(serverCombo);\r
66                 serverLayout.addWidget(disableUploads);\r
67                 serverGroup.setLayout(serverLayout);\r
68 \r
69                 QLabel messageLevelLabel = new QLabel(tr("Message Level"));\r
70                 messageCombo = new QComboBox();\r
71                 messageCombo.addItem(tr("Low"),"Low");\r
72                 messageCombo.addItem(tr("Medium"),"Medium");\r
73                 messageCombo.addItem(tr("High"),"High");\r
74                 messageCombo.addItem(tr("Extreme"),"Extreme");\r
75                 \r
76                 QHBoxLayout messageLayout = new QHBoxLayout();\r
77                 messageLayout.addWidget(messageLevelLabel);\r
78                 messageLayout.addWidget(messageCombo);\r
79                 messageLayout.setStretch(1, 100);\r
80                 \r
81                 \r
82                 QHBoxLayout databaseCacheLayout = new QHBoxLayout();\r
83                 databaseCache = new QSpinBox();\r
84                 databaseCacheLayout.addWidget(new QLabel(tr("Database Cache (MB) - Requires restart")));\r
85                 databaseCache.setMinimum(4);\r
86                 databaseCache.setMaximum(128);\r
87                 databaseCache.setValue(new Integer(Global.databaseCache)/1024);\r
88                 databaseCacheLayout.addWidget(databaseCache);\r
89                 databaseCacheLayout.setStretch(1, 100);\r
90                 \r
91                 QVBoxLayout mainLayout = new QVBoxLayout();\r
92                 mainLayout.addLayout(messageLayout);\r
93                 mainLayout.addLayout(databaseCacheLayout);\r
94                 \r
95                 QHBoxLayout thumbnailLayout = new QHBoxLayout();\r
96                 QLabel thumbnailLabel = new QLabel(tr("Enable Thumbnails (experimental)"));\r
97                 thumbnailLayout.addWidget(thumbnailLabel);\r
98                 enableThumbnails = new QCheckBox(this);\r
99                 thumbnailLayout.addWidget(enableThumbnails);\r
100                 mainLayout.addLayout(thumbnailLayout);\r
101                 \r
102                 mainLayout.addWidget(serverGroup);\r
103                 \r
104                 QGroupBox crlfGroup = new QGroupBox(tr("Carriage Return Fix"));\r
105                 String crlfMessage = new String(tr("Note: The carriage return is a test fix.  If you " +\r
106                 "enable it, it will do some modifications to the notes you view to try and" +\r
107                 " get the carriage returns to look correct.  This is due to the way that " +\r
108                 "the way Evernote 3.1 Windows client is dealing with carriage returns.  This fix"+\r
109                 "will try and correct this problem.  This fix is not permanent unless you edit a note.  If" +\r
110                 "you edit a note, this fix is PERMANENT and will be sent to Evernote on the next sync.  I haven't" +\r
111                 "had any issues with this, but please be aware of this condition."));\r
112                 carriageReturnFix = new QCheckBox(this);\r
113                 QVBoxLayout crlfLayout = new QVBoxLayout();\r
114                 carriageReturnFix.setText(tr("Enable Carriage Return Fix"));\r
115                 crlfLayout.addWidget(carriageReturnFix);\r
116                 crlfGroup.setLayout(crlfLayout);\r
117 \r
118                 QGroupBox htmlGroup = new QGroupBox(tr("Android Note Fix"));\r
119                 String entitiesMessage = new String(tr("Note: This is an experimental fix to correct Unicode" +\r
120                                 " notes created on Android Evernote clients."));\r
121                 htmlEntitiesFix = new QCheckBox(this);\r
122                 QVBoxLayout htmlLayout = new QVBoxLayout();\r
123                 htmlEntitiesFix.setText(tr("Enable Android Fix"));\r
124                 htmlLayout.addWidget(htmlEntitiesFix);\r
125                 htmlGroup.setLayout(htmlLayout);\r
126 \r
127                 \r
128                 QTextBrowser msg = new QTextBrowser(this);\r
129                 QTextBrowser htmlMsg = new QTextBrowser(this);\r
130                 msg.setText(crlfMessage);\r
131                 htmlMsg.setText(entitiesMessage);\r
132                 crlfLayout.addWidget(msg);\r
133                 mainLayout.addWidget(crlfGroup);\r
134                 htmlLayout.addWidget(htmlMsg);\r
135                 mainLayout.addWidget(htmlGroup);\r
136 \r
137                 mainLayout.addStretch(1);\r
138                 setLayout(mainLayout);\r
139                 \r
140                 serverCombo.activated.connect(this, "serverOptionChanged()");\r
141         }\r
142         \r
143         //******************************************\r
144         //* Message set/get\r
145         //******************************************\r
146         public void setDebugLevel(String level) {\r
147                 int i = messageCombo.findData(level);\r
148                 if (i>0)\r
149                         messageCombo.setCurrentIndex(i);\r
150         }\r
151         public String getDebugLevel() {\r
152                 int i = messageCombo.currentIndex();\r
153                 return messageCombo.itemData(i).toString();\r
154         }\r
155 \r
156 \r
157         //******************************************\r
158         //* Experimental fixes\r
159         //******************************************\r
160         public void setHtmlEntitiesFix(boolean val) {\r
161                 htmlEntitiesFix.setChecked(val);\r
162         }\r
163         public boolean getHtmlEntitiesFix() {\r
164                 return htmlEntitiesFix.isChecked();\r
165         }\r
166         public void setCarriageReturnFix(boolean val) {\r
167                 carriageReturnFix.setChecked(val);\r
168         }\r
169         public boolean getCarriageReturnFix() {\r
170                 return carriageReturnFix.isChecked();\r
171         }\r
172 \r
173         \r
174         //******************************************\r
175         //* Server set/get\r
176         //******************************************\r
177         public void setServer(String server) {\r
178                 int i = serverCombo.findText(server);\r
179                 if (i>0)\r
180                         serverCombo.setCurrentIndex(i);\r
181         }\r
182         public String getServer() {\r
183                 int i = serverCombo.currentIndex();\r
184                 return serverCombo.itemText(i);\r
185         }\r
186         @SuppressWarnings("unused")\r
187         private void serverOptionChanged() {\r
188                 String text = serverCombo.currentText();\r
189                 if (text.equalsIgnoreCase("www.evernote.com")) \r
190                         disableUploads.setChecked(true);\r
191         }\r
192         //*****************************************\r
193         //* Disable uploads \r
194         //*****************************************\r
195         public void setDisableUploads(boolean val) {\r
196                 disableUploads.setChecked(val);\r
197         }\r
198         public boolean getDisableUploads() {\r
199                 return disableUploads.isChecked();\r
200         }\r
201         \r
202         //****************************************\r
203         //* Thumbnails\r
204         //****************************************\r
205         public void setEnableThumbnails(boolean val) {\r
206                 enableThumbnails.setChecked(val);\r
207         }\r
208         \r
209         public boolean getEnableThumbnails() {\r
210                 return enableThumbnails.isChecked();\r
211         }\r
212 \r
213         \r
214         public String getDatabaseCacheSize() {\r
215                 return new Integer(databaseCache.value()*1024).toString();\r
216         }\r
217 \r
218 }\r