OSDN Git Service

3719d26f824cc7459f680dc848e6e0c745fe6a3d
[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 package cx.fbn.nevernote.dialog;\r
21 \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
31 \r
32 import cx.fbn.nevernote.Global;\r
33 \r
34 public class ConfigDebugPage extends QWidget {\r
35         \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
42         \r
43         public ConfigDebugPage(QWidget parent) {\r
44                 super(parent);\r
45                 // Server settings\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
53 \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
59 \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
66                 \r
67                 QHBoxLayout messageLayout = new QHBoxLayout();\r
68                 messageLayout.addWidget(messageLevelLabel);\r
69                 messageLayout.addWidget(messageCombo);\r
70                 messageLayout.setStretch(1, 100);\r
71                 \r
72                 \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
81                 \r
82                 QVBoxLayout mainLayout = new QVBoxLayout();\r
83                 mainLayout.addLayout(messageLayout);\r
84                 mainLayout.addLayout(databaseCacheLayout);\r
85                 \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
92                 \r
93                 mainLayout.addWidget(serverGroup);\r
94                 \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
108 \r
109                 QTextBrowser msg = new QTextBrowser(this);\r
110                 msg.setText(crlfMessage);\r
111                 crlfLayout.addWidget(msg);\r
112                 mainLayout.addWidget(crlfGroup);\r
113 \r
114                 mainLayout.addStretch(1);\r
115                 setLayout(mainLayout);\r
116                 \r
117                 serverCombo.activated.connect(this, "serverOptionChanged()");\r
118         }\r
119         \r
120         //******************************************\r
121         //* Message set/get\r
122         //******************************************\r
123         public void setDebugLevel(String level) {\r
124                 int i = messageCombo.findData(level);\r
125                 if (i>0)\r
126                         messageCombo.setCurrentIndex(i);\r
127         }\r
128         public String getDebugLevel() {\r
129                 int i = messageCombo.currentIndex();\r
130                 return messageCombo.itemData(i).toString();\r
131         }\r
132         public void setCarriageReturnFix(boolean val) {\r
133                 carriageReturnFix.setChecked(val);\r
134         }\r
135         public boolean getCarriageReturnFix() {\r
136                 return carriageReturnFix.isChecked();\r
137         }\r
138 \r
139         \r
140         //******************************************\r
141         //* Server set/get\r
142         //******************************************\r
143         public void setServer(String server) {\r
144                 int i = serverCombo.findText(server);\r
145                 if (i>0)\r
146                         serverCombo.setCurrentIndex(i);\r
147         }\r
148         public String getServer() {\r
149                 int i = serverCombo.currentIndex();\r
150                 return serverCombo.itemText(i);\r
151         }\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
157         }\r
158         //*****************************************\r
159         //* Disable uploads \r
160         //*****************************************\r
161         public void setDisableUploads(boolean val) {\r
162                 disableUploads.setChecked(val);\r
163         }\r
164         public boolean getDisableUploads() {\r
165                 return disableUploads.isChecked();\r
166         }\r
167         \r
168         //****************************************\r
169         //* Thumbnails\r
170         //****************************************\r
171         public void setEnableThumbnails(boolean val) {\r
172                 enableThumbnails.setChecked(val);\r
173         }\r
174         \r
175         public boolean getEnableThumbnails() {\r
176                 return enableThumbnails.isChecked();\r
177         }\r
178 \r
179         \r
180         public String getDatabaseCacheSize() {\r
181                 return new Integer(databaseCache.value()*1024).toString();\r
182         }\r
183 \r
184 }\r