OSDN Git Service

Changed source URL from a text label to a push button that will open the source URL...
authorRandy Baumgarte <randy@fbn.cx>
Thu, 19 Aug 2010 17:55:15 +0000 (13:55 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 22 Aug 2010 22:49:57 +0000 (18:49 -0400)
src/cx/fbn/nevernote/gui/BrowserWindow.java

index 077c906..37e143a 100644 (file)
@@ -106,7 +106,7 @@ public class BrowserWindow extends QWidget {
        private final QComboBox geoBox;\r
        public final TagLineEdit tagEdit;\r
        public final QLabel tagLabel;\r
-       private final QLabel urlLabel;\r
+       private final QPushButton urlLabel;\r
        private final QLabel alteredLabel;\r
        private final QDateEdit alteredDate;\r
        private final QTimeEdit alteredTime;\r
@@ -194,7 +194,8 @@ public class BrowserWindow extends QWidget {
                urlText = new QLineEdit();\r
                authorText = new QLineEdit();\r
                geoBox = new QComboBox();\r
-               urlLabel = new QLabel();\r
+               urlLabel = new QPushButton();\r
+               urlLabel.clicked.connect(this, "sourceUrlClicked()");\r
                authorLabel = new QLabel();\r
                conn = c;\r
                \r
@@ -570,6 +571,21 @@ public class BrowserWindow extends QWidget {
                urlText.setText(t);\r
        }\r
 \r
+       // The user want's to launch a web browser on the source of the URL\r
+       public void sourceUrlClicked() {\r
+               // Make sure we have a valid URL\r
+               if (urlText.text().trim().equals(""))\r
+                       return;\r
+               \r
+               String url = urlText.text();\r
+               if (!url.toLowerCase().startsWith(tr("http://")))\r
+                       url = tr("http://") +url;\r
+               \r
+        if (!QDesktopServices.openUrl(new QUrl(url))) {\r
+               logger.log(logger.LOW, "Error opening file :" +url);\r
+        }\r
+       }\r
+       \r
        public void setAuthor(String t) {\r
                authorLabel.setText(tr("Author:\t"));\r
                authorText.setText(t);\r