OSDN Git Service

Add automatic upgrade checking.
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / UpgradeAvailableDialog.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 \r
23 import com.trolltech.qt.core.QUrl;\r
24 import com.trolltech.qt.gui.QCheckBox;\r
25 import com.trolltech.qt.gui.QDialog;\r
26 import com.trolltech.qt.gui.QGridLayout;\r
27 import com.trolltech.qt.gui.QHBoxLayout;\r
28 import com.trolltech.qt.gui.QIcon;\r
29 import com.trolltech.qt.gui.QPushButton;\r
30 import com.trolltech.qt.gui.QVBoxLayout;\r
31 import com.trolltech.qt.webkit.QWebView;\r
32 \r
33 import cx.fbn.nevernote.Global;\r
34 \r
35 public class UpgradeAvailableDialog extends QDialog {\r
36 \r
37         private boolean         okPressed;\r
38         private final QPushButton ok;\r
39         private final QCheckBox doNotRemindeMe;\r
40         private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
41         \r
42         // Constructor\r
43         public UpgradeAvailableDialog() {\r
44                 okPressed = false;\r
45                 setWindowTitle(tr("Upgrade Available"));\r
46                 setWindowIcon(new QIcon(iconPath+"nevernote.png"));\r
47                 QVBoxLayout grid = new QVBoxLayout();\r
48                 QGridLayout input = new QGridLayout();\r
49                 QHBoxLayout button = new QHBoxLayout();\r
50                 setLayout(grid);                \r
51                         \r
52                 QWebView page = new QWebView(this);\r
53                 page.setUrl(new QUrl(Global.getUpdateAnnounceUrl()));\r
54                 \r
55                 doNotRemindeMe = new QCheckBox();\r
56                 doNotRemindeMe.setText(tr("Automatically check for updates at startup"));\r
57                 input.addWidget(page,1,1);\r
58                 doNotRemindeMe.setChecked(true);\r
59                 input.addWidget(doNotRemindeMe,2,1);\r
60                 \r
61                 grid.addLayout(input);\r
62                 \r
63                 ok = new QPushButton("OK");\r
64                 ok.clicked.connect(this, "okButtonPressed()");\r
65 \r
66                 button.addStretch();\r
67                 button.addWidget(ok);\r
68                 button.addStretch();\r
69                 grid.addLayout(button);         \r
70         }\r
71 \r
72         // The OK button was pressed\r
73         @SuppressWarnings("unused")\r
74         private void okButtonPressed() {\r
75                 okPressed = true;\r
76                 close();\r
77         }\r
78         // The CANCEL button was pressed\r
79         @SuppressWarnings("unused")\r
80         private void cancelButtonPressed() {\r
81                 okPressed = false;\r
82                 close();\r
83         }\r
84         // Check if the OK button was pressed\r
85         public boolean okPressed() {\r
86                 return okPressed;\r
87         }\r
88         \r
89         public boolean remindMe() {\r
90                 return doNotRemindeMe.isChecked();\r
91         }\r
92 }\r