New application qwebcontentedit
Status: ugly GUI, editing and saving a page mostly working, preview support in progress
This commit is contained in:
parent
e3f46ac751
commit
dcb2375fd1
8 changed files with 286 additions and 1 deletions
25
scripts/qwebcontentedit
Executable file
25
scripts/qwebcontentedit
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
||||
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from weboob.applications.qwebcontentedit import QWebContentEdit
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
QWebContentEdit.run()
|
||||
5
setup.py
5
setup.py
|
|
@ -46,6 +46,7 @@ def build_qt():
|
|||
os.system('make -C weboob/applications/qboobmsg/ui')
|
||||
os.system('make -C weboob/applications/qhavesex/ui')
|
||||
os.system('make -C weboob/applications/qvideoob/ui')
|
||||
os.system('make -C weboob/applications/qwebcontentedit/ui')
|
||||
os.system('make -C weboob/tools/application/qt')
|
||||
|
||||
class Options:
|
||||
|
|
@ -95,7 +96,7 @@ scripts = set(os.listdir('scripts'))
|
|||
packages = set(find_packages())
|
||||
|
||||
hildon_scripts = set(('masstransit',))
|
||||
qt_scripts = set(('qboobmsg', 'qhavesex', 'qvideoob', 'weboob-config-qt'))
|
||||
qt_scripts = set(('qboobmsg', 'qhavesex', 'qvideoob', 'weboob-config-qt', 'qwebcontentedit'))
|
||||
|
||||
if not options.hildon:
|
||||
scripts = scripts - hildon_scripts
|
||||
|
|
@ -116,6 +117,8 @@ qt_packages = set((
|
|||
'weboob.applications.qvideoob.ui',
|
||||
'weboob.applications.qweboobcfg',
|
||||
'weboob.applications.qweboobcfg.ui',
|
||||
'weboob.applications.qwebcontentedit',
|
||||
'weboob.applications.qwebcontentedit.ui'
|
||||
))
|
||||
|
||||
if not options.hildon:
|
||||
|
|
|
|||
3
weboob/applications/qwebcontentedit/__init__.py
Normal file
3
weboob/applications/qwebcontentedit/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .qwebcontentedit import QWebContentEdit
|
||||
|
||||
__all__ = ['QWebContentEdit']
|
||||
79
weboob/applications/qwebcontentedit/main_window.py
Normal file
79
weboob/applications/qwebcontentedit/main_window.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2011 Clément Schreiner
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
|
||||
|
||||
from weboob.tools.application.qt import QtMainWindow, QtDo
|
||||
|
||||
from .ui.main_window_ui import Ui_MainWindow
|
||||
|
||||
class MainWindow(QtMainWindow):
|
||||
def __init__(self, config, weboob, parent=None):
|
||||
QtMainWindow.__init__(self, parent)
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.config = config
|
||||
self.weboob = weboob
|
||||
|
||||
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.connect(self.ui.saveButton, SIGNAL("clicked()"), self.savePage)
|
||||
|
||||
def _currentTabChanged(self):
|
||||
if self.ui.tabWidget.currentIndex() == 1:
|
||||
self.showPreview()
|
||||
return
|
||||
|
||||
def loadPage(self):
|
||||
id = unicode(self.ui.idEdit.text())
|
||||
if not id:
|
||||
return
|
||||
|
||||
for backend in self.weboob.iter_backends():
|
||||
self.content = backend.get_content(id)
|
||||
if self.content:
|
||||
self.ui.contentEdit.setPlainText(self.content.content)
|
||||
self.backend = backend
|
||||
return
|
||||
|
||||
|
||||
def savePage(self):
|
||||
if not hasattr(self, "backend"):
|
||||
return
|
||||
new_content = unicode(self.ui.contentEdit.toPlainText())
|
||||
if new_content != self.content.content:
|
||||
self.content.content = new_content
|
||||
message = unicode(self.ui.descriptionEdit.text())
|
||||
self.process = QtDo(self.weboob, self._savePage_cb, self._savePage_eb)
|
||||
self.process.do('push_content', self.content, message, backends=self.backend)
|
||||
|
||||
def _savePage_cb(self, backend, data):
|
||||
if not backend:
|
||||
return
|
||||
self.ui.descriptionEdit.clear()
|
||||
|
||||
def _savePage_eb(self, backend, error, backtrace):
|
||||
print error
|
||||
print backtrace
|
||||
|
||||
def showPreview(self):
|
||||
self.ui.previewEdit.setHtml(self.backend.preview_content(self.content))
|
||||
return
|
||||
36
weboob/applications/qwebcontentedit/qwebcontentedit.py
Normal file
36
weboob/applications/qwebcontentedit/qwebcontentedit.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2011 Clément Schreiner
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
from weboob.tools.application.qt import QtApplication
|
||||
from weboob.capabilities.content import ICapContent
|
||||
|
||||
from .main_window import MainWindow
|
||||
|
||||
class QWebContentEdit(QtApplication):
|
||||
APPNAME = 'qwebcontentedit'
|
||||
VERSION = '0.6'
|
||||
COPYRIGHT = 'Copyright(C) 2011 Clément Schreiner'
|
||||
DESCRIPTION = "Qt application for managing content on supported websites"
|
||||
CAPS = ICapContent
|
||||
|
||||
def main(self, argv):
|
||||
self.load_backends(ICapContent, storage=self.create_storage())
|
||||
self.main_window = MainWindow(self.config, self.weboob)
|
||||
self.main_window.show()
|
||||
return self.weboob.loop()
|
||||
|
||||
|
||||
13
weboob/applications/qwebcontentedit/ui/Makefile
Normal file
13
weboob/applications/qwebcontentedit/ui/Makefile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
UI_FILES = $(wildcard *.ui)
|
||||
UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py)
|
||||
PYUIC = pyuic4
|
||||
|
||||
all: $(UI_PY_FILES)
|
||||
|
||||
%_ui.py: %.ui
|
||||
$(PYUIC) -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.pyc
|
||||
rm -f $(UI_PY_FILES)
|
||||
|
||||
0
weboob/applications/qwebcontentedit/ui/__init__.py
Normal file
0
weboob/applications/qwebcontentedit/ui/__init__.py
Normal file
126
weboob/applications/qwebcontentedit/ui/main_window.ui
Normal file
126
weboob/applications/qwebcontentedit/ui/main_window.ui
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>469</width>
|
||||
<height>521</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="idEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="loadButton">
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Edit</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="contentEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Preview</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="previewEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="descriptionEdit">
|
||||
<property name="text">
|
||||
<string>Edit description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="saveButton">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>469</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>actionExit</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>343</x>
|
||||
<y>306</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue