diff --git a/TODO b/TODO index 24b8aa5..5c87bb6 100644 --- a/TODO +++ b/TODO @@ -3,4 +3,8 @@ * install netplug on all servers * verkabelungsanleitung für die sensoren schreiben * server restartsicher machen - \ No newline at end of file + * anne texter erklären und installieren + * + + +11:30 Termin diff --git a/config_files/4.48 Desktop Grabber.desktop b/config_files/4.48 Desktop Grabber.desktop new file mode 100755 index 0000000..0255033 --- /dev/null +++ b/config_files/4.48 Desktop Grabber.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Comment[en_US]= +Comment= +Exec=ffmpeg -f x11grab -s 768x576 -r 30 -i :0.0+9,89 -vcodec mjpeg -vcodec mjpeg http://localhost:8090/webcam.ffm +GenericName[en_US]=Grabs a desktop region +GenericName=Grabs a desktop region +Icon=exec +MimeType= +Name[en_US]=4.48 Desktop Grabber +Name=4.48 Desktop Grabber +Path= +StartupNotify=true +Terminal=true +TerminalOptions=\s--noclose +Type=Application +X-DBUS-ServiceName= +X-DBUS-StartupType=none +X-KDE-SubstituteUID=false +X-KDE-Username= diff --git a/config_files/4.48 Streamer.desktop b/config_files/4.48 Streamer.desktop new file mode 100755 index 0000000..084b9d0 --- /dev/null +++ b/config_files/4.48 Streamer.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Comment[en_US]= +Comment= +Exec=ffserver -d -f /etc/ffserver.conf -v debug\n +GenericName[en_US]=Streams desktop casts +GenericName=Streams desktop casts +Icon=exec +MimeType= +Name[en_US]=4.48 Streamer +Name=4.48 Streamer +Path= +StartupNotify=true +Terminal=true +TerminalOptions=\s--noclose +Type=Application +X-DBUS-ServiceName= +X-DBUS-StartupType= +X-KDE-SubstituteUID=false +X-KDE-Username= diff --git a/config_files/ffserver.conf b/config_files/ffserver.conf new file mode 100644 index 0000000..84410fb --- /dev/null +++ b/config_files/ffserver.conf @@ -0,0 +1,19 @@ +Port 8090 +BindAddress 0.0.0.0 +MaxClients 10 +MaxBandwidth 1000000 +CustomLog /tmp/ffserver.log + + +file /tmp/textcast.ffm +FileMaxSize 10M +ACL allow 127.0.0.1 + + + +Feed textcast.ffm +Format mjpeg +VideoFrameRate 25 +VideoSize 768x576 +Noaudio + diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index a870ce4..e4fc94c 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -136,17 +136,25 @@ class OSCThread(threading.Thread): def run(self): while self.running: - reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) - if reads: - osc_input = self.osc_sock.recv(256) - osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) - #print "thread osc_address", osc_address - if osc_address.find("ekg") != -1 or osc_address.find("plot") != -1: - queue.put_nowait((osc_address, messages)) + try: + reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) + except Exception, e: + print "select error", e + pass else: - queue.put_nowait(("/bjoern/ekg", [0])) - queue.put_nowait(("/merle/ekg", [0])) - queue.put_nowait(("/uwe/ekg", [0])) + if reads: + try: + osc_input, address = self.osc_sock.recvfrom(8192) + osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) + if osc_address.find("ekg") != -1 or osc_address.find("plot") != -1: + queue.put_nowait((osc_address, messages)) + except Exception, e: + print "recvfrom error", e + else: + queue.put_nowait(("/bjoern/ekg", [0])) + queue.put_nowait(("/merle/ekg", [0])) + queue.put_nowait(("/uwe/ekg", [0])) + self.unsubscribe_me() print "OSCThread is going down" @@ -237,11 +245,11 @@ class Actor(object): class EkgPlot(object): def __init__(self, actor_names, num_data, colors): - self.plot = pg.PlotWidget(title="

EKG

") + self.plot = pg.PlotWidget() self.plot.hide() - self.plot.setLabel('left', "

Amplitude

") - self.plot.setLabel('bottom', "

Time

") - self.plot.showGrid(True, True) + #self.plot.setLabel('left', "

Amplitude

") + #self.plot.setLabel('bottom', "

Time

