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
23 import com.trolltech.qt.core.Qt;
\r
24 import com.trolltech.qt.gui.QDialog;
\r
25 import com.trolltech.qt.gui.QGridLayout;
\r
26 import com.trolltech.qt.gui.QLabel;
\r
27 import com.trolltech.qt.gui.QLineEdit;
\r
28 import com.trolltech.qt.gui.QPushButton;
\r
30 public class InsertLinkDialog extends QDialog {
\r
32 private boolean okPressed;
\r
33 private final QLineEdit url;
\r
34 private final QPushButton ok;
\r
35 private String urlText;
\r
39 public InsertLinkDialog() {
\r
41 setWindowTitle("Insert Link");
\r
42 QGridLayout grid = new QGridLayout();
\r
43 QGridLayout input = new QGridLayout();
\r
44 QGridLayout button = new QGridLayout();
\r
48 url = new QLineEdit("");
\r
50 input.addWidget(new QLabel("Url"), 1,1);
\r
51 input.addWidget(url, 1, 2);
\r
52 input.setContentsMargins(10, 10, -10, -10);
\r
53 grid.addLayout(input, 1,1);
\r
55 ok = new QPushButton("OK");
\r
56 ok.clicked.connect(this, "accept()");
\r
57 ok.setEnabled(false);
\r
59 QPushButton cancel = new QPushButton("Cancel");
\r
60 cancel.clicked.connect(this, "reject()");
\r
61 button.addWidget(ok, 1, 1);
\r
62 button.addWidget(cancel, 1,2);
\r
63 grid.addLayout(button, 3, 1);
\r
64 url.textChanged.connect(this, "validateInput()");
\r
66 setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose);
\r
69 // Get the password
\r
70 public String getUrl() {
\r
74 public void setUrl(String u) {
\r
77 // Check if the OK button was pressed
\r
78 public boolean okPressed() {
\r
81 // Check that we have a valid URL
\r
82 @SuppressWarnings("unused")
\r
83 private void validateInput() {
\r
84 ok.setEnabled(true);
\r
85 if (url.text().trim().equals(""))
\r
86 ok.setEnabled(false);
\r
90 public void accept() {
\r
91 if (ok.isEnabled()) {
\r
93 urlText = url.text();
\r
99 public void reject() {
\r