2 * This file is part of NixNote
\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 //**********************************************
\r
23 //**********************************************
\r
24 //* Dialog box presented when the database is
\r
26 //**********************************************
\r
27 //**********************************************
\r
29 import com.trolltech.qt.gui.QDialog;
\r
30 import com.trolltech.qt.gui.QGridLayout;
\r
31 import com.trolltech.qt.gui.QIcon;
\r
32 import com.trolltech.qt.gui.QLabel;
\r
33 import com.trolltech.qt.gui.QLineEdit;
\r
34 import com.trolltech.qt.gui.QPushButton;
\r
36 public class DatabaseLoginDialog extends QDialog {
\r
38 private boolean okPressed;
\r
39 private final QLineEdit password;
\r
40 private final QPushButton ok;
\r
41 private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
\r
45 public DatabaseLoginDialog() {
\r
47 setWindowTitle(tr("Database Password"));
\r
48 setWindowIcon(new QIcon(iconPath+"password.png"));
\r
49 QGridLayout grid = new QGridLayout();
\r
51 QGridLayout passwordGrid = new QGridLayout();
\r
52 QGridLayout buttonGrid = new QGridLayout();
\r
54 String passwordValue = "";
\r
56 password = new QLineEdit(passwordValue);
\r
57 password.setEchoMode(QLineEdit.EchoMode.Password);
\r
59 password.textChanged.connect(this, "validateInput()");
\r
61 passwordGrid.addWidget(new QLabel(tr("Password")), 2,1);
\r
62 passwordGrid.addWidget(password, 2, 2);
\r
63 passwordGrid.setContentsMargins(10, 10, -10, -10);
\r
64 grid.addLayout(passwordGrid,1,1);
\r
66 ok = new QPushButton(tr("OK"));
\r
67 ok.clicked.connect(this, "okButtonPressed()");
\r
68 QPushButton cancel = new QPushButton(tr("Cancel"));
\r
69 cancel.clicked.connect(this, "cancelButtonPressed()");
\r
70 buttonGrid.addWidget(ok, 1, 1);
\r
71 buttonGrid.addWidget(cancel, 1,2);
\r
72 grid.addLayout(buttonGrid,2,1);
\r
75 // The OK button was pressed
\r
76 @SuppressWarnings("unused")
\r
77 private void okButtonPressed() {
\r
82 // The CANCEL button was pressed
\r
83 @SuppressWarnings("unused")
\r
84 private void cancelButtonPressed() {
\r
90 // Get the password
\r
91 public String getPassword() {
\r
92 return password.text();
\r
95 // Check if the OK button was pressed
\r
96 public boolean okPressed() {
\r
100 // Validate user input
\r
101 public void validateInput() {
\r
102 ok.setEnabled(true);
\r
103 if (password.text().trim().equals("")) {
\r
104 ok.setEnabled(false);
\r