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 com.trolltech.qt.gui.QDialog;
\r
23 import com.trolltech.qt.gui.QGridLayout;
\r
24 import com.trolltech.qt.gui.QLabel;
\r
25 import com.trolltech.qt.gui.QLineEdit;
\r
26 import com.trolltech.qt.gui.QPushButton;
\r
28 public class DatabaseLoginDialog extends QDialog {
\r
30 private boolean okPressed;
\r
31 private final QLineEdit password;
\r
32 private final QPushButton ok;
\r
36 public DatabaseLoginDialog() {
\r
38 setWindowTitle("Database Password");
\r
39 QGridLayout grid = new QGridLayout();
\r
41 QGridLayout passwordGrid = new QGridLayout();
\r
42 QGridLayout buttonGrid = new QGridLayout();
\r
44 String passwordValue = "";
\r
46 password = new QLineEdit(passwordValue);
\r
47 password.setEchoMode(QLineEdit.EchoMode.Password);
\r
49 password.textChanged.connect(this, "validateInput()");
\r
51 passwordGrid.addWidget(new QLabel("Password"), 2,1);
\r
52 passwordGrid.addWidget(password, 2, 2);
\r
53 passwordGrid.setContentsMargins(10, 10, -10, -10);
\r
54 grid.addLayout(passwordGrid,1,1);
\r
56 ok = new QPushButton("OK");
\r
57 ok.clicked.connect(this, "okButtonPressed()");
\r
58 QPushButton cancel = new QPushButton("Cancel");
\r
59 cancel.clicked.connect(this, "cancelButtonPressed()");
\r
60 buttonGrid.addWidget(ok, 1, 1);
\r
61 buttonGrid.addWidget(cancel, 1,2);
\r
62 grid.addLayout(buttonGrid,2,1);
\r
65 // The OK button was pressed
\r
66 @SuppressWarnings("unused")
\r
67 private void okButtonPressed() {
\r
72 // The CANCEL button was pressed
\r
73 @SuppressWarnings("unused")
\r
74 private void cancelButtonPressed() {
\r
80 // Get the password
\r
81 public String getPassword() {
\r
82 return password.text();
\r
85 // Check if the OK button was pressed
\r
86 public boolean okPressed() {
\r
90 // Validate user input
\r
91 public void validateInput() {
\r
92 ok.setEnabled(true);
\r
93 if (password.text().trim().equals("")) {
\r
94 ok.setEnabled(false);
\r