changeset 77:d292ab61ed6f

Add another setting to feed: when opening a feed entry in browser, you can force opening it in an external browser now. This is because some sites just crash the QWebView.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 14 Aug 2010 02:53:49 +0200
parents f909550683b0
children a728bbc7171e
files Feed.py FeedSettings.py MainWindow.py Mapping.py Ui_FeedSettings.ui
diffstat 5 files changed, 60 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Feed.py	Wed Aug 11 03:59:33 2010 +0200
+++ b/Feed.py	Sat Aug 14 02:53:49 2010 +0200
@@ -14,6 +14,7 @@
         self.update_interval = 60
         self.incrementNextUpdateDate()
         self.auto_load_entry_link = False
+        self.always_open_in_browser = False
 
     def __repr__(self):
         return "<Feed (%d) %s>" % (self.pk, self.title)
--- a/FeedSettings.py	Wed Aug 11 03:59:33 2010 +0200
+++ b/FeedSettings.py	Sat Aug 14 02:53:49 2010 +0200
@@ -14,6 +14,11 @@
     def initUi(self):
         self.ui.feedTitle.setText(self.feed.title)
         self.ui.autoLoadArticle.setChecked(self.feed.auto_load_entry_link)
+        self.ui.alwaysOpenInBrowser.setChecked(self.feed.always_open_in_browser)
+
+    def editingTitleFinished(self):
+        title = str(self.ui.feedTitle.text())
+        self.feed.title = title
 
     def autoLoadArticleChanged(self, change):
         if change:
@@ -21,6 +26,12 @@
         else:
             self.feed.auto_load_entry_link = False
 
+    def alwaysOpenInExternalBrowser(self, change):
+        if change:
+            self.feed.always_open_in_browser = True
+        else:
+            self.feed.always_open_in_browser = False
+
     def accept(self):
         self.session.commit()
         QtGui.QDialog.accept(self)
@@ -28,7 +39,3 @@
     def reject(self):
         self.session.rollback()
         QtGui.QDialog.reject(self)
-
-    def editingTitleFinished(self):
-        title = str(self.ui.feedTitle.text())
-        self.feed.title = title
--- a/MainWindow.py	Wed Aug 11 03:59:33 2010 +0200
+++ b/MainWindow.py	Sat Aug 14 02:53:49 2010 +0200
@@ -72,10 +72,21 @@
         self.ui.webView.setHtml(self.selectedEntry.summary, baseUrl)
 
     def openLinkFromSelectedEntry(self):
+        if self.selectedEntry.feed.always_open_in_browser:
+            self.openSelectedEntryInBrowser()
+        else:
+            self.openSelectedEntryInWebView()
+            
+    def openSelectedEntryInWebView(self):
         url = QUrl(self.selectedEntry.link)
         self.ui.webView.load(url)
         self.ui.webView.show()
-    
+
+    def openSelectedEntryInBrowser(self):
+        # TODO make browser configurable
+        browser = "/usr/local/bin/opera"
+        subprocess.Popen([browser, self.selectedEntry.link])
+
     def toggleReadOnSelectedEntry(self):
         self.selectedEntry.toggleRead()
         self.session.commit()
@@ -98,11 +109,6 @@
         else:
             self.session.commit()
             self.updateFeedList()
-
-    def openSelectedEntryInBrowser(self):
-        # TODO make browser configurable
-        browser = "/usr/local/bin/opera"
-        subprocess.Popen([browser, self.selectedEntry.link])
                 
     def showPreferences(self):
         preferences = PreferencesDialog(self.session)
--- a/Mapping.py	Wed Aug 11 03:59:33 2010 +0200
+++ b/Mapping.py	Sat Aug 14 02:53:49 2010 +0200
@@ -37,7 +37,10 @@
         Column("next_update", DateTime, nullable=False),
         # when displaying an entry of this feed, do not display the summary but rather load 
         # the link directly
-        Column("auto_load_entry_link", Boolean, nullable=False)
+        Column("auto_load_entry_link", Boolean, nullable=False),
+        # this is actually a hack: when opening some sites in the QWebView it just crashes.
+        # This setting forces to open an entry's link in the external browser
+        Column("always_open_in_browser", Boolean, nullable=False)
     )
     
     global feedEntryTable
--- a/Ui_FeedSettings.ui	Wed Aug 11 03:59:33 2010 +0200
+++ b/Ui_FeedSettings.ui	Sat Aug 14 02:53:49 2010 +0200
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>400</width>
-    <height>126</height>
+    <height>140</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -21,7 +21,7 @@
    <property name="geometry">
     <rect>
      <x>20</x>
-     <y>80</y>
+     <y>100</y>
      <width>341</width>
      <height>32</height>
     </rect>
@@ -69,6 +69,19 @@
     <string>Title</string>
    </property>
   </widget>
+  <widget class="QCheckBox" name="alwaysOpenInBrowser">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>70</y>
+     <width>371</width>
+     <height>22</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>when loading article's url, always use external browser</string>
+   </property>
+  </widget>
  </widget>
  <resources>
   <include location="Feedworm.qrc"/>
@@ -138,9 +151,26 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>alwaysOpenInBrowser</sender>
+   <signal>stateChanged(int)</signal>
+   <receiver>FeedSettings</receiver>
+   <slot>alwaysOpenInExternalBrowser()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>195</x>
+     <y>80</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>199</x>
+     <y>69</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>autoLoadArticleChanged()</slot>
   <slot>editingTitleFinished()</slot>
+  <slot>alwaysOpenInExternalBrowser()</slot>
  </slots>
 </ui>