# HG changeset patch # User Dirk Olmes # Date 1430182257 -7200 # Node ID e0e7459556bcc462843e21e31eb3776935a2ca2d # Parent 1b98925facf67d60aa947f3413d13bf19444bf87 use Qt to open the selected article in the system browser diff -r 1b98925facf6 -r e0e7459556bc MainWindow.py --- a/MainWindow.py Tue Apr 28 02:23:44 2015 +0200 +++ b/MainWindow.py Tue Apr 28 02:50:57 2015 +0200 @@ -7,7 +7,7 @@ from FeedSettings import FeedSettings from PreferencesDialog import PreferencesDialog from PyQt4.QtCore import QUrl -from PyQt4.QtGui import QApplication, QMainWindow, QWidget +from PyQt4.QtGui import QApplication, QDesktopServices, QMainWindow, QWidget from Ui_MainWindow import Ui_MainWindow STATUS_MESSAGE_DISPLAY_MILLIS = 20000 @@ -28,14 +28,14 @@ self.ui.feedList.setModel(feedModel) self.ui.feedList.update() self.__updateFeedCountLabel(allFeeds) - + def __updateFeedCountLabel(self, feeds): feedCount = len(feeds) text = '%d feed' % feedCount if feedCount > 1: text = text + 's' self.ui.feedCountLabel.setText(text) - + def initFeedEntryTable(self): # setup the default row height. This must be called before a table model is set self.ui.feedEntryTable.verticalHeader().setDefaultSectionSize(20) @@ -48,7 +48,7 @@ def __buildFeedEntryTableModel(self): model = GenericTableModel(self, []) titleDisplay = lambda feedEntry: feedEntry.title - model.defineColumn('Title', titleDisplay) + model.defineColumn('Title', titleDisplay) dateDisplay = lambda feedEntry: feedEntry.updated.strftime('%d.%m.%Y') model.defineColumn('Date', dateDisplay) return model @@ -92,7 +92,7 @@ if count > 1: text = text + 's' self.ui.feedEntryCountLabel.setText(text) - + def feedEntrySelected(self, index): self.ui.webView.setZoomFactor(1.0) self.ui.menuArticle.setEnabled(True) @@ -131,12 +131,11 @@ self.ui.webView.show() def openSelectedEntryInBrowser(self): - feedEntry = self.backend.selectedFeedEntry - message = "Open %s in external browser" % (feedEntry.title) + article = self.backend.selectedFeedEntry + message = "Open %s in external browser" % (article.title) self._updateStatusBar(message) - # TODO: make browser configurable - browser = "/usr/bin/chromium" - subprocess.Popen([browser, feedEntry.link]) + url = QUrl(article.link) + QDesktopServices.openUrl(url) def toggleReadOnSelectedEntry(self): self.backend.toggleSelectedFeedEntryRead()