2 * This file is part of NeverNote
\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
20 package cx.fbn.nevernote.dialog;
\r
22 import java.util.List;
\r
24 import com.trolltech.qt.gui.QCheckBox;
\r
25 import com.trolltech.qt.gui.QComboBox;
\r
26 import com.trolltech.qt.gui.QFormLayout;
\r
27 import com.trolltech.qt.gui.QGroupBox;
\r
28 import com.trolltech.qt.gui.QLabel;
\r
29 import com.trolltech.qt.gui.QLineEdit;
\r
30 import com.trolltech.qt.gui.QVBoxLayout;
\r
31 import com.trolltech.qt.gui.QWidget;
\r
33 import cx.fbn.nevernote.Global;
\r
34 import cx.fbn.nevernote.utilities.SyncTimes;
\r
36 public class ConfigConnectionPage extends QWidget {
\r
37 private final QLineEdit useridEdit;
\r
38 private final QLineEdit passwordEdit;
\r
39 private final QCheckBox rememberPassword;
\r
40 private final QCheckBox autoLogin;
\r
41 private final QComboBox syncInterval;
\r
42 private final SyncTimes syncTimes;
\r
43 private final QCheckBox synchronizeOnClose;
\r
44 private final QCheckBox synchronizeDeletedContents;
\r
46 public ConfigConnectionPage(QWidget parent) {
\r
49 QGroupBox useridGroup = new QGroupBox(tr("Connection"));
\r
50 QLabel useridLabel = new QLabel(tr("Userid"));
\r
51 QLabel passwordLabel = new QLabel(tr("Password"));
\r
54 useridEdit = new QLineEdit();
\r
55 useridEdit.setText(Global.username);
\r
57 passwordEdit = new QLineEdit();
\r
58 passwordEdit.setText(Global.password);
\r
59 passwordEdit.setEchoMode(QLineEdit.EchoMode.Password);
\r
61 syncInterval = new QComboBox(this);
\r
62 syncTimes = new SyncTimes();
\r
63 syncInterval.addItems(syncTimes.stringValues());
\r
65 rememberPassword = new QCheckBox("Remember Userid & Password");
\r
66 autoLogin = new QCheckBox("Automatic Connect");
\r
67 synchronizeDeletedContents = new QCheckBox("Synchronze Deleted Note Content");
\r
68 synchronizeOnClose = new QCheckBox("Synchronize On Shutdown (only if connected)");
\r
71 QFormLayout useridLayout = new QFormLayout();
\r
72 useridLayout.addWidget(useridLabel);
\r
73 useridLayout.addWidget(useridEdit);
\r
74 useridLayout.addWidget(passwordLabel);
\r
75 useridLayout.addWidget(passwordEdit);
\r
76 useridLayout.addWidget(new QLabel(tr("Syncronization Interval")));
\r
77 useridLayout.addWidget(syncInterval);
\r
78 useridLayout.addWidget(rememberPassword);
\r
79 useridLayout.addWidget(autoLogin);
\r
80 useridLayout.addWidget(synchronizeOnClose);
\r
81 useridLayout.addWidget(synchronizeDeletedContents);
\r
83 useridGroup.setLayout(useridLayout);
\r
85 // Add everything together
\r
86 QVBoxLayout mainLayout = new QVBoxLayout();
\r
87 mainLayout.addWidget(useridGroup);
\r
88 mainLayout.addStretch(1);
\r
89 setLayout(mainLayout);
\r
94 //*****************************************
\r
95 //* Userid get/set methods
\r
96 //*****************************************
\r
97 public void setUserid(String id) {
\r
98 useridEdit.setText(id);
\r
100 public String getUserid() {
\r
101 return useridEdit.text();
\r
105 //*****************************************
\r
106 //* Password get/set methods
\r
107 //*****************************************
\r
108 public void setPassword(String id) {
\r
109 passwordEdit.setText(id);
\r
111 public String getPassword() {
\r
112 return passwordEdit.text();
\r
116 //*******************************************
\r
117 //* Remember Password get/set
\r
118 //*******************************************
\r
119 public void setRememberPassword(boolean val) {
\r
120 rememberPassword.setChecked(val);
\r
122 public boolean getRememberPassword() {
\r
123 return rememberPassword.isChecked();
\r
129 //*******************************************
\r
130 //* Automatic login get/set
\r
131 //*******************************************
\r
132 public void setAutomaticLogin(boolean val) {
\r
133 autoLogin.setChecked(val);
\r
135 public boolean getAutomaticLogin() {
\r
136 return autoLogin.isChecked();
\r
141 //*****************************************
\r
142 //* Synchronize Deleted Note Content
\r
143 //*****************************************
\r
144 public void setSyncronizeDeletedContent(boolean val) {
\r
145 synchronizeDeletedContents.setChecked(val);
\r
147 public boolean getSynchronizeDeletedContent() {
\r
148 return synchronizeDeletedContents.isChecked();
\r
157 //*****************************************
\r
158 //* Get/set synchronize on close
\r
159 //*****************************************
\r
160 public boolean getSynchronizeOnClose() {
\r
161 return synchronizeOnClose.isChecked();
\r
163 public void setSynchronizeOnClose(boolean val) {
\r
164 synchronizeOnClose.setChecked(val);
\r
168 //*****************************************
\r
169 //* Get/set sync intervals
\r
170 //*****************************************
\r
171 public String getSyncInterval() {
\r
172 int i = syncInterval.currentIndex();
\r
173 return syncInterval.itemText(i);
\r
175 public void setSyncInterval(String s) {
\r
176 List<String> vals = syncTimes.stringValues();
\r
177 for (int i=0; i<vals.size(); i++) {
\r
178 if (vals.get(i).equalsIgnoreCase(s))
\r
179 syncInterval.setCurrentIndex(i);
\r