add a button to configure backends

This commit is contained in:
Romain Bignon 2011-02-26 11:47:01 +01:00
commit 38d6052afb
2 changed files with 36 additions and 6 deletions

View file

@ -17,8 +17,9 @@
from PyQt4.QtCore import SIGNAL
from weboob.tools.application.qt import QtMainWindow, QtDo
from weboob.tools.application.qt.backendcfg import BackendCfg
from weboob.capabilities.content import ICapContent
from .ui.main_window_ui import Ui_MainWindow
@ -35,9 +36,22 @@ class MainWindow(QtMainWindow):
self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.loadPage)
self.connect(self.ui.loadButton, SIGNAL("clicked()"), self.loadPage)
self.connect(self.ui.tabWidget, SIGNAL("currentChanged(int)"),
self._currentTabChanged)
self._currentTabChanged)
self.connect(self.ui.saveButton, SIGNAL("clicked()"), self.savePage)
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
if self.weboob.count_backends() == 0:
self.backendsConfig()
else:
self.loadBackends()
def backendsConfig(self):
bckndcfg = BackendCfg(self.weboob, (ICapContent,), self)
if bckndcfg.run():
self.loadBackends()
def loadBackends(self):
self.ui.backendBox.clear()
for backend in self.weboob.iter_backends():
self.ui.backendBox.insertItem(0, backend.name)
@ -55,8 +69,6 @@ self._currentTabChanged)
self.process = QtDo(self.weboob, self._loadPage_cb, self._loadPage_eb)
self.process.do('get_content', _id, backends=(backend,))
def _loadPage_cb(self, backend, data):
if not backend or not data:
return
@ -92,4 +104,3 @@ self._currentTabChanged)
tmp_content = self.content
tmp_content.content=unicode(self.ui.contentEdit.toPlainText())
self.ui.previewEdit.setHtml(self.backend.get_content_preview(tmp_content))
return

View file

@ -100,23 +100,42 @@
<x>0</x>
<y>0</y>
<width>469</width>
<height>21</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionBackends"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionBackends"/>
</widget>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
<action name="actionBackends">
<property name="text">
<string>Backends</string>
</property>
</action>
</widget>
<resources/>
<connections>