") + self.plot.showGrid(False, False) self.plot.setYRange(0, 255) self.plot.setXRange(0, num_data) self.plot.resize(1280, 720) @@ -354,7 +362,7 @@ class MyHandler(BaseHTTPRequestHandler): self.thread = thread = OSCThread(self.server.args) thread.daemon = True thread.start() - actor_names = ["bjoern", "merle", "uwe"] + actor_names = ["merle", "bjoern", "uwe"] num_data = 100 colors = ["r", "g", "b"] qtapp = QtGui.QApplication([]) @@ -374,8 +382,8 @@ class MyHandler(BaseHTTPRequestHandler): osc_address, args = queue.get_nowait() except Queue.Empty: break - - plotter.update(osc_address, args[0]) + else: + plotter.update(osc_address, args[0]) exporter = pg.exporters.ImageExporter.ImageExporter(plotter.plot.plotItem) img = exporter.export("tmpfile", True) @@ -386,10 +394,10 @@ class MyHandler(BaseHTTPRequestHandler): JpegData = buffer.data() self.wfile.write("--aaboundary\r\nContent-Type: image/jpeg\r\nContent-length: %d\r\n\r\n%s\r\n\r\n\r\n" % (len(JpegData), JpegData)) - del JpegData - del buffer - del img - del exporter + JpegData = None + buffer = None + img = None + exporter = None #now = time.time() #dt = now - lastTime #lastTime = now @@ -410,21 +418,24 @@ class MyHandler(BaseHTTPRequestHandler): return except (KeyboardInterrupt, SystemError): print "queue size", queue.qsize() - if hasattr(self, "thread"): + if hasattr(self, "thread") and self.thread is not None: self.thread.running = False self.thread.join() - del self.thread + self.thread = None except IOError, e: - if hasattr(self, "thread"): - self.thread.running = False - self.thread.join() - del self.thread - print "ioerror", e - print '-'*40 - print 'Exception happened during processing of request from' - traceback.print_exc() # XXX But this goes to stderr! - print '-'*40 - self.send_error(404,'File Not Found: %s' % self.path) + print "ioerror", e, e[0] + print dir(e) + if e[0] in (32, 104): + if hasattr(self, "thread") and self.thread is not None: + self.thread.running = False + self.thread.join() + self.thread = None + else: + print '-'*40 + print 'Exception happened during processing of request from' + traceback.print_exc() # XXX But this goes to stderr! + print '-'*40 + self.send_error(404,'File Not Found: %s' % self.path) class JustAHTTPServer(HTTPServer): diff --git a/texter/main.py b/texter/main.py deleted file mode 100644 index 5dc8fec..0000000 --- a/texter/main.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -import PyQt4.uic -from PyQt4 import QtCore, QtGui -from PyKDE4.kdeui import KActionCollection, KRichTextWidget - -MainWindowForm, MainWindowBase = PyQt4.uic.loadUiType('texter.ui') - -from operator import itemgetter -import cPickle - -class MainWindow(MainWindowBase, MainWindowForm): - def __init__(self, parent = None): - super(MainWindow, self).__init__(parent) - - - # setup the ui - self.setupUi(self) - self.show_private_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) - self.edit_private_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) - self.edit_action_collection = KActionCollection(self) - self.edit_private_text.createActions(self.edit_action_collection) - for action in self.edit_action_collection.actions(): - self.toolBar.addAction(action) - - - print dir(self) - - - self.tabWidget.currentChanged.connect(self.slot_toggleToolbox) - self.add_button.clicked.connect(self.slot_addText) - self.save_button.clicked.connect(self.slot_save) - self.publish_button.clicked.connect(self.slot_publish) - self.clear_button.clicked.connect(self.slot_clear) - self.remove_item_button.clicked.connect(self.slot_removeItem) - self.edit_item_selection.activated.connect(self.slot_editLoadItem) - self.item_list.currentRowChanged.connect(self.slot_showLoadItem) - - self.items = dict() - self.slot_load() - self.next_button.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Space)) - self.next_button.clicked.connect(self.slot_next_item) - - self.previous_button.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Backspace)) - self.previous_button.clicked.connect(self.slot_previous_item) - - def slot_next_item(self): - print "slot_next_item" - index = (self.item_list.currentRow() + 1) % self.item_list.count() - self.item_list.setCurrentRow(index) - self.edit_item_selection.setCurrentIndex(index) - self.slot_editLoadItem(index) - self.slot_showLoadItem(index) - - def slot_previous_item(self): - print "slot_previous_item" - index = (self.item_list.currentRow() - 1) % self.item_list.count() - self.item_list.setCurrentRow(index) - self.edit_item_selection.setCurrentIndex(index) - self.slot_editLoadItem(index) - self.slot_showLoadItem(index) - - def slot_toggleToolbox(self, index): - if index == 0: - self.toolBar.setEnabled(True) - else: - self.toolBar.setEnabled(False) - - def slot_publish(self): - #QPropertyAnimation animation(self.public_text.palette(), "geometry"); - #animation.setDuration(10000); - #animation.setStartValue(QRect(0, 0, 100, 30)); - #animation.setEndValue(QRect(250, 250, 100, 30)); - #animation.start(); - print "slot_publish" - self.show_public_text.setTextOrHtml(self.show_private_text.textOrHtml()) - - def slot_clear(self): - self.show_public_text.clear() - - def slot_removeItem(self): - text = self.edit_item_selection.currentText() - index = self.edit_item_selection.currentIndex() - title = text.split(": ")[1] - del self.items[title] - self.edit_item_selection.removeItem(index) - self.show_item_selection.removeItem(index) - - def slot_editLoadItem(self, index): - print "slot_editLoadItem", index - itemText = self.edit_item_selection.itemText(index) - position, title = itemText.split(": ", 1) - text, position = self.items[title] - self.edit_private_text.setTextOrHtml(text) - self.item_title.setText(title) - self.item_position_input.setValue(position) - - def slot_showLoadItem(self, index): - public_rect = self.show_public_text.geometry() - global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) - print "slot_showLoadItem", global_rect - item = self.item_list.item(index) - if item is None: - return - title = item.text() - text, index = self.items[title] - self.show_private_text.setHtml(text) - if self.auto_publish_checkbox.isChecked(): - self.show_public_text.setHtml(text) - - def title_by_index(self, ix): - for title, (text, index) in self.items.iteritems(): - if index == ix: - return title - return None - - def slot_changeItem(self, old_title): - print "slot_changeItem" - text, index = self.items.pop(old_title) - new_text = self.edit_private_text.textOrHtml() - new_title = self.item_title.text() - self.items[new_title] = (new_text, index) - self.show_public_text.setTextOrHtml(new_text) - self.item_title.setText(new_title) - self.edit_item_selection.setItemText(index, "%d: %s" % (index, new_title)) - self.item_list.item(index).setText(new_title) - - def slot_addText(self): - print "slot add" - index = self.item_position_input.value() - if index - self.item_list.count() > 1: - old_title = self.edit_item_selection.currentText().split(": ")[1] - self.item_title.setText(old_title) - text, index = self.items[old_title] - self.edit_private_text.setTextOrHtml(text) - self.item_position_input.setValue(index) - return - old_title = self.title_by_index(index) - if old_title is not None: - self.slot_changeItem(old_title) - return - - title = self.item_title.text() - text = self.edit_private_text.textOrHtml() - self.items[title] = (text, index) - self.edit_item_selection.insertItem(index, "%d: %s" % (index, title)) - self.item_list.insertItem(index, title) - self.edit_item_selection.setCurrentIndex(index) - self.item_list.setCurrentRow(index) - - def slot_save(self): - cPickle.dump(self.items, open("448_texter.db", "w"), cPickle.HIGHEST_PROTOCOL) - - def slot_load(self): - try: - self.items = cPickle.load(open("448_texter.db")) - except Exception, e: - print e - - data = list() - for title, (text, index) in self.items.iteritems(): - data.append((title, text, index)) - - data = sorted(data, key=itemgetter(2)) - for title, text, index in data: - self.edit_item_selection.addItem("%d: %s" % (index, title)) - self.item_list.addItem(title) - - self.edit_item_selection.setCurrentIndex(0) - self.item_list.setCurrentRow(0) - title, text, position = data[0] - self.edit_private_text.setTextOrHtml(text) - self.show_private_text.setTextOrHtml(text) - self.item_position_input.setValue(position) - self.item_title.setText(title) - - - -if ( __name__ == '__main__' ): - app = None - if ( not app ): - app = QtGui.QApplication([]) - - window = MainWindow() - window.show() - - if ( app ): - app.exec_() diff --git a/texter/setup.py b/texter/setup.py new file mode 100644 index 0000000..72c3973 --- /dev/null +++ b/texter/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from distribute_setup import use_setuptools +use_setuptools() + +import sys +from setuptools import find_packages, setup + +if sys.version_info >= (3,): + extras['use_2to3'] = True + +setup( + name='texter', + version="0.1", + packages=find_packages(exclude=["scripts",]), + + include_package_data = True, + + package_data = { + "texter" : ["*.ui", "*.qrc", "*.png"]}, + + exclude_package_data = {'': ['.gitignore']}, + + #install_requires=[], + data_files=[ + ('/usr/share/applications', ['texter/texter.desktop']), + ('/usr/share/icons/hicolor/32x32/apps/texter_icon.png', ['texter/icon.png'])], + + # installing unzipped + zip_safe = False, + + # predefined extension points, e.g. for plugins + entry_points = """ + [console_scripts] + texter = texter.main:main + """, + # pypi metadata + author = "Stefan Kögl", + + # FIXME: add author email + author_email = "hotte@ctdo.de", + description = "live text tool", + + # FIXME: add long_description + long_description = """ + """, + + # FIXME: add license + license = "LGPL", + + # FIXME: add keywords + keywords = "", + + # FIXME: add download url + url = "", + test_suite='tests' +) diff --git a/texter/texter.ui b/texter/texter.ui deleted file mode 100644 index 8d700e9..0000000 --- a/texter/texter.ui +++ /dev/null @@ -1,1588 +0,0 @@ - - - MainWindow - - - 448 Texter - - - - - - - 1 - - - - &Edit - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - &Title - - - item_title - - - - - - - - - - P&osition - - - item_position_input - - - - - - - - - - S&election - - - edit_item_selection - - - - - - - - 0 - 0 - - - - - - - - &Add / Change - - - - - - - &Remove - - - - - - - Sa&ve - - - - - - - - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - Monospace - 14 - - - - true - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - - - - - Sho&w - - - - - - - 640 - 480 - - - - - 640 - 480 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - Monospace - 14 - - - - true - - - - - - true - - - true - - - - - - - - - Next - - - - - - - - - - Previous - - - - - - - &Publish - - - - - - - &Clear - - - - - - - A&uto Publish - - - - - - - - - - - - 0 - 480 - - - - - 16777215 - 480 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - Monospace - 14 - - - - true - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - Item - - - item_list - - - - - - - - - - - - clear_button - show_private_text - show_item_selection - publish_button - show_public_text - item_list - label_7 - item_list - item_list - item_list - - - - - - private_text - kbuttongroup - verticalSpacer - item_title - edit_item_selection - tabWidget - - - - - toolBar - - - false - - - false - - - TopToolBarArea - - - false - - - - - - KRichTextEdit - KTextEdit -
krichtextedit.h
-
- - KTextEdit - QTextEdit -
ktextedit.h
-
- - KListWidget - QListWidget -
klistwidget.h
-
- - KRichTextWidget - KRichTextEdit -
krichtextwidget.h
-
- - KIntNumInput - QWidget -
knuminput.h
-
-
- - edit_private_text - item_title - item_position_input - edit_item_selection - remove_item_button - - - -
diff --git a/texter/texter/448_texter.db b/texter/texter/448_texter.db new file mode 100644 index 0000000..2604dd1 Binary files /dev/null and b/texter/texter/448_texter.db differ diff --git a/texter/texter/__init__.py b/texter/texter/__init__.py new file mode 100644 index 0000000..fa924e5 --- /dev/null +++ b/texter/texter/__init__.py @@ -0,0 +1 @@ +import texter_rc diff --git a/texter/texter/build.sh b/texter/texter/build.sh new file mode 100644 index 0000000..2239a83 --- /dev/null +++ b/texter/texter/build.sh @@ -0,0 +1,2 @@ +# pykdeuic4-python2.7 -o texter_ui.py texter3.ui +pykdeuic4-python2.7 -o text_sorter_ui.py texter4.ui diff --git a/texter/texter/icon.png b/texter/texter/icon.png new file mode 100644 index 0000000..fd05fbc Binary files /dev/null and b/texter/texter/icon.png differ diff --git a/texter/texter/main.py b/texter/texter/main.py new file mode 100644 index 0000000..8c827a7 --- /dev/null +++ b/texter/texter/main.py @@ -0,0 +1,660 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import cPickle +import os.path +import re +import subprocess +import sys +from math import pow + +from operator import itemgetter + +from PyQt4 import QtCore, QtGui + +from PyKDE4.kdecore import ki18n, KCmdLineArgs, KAboutData +from PyKDE4.kdeui import KDialog, KActionCollection, KRichTextWidget, KComboBox, KPushButton, KRichTextWidget, KMainWindow, KToolBar, KApplication, KAction, KToolBarSpacerAction, KSelectAction, KToggleAction, KShortcut + +from texter_ui import Ui_MainWindow, _fromUtf8 +from text_sorter_ui import Ui_TextSorterDialog +from text_model import TextModel + +appName = "texter" +catalog = "448texter" +programName = ki18n("4.48 Psychose Texter") +version = "0.1" + +aboutData = KAboutData(appName, catalog, programName, version) + +KCmdLineArgs.init (sys.argv, aboutData) + +app = KApplication() + +for path in QtGui.QIcon.themeSearchPaths(): + print "%s/%s" % (path, QtGui.QIcon.themeName()) + + +# NOTE: if the QIcon.fromTheme method does not find any icons, you can set a theme +# in your local icon directory: +# ln -s /your/icon/theme/directory $HOME/.icons/hicolor + +class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog): + def __init__(self, parent = None): + super(TextSorterDialog, self).__init__(parent) + + self.setupUi(self) + self.fill_list() + + self.text_list.clicked.connect(self.slot_show_text) + self.remove_button.clicked.connect(self.slot_removeItem) + self.move_up_button.clicked.connect(self.slot_text_up) + self.move_down_button.clicked.connect(self.slot_text_down) + self.text_list.clicked.connect(self.slot_toggle_buttons) + self.move_up_button.setEnabled(False) + self.move_down_button.setEnabled(False) + + + def slot_toggle_buttons(self, index): + row = index.row() + if row <= 0: + self.move_up_button.setEnabled(False) + else: + self.move_up_button.setEnabled(True) + + if row >= len(self.model.text_db) - 1: + self.move_down_button.setEnabled(False) + else: + self.move_down_button.setEnabled(True) + + def fill_list(self): + self.model = self.parent().parent().model + self.text_list.setModel(self.model) + + def slot_text_up(self): + row = self.text_list.currentIndex().row() + if row <= 0: + return False + + text_db = self.model.text_db + text_db[row-1], text_db[row] = text_db[row], text_db[row-1] + self.text_list.setCurrentIndex(self.model.index(row - 1, 0)) + self.text_list.clicked.emit(self.model.index(row - 1, 0)) + return True + + def slot_text_down(self): + text_db = self.model.text_db + row = self.text_list.currentIndex().row() + if row >= len(text_db) - 1: + return False + + text_db[row], text_db[row+1] = text_db[row+1], text_db[row] + index = self.model.index(row + 1, 0) + self.text_list.setCurrentIndex(index) + self.text_list.clicked.emit(index) + return True + + def slot_show_text(self, model_index): + self.text_preview.setTextOrHtml(self.parent().parent().model.text_db[model_index.row()][1]) + + + def slot_removeItem(self): + index = self.text_list.currentIndex().row() + print "remote index", index + self.model.removeRows(index, 1) + index = self.model.index(0, 0) + self.text_list.setCurrentIndex(index) + self.text_list.clicked.emit(index) + + +class MainWindow(KMainWindow, Ui_MainWindow): + def __init__(self, parent=None): + super(MainWindow, self).__init__(parent) + + self.is_streaming = False + self.ffserver = None + self.ffmpeg = None + self.live_center_action = None + self.preview_center_action = None + self.live_size_action = None + self.preview_font_action = None + self.live_font_action = None + self.preview_size_action = None + self.default_size = 28 + self.default_align_text = "format_align_center" + self.preview_actions = list() + self.live_actions = list() + self.current = 0 + self.model = TextModel(self) + + self.is_auto_publish = False + + self.setupUi(self) + + self.font = QtGui.QFont("monospace", self.default_size) + self.font.setStyleHint(QtGui.QFont.TypeWriter) + + self.toolbar = KToolBar(self, True, True) + self.toolbar.setAllowedAreas(QtCore.Qt.BottomToolBarArea) + self.toolbar.setMovable(False) + self.toolbar.setFloatable(False) + self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) + self.addToolBar(QtCore.Qt.BottomToolBarArea, self.toolbar) + + self.createLiveActions() + self.createPreviewActions() + self.slot_load() + + self.preview_text.document().setDefaultFont(self.font) + self.preview_text.setFont(self.font) + self.preview_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) + self.preview_editor_collection = KActionCollection(self) + self.preview_text.createActions(self.preview_editor_collection) + + self.live_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) + self.live_text.document().setDefaultFont(self.font) + self.live_text.setFont(self.font) + self.live_editor_collection = KActionCollection(self) + self.live_text.createActions(self.live_editor_collection) + self.filter_editor_actions() + self.toolbar.insertSeparator(self.publish_action) + self.toolbar.addSeparator() + + self.show() + + self.save_action.triggered.connect(self.slot_save) + #self.valign_action.triggered.connect(self.slot_valign) + self.publish_action.triggered.connect(self.slot_publish) + self.clear_live_action.triggered.connect(self.slot_clear_live) + self.clear_preview_action.triggered.connect(self.slot_clear_preview) + #self.remove_item_button.triggered.connect(self.slot_removeItem) + self.text_combo.triggered[int].connect(self.slot_load_preview_text) + + app.focusChanged.connect(self.focusChanged) + self.text_editor_action.triggered.connect(self.slot_open_dialog) + self.save_live_action.triggered.connect(self.slot_save_live_text) + self.save_preview_action.triggered.connect(self.slot_save_preview_text) + self.streaming_action.triggered.connect(self.slot_toggle_streaming) + self.auto_publish_action.toggled.connect(self.slot_auto_publish) + self.preview_size_action.triggered[QtGui.QAction].connect(self.slot_preview_font_size) + self.live_size_action.triggered[QtGui.QAction].connect(self.slot_live_font_size) + + self.next_action.triggered.connect(self.slot_next_item) + self.previous_action.triggered.connect(self.slot_previous_item) + + app.aboutToQuit.connect(self.kill_streaming) + self.getLiveCoords() + print "desktop", app.desktop().availableGeometry() + + + def getLiveCoords(self): + public_rect = self.live_text.geometry() + global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) + x = global_rect.x() + y = global_rect.y() + self.statusBar().showMessage("live text editor dimensions: x=%r, y=%r, width=%r, height=%r" % (x, y, global_rect.width(), global_rect.height())) + + def getPreviewCoords(self): + public_rect = self.preview_text.geometry() + global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) + return global_rect.x(), global_rect.y() + + + def filter_editor_actions(self): + + disabled_action_names = [ + "action_to_plain_text", + "format_painter", + "direction_ltr", + "direction_rtl", + "format_font_family", + #"format_font_size", + "format_text_background_color", + "format_list_indent_more", + "format_list_indent_less", + "format_text_bold", + "format_text_underline", + "format_text_strikeout", + "format_text_italic", + "format_align_right", + "format_align_justify", + "manage_link", + "format_text_subscript", + "format_text_superscript", + "insert_horizontal_rule" + ] + + for action in self.live_editor_collection.actions(): + text = str(action.objectName()) + if text in disabled_action_names: + action.setVisible(False) + + if text == self.default_align_text: + self.live_center_action = action + elif text == "format_font_size": + self.live_size_action = action + elif text == "format_font_family": + self.live_font_action = action + + for action in self.preview_editor_collection.actions(): + text = str(action.objectName()) + if text in disabled_action_names: + action.setVisible(False) + + if text == self.default_align_text: + self.preview_center_action = action + elif text == "format_font_size": + self.preview_size_action = action + elif text == "format_font_family": + self.preview_font_action = action + + self.slot_set_preview_defaults() + self.slot_set_live_defaults() + + + def createLiveActions(self): + self.toolbar.show() + self.live_text_collection = KActionCollection(self) + self.live_text_collection.addAssociatedWidget(self.toolbar) + + self.clear_live_action = self.live_text_collection.addAction("clear_live_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) + self.clear_live_action.setIcon(icon) + self.clear_live_action.setIconText("clear live") + self.clear_live_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Q)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + + self.save_live_action = self.live_text_collection.addAction("save_live_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-new")) + self.save_live_action.setIcon(icon) + self.save_live_action.setIconText("save live") + self.save_live_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_W)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + def createPreviewActions(self): + self.toolbar.show() + self.preview_text_collection = KActionCollection(self) + self.preview_text_collection.addAssociatedWidget(self.toolbar) + + self.clear_preview_action = self.preview_text_collection.addAction("clear_preview_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) + self.clear_preview_action.setIcon(icon) + self.clear_preview_action.setIconText("clear preview") + #self.clear_preview_action.setObjectName("clear_preview") + self.clear_preview_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_A)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + + self.save_preview_action = self.preview_text_collection.addAction("save_preview_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-new")) + self.save_preview_action.setIcon(icon) + self.save_preview_action.setIconText("save preview") + self.save_preview_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_S)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + + self.publish_action = self.preview_text_collection.addAction("publish_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-playback-start")) + self.publish_action.setIcon(icon) + self.publish_action.setIconText("publish") + self.publish_action.setShortcutConfigurable(True) + self.publish_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Return)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + + self.previous_action = self.preview_text_collection.addAction("previous_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-backward")) + self.previous_action.setIcon(icon) + self.previous_action.setIconText("previous") + self.previous_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Left)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + self.next_action = self.preview_text_collection.addAction("next_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-forward")) + self.next_action.setIcon(icon) + self.next_action.setIconText("next") + self.next_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Right)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + self.text_editor_action = KToggleAction(self.preview_text_collection) + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open")) + self.text_editor_action.setIcon(icon) + self.text_editor_action.setIconText("sort") + self.preview_text_collection.addAction("text editor", self.text_editor_action) + self.text_editor_action.setObjectName("text_editor_action") + self.text_editor_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_O)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + self.auto_publish_action = KToggleAction(self.preview_text_collection) + self.preview_text_collection.addAction("auto publish", self.auto_publish_action) + icon = QtGui.QIcon.fromTheme(_fromUtf8("view-refresh")) + self.auto_publish_action.setIcon(icon) + self.auto_publish_action.setObjectName("auto_publish_action") + self.auto_publish_action.setIconText("auto publish") + + self.save_action = self.preview_text_collection.addAction("save_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-save")) + self.save_action.setIcon(icon) + self.save_action.setIconText("save") + self.save_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_S)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + self.streaming_action = KToggleAction(self.preview_text_collection) + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-record")) + self.streaming_action.setIcon(icon) + self.streaming_action.setIconText("stream") + self.streaming_action.setObjectName("stream") + self.streaming_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_1)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + self.preview_text_collection.addAction("stream", self.streaming_action) + + #self.valign_action = self.preview_text_collection.addAction("valign_action") + #icon = QtGui.QIcon.fromTheme(_fromUtf8("media-stop")) + #self.valign_action.setIcon(icon) + #self.valign_action.setIconText("valign") + #self.valign_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Plus)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + self.spacer = KToolBarSpacerAction(self.preview_text_collection) + self.preview_text_collection.addAction("spacer", self.spacer) + + self.text_combo = KSelectAction(self.preview_text_collection) + self.text_combo.setEditable(False) + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open-recent")) + self.text_combo.setIcon(icon) + self.text_combo.setIconText("saved texts") + self.text_combo.setObjectName("text_combo") + self.preview_text_collection.addAction("saved texts", self.text_combo) + + def slot_auto_publish(self, state): + self.is_auto_publish = bool(state) + + + def slot_toggle_streaming(self): + if self.ffserver is None: + self.start_streaming() + else: + self.kill_streaming() + + + def kill_streaming(self): + self.is_streaming = False + if self.ffmpeg is not None: + self.ffmpeg.kill() + self.ffmpeg = None + if self.ffserver is not None: + self.ffserver.kill() + self.ffserver = None + + def start_streaming(self): + public_rect = self.live_text.geometry() + global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) + self.ffserver = subprocess.Popen("ffserver -f /etc/ffserver.conf", shell=True, close_fds=True) + self.ffmpeg = subprocess.Popen("ffmpeg -f x11grab -s 768x576 -r 25 -i :0.0+%d,%d -vcodec mjpeg -pix_fmt yuvj422p -r 25 -aspect 4:3 http://localhost:8090/webcam.ffm" % (global_rect.x()+1, global_rect.y()+1), shell=True, close_fds=True) + self.is_streaming = True + + def focusChanged(self, old, new): + if new == self.preview_text: + self.live_editor_collection.clearAssociatedWidgets() + self.preview_editor_collection.addAssociatedWidget(self.toolbar) + elif new == self.live_text: + self.preview_editor_collection.clearAssociatedWidgets() + self.live_editor_collection.addAssociatedWidget(self.toolbar) + + def custom_clear(self, cursor): + cursor.beginEditBlock() + cursor.movePosition(QtGui.QTextCursor.Start); + cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.KeepAnchor); + cursor.removeSelectedText() + cursor.endEditBlock() + + + def get_preview_text(self, text): + return re.sub(" +", " ", text.replace("\n", " ")).strip()[:20] + + + def slot_next_item(self): + self.current = (self.text_combo.currentItem() + 1) % len(self.model.text_db) + self.text_combo.setCurrentItem(self.current) + self.slot_load_preview_text(self.current) + + + def slot_previous_item(self): + self.current = (self.text_combo.currentItem() - 1) % len(self.model.text_db) + self.text_combo.setCurrentItem(self.current) + self.slot_load_preview_text(self.current) + + + def slot_toggleToolbox(self, index): + if index == 0: + self.toolBar.setEnabled(True) + else: + self.toolBar.setEnabled(False) + + + def slot_publish(self): + self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) + + def slot_live_font_size(self, action): + print "font_size" + self.default_size = self.live_size_action.fontSize() + self.slot_set_preview_defaults() + self.slot_set_live_defaults() + + + def slot_preview_font_size(self, action): + print "font_size" + self.default_size = self.preview_size_action.fontSize() + self.slot_set_live_defaults() + self.slot_set_preview_defaults() + + + def slot_toggle_publish(self, state=None): + + if state: + self.slot_publish() + else: + self.slot_clear_live() + + + def slot_set_preview_defaults(self): + self.preview_center_action.setChecked(True) + self.preview_text.alignCenter() + self.font.setPointSize(self.default_size) + self.preview_text.setFontSize(self.default_size) + self.preview_text.setFont(self.font) + self.preview_size_action.setFontSize(self.default_size) + self.preview_text.document().setDefaultFont(self.font) + + + def slot_set_live_defaults(self): + self.live_center_action.setChecked(True) + self.live_text.alignCenter() + self.font.setPointSize(self.default_size) + self.live_text.setFontSize(self.default_size) + self.live_text.setFont(self.font) + self.live_size_action.setFontSize(self.default_size) + self.live_text.document().setDefaultFont(self.font) + + + def slot_clear_live(self): + self.live_text.clear() + self.slot_set_live_defaults() + + + def slot_clear_preview(self): + self.preview_text.clear() + self.slot_set_preview_defaults() + + def fill_combo_box(self): + print "fill_combo_box" + self.text_combo.clear() + for preview, text in self.model.text_db: + self.text_combo.addAction(preview) + + self.text_combo.setCurrentItem(0) + self.slot_load_preview_text(0) + + + def slot_removeItem(self): + text = self.edit_item_selection.currentText() + index = self.edit_item_selection.currentIndex() + title = text.split(": ")[1] + del self.items[title] + self.edit_item_selection.removeItem(index) + new_index = self.edit_item_selection.currentIndex() + if new_index != -1: + self.slot_editLoadItem() + else: + self.item_title.clear() + self.item_position_input.setValue(0) + + + def slot_load_preview_text(self, index): + try: + preview, text = self.model.text_db[index] + except IndexError: + return + self.preview_text.setTextOrHtml(text) + if self.is_auto_publish: + self.live_text.setTextOrHtml(text) + + + def slot_save_live_text(self): + text = self.live_text.toHtml() + preview = self.get_preview_text(unicode(self.live_text.toPlainText())) + if not preview: + return + old_item = self.model.text_by_preview(preview) + if old_item is not None: + suffix = 1 + while 1: + tmp_preview = "%s_%d" % (preview, suffix) + tmp = self.model.text_by_preview(tmp_preview) + if tmp is None: + preview = tmp_preview + break + else: + suffix += 1 + + self.model.text_db.append([preview, text]) + self.model.modelReset.emit() + action = self.text_combo.addAction(preview) + self.text_combo.setCurrentAction(action) + + def slot_save_preview_text(self): + text = self.preview_text.toHtml() + preview = self.get_preview_text(unicode(self.preview_text.toPlainText())) + + if not preview: + return + old_item = self.model.text_by_preview(preview) + if old_item is not None: + suffix = 1 + while 1: + tmp_preview = "%s_%d" % (preview, suffix) + tmp = self.model.text_by_preview(tmp_preview) + if tmp is None: + preview = tmp_preview + break + else: + suffix += 1 + + self.model.text_db.append([preview, text]) + self.model.modelReset.emit() + action = self.text_combo.addAction(preview) + self.text_combo.setCurrentAction(action) + + def slot_save(self): + path = os.path.expanduser("~/.texter") + if not os.path.isdir(path): + os.mkdir(path) + try: + f = open(os.path.join(path, "texter.db"), "w") + except IOError: + return + else: + cPickle.dump(self.model.text_db, f, cPickle.HIGHEST_PROTOCOL) + + #def slot_valign(self): + #fm = QtGui.QFontMetrics(self.font) + ##h = fn.height() + ##max_lines = 576 / h + ##text = unicode(self.preview_text.toPlainText()) + ##text = text.strip().strip("\n") + ##lines = text.count("\n") + 1 + ##self.preview_text.setTextOrHtml("\n" * ((max_lines - lines) / 2) + text) + ##self.statusBar().showMessage("text lines = %d, line height = %d, max lines = %d" % (lines, h, max_lines)) + #text_layout = QtGui.QTextLayout(self.preview_text.textOrHtml(), self.font, self.preview_text) + + ##self.text_combo.setCurrentAction(action) + + #margin = 10. + #radius = min(self.preview_text.width()/2.0, self.preview_text.height()/2.0) - margin + #print "radius", type(radius), radius + + #lineHeight = float(fm.height()) + #print "lineHeight", type(lineHeight), lineHeight + #y = 0. + + #text_layout.beginLayout() + + #while 1: + #line = text_layout.createLine() + #if not line.isValid(): + #break + + #x1 = max(0.0, pow(pow(radius,2)-pow(radius-y,2), 0.5)) + #x2 = max(0.0, pow(pow(radius,2)-pow(radius-(y+lineHeight),2), 0.5)) + #x = max(x1, x2) + margin + #lineWidth = (self.preview_text.width() - margin) - x + + #line.setLineWidth(lineWidth) + #line.setPosition(QtCore.QPointF(x, margin+y)) + #y += line.height() + + #text_layout.endLayout() + + #painter = QtGui.QPainter() + #painter.begin(self.preview_text) + #painter.setRenderHint(QtGui.QPainter.Antialiasing) + #painter.fillRect(self.rect(), QtCore.Qt.black) + #painter.setBrush(QtGui.QBrush(QtCore.Qt.white)) + #painter.setPen(QtGui.QPen(QtCore.Qt.white)) + #text_layout.draw(painter, QtCore.QPoint(0,0)) + + #painter.setBrush(QtGui.QBrush(QtGui.QColor("#a6ce39"))) + #painter.setPen(QtGui.QPen(QtCore.Qt.black)) + #painter.drawEllipse(QtCore.QRectF(-radius, margin, 2*radius, 2*radius)) + #painter.end() + + def slot_open_dialog(self): + self.dialog = KDialog(self) + self.dialog_widget = TextSorterDialog(self.dialog) + self.dialog.setMainWidget(self.dialog_widget) + pos_x, pos_y = self.getPreviewCoords() + self.dialog.move(pos_x, 0) + rect = app.desktop().availableGeometry() + global_width = rect.width() + global_height = rect.height() + x = global_width - pos_x - 10 + self.dialog.setFixedSize(x, global_height-40); + self.dialog.exec_() + self.fill_combo_box() + + def slot_load(self): + path = os.path.expanduser("~/.texter") + if not os.path.isdir(path): + os.mkdir(path) + try: + f = open(os.path.join(path, "texter.db")) + except IOError: + return + + try: + self.model.text_db = [list(i) for i in cPickle.load(f)] + except Exception, e: + print e + + self.fill_combo_box() + self.text_combo.setCurrentItem(0) + self.slot_load_preview_text(0) + self.slot_load_preview_text(0) + + +def main(): + window = MainWindow() + app.exec_() + + +if ( __name__ == '__main__' ): + main() diff --git a/texter/texter/text_model.py b/texter/texter/text_model.py new file mode 100644 index 0000000..9a77880 --- /dev/null +++ b/texter/texter/text_model.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from PyQt4 import QtCore, QtGui +from operator import itemgetter + +class TextModel(QtCore.QAbstractTableModel): + def __init__(self, parent=None): + super(TextModel, self).__init__(parent) + self.text_db = list() + self.default_size = 32 + self.font = QtGui.QFont("monospace", self.default_size) + self.font.setStyleHint(QtGui.QFont.TypeWriter) + + def rowCount(self, parent=QtCore.QModelIndex()): + return len(self.text_db) + + def columnCount(self, parent=QtCore.QModelIndex()): + return 2 + + def data(self, index, role): + if not index.isValid() or \ + not 0 <= index.row() < self.rowCount(): + return QVariant() + + row = index.row() + column = index.column() + if role == QtCore.Qt.DisplayRole: + return self.text_db[row][column] + #return "foo bar" + + return QtCore.QVariant() + + + def headerData(self, section, orientation=QtCore.Qt.Horizontal, role=QtCore.Qt.DisplayRole): + if orientation == QtCore.Qt.Horizontal: + if section == 0: + return "Preview" + else: + return "Text" + return QtCore.QVariant() + + def setData(self, index, value, role): + + if role == QtCore.Qt.EditRole: + self.text_db[index.row()][index.column()] = value.toString() + + return True + + def flags(self, index): + return QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemIsDropEnabled + + def supportedDropActions(self): + return QtCore.Qt.MoveAction + + def insertRows(self, row, count, parent=QtCore.QModelIndex()): + self.beginInsertRows(parent, row, row+count+1) + for i in range(row, row+count): + self.text_db.insert(parent.child(i).data()) + self.endInsertRows() + return True + + def removeRows(self, row, count, parent=QtCore.QModelIndex()): + print "removeRows", row, count + print map(itemgetter(0), self.text_db) + self.beginRemoveRows(QtCore.QModelIndex(), row, row+count+1) + for i in range(row, row+count): + print "del", i, self.text_db[row] + self.text_db.pop(row) + print "after" + print map(itemgetter(0), self.text_db) + self.endRemoveRows() + return True + + + def text_by_preview(self, preview): + for title, text in self.text_db: + if title == preview: + return title, text + return None + diff --git a/texter/texter/text_sorter.ui b/texter/texter/text_sorter.ui new file mode 100644 index 0000000..e5c8389 --- /dev/null +++ b/texter/texter/text_sorter.ui @@ -0,0 +1,157 @@ + + + text_sorter_dialog + + + + 0 + 0 + + + + Dialog + + + + + + + + + 0 + 576 + + + + + 16777215 + 576 + + + + + + + + + + + Remove + + + + + + + + + + + + + 2 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + KArrowButton + QPushButton +
karrowbutton.h
+
+ + KRichTextEdit + KTextEdit +
krichtextedit.h
+
+ + KButtonGroup + QGroupBox +
kbuttongroup.h
+ 1 +
+ + KPushButton + QPushButton +
kpushbutton.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+ + KRichTextWidget + KRichTextEdit +
krichtextwidget.h
+
+
+ + + + buttonBox + accepted() + text_sorter_dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + text_sorter_dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/texter/texter/text_sorter_ui.py b/texter/texter/text_sorter_ui.py new file mode 100644 index 0000000..5e34386 --- /dev/null +++ b/texter/texter/text_sorter_ui.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python +# coding=UTF-8 +# +# Generated by pykdeuic4 from texter4.ui on Wed Apr 16 00:27:54 2014 +# +# WARNING! All changes to this file will be lost. +from PyKDE4 import kdecore +from PyKDE4 import kdeui +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_TextSorterDialog(object): + def setupUi(self, TextSorterDialog): + TextSorterDialog.setObjectName(_fromUtf8("TextSorterDialog")) + TextSorterDialog.resize(662, 716) + self.verticalLayout = QtGui.QVBoxLayout(TextSorterDialog) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.text_list = QtGui.QListView(TextSorterDialog) + self.text_list.setMinimumSize(QtCore.QSize(0, 576)) + self.text_list.setMaximumSize(QtCore.QSize(16777215, 576)) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(128, 125, 123)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + self.text_list.setPalette(palette) + self.text_list.setObjectName(_fromUtf8("text_list")) + self.horizontalLayout_2.addWidget(self.text_list) + self.text_preview = KRichTextWidget(TextSorterDialog) + self.text_preview.setMinimumSize(QtCore.QSize(0, 576)) + self.text_preview.setMaximumSize(QtCore.QSize(16777215, 576)) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + self.text_preview.setPalette(palette) + self.text_preview.setReadOnly(True) + self.text_preview.setObjectName(_fromUtf8("text_preview")) + self.horizontalLayout_2.addWidget(self.text_preview) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.kbuttongroup = KButtonGroup(TextSorterDialog) + self.kbuttongroup.setObjectName(_fromUtf8("kbuttongroup")) + self.horizontalLayout = QtGui.QHBoxLayout(self.kbuttongroup) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.move_down_button = KArrowButton(self.kbuttongroup) + self.move_down_button.setProperty("arrowType", 2) + self.move_down_button.setObjectName(_fromUtf8("move_down_button")) + self.horizontalLayout.addWidget(self.move_down_button) + self.move_up_button = KArrowButton(self.kbuttongroup) + self.move_up_button.setObjectName(_fromUtf8("move_up_button")) + self.horizontalLayout.addWidget(self.move_up_button) + self.remove_button = KPushButton(self.kbuttongroup) + icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-delete")) + self.remove_button.setIcon(icon) + self.remove_button.setObjectName(_fromUtf8("remove_button")) + self.horizontalLayout.addWidget(self.remove_button) + self.verticalLayout.addWidget(self.kbuttongroup) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem) + + self.retranslateUi(TextSorterDialog) + QtCore.QMetaObject.connectSlotsByName(TextSorterDialog) + + def retranslateUi(self, TextSorterDialog): + TextSorterDialog.setWindowTitle(kdecore.i18n(_fromUtf8("Form"))) + self.remove_button.setText(kdecore.i18n(_fromUtf8("Remove"))) + +from PyKDE4.kdeui import KButtonGroup, KArrowButton, KPushButton, KRichTextWidget diff --git a/texter/texter/texter.desktop b/texter/texter/texter.desktop new file mode 100755 index 0000000..774cffc --- /dev/null +++ b/texter/texter/texter.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Comment[de]= +Comment= +Exec=texter +GenericName[de]=Live Text Streaming +GenericName=Live Text Streaming +Icon=texter_icon +MimeType= +Name[de]=texter +Name=texter +Path=/usr/bin/texter +StartupNotify=true +Type=Application +Categories=AudioVideo;Recorder; +X-DBUS-ServiceName= +X-DBUS-StartupType=none +X-KDE-SubstituteUID=false +X-KDE-Username= +Keywords=Capture;Broadcast; diff --git a/texter/texter/texter.qrc b/texter/texter/texter.qrc new file mode 100644 index 0000000..b4b4a29 --- /dev/null +++ b/texter/texter/texter.qrc @@ -0,0 +1,5 @@ + + + icon.png + + diff --git a/texter/texter/texter.ui b/texter/texter/texter.ui new file mode 100644 index 0000000..335ee8d --- /dev/null +++ b/texter/texter/texter.ui @@ -0,0 +1,920 @@ + + + MainWindow + + + + 0 + 0 + 1207 + 634 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + 4.48 Texter + + + + + + + + + &Title + + + item_title + + + + + + + + 100 + 0 + + + + + + + + P&osition + + + item_position_input + + + + + + + + 50 + 16777215 + + + + + + + + S&election + + + edit_item_selection + + + + + + + + 100 + 0 + + + + + + + + &Add / Change + + + + + + + &Remove + + + + + + + Sa&ve + + + + + + + &Publish + + + false + + + + + + + Clear Live + + + + + + + Clear Preview + + + + + + + Previous + + + + + + + Next + + + + + + + + + + A&uto Publish + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 768 + 576 + + + + + 768 + 576 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + + + 128 + 125 + 123 + + + + + + + 128 + 125 + 123 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + + + Monospace + 22 + + + + true + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 400 + 576 + + + + + 768 + 576 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + + + 128 + 125 + 123 + + + + + + + 128 + 125 + 123 + + + + + + + 0 + 0 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + + + Monospace + 22 + + + + Qt::ActionsContextMenu + + + true + + + QFrame::StyledPanel + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + + KRichTextEdit + KTextEdit +
krichtextedit.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+ + KRichTextWidget + KRichTextEdit +
krichtextwidget.h
+
+ + KIntNumInput + QWidget +
knuminput.h
+
+
+ + item_title + item_position_input + remove_item_button + + + +
diff --git a/texter/texter/texter2.ui b/texter/texter/texter2.ui new file mode 100644 index 0000000..c4e8da1 --- /dev/null +++ b/texter/texter/texter2.ui @@ -0,0 +1,395 @@ + + + MainWindow + + + + 0 + 0 + 1554 + 617 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 169 + 167 + 167 + + + + + + + 244 + 244 + 244 + + + + + + + + 4.48 Texter + + + + :/texter/icon.png:/texter/icon.png + + + + + + + + + + 768 + 576 + + + + + 768 + 576 + + + + + Monospace + 22 + + + + BlankCursor + + + + + + + + + + + + false + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + clear live text [F1] + + + + + + + + F1 + + + + + + + save live text [F2] + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + starts/stops live textfield streaming [F9] + + + + + + true + + + + + + + + + + + + + + 400 + 576 + + + + + 768 + 576 + + + + + Monospace + 22 + + + + Qt::ActionsContextMenu + + + preview text + + + false + + + QFrame::StyledPanel + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + clear preview text [F4] + + + + + + + + + + + + + + F2 + + + + + + + + + + + + + + + + ArrowCursor + + + go live with text [F5] + + + + + + + + F4 + + + + + + + Qt::Vertical + + + + + + + load previous text [F6] + + + + + + + + + + + + load next text [F7] + + + + + + + + + + + + + 0 + 0 + + + + true + + + + + + + edit sorting of saved texts [F10] + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + KRichTextEdit + KTextEdit +
krichtextedit.h
+
+ + KComboBox + QComboBox +
kcombobox.h
+
+ + KPushButton + QPushButton +
kpushbutton.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+ + KRichTextWidget + KRichTextEdit +
krichtextwidget.h
+
+
+ + live_text + preview_text + clear_preview_button + clear_live_button + + + + + +
diff --git a/texter/texter/texter3.ui b/texter/texter/texter3.ui new file mode 100644 index 0000000..bb7834f --- /dev/null +++ b/texter/texter/texter3.ui @@ -0,0 +1,409 @@ + + + MainWindow + + + + 0 + 0 + 1475 + 651 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 169 + 167 + 167 + + + + + + + 244 + 244 + 244 + + + + + + + + 4.48 Texter + + + + :/texter/icon.png:/texter/icon.png + + + + + + + + + + 775 + 578 + + + + + 775 + 578 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + + BlankCursor + + + true + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + KRichTextWidget::SupportAlignment|KRichTextWidget::SupportChangeListStyle|KRichTextWidget::SupportFontFamily|KRichTextWidget::SupportFontSize|KRichTextWidget::SupportIndentLists|KRichTextWidget::SupportTextForegroundColor + + + + + + + + 10 + 0 + + + + + 300 + 577 + + + + + 769 + 577 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + Qt::ActionsContextMenu + + + preview text + + + true + + + QFrame::StyledPanel + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + KRichTextWidget::SupportAlignment|KRichTextWidget::SupportChangeListStyle|KRichTextWidget::SupportFontFamily|KRichTextWidget::SupportFontSize|KRichTextWidget::SupportTextForegroundColor + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + KRichTextEdit + KTextEdit +
krichtextedit.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+ + KRichTextWidget + KRichTextEdit +
krichtextwidget.h
+
+
+ + live_text + preview_text + + + + + +
diff --git a/texter/texter/texter4.ui b/texter/texter/texter4.ui new file mode 100644 index 0000000..bf97ac0 --- /dev/null +++ b/texter/texter/texter4.ui @@ -0,0 +1,234 @@ + + + TextSorterDialog + + + + 0 + 0 + 662 + 716 + + + + Form + + + + + + + + + 0 + 576 + + + + + 16777215 + 576 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 128 + 125 + 123 + + + + + + + 255 + 255 + 255 + + + + + + + + + + + + + 0 + 576 + + + + + 16777215 + 576 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + true + + + + + + + + + + + + 2 + + + + + + + + + + Remove + + + + ../../../../../../../../ + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KArrowButton + QPushButton +
karrowbutton.h
+
+ + KRichTextEdit + KTextEdit +
krichtextedit.h
+
+ + KButtonGroup + QGroupBox +
kbuttongroup.h
+ 1 +
+ + KPushButton + QPushButton +
kpushbutton.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+ + KRichTextWidget + KRichTextEdit +
krichtextwidget.h
+
+
+ + +
diff --git a/texter/texter/texter_rc.py b/texter/texter/texter_rc.py new file mode 100644 index 0000000..6f17bd2 --- /dev/null +++ b/texter/texter/texter_rc.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- + +# Resource object code +# +# Created: Sa. Apr 12 08:49:54 2014 +# by: The Resource Compiler for PyQt (Qt v4.8.5) +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore + +qt_resource_data = "\ +\x00\x00\x02\x2c\ +\x89\ +\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ +\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\ +\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\ +\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\ +\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\ +\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\ +\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\xa9\x49\x44\ +\x41\x54\x58\x85\xed\xd5\x4f\x88\xcd\x51\x14\xc0\xf1\xcf\x11\x13\ +\x8a\x86\xb2\x65\x61\xc1\x42\xc9\x8a\x27\x1b\x1b\xb1\xb0\x92\x62\ +\x27\x35\x3b\x59\xd8\x68\x1a\x29\x4b\x89\xa4\x69\xca\x5a\x59\x21\ +\x93\x85\x89\x85\x48\x42\xcd\x42\x16\x4a\x9a\xa2\xc8\x66\x9a\x86\ +\x31\x91\x3f\xc7\xe2\xfd\xde\x73\xc7\xbc\xc9\xcc\x2c\xbc\x59\xfc\ +\x4e\x9d\x7e\x9d\x73\xef\x39\xf7\x7b\xce\x3d\xb7\x5f\x64\xa6\x6e\ +\xca\xb2\xae\x9e\x5e\x03\xd4\x00\x35\x40\x0d\xb0\x24\x01\x22\xa2\ +\x11\x11\x23\x11\xb1\x6f\x31\x09\x23\x62\xa0\x8a\x5f\x5e\xf8\x36\ +\x44\x44\x7f\x44\x3c\x8f\x88\x5b\x11\x71\xa4\x1d\x90\x99\x6d\x45\ +\x0f\x9e\xe1\x33\x8e\x97\x6b\xf3\x51\x34\xf0\x1e\x89\x9e\xc2\x3f\ +\x88\xc7\xd8\x89\x43\x98\x42\x23\x33\x67\x01\x9c\x45\x7f\x95\x64\ +\x41\x00\x58\x81\x51\xf4\x75\x00\x18\xc7\xd1\xc2\xbe\x8d\xa1\xcc\ +\xfc\x73\x05\x11\xb1\x15\x87\x71\x71\x31\xad\xc7\x69\x8c\xe0\x4d\ +\x87\xb5\x51\xec\xaa\xce\x59\x85\xed\x78\xda\xbe\x02\x04\x1e\xe1\ +\x40\x65\x2f\xa8\x03\xd8\x82\xd7\x58\x8d\xbd\x1d\x3a\xb0\x1e\xf7\ +\x30\x86\x4f\x38\x89\xc8\x4c\xad\x41\xe9\xc3\x44\x66\xde\x5d\x68\ +\xd9\x11\x11\xb8\x8a\x81\xcc\x9c\x6e\x9a\xb3\xe4\x14\x7a\x71\x0e\ +\x9b\x70\x02\x2f\xf1\xa0\x45\x38\x86\x9b\xb8\x5c\xe9\x14\xee\xe3\ +\xd8\x3c\xaa\xdf\x8d\x2f\x45\xec\x8d\xaa\x03\x57\xb0\x0d\x6b\xf0\ +\x0d\x7b\x8a\x98\x21\x0c\x97\x1d\x18\xc4\xda\x82\xf8\x17\xa6\xab\ +\xc4\x65\xb5\x1b\xb1\x2e\x33\x5f\x14\xee\x0f\xb8\x50\xd8\xbd\xd5\ +\x77\x12\xdf\xb1\x59\xf3\x75\x4d\x16\x7b\xc6\x35\xaf\xca\x5c\x55\ +\x75\x9c\x01\x5c\xc3\x8f\x7f\x74\x64\xc6\x0c\x60\x25\xde\xe2\x0e\ +\x76\xe0\x20\xde\xe1\xd2\x8c\x57\xf0\x97\x3c\xc1\xc7\x0e\xfe\x57\ +\x78\x38\x47\x4c\x4b\x26\xaa\x3d\x59\x15\xf8\x15\xfb\xf1\x13\xc3\ +\x38\x8f\xeb\x38\x43\x35\x89\xdd\x94\xa5\xf7\x2f\xa8\x01\x6a\x80\ +\x1a\xa0\x06\xf8\xdf\xf2\x1b\xf1\xb2\x57\x16\x4f\x60\xf0\x28\x00\ +\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\ +" + +qt_resource_name = "\ +\x00\x06\ +\x07\xac\xfa\xc2\ +\x00\x74\ +\x00\x65\x00\x78\x00\x74\x00\x65\x00\x72\ +\x00\x08\ +\x0a\x61\x5a\xa7\ +\x00\x69\ +\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\ +" + +qt_resource_struct = "\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ +\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +" + +def qInitResources(): + QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py new file mode 100644 index 0000000..730e3c3 --- /dev/null +++ b/texter/texter/texter_ui.py @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'texter3.ui' +# +# Created: Wed Apr 16 20:48:51 2014 +# by: PyQt4 UI code generator 4.10.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName(_fromUtf8("MainWindow")) + MainWindow.resize(1475, 651) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(169, 167, 167)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(244, 244, 244)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + MainWindow.setPalette(palette) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/texter/icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) + MainWindow.setWindowIcon(icon) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName(_fromUtf8("centralwidget")) + self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.live_text = KRichTextWidget(self.centralwidget) + self.live_text.setMinimumSize(QtCore.QSize(772,580)) + self.live_text.setMaximumSize(QtCore.QSize(772,580)) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Link, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Link, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Link, brush) + self.live_text.setPalette(palette) + self.live_text.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.BlankCursor)) + self.live_text.setAutoFillBackground(True) + self.live_text.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.live_text.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.live_text.setAcceptRichText(True) + self.live_text.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextEditable|QtCore.Qt.TextEditorInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) + self.live_text.setRichTextSupport(KRichTextWidget.RichTextSupportValues(KRichTextWidget.SupportAlignment|KRichTextWidget.SupportChangeListStyle|KRichTextWidget.SupportFontFamily|KRichTextWidget.SupportFontSize|KRichTextWidget.SupportTextForegroundColor)) + self.live_text.setObjectName(_fromUtf8("live_text")) + self.horizontalLayout.addWidget(self.live_text) + self.preview_text = KRichTextWidget(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(10) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.preview_text.sizePolicy().hasHeightForWidth()) + self.preview_text.setSizePolicy(sizePolicy) + self.preview_text.setMinimumSize(QtCore.QSize(300, 577)) + self.preview_text.setMaximumSize(QtCore.QSize(772,580)) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) + self.preview_text.setPalette(palette) + self.preview_text.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.preview_text.setAutoFillBackground(True) + self.preview_text.setFrameShape(QtGui.QFrame.StyledPanel) + self.preview_text.setAcceptRichText(True) + self.preview_text.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextEditable|QtCore.Qt.TextEditorInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) + self.preview_text.setRichTextSupport(KRichTextWidget.RichTextSupportValues(KRichTextWidget.SupportAlignment|KRichTextWidget.SupportChangeListStyle|KRichTextWidget.SupportFontFamily|KRichTextWidget.SupportFontSize|KRichTextWidget.SupportTextForegroundColor)) + self.preview_text.setObjectName(_fromUtf8("preview_text")) + self.horizontalLayout.addWidget(self.preview_text) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.verticalLayout.addLayout(self.horizontalLayout) + spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem1) + MainWindow.setCentralWidget(self.centralwidget) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + MainWindow.setTabOrder(self.live_text, self.preview_text) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(_translate("MainWindow", "4.48 Texter", None)) + self.preview_text.setToolTip(_translate("MainWindow", "preview text", None)) + +from PyKDE4.kdeui import KRichTextWidget +import texter_rc