OSDN Git Service

Added more thumbnail logic & correct search bugs.
[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.QTextBrowser;\r
28 import com.trolltech.qt.gui.QVBoxLayout;\r
29 import com.trolltech.qt.gui.QWidget;\r
30 \r
31 public class ConfigDebugPage extends QWidget {\r
32         \r
33         QComboBox messageCombo;\r
34         QComboBox serverCombo;\r
35         QCheckBox disableUploads;\r
36         QCheckBox carriageReturnFix;\r
37         QCheckBox enableThumbnails;\r
38         \r
39         public ConfigDebugPage(QWidget parent) {\r
40                 super(parent);\r
41                 // Server settings\r
42                 QGroupBox serverGroup =  new QGroupBox(tr("Server Configuration"));\r
43                 QLabel serverLabel = new QLabel(tr("Server"));\r
44                 serverCombo = new QComboBox();\r
45                 serverCombo.addItem("www.evernote.com");\r
46                 serverCombo.addItem("sandbox.evernote.com");\r
47                 disableUploads = new QCheckBox();\r
48                 disableUploads.setText(tr("Disable uploads to server"));\r
49 \r
50                 QHBoxLayout serverLayout = new QHBoxLayout();\r
51                 serverLayout.addWidget(serverLabel);\r
52                 serverLayout.addWidget(serverCombo);\r
53                 serverLayout.addWidget(disableUploads);\r
54                 serverGroup.setLayout(serverLayout);\r
55 \r
56                 QGroupBox messageGroup = new QGroupBox(tr("Debug Messages"));\r
57                 QLabel messageLevelLabel = new QLabel(tr("Message Level"));\r
58                 messageCombo = new QComboBox();\r
59                 messageCombo.addItem(tr("Low"),"Low");\r
60                 messageCombo.addItem(tr("Medium"),"Medium");\r
61                 messageCombo.addItem(tr("High"),"High");\r
62                 messageCombo.addItem(tr("Extreme"),"Extreme");\r
63                 \r
64                 QHBoxLayout messageLayout = new QHBoxLayout();\r
65                 messageLayout.addWidget(messageLevelLabel);\r
66                 messageLayout.addWidget(messageCombo);\r
67                 messageLayout.setStretch(1, 100);\r
68                 messageGroup.setLayout(messageLayout);\r
69                 \r
70                 QVBoxLayout mainLayout = new QVBoxLayout();\r
71                 mainLayout.addWidget(serverGroup);\r
72                 mainLayout.addWidget(messageGroup);\r
73                 \r
74                 QGroupBox thumbnailGroup = new QGroupBox(tr("Thumbnails"));\r
75                 QHBoxLayout thumbnailLayout = new QHBoxLayout();\r
76                 QLabel thumbnailLabel = new QLabel(tr("Enable Thumbnails (experimental)"));\r
77                 thumbnailLayout.addWidget(thumbnailLabel);\r
78                 enableThumbnails = new QCheckBox(this);\r
79                 thumbnailLayout.addWidget(enableThumbnails);\r
80                 thumbnailGroup.setLayout(thumbnailLayout);\r
81                 mainLayout.addWidget(thumbnailGroup);\r
82                 \r
83                 QGroupBox crlfGroup = new QGroupBox(tr("Carriage Return Fix"));\r
84                 String crlfMessage = new String(tr("Note: The carriage return is a test fix.  If you " +\r
85                 "enable it, it will do some modifications to the notes you view to try and" +\r
86                 " get the carriage returns to look correct.  This is due to the way that " +\r
87                 "the way Evernote 3.1 Windows client is dealing with carriage returns.  This fix"+\r
88                 "will try and correct this problem.  This fix is not permanent unless you edit a note.  If" +\r
89                 "you edit a note, this fix is PERMANENT and will be sent to Evernote on the next sync.  I haven't" +\r
90                 "had any issues with this, but please be aware of this condition."));\r
91                 carriageReturnFix = new QCheckBox(this);\r
92                 QHBoxLayout crlfLayout = new QHBoxLayout();\r
93                 QLabel carriageReturnLabel = new QLabel(tr("Enable Carriage Return Fix"));\r
94                 crlfLayout.addWidget(carriageReturnLabel);\r
95                 crlfLayout.addWidget(carriageReturnFix);\r
96                 crlfGroup.setLayout(crlfLayout);\r
97 \r
98                 QTextBrowser msg = new QTextBrowser(this);\r
99                 msg.setText(crlfMessage);\r
100                 mainLayout.addWidget(crlfGroup);\r
101 \r
102                 mainLayout.addWidget(msg);\r
103                 \r
104                 mainLayout.addStretch(1);\r
105                 setLayout(mainLayout);\r
106                 \r
107                 serverCombo.activated.connect(this, "serverOptionChanged()");\r
108         }\r
109         \r
110         //******************************************\r
111         //* Message set/get\r
112         //******************************************\r
113         public void setDebugLevel(String level) {\r
114                 int i = messageCombo.findData(level);\r
115                 if (i>0)\r
116                         messageCombo.setCurrentIndex(i);\r
117         }\r
118         public String getDebugLevel() {\r
119                 int i = messageCombo.currentIndex();\r
120                 return messageCombo.itemData(i).toString();\r
121         }\r
122         public void setCarriageReturnFix(boolean val) {\r
123                 carriageReturnFix.setChecked(val);\r
124         }\r
125         public boolean getCarriageReturnFix() {\r
126                 return carriageReturnFix.isChecked();\r
127         }\r
128 \r
129         \r
130         //******************************************\r
131         //* Server set/get\r
132         //******************************************\r
133         public void setServer(String server) {\r
134                 int i = serverCombo.findText(server);\r
135                 if (i>0)\r
136                         serverCombo.setCurrentIndex(i);\r
137         }\r
138         public String getServer() {\r
139                 int i = serverCombo.currentIndex();\r
140                 return serverCombo.itemText(i);\r
141         }\r
142         @SuppressWarnings("unused")\r
143         private void serverOptionChanged() {\r
144                 String text = serverCombo.currentText();\r
145                 if (text.equalsIgnoreCase("www.evernote.com")) \r
146                         disableUploads.setChecked(true);\r
147         }\r
148         //*****************************************\r
149         //* Disable uploads \r
150         //*****************************************\r
151         public void setDisableUploads(boolean val) {\r
152                 disableUploads.setChecked(val);\r
153         }\r
154         public boolean getDisableUploads() {\r
155                 return disableUploads.isChecked();\r
156         }\r
157         \r
158         //****************************************\r
159         //* Thumbnails\r
160         //****************************************\r
161         public void setEnableThumbnails(boolean val) {\r
162                 enableThumbnails.setChecked(val);\r
163         }\r
164         \r
165         public boolean getEnableThumbnails() {\r
166                 return enableThumbnails.isChecked();\r
167         }\r
168 \r
169 \r
170 }\r