From 3a12ff7dc5d1b96287eb5abcc276c598ba3601ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Fri, 11 Apr 2014 10:11:13 +0200 Subject: [PATCH 01/16] new smaller design --- texter/main.py | 71 +++- texter/texter.ui | 1010 ++++++++++++++++++++++------------------------ 2 files changed, 542 insertions(+), 539 deletions(-) diff --git a/texter/main.py b/texter/main.py index 5dc8fec..6c0ce10 100644 --- a/texter/main.py +++ b/texter/main.py @@ -17,25 +17,26 @@ class MainWindow(MainWindowBase, MainWindowForm): # setup the ui self.setupUi(self) - self.show_private_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) + #self.show_public_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.current_text = None + self.current_title = None + self.current_index = None + self.is_published = False 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.publish_button.toggled.connect(self.slot_toggle_publish) 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.auto_publish_checkbox.toggled.connect(self.slot_toggle_publish) self.items = dict() self.slot_load() @@ -45,8 +46,10 @@ class MainWindow(MainWindowBase, MainWindowForm): 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" + print "current_title", self.current_title, self.current_text index = (self.item_list.currentRow() + 1) % self.item_list.count() self.item_list.setCurrentRow(index) self.edit_item_selection.setCurrentIndex(index) @@ -55,6 +58,7 @@ class MainWindow(MainWindowBase, MainWindowForm): def slot_previous_item(self): print "slot_previous_item" + print "current_title", self.current_title, self.current_text index = (self.item_list.currentRow() - 1) % self.item_list.count() self.item_list.setCurrentRow(index) self.edit_item_selection.setCurrentIndex(index) @@ -62,6 +66,8 @@ class MainWindow(MainWindowBase, MainWindowForm): self.slot_showLoadItem(index) def slot_toggleToolbox(self, index): + print "slot_toggleToolbox" + print "current_title", self.current_title, self.current_text if index == 0: self.toolBar.setEnabled(True) else: @@ -74,10 +80,30 @@ class MainWindow(MainWindowBase, MainWindowForm): #animation.setEndValue(QRect(250, 250, 100, 30)); #animation.start(); print "slot_publish" - self.show_public_text.setTextOrHtml(self.show_private_text.textOrHtml()) + print "current_title", self.current_title, self.current_text + self.show_public_text.setTextOrHtml(self.current_text) + self.is_published = True + + def slot_toggle_publish(self, state=None): + #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_toggle_publish", state + print "current_title", self.current_title, self.current_text + + if state: + self.slot_publish() + else: + self.slot_clear() def slot_clear(self): + print "slot_clear" + print "current_title", self.current_title, self.current_text + self.show_public_text.clear() + self.is_published = False def slot_removeItem(self): text = self.edit_item_selection.currentText() @@ -85,7 +111,14 @@ class MainWindow(MainWindowBase, MainWindowForm): title = text.split(": ")[1] del self.items[title] self.edit_item_selection.removeItem(index) - self.show_item_selection.removeItem(index) + self.item_list.removeItemWidget(self.item_list.item(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_editLoadItem(self, index): print "slot_editLoadItem", index @@ -99,15 +132,17 @@ class MainWindow(MainWindowBase, MainWindowForm): 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 + print "slot_showLoadItem", global_rect, index + print "current_title", self.current_title, self.current_text item = self.item_list.item(index) + print "item", item if item is None: return - title = item.text() - text, index = self.items[title] - self.show_private_text.setHtml(text) + self.current_title = item.text() + self.current_text, self.current_index = self.items[self.current_title] + print "current_title", self.current_title, self.current_text if self.auto_publish_checkbox.isChecked(): - self.show_public_text.setHtml(text) + self.show_public_text.setHtml(self.current_text) def title_by_index(self, ix): for title, (text, index) in self.items.iteritems(): @@ -169,11 +204,11 @@ class MainWindow(MainWindowBase, MainWindowForm): 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) + self.current_title, self.current_text, self.current_index = data[0] + + self.edit_private_text.setTextOrHtml(self.current_text) + self.item_position_input.setValue(self.current_index) + self.item_title.setText(self.current_title) diff --git a/texter/texter.ui b/texter/texter.ui index 8d700e9..ecaeaf1 100644 --- a/texter/texter.ui +++ b/texter/texter.ui @@ -10,26 +10,13 @@ - 1 + 0 &Edit - - - - - Qt::Vertical - - - - 20 - 40 - - - - + @@ -102,465 +89,17 @@ - - - - - - - - - - 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 + 768 + 576 - 640 - 480 + 768 + 576 @@ -987,17 +526,34 @@ true - - - - - true - true + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Sho&w + + @@ -1022,12 +578,8 @@ &Publish - - - - - - &Clear + + true @@ -1041,19 +593,19 @@ - + - + - 0 - 480 + 768 + 576 - 16777215 - 480 + 768 + 576 @@ -1480,55 +1032,471 @@ true - + + + + true - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + true - - - - - Item - - - item_list - - - - - - - + + + + 0 + 576 + + + + + 16777215 + 576 + + + + + + + + + 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 + + + + + + + + true + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - 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 From 2fb5177a6c459e6d53b1c6a87eb17098d3735868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 12 Apr 2014 09:42:03 +0200 Subject: [PATCH 02/16] new version of texter with icon and optimized ui for live texting --- texter/main.py | 224 ------ texter/texter.ui | 1556 ------------------------------------ texter/texter/__init__.py | 1 + texter/texter/icon.png | Bin 0 -> 556 bytes texter/texter/main.py | 266 ++++++ texter/texter/texter.qrc | 5 + texter/texter/texter2.ui | 641 +++++++++++++++ texter/texter/texter_rc.py | 75 ++ texter/texter/texter_ui.py | 259 ++++++ 9 files changed, 1247 insertions(+), 1780 deletions(-) delete mode 100644 texter/main.py delete mode 100644 texter/texter.ui create mode 100644 texter/texter/__init__.py create mode 100644 texter/texter/icon.png create mode 100644 texter/texter/main.py create mode 100644 texter/texter/texter.qrc create mode 100644 texter/texter/texter2.ui create mode 100644 texter/texter/texter_rc.py create mode 100644 texter/texter/texter_ui.py diff --git a/texter/main.py b/texter/main.py deleted file mode 100644 index 6c0ce10..0000000 --- a/texter/main.py +++ /dev/null @@ -1,224 +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_public_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) - - self.current_text = None - self.current_title = None - self.current_index = None - self.is_published = False - - 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.toggled.connect(self.slot_toggle_publish) - 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.auto_publish_checkbox.toggled.connect(self.slot_toggle_publish) - - 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" - print "current_title", self.current_title, self.current_text - 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" - print "current_title", self.current_title, self.current_text - 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): - print "slot_toggleToolbox" - print "current_title", self.current_title, self.current_text - 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" - print "current_title", self.current_title, self.current_text - self.show_public_text.setTextOrHtml(self.current_text) - self.is_published = True - - def slot_toggle_publish(self, state=None): - #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_toggle_publish", state - print "current_title", self.current_title, self.current_text - - if state: - self.slot_publish() - else: - self.slot_clear() - - def slot_clear(self): - print "slot_clear" - print "current_title", self.current_title, self.current_text - - self.show_public_text.clear() - self.is_published = False - - 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.item_list.removeItemWidget(self.item_list.item(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_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, index - print "current_title", self.current_title, self.current_text - item = self.item_list.item(index) - print "item", item - if item is None: - return - self.current_title = item.text() - self.current_text, self.current_index = self.items[self.current_title] - print "current_title", self.current_title, self.current_text - if self.auto_publish_checkbox.isChecked(): - self.show_public_text.setHtml(self.current_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) - self.current_title, self.current_text, self.current_index = data[0] - - self.edit_private_text.setTextOrHtml(self.current_text) - self.item_position_input.setValue(self.current_index) - self.item_title.setText(self.current_title) - - - -if ( __name__ == '__main__' ): - app = None - if ( not app ): - app = QtGui.QApplication([]) - - window = MainWindow() - window.show() - - if ( app ): - app.exec_() diff --git a/texter/texter.ui b/texter/texter.ui deleted file mode 100644 index ecaeaf1..0000000 --- a/texter/texter.ui +++ /dev/null @@ -1,1556 +0,0 @@ - - - MainWindow - - - 448 Texter - - - - - - - 0 - - - - &Edit - - - - - - - - &Title - - - item_title - - - - - - - - - - P&osition - - - item_position_input - - - - - - - - - - S&election - - - edit_item_selection - - - - - - - - 0 - 0 - - - - - - - - &Add / Change - - - - - - - &Remove - - - - - - - Sa&ve - - - - - - - - - - 768 - 576 - - - - - 768 - 576 - - - - - - - - - 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 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Sho&w - - - - - - - - Next - - - - - - - - - - Previous - - - - - - - &Publish - - - true - - - - - - - A&uto Publish - - - - - - - - - - - - 768 - 576 - - - - - 768 - 576 - - - - - - - - - 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 - - - - - - - - 0 - 576 - - - - - 16777215 - 576 - - - - - - - - - 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 - - - - - - - - true - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - 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/__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/icon.png b/texter/texter/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..fd05fbcf68ec00f16d7e5057c4bb47b4d846480b GIT binary patch literal 556 zcmV+{0@MA8P)`F_AyV;{D!p$GpkREWBC#PMv<8bMHC# zd(J(#Uu33k%CfGWUIWwsH9!rpBmp9#5fLL1v2QU6BVwS6Utah&L_~i?JdcQ55pkp) zkeO{o51!#Oj+blmQ8e%#iJrngh{xE8LzqG%GiL#uMSqoKK>%2RQS@~H7{}4VzKx;G z{Bs2nu@#4LaWSpOX^h}ahqY1cs?J%3?ReV00t6o6KxHqe1K5JsSdG0MIB{ literal 0 HcmV?d00001 diff --git a/texter/texter/main.py b/texter/texter/main.py new file mode 100644 index 0000000..109f3a6 --- /dev/null +++ b/texter/texter/main.py @@ -0,0 +1,266 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import os.path + +import PyQt4.uic +from PyQt4 import QtCore, QtGui +from PyKDE4.kdeui import KActionCollection, KRichTextWidget + +from texter_ui import Ui_MainWindow + + +from operator import itemgetter +import cPickle + +app = QtGui.QApplication([]) + +class MainWindow(QtGui.QMainWindow, Ui_MainWindow): + def __init__(self, parent = None): + super(MainWindow, self).__init__(parent) + + self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint) + + # setup the ui + self.setupUi(self) + self.font = QtGui.QFont("monospace", 22) + self.font.setStyleHint(QtGui.QFont.TypeWriter) + self.preview_text.document().setDefaultFont(self.font) + + self.preview_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) + self.preview_action_collection = KActionCollection(self) + self.preview_text.createActions(self.preview_action_collection) + self.preview_toolbar = QtGui.QToolBar("preview editor toolbar", self) + self.preview_toolbar.setAllowedAreas(QtCore.Qt.BottomToolBarArea) + self.preview_toolbar.setMovable(False) + self.preview_toolbar.setFloatable(False) + #self.addToolBar(QtCore.Qt.BottomToolBarArea, self.preview_toolbar) + for action in self.preview_action_collection.actions(): + self.preview_toolbar.addAction(action) + + self.live_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) + self.live_text.document().setDefaultFont(self.font) + self.live_action_collection = KActionCollection(self) + self.live_text.createActions(self.live_action_collection) + self.live_toolbar = QtGui.QToolBar("live editor toolbar", self) + self.live_toolbar.setAllowedAreas(QtCore.Qt.BottomToolBarArea) + self.live_toolbar.setMovable(False) + self.live_toolbar.setFloatable(False) + #self.addToolBar(QtCore.Qt.RightToolBarArea, self.live_toolbar) + for action in self.live_action_collection.actions(): + self.live_toolbar.addAction(action) + + self.show() + + self.is_published = False + + #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_live_button.clicked.connect(self.slot_clear_live) + self.clear_preview_button.clicked.connect(self.slot_clear_preview) + #self.remove_item_button.clicked.connect(self.slot_removeItem) + #self.edit_item_selection.activated.connect(self.slot_editLoadItem) + #self.auto_publish_checkbox.clicked.connect(self.slot_publish) + app.focusChanged.connect(self.focusChanged) + + + 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) + public_rect = self.live_text.geometry() + global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) + self.statusBar().showMessage("geometry to cast: %d, %d, %d, %d" % (global_rect.x(), global_rect.y(), global_rect.width(), global_rect.height())) + + def focusChanged(self, old, new): + print "focusChanged", old, new + if new == self.preview_text: + try: + self.removeToolBar(self.live_toolbar) + except Exception, e: + print e + try: + self.removeToolBar(self.preview_toolbar) + except Exception, e: + print e + try: + self.addToolBar(QtCore.Qt.BottomToolBarArea, self.preview_toolbar) + self.preview_toolbar.show() + except Exception, e: + print e + elif new == self.live_text: + try: + self.removeToolBar(self.live_toolbar) + except Exception, e: + print e + try: + self.removeToolBar(self.preview_toolbar) + except Exception, e: + print e + try: + self.addToolBar(QtCore.Qt.BottomToolBarArea, self.live_toolbar) + self.live_toolbar.show() + except Exception, e: + print e + + + def slot_next_item(self): + print "slot_next_item" + #print "current_title", self.current_title, self.current_text + #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" + ##print "current_title", self.current_title, self.current_text + #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): + print "slot_toggleToolbox" + #print "current_title", self.current_title, self.current_text + if index == 0: + self.toolBar.setEnabled(True) + else: + self.toolBar.setEnabled(False) + + def slot_publish(self): + print "slot_publish" + public_rect = self.live_text.geometry() + global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) + self.statusBar().showMessage("geometry to cast: %d, %d, %d, %d" % (global_rect.x(), global_rect.y(), global_rect.width(), global_rect.height())) + + self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) + self.is_published = True + + def slot_toggle_publish(self, state=None): + #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_toggle_publish", state + #print "current_title", self.current_title, self.current_text + + if state: + self.slot_publish() + else: + self.slot_clear() + + def slot_clear_live(self): + self.live_text.clear() + self.is_published = False + + def slot_clear_preview(self): + self.preview_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) + 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_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.preview_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())) + self.statusBar().showMessage("geometry to cast: %d, %d, %d, %d" % (global_rect.x(), global_rect.y(), global_rect.width(), global_rect.height())) + item = self.item_list.item(index) + if item is None: + return + title = item.text() + text, index = self.items[title] + if self.auto_publish_checkbox.isChecked(): + self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) + + 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.preview_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)) + + + def slot_addText(self): + print "slot add" + index = self.item_position_input.value() + + 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.preview_text.toHtml() + self.items[title] = (text, index) + self.edit_item_selection.insertItem(index, "%d: %s" % (index, title)) + self.edit_item_selection.setCurrentIndex(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.edit_item_selection.setCurrentIndex(0) + title, text, index = data[0] + + self.preview_text.setTextOrHtml(text) + self.item_position_input.setValue(index) + self.item_title.setText(title) + + +def main(): + window = MainWindow() + app.exec_() + + +if ( __name__ == '__main__' ): + main() 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/texter2.ui b/texter/texter/texter2.ui new file mode 100644 index 0000000..cd81024 --- /dev/null +++ b/texter/texter/texter2.ui @@ -0,0 +1,641 @@ + + + MainWindow + + + + 0 + 0 + 1554 + 636 + + + + + + + + + 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 + + + + :/texter/icon.png:/texter/icon.png + + + + + + + + + + 768 + 576 + + + + + 768 + 576 + + + + + Monospace + 22 + + + + live text + + + + + + + + + false + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + clear live text + + + + + + F1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + 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 + + + status tip2 + + + whatsthis2 + + + + + + F2 + + + + + + + go live with text + + + + + + F4 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + KRichTextEdit + KTextEdit +
krichtextedit.h
+
+ + KPushButton + QPushButton +
kpushbutton.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+ + KRichTextWidget + KRichTextEdit +
krichtextwidget.h
+
+
+ + live_text + preview_text + publish_button + clear_preview_button + clear_live_button + + + + + +
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..1d83afe --- /dev/null +++ b/texter/texter/texter_ui.py @@ -0,0 +1,259 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'texter2.ui' +# +# Created: Sat Apr 12 09:29:22 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(1554, 636) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) + 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(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + 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.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, 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(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + 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.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + 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.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, 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.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, 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.horizontalLayout_3 = QtGui.QHBoxLayout(self.centralwidget) + self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.live_text = KRichTextWidget(self.centralwidget) + self.live_text.setMinimumSize(QtCore.QSize(768, 576)) + self.live_text.setMaximumSize(QtCore.QSize(768, 576)) + font = QtGui.QFont() + font.setFamily(_fromUtf8("Monospace")) + font.setPointSize(22) + self.live_text.setFont(font) + self.live_text.setStatusTip(_fromUtf8("")) + self.live_text.setWhatsThis(_fromUtf8("")) + self.live_text.setAutoFillBackground(False) + 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.setObjectName(_fromUtf8("live_text")) + self.verticalLayout.addWidget(self.live_text) + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.clear_live_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) + self.clear_live_button.setIcon(icon) + self.clear_live_button.setObjectName(_fromUtf8("clear_live_button")) + self.horizontalLayout_2.addWidget(self.clear_live_button) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.horizontalLayout_3.addLayout(self.verticalLayout) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.preview_text = KRichTextWidget(self.centralwidget) + self.preview_text.setMinimumSize(QtCore.QSize(400, 576)) + self.preview_text.setMaximumSize(QtCore.QSize(768, 576)) + font = QtGui.QFont() + font.setFamily(_fromUtf8("Monospace")) + font.setPointSize(22) + self.preview_text.setFont(font) + self.preview_text.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.preview_text.setAutoFillBackground(False) + 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.setObjectName(_fromUtf8("preview_text")) + self.verticalLayout_2.addWidget(self.preview_text) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.clear_preview_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) + self.clear_preview_button.setIcon(icon) + self.clear_preview_button.setObjectName(_fromUtf8("clear_preview_button")) + self.horizontalLayout.addWidget(self.clear_preview_button) + self.publish_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-playback-start")) + self.publish_button.setIcon(icon) + self.publish_button.setObjectName(_fromUtf8("publish_button")) + self.horizontalLayout.addWidget(self.publish_button) + spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem1) + self.verticalLayout_2.addLayout(self.horizontalLayout) + self.horizontalLayout_3.addLayout(self.verticalLayout_2) + MainWindow.setCentralWidget(self.centralwidget) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName(_fromUtf8("statusbar")) + MainWindow.setStatusBar(self.statusbar) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + MainWindow.setTabOrder(self.live_text, self.preview_text) + MainWindow.setTabOrder(self.preview_text, self.publish_button) + MainWindow.setTabOrder(self.publish_button, self.clear_preview_button) + MainWindow.setTabOrder(self.clear_preview_button, self.clear_live_button) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(_translate("MainWindow", "4.48 Texter", None)) + self.live_text.setToolTip(_translate("MainWindow", "live text", "tooltip1")) + self.clear_live_button.setToolTip(_translate("MainWindow", "clear live text", None)) + self.clear_live_button.setShortcut(_translate("MainWindow", "F1", None)) + self.preview_text.setToolTip(_translate("MainWindow", "preview text", None)) + self.clear_preview_button.setToolTip(_translate("MainWindow", "clear preview text", None)) + self.clear_preview_button.setStatusTip(_translate("MainWindow", "status tip2", None)) + self.clear_preview_button.setWhatsThis(_translate("MainWindow", "whatsthis2", None)) + self.clear_preview_button.setShortcut(_translate("MainWindow", "F2", None)) + self.publish_button.setToolTip(_translate("MainWindow", "go live with text", None)) + self.publish_button.setShortcut(_translate("MainWindow", "F4", None)) + +from PyKDE4.kdeui import KPushButton, KRichTextWidget +import texter_rc From 27ff7f53b9ba65ab75b038420d6b71e489d7a6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 12 Apr 2014 09:44:48 +0200 Subject: [PATCH 03/16] ekgplotter better plotting --- ekgplotter/ekgplotter/main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index a870ce4..dc8dfa1 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -136,7 +136,10 @@ class OSCThread(threading.Thread): def run(self): while self.running: - reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) + try: + reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) + except select.error: + pass if reads: osc_input = self.osc_sock.recv(256) osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) @@ -237,11 +240,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 +357,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([]) From 20319d3cda84e138762d412a9706cfe85b8d678d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 12 Apr 2014 09:47:45 +0200 Subject: [PATCH 04/16] added missing setup.py --- texter/setup.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 texter/setup.py diff --git a/texter/setup.py b/texter/setup.py new file mode 100644 index 0000000..9c9f8d9 --- /dev/null +++ b/texter/setup.py @@ -0,0 +1,55 @@ +#!/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=[], + + # 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' +) From 7ac1779ef8f13b26c0d06598458f0a6f8c20eac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 12 Apr 2014 09:52:16 +0200 Subject: [PATCH 05/16] config files for texter --- config_files/4.48 Desktop Grabber.desktop | 19 +++++++++++++++++++ config_files/4.48 Streamer.desktop | 19 +++++++++++++++++++ config_files/ffserver.conf | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100755 config_files/4.48 Desktop Grabber.desktop create mode 100755 config_files/4.48 Streamer.desktop create mode 100644 config_files/ffserver.conf 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..5cc3c48 --- /dev/null +++ b/config_files/ffserver.conf @@ -0,0 +1,19 @@ +Port 8090 +BindAddress 0.0.0.0 +MaxClients 10 +MaxBandwidth 1000000 +CustomLog - + + +file /tmp/webcam.ffm +FileMaxSize 10M +ACL allow 127.0.0.1 + + + +Feed webcam.ffm +Format mjpeg +VideoFrameRate 25 +VideoSize 768x576 +Noaudio + From 41a23990348b175f943e49f75693d674d4a691d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 12 Apr 2014 10:12:57 +0200 Subject: [PATCH 06/16] added desktop entry --- texter/setup.py | 3 +++ texter/texter/texter.desktop | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 texter/texter/texter.desktop diff --git a/texter/setup.py b/texter/setup.py index 9c9f8d9..72c3973 100644 --- a/texter/setup.py +++ b/texter/setup.py @@ -23,6 +23,9 @@ setup( 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, diff --git a/texter/texter/texter.desktop b/texter/texter/texter.desktop new file mode 100755 index 0000000..65c05a9 --- /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= +StartupNotify=true +Terminal=false +TerminalOptions= +Type=Application +X-DBUS-ServiceName= +X-DBUS-StartupType=none +X-KDE-SubstituteUID=false +X-KDE-Username= From d4d4154f92316a17107eec44da2a2c2a884f0269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 12 Apr 2014 20:51:49 +0200 Subject: [PATCH 07/16] new layout --- texter/texter/build.sh | 2 + texter/texter/main.py | 106 +++++--- texter/texter/text_sorter.ui | 96 +++++++ texter/texter/text_sorter_ui.py | 55 ++++ texter/texter/texter2.ui | 438 ++++++-------------------------- texter/texter/texter_ui.py | 169 ++++-------- 6 files changed, 350 insertions(+), 516 deletions(-) create mode 100644 texter/texter/build.sh create mode 100644 texter/texter/text_sorter.ui create mode 100644 texter/texter/text_sorter_ui.py diff --git a/texter/texter/build.sh b/texter/texter/build.sh new file mode 100644 index 0000000..8bd8f91 --- /dev/null +++ b/texter/texter/build.sh @@ -0,0 +1,2 @@ +pyuic4 -o texter_ui.py texter2.ui +pyuic4 -o text_sorter_ui.py text_sorter.ui diff --git a/texter/texter/main.py b/texter/texter/main.py index 109f3a6..0699560 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -8,13 +8,53 @@ from PyQt4 import QtCore, QtGui from PyKDE4.kdeui import KActionCollection, KRichTextWidget from texter_ui import Ui_MainWindow - +from text_sorter_ui import Ui_text_sorter_dialog from operator import itemgetter import cPickle app = QtGui.QApplication([]) + +class TextSorterDialog(QtGui.QDialog, Ui_text_sorter_dialog): + def __init__(self, parent = None): + super(TextSorterDialog, self).__init__(parent) + + # setup the ui + self.setupUi(self) + self.fill_list() + + self.text_list.listView().clicked.connect(self.slot_show_text) + self.accepted.connect(self.slot_saveToDb) + + def fill_list(self): + for preview, text in self.parent().text_db: + self.text_list.insertItem(preview) + + def slot_text_up(self): + pass + + def slot_text_down(self): + pass + + def slot_show_text(self, model_index): + self.text_preview.setTextOrHtml(self.parent().text_db[model_index.row()][1]) + + def slot_saveToDb(self): + data = list() + def findInDb(title): + for preview, text in self.parent().text_db: + if title == preview: + return text + return None + + for i in self.text_list.items(): + text = findInDb(i) + data.append((i, text)) + self.parent().text_db = data + print self.parent().text_db + + class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def __init__(self, parent = None): super(MainWindow, self).__init__(parent) @@ -53,6 +93,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.show() self.is_published = False + self.current = 0 #self.add_button.clicked.connect(self.slot_addText) #self.save_button.clicked.connect(self.slot_save) @@ -63,15 +104,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): #self.edit_item_selection.activated.connect(self.slot_editLoadItem) #self.auto_publish_checkbox.clicked.connect(self.slot_publish) app.focusChanged.connect(self.focusChanged) + self.text_open_button.clicked.connect(self.slot_open_dialog) + self.live_save_button.clicked.connect(self.slot_save_live) + self.preview_save_button.clicked.connect(self.slot_save_preview) - self.items = dict() + self.text_db = list() #self.slot_load() - #self.next_button.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Space)) - #self.next_button.clicked.connect(self.slot_next_item) + 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) + self.previous_button.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Backspace)) + self.previous_button.clicked.connect(self.slot_previous_item) public_rect = self.live_text.geometry() global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) self.statusBar().showMessage("geometry to cast: %d, %d, %d, %d" % (global_rect.x(), global_rect.y(), global_rect.width(), global_rect.height())) @@ -111,20 +155,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def slot_next_item(self): print "slot_next_item" #print "current_title", self.current_title, self.current_text - #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) + self.current = (self.current + 1) % len(self.text_db) + self.preview_text.setTextOrHtml(self.text_db[self.current][1]) + print "current", self.current def slot_previous_item(self): print "slot_previous_item" - ##print "current_title", self.current_title, self.current_text - #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) + #print "current_title", self.current_title, self.current_text + self.current = (self.current - 1) % len(self.text_db) + self.preview_text.setTextOrHtml(self.text_db[self.current][1]) + + print "current", self.current def slot_toggleToolbox(self, index): print "slot_toggleToolbox" @@ -216,24 +257,27 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.item_title.setText(new_title) self.edit_item_selection.setItemText(index, "%d: %s" % (index, new_title)) - - def slot_addText(self): - print "slot add" - index = self.item_position_input.value() - - old_title = self.title_by_index(index) - if old_title is not None: - self.slot_changeItem(old_title) - return - - title = self.item_title.text() + def slot_save_live(self): + print "slot save live text" + text = self.live_text.toHtml() + preview = self.live_text.toPlainText()[:10] + print "represent", preview + self.text_db.append((preview, text)) + + def slot_save_preview(self): + print "slot save live text" text = self.preview_text.toHtml() - self.items[title] = (text, index) - self.edit_item_selection.insertItem(index, "%d: %s" % (index, title)) - self.edit_item_selection.setCurrentIndex(index) + preview = self.preview_text.toPlainText()[:10] + print "represent", preview + self.text_db.append((preview, text)) def slot_save(self): cPickle.dump(self.items, open("448_texter.db", "w"), cPickle.HIGHEST_PROTOCOL) + + def slot_open_dialog(self): + self.dialog = TextSorterDialog(self) + print "modal", self.dialog.isModal() + self.dialog.open() def slot_load(self): try: diff --git a/texter/texter/text_sorter.ui b/texter/texter/text_sorter.ui new file mode 100644 index 0000000..fd34eea --- /dev/null +++ b/texter/texter/text_sorter.ui @@ -0,0 +1,96 @@ + + + text_sorter_dialog + + + + 0 + 0 + 612 + 280 + + + + Dialog + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + KEditListWidget + QWidget +
keditlistwidget.h
+
+ + KRichTextEdit + KTextEdit +
krichtextedit.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..ff3790d --- /dev/null +++ b/texter/texter/text_sorter_ui.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'text_sorter.ui' +# +# Created: Sat Apr 12 14:47:10 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_text_sorter_dialog(object): + def setupUi(self, text_sorter_dialog): + text_sorter_dialog.setObjectName(_fromUtf8("text_sorter_dialog")) + text_sorter_dialog.resize(612, 280) + self.verticalLayout = QtGui.QVBoxLayout(text_sorter_dialog) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.text_list = KEditListWidget(text_sorter_dialog) + self.text_list.setObjectName(_fromUtf8("text_list")) + self.horizontalLayout.addWidget(self.text_list) + self.text_preview = KRichTextWidget(text_sorter_dialog) + self.text_preview.setObjectName(_fromUtf8("text_preview")) + self.horizontalLayout.addWidget(self.text_preview) + self.verticalLayout.addLayout(self.horizontalLayout) + self.buttonBox = QtGui.QDialogButtonBox(text_sorter_dialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.verticalLayout.addWidget(self.buttonBox) + + self.retranslateUi(text_sorter_dialog) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), text_sorter_dialog.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), text_sorter_dialog.reject) + QtCore.QMetaObject.connectSlotsByName(text_sorter_dialog) + + def retranslateUi(self, text_sorter_dialog): + text_sorter_dialog.setWindowTitle(_translate("text_sorter_dialog", "Dialog", None)) + +from PyKDE4.kdeui import KEditListWidget, KRichTextWidget diff --git a/texter/texter/texter2.ui b/texter/texter/texter2.ui index cd81024..b177683 100644 --- a/texter/texter/texter2.ui +++ b/texter/texter/texter2.ui @@ -7,66 +7,12 @@ 0 0 1554 - 636 + 658 - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - @@ -76,70 +22,7 @@ - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - 0 - 0 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - 0 @@ -150,60 +33,6 @@ - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - @@ -213,70 +42,7 @@ - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - 0 - 0 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - 0 @@ -287,138 +53,21 @@ - - - - 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 + 169 + 167 + 167 - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 + 244 + 244 + 244 @@ -484,13 +133,29 @@ clear live text - + + + F1
+ + + + + + + + + + + background + + + @@ -564,7 +229,9 @@ whatsthis2 - + + + F2 @@ -577,13 +244,57 @@ go live with text - + + + F4
+ + + + + + + + + + + + + + + + + + Qt::Vertical + + + + + + + background + + + + + + + + + + + + + + + + + @@ -611,6 +322,11 @@ KTextEdit
krichtextedit.h
+ + KColorButton + QPushButton +
kcolorbutton.h
+
KPushButton QPushButton diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py index 1d83afe..ec9116f 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'texter2.ui' # -# Created: Sat Apr 12 09:29:22 2014 +# Created: Sat Apr 12 14:47:10 2014 # by: PyQt4 UI code generator 4.10.3 # # WARNING! All changes made in this file will be lost! @@ -26,143 +26,26 @@ except AttributeError: class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) - MainWindow.resize(1554, 636) + MainWindow.resize(1554, 658) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) - 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(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + 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.Shadow, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, 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(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) + 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.Shadow, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + 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(255, 255, 255)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush = QtGui.QBrush(QtGui.QColor(244, 244, 244)) 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.Shadow, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) - brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) - brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) MainWindow.setPalette(palette) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/texter/icon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) @@ -194,6 +77,14 @@ class Ui_MainWindow(object): self.clear_live_button.setIcon(icon) self.clear_live_button.setObjectName(_fromUtf8("clear_live_button")) self.horizontalLayout_2.addWidget(self.clear_live_button) + self.live_save_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-save")) + self.live_save_button.setIcon(icon) + self.live_save_button.setObjectName(_fromUtf8("live_save_button")) + self.horizontalLayout_2.addWidget(self.live_save_button) + self.live_color = KColorButton(self.centralwidget) + self.live_color.setObjectName(_fromUtf8("live_color")) + self.horizontalLayout_2.addWidget(self.live_color) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.verticalLayout.addLayout(self.horizontalLayout_2) @@ -226,6 +117,34 @@ class Ui_MainWindow(object): self.publish_button.setIcon(icon) self.publish_button.setObjectName(_fromUtf8("publish_button")) self.horizontalLayout.addWidget(self.publish_button) + self.previous_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-backward")) + self.previous_button.setIcon(icon) + self.previous_button.setObjectName(_fromUtf8("previous_button")) + self.horizontalLayout.addWidget(self.previous_button) + self.next_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-forward")) + self.next_button.setIcon(icon) + self.next_button.setObjectName(_fromUtf8("next_button")) + self.horizontalLayout.addWidget(self.next_button) + self.line = QtGui.QFrame(self.centralwidget) + self.line.setFrameShape(QtGui.QFrame.VLine) + self.line.setFrameShadow(QtGui.QFrame.Sunken) + self.line.setObjectName(_fromUtf8("line")) + self.horizontalLayout.addWidget(self.line) + self.preview_color = KColorButton(self.centralwidget) + self.preview_color.setObjectName(_fromUtf8("preview_color")) + self.horizontalLayout.addWidget(self.preview_color) + self.preview_save_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-save")) + self.preview_save_button.setIcon(icon) + self.preview_save_button.setObjectName(_fromUtf8("preview_save_button")) + self.horizontalLayout.addWidget(self.preview_save_button) + self.text_open_button = KPushButton(self.centralwidget) + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open")) + self.text_open_button.setIcon(icon) + self.text_open_button.setObjectName(_fromUtf8("text_open_button")) + self.horizontalLayout.addWidget(self.text_open_button) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.verticalLayout_2.addLayout(self.horizontalLayout) @@ -247,6 +166,7 @@ class Ui_MainWindow(object): self.live_text.setToolTip(_translate("MainWindow", "live text", "tooltip1")) self.clear_live_button.setToolTip(_translate("MainWindow", "clear live text", None)) self.clear_live_button.setShortcut(_translate("MainWindow", "F1", None)) + self.live_color.setText(_translate("MainWindow", "background", None)) self.preview_text.setToolTip(_translate("MainWindow", "preview text", None)) self.clear_preview_button.setToolTip(_translate("MainWindow", "clear preview text", None)) self.clear_preview_button.setStatusTip(_translate("MainWindow", "status tip2", None)) @@ -254,6 +174,7 @@ class Ui_MainWindow(object): self.clear_preview_button.setShortcut(_translate("MainWindow", "F2", None)) self.publish_button.setToolTip(_translate("MainWindow", "go live with text", None)) self.publish_button.setShortcut(_translate("MainWindow", "F4", None)) + self.preview_color.setText(_translate("MainWindow", "background", None)) -from PyKDE4.kdeui import KPushButton, KRichTextWidget +from PyKDE4.kdeui import KColorButton, KPushButton, KRichTextWidget import texter_rc From 012c90744e20d309c0da8a75d2f9cf0a710bdc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Mon, 14 Apr 2014 12:50:53 +0200 Subject: [PATCH 08/16] new version --- texter/texter/448_texter.db | Bin 0 -> 5412 bytes texter/texter/build.sh | 4 +- texter/texter/main.py | 594 ++++++++++++++------- texter/texter/text_sorter.ui | 6 +- texter/texter/text_sorter_ui.py | 16 +- texter/texter/texter.desktop | 6 +- texter/texter/texter.ui | 920 ++++++++++++++++++++++++++++++++ texter/texter/texter2.ui | 122 +++-- texter/texter/texter3.ui | 203 +++++++ texter/texter/texter_ui.py | 119 +---- 10 files changed, 1651 insertions(+), 339 deletions(-) create mode 100644 texter/texter/448_texter.db create mode 100644 texter/texter/texter.ui create mode 100644 texter/texter/texter3.ui diff --git a/texter/texter/448_texter.db b/texter/texter/448_texter.db new file mode 100644 index 0000000000000000000000000000000000000000..2604dd1d42f9aa2b580e05baec4f45c61e5e765f GIT binary patch literal 5412 zcmeHLL2uJA6z)1;tQ+hCcM}dng4EsC14`2#=q7=*!8STk4rp>yH?fw)j^j2f6A~B7 zzu^~h;5l7NJ5|$!rfn*%qAGTr=X}rK^LwAa=f6Y?FPcwsxg7BodWj-bMUGF2L_X_L zCuX8>+zkbDPJDW-`hpgs{L$)u|3Hu`*6XQ=?b&R(g+rtOtVhQ7&_XaXNrG$lXk|f1stH`B`8;AICr*3*G z@XI9}gK z{`RV&2Vf_T!H{?b5YZV*Jf^4_3*t}<2}#XF5>Y|l3N}m(Z`N!)oUFy$eUx@p4b*`- z%nk{d-?!ES9`e+{dS&<^W?!kbxhd3nJE6?=lvOU3vH{w%6>=F6zoJozk>!9$mxZR{ z!YYZ=3OaAMxKccr=<;btO?1d~mh>$%QfABN&WXvwHaNqAnKk%P6HFW68$rU+%oCXQ zrek`oF*)4l(t6(Ml;8(urcnpH2e!d^Vm8nv5EwD((KIfmgVR12L=qPWu1I9WV9hcZ1xyUru#k%lbdnzb%srx5$jTXb8hKv?V5KiNmW;d;D6C= z`7HKkjaoWE06L$Ow$5xl#=CKv1!fIsn)ouLA*8uWP|hRiS|bUHGZ*T{Y!{myW}O4$ zKr1e2h-jNBE@uwk2H=YokqW9^uB%W-cZQdj_r^rZ?}fQY(dy-2L<;el8&(Ym6a|&WNIBfHW*H*U(gd_fw&-I7zQB?t z&60CEE5%1S)6(tqh{o^x#C%Sl1ibUx#x - + + + KEditListWidget::Remove|KEditListWidget::UpDown + + diff --git a/texter/texter/text_sorter_ui.py b/texter/texter/text_sorter_ui.py index ff3790d..12029ec 100644 --- a/texter/texter/text_sorter_ui.py +++ b/texter/texter/text_sorter_ui.py @@ -1,12 +1,11 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'text_sorter.ui' +#!/usr/bin/env python +# coding=UTF-8 # -# Created: Sat Apr 12 14:47:10 2014 -# by: PyQt4 UI code generator 4.10.3 +# Generated by pykdeuic4 from text_sorter.ui on Mon Apr 14 08:37:13 2014 # -# WARNING! All changes made in this file will be lost! - +# WARNING! All changes to this file will be lost. +from PyKDE4 import kdecore +from PyKDE4 import kdeui from PyQt4 import QtCore, QtGui try: @@ -32,6 +31,7 @@ class Ui_text_sorter_dialog(object): self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.text_list = KEditListWidget(text_sorter_dialog) + self.text_list.setButtons(KEditListWidget.Buttons(KEditListWidget.Remove|KEditListWidget.UpDown)) self.text_list.setObjectName(_fromUtf8("text_list")) self.horizontalLayout.addWidget(self.text_list) self.text_preview = KRichTextWidget(text_sorter_dialog) @@ -50,6 +50,6 @@ class Ui_text_sorter_dialog(object): QtCore.QMetaObject.connectSlotsByName(text_sorter_dialog) def retranslateUi(self, text_sorter_dialog): - text_sorter_dialog.setWindowTitle(_translate("text_sorter_dialog", "Dialog", None)) + text_sorter_dialog.setWindowTitle(kdecore.i18n(_fromUtf8("Dialog"))) from PyKDE4.kdeui import KEditListWidget, KRichTextWidget diff --git a/texter/texter/texter.desktop b/texter/texter/texter.desktop index 65c05a9..774cffc 100755 --- a/texter/texter/texter.desktop +++ b/texter/texter/texter.desktop @@ -8,12 +8,12 @@ Icon=texter_icon MimeType= Name[de]=texter Name=texter -Path= +Path=/usr/bin/texter StartupNotify=true -Terminal=false -TerminalOptions= 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.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 index b177683..c4e8da1 100644 --- a/texter/texter/texter2.ui +++ b/texter/texter/texter2.ui @@ -7,7 +7,7 @@ 0 0 1554 - 658 + 617
@@ -105,14 +105,17 @@ 22 + + BlankCursor + - live text + - + - + false @@ -130,7 +133,7 @@ - clear live text + clear live text [F1] @@ -144,15 +147,13 @@ - - + + save live text [F2] - - - - - - background + + + + @@ -169,6 +170,19 @@
+ + + + starts/stops live textfield streaming [F9] + + + + + + true + + + @@ -220,13 +234,13 @@ - clear preview text + clear preview text [F4] - status tip2 + - whatsthis2 + @@ -238,10 +252,22 @@ + + + + + + + + + + + ArrowCursor + - go live with text + go live with text [F5] @@ -253,20 +279,6 @@ - - - - - - - - - - - - - - @@ -275,23 +287,51 @@ - - - background + + + load previous text [F6] + + + + + - + + + load next text [F7] + - + + + + + + + + + + + 0 + 0 + + + + true + + edit sorting of saved texts [F10] + - + + + @@ -314,7 +354,6 @@ - @@ -323,9 +362,9 @@
krichtextedit.h
- KColorButton - QPushButton -
kcolorbutton.h
+ KComboBox + QComboBox +
kcombobox.h
KPushButton @@ -346,7 +385,6 @@ live_text preview_text - publish_button clear_preview_button clear_live_button diff --git a/texter/texter/texter3.ui b/texter/texter/texter3.ui new file mode 100644 index 0000000..a85a248 --- /dev/null +++ b/texter/texter/texter3.ui @@ -0,0 +1,203 @@ + + + MainWindow + + + + 0 + 0 + 1554 + 584 + + + + + + + + + 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 + + + KRichTextWidget::SupportAlignment|KRichTextWidget::SupportChangeListStyle|KRichTextWidget::SupportFontFamily|KRichTextWidget::SupportFontSize|KRichTextWidget::SupportIndentLists|KRichTextWidget::SupportTextForegroundColor + + + + + + + + 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 + + + KRichTextWidget::SupportAlignment|KRichTextWidget::SupportChangeListStyle|KRichTextWidget::SupportFontFamily|KRichTextWidget::SupportFontSize|KRichTextWidget::SupportTextForegroundColor + + + + + + + + + KRichTextEdit + KTextEdit +
krichtextedit.h
+
+ + KTextEdit + QTextEdit +
ktextedit.h
+
+ + KRichTextWidget + KRichTextEdit +
krichtextwidget.h
+
+
+ + live_text + preview_text + + + + + +
diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py index ec9116f..b4d1db0 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -1,12 +1,11 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'texter2.ui' +#!/usr/bin/env python +# coding=UTF-8 # -# Created: Sat Apr 12 14:47:10 2014 -# by: PyQt4 UI code generator 4.10.3 +# Generated by pykdeuic4 from texter3.ui on Mon Apr 14 08:37:12 2014 # -# WARNING! All changes made in this file will be lost! - +# WARNING! All changes to this file will be lost. +from PyKDE4 import kdecore +from PyKDE4 import kdeui from PyQt4 import QtCore, QtGui try: @@ -26,7 +25,7 @@ except AttributeError: class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) - MainWindow.resize(1554, 658) + MainWindow.resize(1554, 584) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) @@ -52,10 +51,8 @@ class Ui_MainWindow(object): MainWindow.setWindowIcon(icon) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) - self.horizontalLayout_3 = QtGui.QHBoxLayout(self.centralwidget) - self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.live_text = KRichTextWidget(self.centralwidget) self.live_text.setMinimumSize(QtCore.QSize(768, 576)) self.live_text.setMaximumSize(QtCore.QSize(768, 576)) @@ -63,34 +60,16 @@ class Ui_MainWindow(object): font.setFamily(_fromUtf8("Monospace")) font.setPointSize(22) self.live_text.setFont(font) + self.live_text.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.BlankCursor)) + self.live_text.setToolTip(_fromUtf8("")) self.live_text.setStatusTip(_fromUtf8("")) self.live_text.setWhatsThis(_fromUtf8("")) self.live_text.setAutoFillBackground(False) 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.SupportIndentLists|KRichTextWidget.SupportTextForegroundColor)) self.live_text.setObjectName(_fromUtf8("live_text")) - self.verticalLayout.addWidget(self.live_text) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) - self.clear_live_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) - self.clear_live_button.setIcon(icon) - self.clear_live_button.setObjectName(_fromUtf8("clear_live_button")) - self.horizontalLayout_2.addWidget(self.clear_live_button) - self.live_save_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("document-save")) - self.live_save_button.setIcon(icon) - self.live_save_button.setObjectName(_fromUtf8("live_save_button")) - self.horizontalLayout_2.addWidget(self.live_save_button) - self.live_color = KColorButton(self.centralwidget) - self.live_color.setObjectName(_fromUtf8("live_color")) - self.horizontalLayout_2.addWidget(self.live_color) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem) - self.verticalLayout.addLayout(self.horizontalLayout_2) - self.horizontalLayout_3.addLayout(self.verticalLayout) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.horizontalLayout.addWidget(self.live_text) self.preview_text = KRichTextWidget(self.centralwidget) self.preview_text.setMinimumSize(QtCore.QSize(400, 576)) self.preview_text.setMaximumSize(QtCore.QSize(768, 576)) @@ -103,78 +82,18 @@ class Ui_MainWindow(object): 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.verticalLayout_2.addWidget(self.preview_text) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.clear_preview_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) - self.clear_preview_button.setIcon(icon) - self.clear_preview_button.setObjectName(_fromUtf8("clear_preview_button")) - self.horizontalLayout.addWidget(self.clear_preview_button) - self.publish_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("media-playback-start")) - self.publish_button.setIcon(icon) - self.publish_button.setObjectName(_fromUtf8("publish_button")) - self.horizontalLayout.addWidget(self.publish_button) - self.previous_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-backward")) - self.previous_button.setIcon(icon) - self.previous_button.setObjectName(_fromUtf8("previous_button")) - self.horizontalLayout.addWidget(self.previous_button) - self.next_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-forward")) - self.next_button.setIcon(icon) - self.next_button.setObjectName(_fromUtf8("next_button")) - self.horizontalLayout.addWidget(self.next_button) - self.line = QtGui.QFrame(self.centralwidget) - self.line.setFrameShape(QtGui.QFrame.VLine) - self.line.setFrameShadow(QtGui.QFrame.Sunken) - self.line.setObjectName(_fromUtf8("line")) - self.horizontalLayout.addWidget(self.line) - self.preview_color = KColorButton(self.centralwidget) - self.preview_color.setObjectName(_fromUtf8("preview_color")) - self.horizontalLayout.addWidget(self.preview_color) - self.preview_save_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("document-save")) - self.preview_save_button.setIcon(icon) - self.preview_save_button.setObjectName(_fromUtf8("preview_save_button")) - self.horizontalLayout.addWidget(self.preview_save_button) - self.text_open_button = KPushButton(self.centralwidget) - icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open")) - self.text_open_button.setIcon(icon) - self.text_open_button.setObjectName(_fromUtf8("text_open_button")) - self.horizontalLayout.addWidget(self.text_open_button) - spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem1) - self.verticalLayout_2.addLayout(self.horizontalLayout) - self.horizontalLayout_3.addLayout(self.verticalLayout_2) + self.horizontalLayout.addWidget(self.preview_text) MainWindow.setCentralWidget(self.centralwidget) - self.statusbar = QtGui.QStatusBar(MainWindow) - self.statusbar.setObjectName(_fromUtf8("statusbar")) - MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) MainWindow.setTabOrder(self.live_text, self.preview_text) - MainWindow.setTabOrder(self.preview_text, self.publish_button) - MainWindow.setTabOrder(self.publish_button, self.clear_preview_button) - MainWindow.setTabOrder(self.clear_preview_button, self.clear_live_button) def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(_translate("MainWindow", "4.48 Texter", None)) - self.live_text.setToolTip(_translate("MainWindow", "live text", "tooltip1")) - self.clear_live_button.setToolTip(_translate("MainWindow", "clear live text", None)) - self.clear_live_button.setShortcut(_translate("MainWindow", "F1", None)) - self.live_color.setText(_translate("MainWindow", "background", None)) - self.preview_text.setToolTip(_translate("MainWindow", "preview text", None)) - self.clear_preview_button.setToolTip(_translate("MainWindow", "clear preview text", None)) - self.clear_preview_button.setStatusTip(_translate("MainWindow", "status tip2", None)) - self.clear_preview_button.setWhatsThis(_translate("MainWindow", "whatsthis2", None)) - self.clear_preview_button.setShortcut(_translate("MainWindow", "F2", None)) - self.publish_button.setToolTip(_translate("MainWindow", "go live with text", None)) - self.publish_button.setShortcut(_translate("MainWindow", "F4", None)) - self.preview_color.setText(_translate("MainWindow", "background", None)) + MainWindow.setWindowTitle(kdecore.i18n(_fromUtf8("4.48 Texter"))) + self.preview_text.setToolTip(kdecore.i18n(_fromUtf8("preview text"))) -from PyKDE4.kdeui import KColorButton, KPushButton, KRichTextWidget -import texter_rc +from PyKDE4.kdeui import KRichTextWidget +import texter From 80b31ecaf23e859ef9505fbd1e02e92478e603a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Tue, 15 Apr 2014 09:18:28 +0200 Subject: [PATCH 09/16] fixed font size issue --- texter/texter/main.py | 82 +++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/texter/texter/main.py b/texter/texter/main.py index 5011cd6..19e7478 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -67,7 +67,6 @@ class TextSorterDialog(QtGui.QDialog, Ui_text_sorter_dialog): parent = self.parent() for preview in self.text_list.items(): pre, text = parent.text_by_preview(preview) - print "pre, text", pre, preview data.append((preview, text)) parent.text_combo.addAction(preview) parent.text_combo.setCurrentItem(0) @@ -90,19 +89,17 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_font_action = None self.live_font_action = None self.preview_size_action = None - self.default_size = 28 - self.default_font = None + self.default_size = 48 self.default_align_text = "format_align_center" self.preview_actions = list() self.live_actions = list() - self.is_published = False self.current = 0 self.text_db = list() self.is_auto_publish = False self.setupUi(self) - self.font = QtGui.QFont("monospace", 22) + self.font = QtGui.QFont("monospace", self.default_size) self.font.setStyleHint(QtGui.QFont.TypeWriter) self.toolbar = KToolBar(self, True, True) @@ -115,12 +112,14 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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() @@ -131,6 +130,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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) @@ -209,11 +209,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_font_action = action - print "live_center_action", self.live_center_action - print "live_size_action", self.live_size_action - print "preview_center_action", self.preview_center_action - print "preview_size_action", self.preview_size_action - #print "widgets", self.preview_font_action.associatedGraphicsWidgets() self.slot_set_preview_defaults() self.slot_set_live_defaults() @@ -316,9 +311,15 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.streaming_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_1)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) self.live_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)) + + def slot_auto_publish(self, state): - print "auto_publish", state self.is_auto_publish = bool(state) @@ -386,14 +387,12 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_previous_item(self): - #print "current_title", self.current_title, self.current_text self.current = (self.text_combo.currentItem() - 1) % len(self.text_db) self.text_combo.setCurrentItem(self.current) self.slot_load_preview_text(self.current) def slot_toggleToolbox(self, index): - #print "current_title", self.current_title, self.current_text if index == 0: self.toolBar.setEnabled(True) else: @@ -402,7 +401,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_publish(self): self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) - self.is_published = True def slot_toggle_publish(self, state=None): @@ -416,31 +414,37 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_set_preview_defaults(self): self.preview_center_action.setChecked(True) self.preview_text.alignCenter() - self.preview_size_action.setFontSize(self.default_size) - #self.preview_size_action.fontSizeChanged.emit(self.default_size) + self.font.setPointSize(self.default_size) + self.preview_text.setFont(self.font) self.preview_text.setFontSize(self.default_size) + 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.live_size_action.setFontSize(self.default_size) + self.font.setPointSize(self.default_size) + self.live_text.setFont(self.font) self.live_text.setFontSize(self.default_size) + self.live_size_action.setFontSize(self.default_size) + self.live_text.document().setDefaultFont(self.font) def slot_clear_live(self): - self.default_size = self.live_size_action.fontSize() - self.is_published = False - cursor = self.live_text.textCursor() - self.custom_clear(cursor) + #self.default_size = self.live_size_action.fontSize() + #cursor = self.live_text.textCursor() + #self.custom_clear(cursor) + self.live_text.clear() self.slot_set_live_defaults() def slot_clear_preview(self): #self.preview_text.document().clear() - self.default_size = self.preview_size_action.fontSize() - cursor = self.preview_text.textCursor() - self.custom_clear(cursor) + #self.default_size = self.preview_size_action.fontSize() + #cursor = self.preview_text.textCursor() + #self.custom_clear(cursor) + self.preview_text.clear() self.slot_set_preview_defaults() @@ -508,15 +512,41 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.text_combo.setCurrentAction(action) def slot_save(self): - cPickle.dump(self.text_db, open("448_texter.db", "w"), cPickle.HIGHEST_PROTOCOL) + 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.text_db, f, cPickle.HIGHEST_PROTOCOL) + + def slot_valign(self): + fn = 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)) def slot_open_dialog(self): self.dialog = TextSorterDialog(self) self.dialog.open() def slot_load(self): + path = os.path.expanduser("~/.texter") + if not os.path.isdir(path): + os.mkdir(path) try: - self.text_db = cPickle.load(open("448_texter.db")) + f = open(os.path.join(path, "texter.db")) + except IOError: + return + + try: + self.text_db = cPickle.load(f) except Exception, e: print e From ae53e8e3ef24525055889779bf273738183516c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Tue, 15 Apr 2014 18:08:00 +0200 Subject: [PATCH 10/16] implemented real model/view interface --- texter/texter/build.sh | 4 +- texter/texter/main.py | 114 ++++++++++++++++------------- texter/texter/text_sorter.ui | 85 +++++++++++++++++---- texter/texter/text_sorter_ui.py | 61 ++++++++++------ texter/texter/texter4.ui | 126 ++++++++++++++++++++++++++++++++ texter/texter/texter_ui.py | 4 +- 6 files changed, 302 insertions(+), 92 deletions(-) create mode 100644 texter/texter/texter4.ui diff --git a/texter/texter/build.sh b/texter/texter/build.sh index 6e82d76..2239a83 100644 --- a/texter/texter/build.sh +++ b/texter/texter/build.sh @@ -1,2 +1,2 @@ -pykdeuic4-python2.7 -o texter_ui.py texter3.ui -pykdeuic4-python2.7 -o text_sorter_ui.py text_sorter.ui +# pykdeuic4-python2.7 -o texter_ui.py texter3.ui +pykdeuic4-python2.7 -o text_sorter_ui.py texter4.ui diff --git a/texter/texter/main.py b/texter/texter/main.py index 19e7478..c24ed78 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -12,10 +12,11 @@ from operator import itemgetter from PyQt4 import QtCore, QtGui from PyKDE4.kdecore import ki18n, KCmdLineArgs, KAboutData -from PyKDE4.kdeui import KActionCollection, KRichTextWidget, KComboBox, KPushButton, KRichTextWidget, KMainWindow, KToolBar, KApplication, KAction, KToolBarSpacerAction, KSelectAction, KToggleAction, KShortcut +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_text_sorter_dialog +from text_sorter_ui import Ui_TextSorterDialog +from text_model import TextModel appName = "texter" catalog = "448texter" @@ -36,21 +37,24 @@ for path in QtGui.QIcon.themeSearchPaths(): # in your local icon directory: # ln -s /your/icon/theme/directory $HOME/.icons/hicolor -class TextSorterDialog(QtGui.QDialog, Ui_text_sorter_dialog): +class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog): def __init__(self, parent = None): super(TextSorterDialog, self).__init__(parent) - # setup the ui + ## setup the ui self.setupUi(self) - self.setModal(False) + #self.setModal(False) self.fill_list() - self.text_list.listView().clicked.connect(self.slot_show_text) - self.accepted.connect(self.slot_saveToDb) + self.text_list.clicked.connect(self.slot_show_text) + #self.accepted.connect(self.slot_saveToDb) + self.remove_button.clicked.connect(self.slot_removeItem) def fill_list(self): - for preview, text in self.parent().text_db: - self.text_list.insertItem(preview) + self.model = self.parent().parent().model + self.text_list.setModel(self.model) + #for preview, text in self.parent().text_db: + #self.text_list.insertItem(preview) def slot_text_up(self): pass @@ -59,21 +63,19 @@ class TextSorterDialog(QtGui.QDialog, Ui_text_sorter_dialog): pass def slot_show_text(self, model_index): - self.text_preview.setTextOrHtml(self.parent().text_db[model_index.row()][1]) + self.text_preview.setTextOrHtml(self.parent().parent().model.text_db[model_index.row()][1]) def slot_saveToDb(self): data = list() - self.parent().text_combo.clear() - parent = self.parent() - for preview in self.text_list.items(): - pre, text = parent.text_by_preview(preview) - data.append((preview, text)) - parent.text_combo.addAction(preview) - parent.text_combo.setCurrentItem(0) - parent.text_db = data - parent.slot_load_preview_text(0) - parent.slot_set_live_defaults() - parent.slot_set_preview_defaults() + pass + + + def slot_removeItem(self): + index = self.text_list.currentIndex().row() + print "remote index", index + self.model.removeRows(index, 1) + + class MainWindow(KMainWindow, Ui_MainWindow): @@ -94,7 +96,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_actions = list() self.live_actions = list() self.current = 0 - self.text_db = list() + self.model = TextModel(self) + self.is_auto_publish = False self.setupUi(self) @@ -107,8 +110,10 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.toolbar.setMovable(False) self.toolbar.setFloatable(False) self.addToolBar(QtCore.Qt.BottomToolBarArea, self.toolbar) + self.createLiveActions() self.createPreviewActions() + self.slot_load() self.preview_text.document().setDefaultFont(self.font) @@ -144,7 +149,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.streaming_action.triggered.connect(self.slot_toggle_streaming) self.auto_publish_action.toggled.connect(self.slot_auto_publish) - self.slot_load() + self.next_action.triggered.connect(self.slot_next_item) self.previous_action.triggered.connect(self.slot_previous_item) @@ -363,14 +368,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): def get_preview_text(self, text): - return re.sub(" +", " ", text.replace("\n", " "))[:20] - - - def text_by_preview(self, preview): - for title, text in self.text_db: - if title == preview: - return title, text - return None + return re.sub(" +", " ", text.replace("\n", " ")).strip()[:20] def title_by_index(self, ix): @@ -381,13 +379,13 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_next_item(self): - self.current = (self.text_combo.currentItem() + 1) % len(self.text_db) + 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.text_db) + 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) @@ -447,6 +445,15 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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() @@ -461,8 +468,12 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.item_title.clear() self.item_position_input.setValue(0) + def slot_load_preview_text(self, index): - preview, text = self.text_db[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) @@ -473,19 +484,20 @@ class MainWindow(KMainWindow, Ui_MainWindow): preview = self.get_preview_text(unicode(self.live_text.toPlainText())) if not preview: return - old_item = self.text_by_preview(preview) + 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.text_by_preview(tmp_preview) + tmp = self.model.text_by_preview(tmp_preview) if tmp is None: preview = tmp_preview break else: suffix += 1 - self.text_db.append((preview, text)) + self.model.text_db.append([preview, text]) + self.model.modelReset.emit() action = self.text_combo.addAction(preview) self.text_combo.setCurrentAction(action) @@ -495,7 +507,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): if not preview: return - old_item = self.text_by_preview(preview) + old_item = self.model.text_by_preview(preview) if old_item is not None: suffix = 1 while 1: @@ -507,9 +519,10 @@ class MainWindow(KMainWindow, Ui_MainWindow): else: suffix += 1 - self.text_db.append((preview, text)) - action = self.text_combo.addAction(preview) - self.text_combo.setCurrentAction(action) + 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") @@ -520,7 +533,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): except IOError: return else: - cPickle.dump(self.text_db, f, cPickle.HIGHEST_PROTOCOL) + cPickle.dump(self.model.text_db, f, cPickle.HIGHEST_PROTOCOL) def slot_valign(self): fn = QtGui.QFontMetrics(self.font) @@ -533,8 +546,12 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.statusBar().showMessage("text lines = %d, line height = %d, max lines = %d" % (lines, h, max_lines)) def slot_open_dialog(self): - self.dialog = TextSorterDialog(self) - self.dialog.open() + self.dialog = KDialog(self) + self.dialog_widget = TextSorterDialog(self.dialog) + self.dialog.setMainWidget(self.dialog_widget) + self.dialog.move(800, 0) + self.dialog.exec_() + self.fill_combo_box() def slot_load(self): path = os.path.expanduser("~/.texter") @@ -546,17 +563,14 @@ class MainWindow(KMainWindow, Ui_MainWindow): return try: - self.text_db = cPickle.load(f) + self.model.text_db = [list(i) for i in cPickle.load(f)] except Exception, e: print e - data = list() - for title, text in self.text_db: - data.append((title, text)) - self.text_combo.addAction(title) - + self.fill_combo_box() self.text_combo.setCurrentItem(0) self.slot_load_preview_text(0) + self.slot_load_preview_text(0) def main(): diff --git a/texter/texter/text_sorter.ui b/texter/texter/text_sorter.ui index 02e6b16..e5c8389 100644 --- a/texter/texter/text_sorter.ui +++ b/texter/texter/text_sorter.ui @@ -2,25 +2,71 @@ text_sorter_dialog - - - 0 - 0 - 612 - 280 - + + + 0 + 0 + Dialog - + - - - KEditListWidget::Remove|KEditListWidget::UpDown + + + + 0 + 576 + + + + 16777215 + 576 + + + + + + + + + + + Remove + + + + + + + + + + + + + 2 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -42,15 +88,26 @@ - KEditListWidget - QWidget -
keditlistwidget.h
+ KArrowButton + QPushButton +
karrowbutton.h
KRichTextEdit KTextEdit
krichtextedit.h
+ + KButtonGroup + QGroupBox +
kbuttongroup.h
+ 1 +
+ + KPushButton + QPushButton +
kpushbutton.h
+
KTextEdit QTextEdit diff --git a/texter/texter/text_sorter_ui.py b/texter/texter/text_sorter_ui.py index 12029ec..3e67e8e 100644 --- a/texter/texter/text_sorter_ui.py +++ b/texter/texter/text_sorter_ui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding=UTF-8 # -# Generated by pykdeuic4 from text_sorter.ui on Mon Apr 14 08:37:13 2014 +# Generated by pykdeuic4 from texter4.ui on Tue Apr 15 17:09:47 2014 # # WARNING! All changes to this file will be lost. from PyKDE4 import kdecore @@ -22,34 +22,47 @@ except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) -class Ui_text_sorter_dialog(object): - def setupUi(self, text_sorter_dialog): - text_sorter_dialog.setObjectName(_fromUtf8("text_sorter_dialog")) - text_sorter_dialog.resize(612, 280) - self.verticalLayout = QtGui.QVBoxLayout(text_sorter_dialog) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.horizontalLayout = QtGui.QHBoxLayout() +class Ui_TextSorterDialog(object): + def setupUi(self, TextSorterDialog): + TextSorterDialog.setObjectName(_fromUtf8("TextSorterDialog")) + TextSorterDialog.resize(588, 584) + self.horizontalLayout = QtGui.QHBoxLayout(TextSorterDialog) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.text_list = KEditListWidget(text_sorter_dialog) - self.text_list.setButtons(KEditListWidget.Buttons(KEditListWidget.Remove|KEditListWidget.UpDown)) + self.text_list = QtGui.QListView(TextSorterDialog) + self.text_list.setMinimumSize(QtCore.QSize(0, 576)) + self.text_list.setMaximumSize(QtCore.QSize(16777215, 576)) self.text_list.setObjectName(_fromUtf8("text_list")) self.horizontalLayout.addWidget(self.text_list) - self.text_preview = KRichTextWidget(text_sorter_dialog) + self.kbuttongroup = KButtonGroup(TextSorterDialog) + self.kbuttongroup.setObjectName(_fromUtf8("kbuttongroup")) + self.verticalLayout = QtGui.QVBoxLayout(self.kbuttongroup) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + 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.verticalLayout.addWidget(self.remove_button) + self.move_up_button = KArrowButton(self.kbuttongroup) + self.move_up_button.setObjectName(_fromUtf8("move_up_button")) + self.verticalLayout.addWidget(self.move_up_button) + self.move_down_button = KArrowButton(self.kbuttongroup) + self.move_down_button.setProperty("arrowType", 2) + self.move_down_button.setObjectName(_fromUtf8("move_down_button")) + self.verticalLayout.addWidget(self.move_down_button) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem) + self.horizontalLayout.addWidget(self.kbuttongroup) + self.text_preview = KRichTextWidget(TextSorterDialog) + self.text_preview.setMinimumSize(QtCore.QSize(0, 576)) + self.text_preview.setMaximumSize(QtCore.QSize(16777215, 576)) self.text_preview.setObjectName(_fromUtf8("text_preview")) self.horizontalLayout.addWidget(self.text_preview) - self.verticalLayout.addLayout(self.horizontalLayout) - self.buttonBox = QtGui.QDialogButtonBox(text_sorter_dialog) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName(_fromUtf8("buttonBox")) - self.verticalLayout.addWidget(self.buttonBox) - self.retranslateUi(text_sorter_dialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), text_sorter_dialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), text_sorter_dialog.reject) - QtCore.QMetaObject.connectSlotsByName(text_sorter_dialog) + self.retranslateUi(TextSorterDialog) + QtCore.QMetaObject.connectSlotsByName(TextSorterDialog) - def retranslateUi(self, text_sorter_dialog): - text_sorter_dialog.setWindowTitle(kdecore.i18n(_fromUtf8("Dialog"))) + def retranslateUi(self, TextSorterDialog): + TextSorterDialog.setWindowTitle(kdecore.i18n(_fromUtf8("Form"))) + self.remove_button.setText(kdecore.i18n(_fromUtf8("Remove"))) -from PyKDE4.kdeui import KEditListWidget, KRichTextWidget +from PyKDE4.kdeui import KButtonGroup, KArrowButton, KPushButton, KRichTextWidget diff --git a/texter/texter/texter4.ui b/texter/texter/texter4.ui new file mode 100644 index 0000000..a2b8a82 --- /dev/null +++ b/texter/texter/texter4.ui @@ -0,0 +1,126 @@ + + + TextSorterDialog + + + + 0 + 0 + 588 + 584 + + + + Form + + + + + + + 0 + 576 + + + + + 16777215 + 576 + + + + + + + + + + + Remove + + + + ../../../../../../../../ + + + + + + + + + + 2 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 0 + 576 + + + + + 16777215 + 576 + + + + + + + + + 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_ui.py b/texter/texter/texter_ui.py index b4d1db0..b60c6a7 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding=UTF-8 # -# Generated by pykdeuic4 from texter3.ui on Mon Apr 14 08:37:12 2014 +# Generated by pykdeuic4 from texter3.ui on Tue Apr 15 16:21:39 2014 # # WARNING! All changes to this file will be lost. from PyKDE4 import kdecore @@ -67,7 +67,7 @@ class Ui_MainWindow(object): self.live_text.setAutoFillBackground(False) 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.SupportIndentLists|KRichTextWidget.SupportTextForegroundColor)) + 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) From 155b2ececd11538549b9ee72550d3531948e1a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Tue, 15 Apr 2014 18:51:50 +0200 Subject: [PATCH 11/16] added model --- texter/texter/text_model.py | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 texter/texter/text_model.py diff --git a/texter/texter/text_model.py b/texter/texter/text_model.py new file mode 100644 index 0000000..c58c3ed --- /dev/null +++ b/texter/texter/text_model.py @@ -0,0 +1,78 @@ +#!/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 + + 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 + From e78c7f41a053c8cc7f7cdc6b17662805d539c70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 16 Apr 2014 02:23:36 +0200 Subject: [PATCH 12/16] up and down feature, editor and text selection popup will not disturb the live text anymore, better layout --- TODO | 6 +- config_files/ffserver.conf | 10 +- texter/texter/main.py | 203 +++++++++++++++++-------- texter/texter/text_model.py | 5 +- texter/texter/text_sorter_ui.py | 77 +++++++--- texter/texter/texter3.ui | 252 +++++++++++++++++++++----------- texter/texter/texter4.ui | 212 ++++++++++++++++++++------- texter/texter/texter_ui.py | 57 +++++--- 8 files changed, 580 insertions(+), 242 deletions(-) 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/ffserver.conf b/config_files/ffserver.conf index 5cc3c48..84410fb 100644 --- a/config_files/ffserver.conf +++ b/config_files/ffserver.conf @@ -2,16 +2,16 @@ Port 8090 BindAddress 0.0.0.0 MaxClients 10 MaxBandwidth 1000000 -CustomLog - +CustomLog /tmp/ffserver.log - -file /tmp/webcam.ffm + +file /tmp/textcast.ffm FileMaxSize 10M ACL allow 127.0.0.1 - -Feed webcam.ffm + +Feed textcast.ffm Format mjpeg VideoFrameRate 25 VideoSize 768x576 diff --git a/texter/texter/main.py b/texter/texter/main.py index c24ed78..4b9411f 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -6,6 +6,7 @@ import os.path import re import subprocess import sys +from math import pow from operator import itemgetter @@ -41,41 +42,68 @@ class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog): def __init__(self, parent = None): super(TextSorterDialog, self).__init__(parent) - ## setup the ui self.setupUi(self) - #self.setModal(False) self.fill_list() self.text_list.clicked.connect(self.slot_show_text) - #self.accepted.connect(self.slot_saveToDb) 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) - #for preview, text in self.parent().text_db: - #self.text_list.insertItem(preview) def slot_text_up(self): - pass + 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): - pass + 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_saveToDb(self): - data = list() - pass - 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): @@ -109,13 +137,13 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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)) @@ -133,9 +161,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.show() - self.save_action.triggered.connect(self.slot_save) - self.valign_action.triggered.connect(self.slot_valign) + #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) @@ -148,13 +175,15 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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): @@ -164,6 +193,11 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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): @@ -173,7 +207,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): "direction_ltr", "direction_rtl", "format_font_family", - "format_font_size", + #"format_font_size", "format_text_background_color", "format_list_indent_more", "format_list_indent_less", @@ -213,7 +247,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): elif text == "format_font_family": self.preview_font_action = action - self.slot_set_preview_defaults() self.slot_set_live_defaults() @@ -236,8 +269,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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) @@ -272,15 +303,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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.text_combo = KSelectAction(self.preview_text_collection) - self.text_combo.setEditable(False) - self.text_combo.setComboWidth(100) - 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) - self.next_action = self.preview_text_collection.addAction("next_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-forward")) self.next_action.setIcon(icon) @@ -308,21 +330,30 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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.live_text_collection) + 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.live_text_collection.addAction("stream", self.streaming_action) + 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.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) @@ -400,6 +431,19 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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): @@ -413,8 +457,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_center_action.setChecked(True) self.preview_text.alignCenter() self.font.setPointSize(self.default_size) - self.preview_text.setFont(self.font) 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) @@ -423,25 +467,18 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.live_center_action.setChecked(True) self.live_text.alignCenter() self.font.setPointSize(self.default_size) - self.live_text.setFont(self.font) 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.default_size = self.live_size_action.fontSize() - #cursor = self.live_text.textCursor() - #self.custom_clear(cursor) self.live_text.clear() self.slot_set_live_defaults() def slot_clear_preview(self): - #self.preview_text.document().clear() - #self.default_size = self.preview_size_action.fontSize() - #cursor = self.preview_text.textCursor() - #self.custom_clear(cursor) self.preview_text.clear() self.slot_set_preview_defaults() @@ -512,7 +549,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): suffix = 1 while 1: tmp_preview = "%s_%d" % (preview, suffix) - tmp = self.text_by_preview(tmp_preview) + tmp = self.model.text_by_preview(tmp_preview) if tmp is None: preview = tmp_preview break @@ -521,8 +558,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.model.text_db.append([preview, text]) self.model.modelReset.emit() - #action = self.text_combo.addAction(preview) - #self.text_combo.setCurrentAction(action) + action = self.text_combo.addAction(preview) + self.text_combo.setCurrentAction(action) def slot_save(self): path = os.path.expanduser("~/.texter") @@ -535,21 +572,69 @@ class MainWindow(KMainWindow, Ui_MainWindow): else: cPickle.dump(self.model.text_db, f, cPickle.HIGHEST_PROTOCOL) - def slot_valign(self): - fn = 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)) + #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) - self.dialog.move(800, 0) + 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() diff --git a/texter/texter/text_model.py b/texter/texter/text_model.py index c58c3ed..9a77880 100644 --- a/texter/texter/text_model.py +++ b/texter/texter/text_model.py @@ -48,7 +48,10 @@ class TextModel(QtCore.QAbstractTableModel): return True def flags(self, index): - return QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled + 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) diff --git a/texter/texter/text_sorter_ui.py b/texter/texter/text_sorter_ui.py index 3e67e8e..5e34386 100644 --- a/texter/texter/text_sorter_ui.py +++ b/texter/texter/text_sorter_ui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding=UTF-8 # -# Generated by pykdeuic4 from texter4.ui on Tue Apr 15 17:09:47 2014 +# 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 @@ -25,38 +25,73 @@ except AttributeError: class Ui_TextSorterDialog(object): def setupUi(self, TextSorterDialog): TextSorterDialog.setObjectName(_fromUtf8("TextSorterDialog")) - TextSorterDialog.resize(588, 584) - self.horizontalLayout = QtGui.QHBoxLayout(TextSorterDialog) - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + 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.addWidget(self.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.verticalLayout = QtGui.QVBoxLayout(self.kbuttongroup) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + 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.verticalLayout.addWidget(self.remove_button) - self.move_up_button = KArrowButton(self.kbuttongroup) - self.move_up_button.setObjectName(_fromUtf8("move_up_button")) - self.verticalLayout.addWidget(self.move_up_button) - self.move_down_button = KArrowButton(self.kbuttongroup) - self.move_down_button.setProperty("arrowType", 2) - self.move_down_button.setObjectName(_fromUtf8("move_down_button")) - self.verticalLayout.addWidget(self.move_down_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.horizontalLayout.addWidget(self.kbuttongroup) - self.text_preview = KRichTextWidget(TextSorterDialog) - self.text_preview.setMinimumSize(QtCore.QSize(0, 576)) - self.text_preview.setMaximumSize(QtCore.QSize(16777215, 576)) - self.text_preview.setObjectName(_fromUtf8("text_preview")) - self.horizontalLayout.addWidget(self.text_preview) self.retranslateUi(TextSorterDialog) QtCore.QMetaObject.connectSlotsByName(TextSorterDialog) diff --git a/texter/texter/texter3.ui b/texter/texter/texter3.ui index a85a248..5318dac 100644 --- a/texter/texter/texter3.ui +++ b/texter/texter/texter3.ui @@ -6,8 +6,8 @@ 0 0 - 1554 - 584 + 1475 + 651 @@ -82,95 +82,177 @@ :/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 - - - KRichTextWidget::SupportAlignment|KRichTextWidget::SupportChangeListStyle|KRichTextWidget::SupportFontFamily|KRichTextWidget::SupportFontSize|KRichTextWidget::SupportIndentLists|KRichTextWidget::SupportTextForegroundColor - - + + + + + + 769 + 577 + + + + + 769 + 577 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + + BlankCursor + + + false + + + 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 + + + + Qt::ActionsContextMenu + + + preview text + + + false + + + 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 + + - 400 - 576 + 20 + 40 - - - 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 - - - KRichTextWidget::SupportAlignment|KRichTextWidget::SupportChangeListStyle|KRichTextWidget::SupportFontFamily|KRichTextWidget::SupportFontSize|KRichTextWidget::SupportTextForegroundColor - - + diff --git a/texter/texter/texter4.ui b/texter/texter/texter4.ui index a2b8a82..bf97ac0 100644 --- a/texter/texter/texter4.ui +++ b/texter/texter/texter4.ui @@ -6,33 +6,167 @@ 0 0 - 588 - 584 + 662 + 716 Form - + - - - - 0 - 576 - - - - - 16777215 - 576 - - - + + + + + + 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 + + + + + + @@ -44,47 +178,21 @@ - - - - - - - 2 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + + Qt::Vertical + + - 0 - 576 + 20 + 40 - - - 16777215 - 576 - - - + diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py index b60c6a7..c6c0bac 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding=UTF-8 # -# Generated by pykdeuic4 from texter3.ui on Tue Apr 15 16:21:39 2014 +# Generated by pykdeuic4 from texter3.ui on Wed Apr 16 00:07:33 2014 # # WARNING! All changes to this file will be lost. from PyKDE4 import kdecore @@ -25,7 +25,7 @@ except AttributeError: class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) - MainWindow.resize(1554, 584) + MainWindow.resize(1475, 651) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) @@ -51,19 +51,34 @@ class Ui_MainWindow(object): MainWindow.setWindowIcon(icon) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) - self.horizontalLayout = QtGui.QHBoxLayout(self.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(768, 576)) - self.live_text.setMaximumSize(QtCore.QSize(768, 576)) - font = QtGui.QFont() - font.setFamily(_fromUtf8("Monospace")) - font.setPointSize(22) - self.live_text.setFont(font) + self.live_text.setMinimumSize(QtCore.QSize(769, 577)) + self.live_text.setMaximumSize(QtCore.QSize(769, 577)) + palette = QtGui.QPalette() + 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.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.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.setToolTip(_fromUtf8("")) - self.live_text.setStatusTip(_fromUtf8("")) - self.live_text.setWhatsThis(_fromUtf8("")) self.live_text.setAutoFillBackground(False) 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) @@ -71,12 +86,13 @@ class Ui_MainWindow(object): self.live_text.setObjectName(_fromUtf8("live_text")) self.horizontalLayout.addWidget(self.live_text) self.preview_text = KRichTextWidget(self.centralwidget) - self.preview_text.setMinimumSize(QtCore.QSize(400, 576)) - self.preview_text.setMaximumSize(QtCore.QSize(768, 576)) - font = QtGui.QFont() - font.setFamily(_fromUtf8("Monospace")) - font.setPointSize(22) - self.preview_text.setFont(font) + 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(769, 577)) self.preview_text.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.preview_text.setAutoFillBackground(False) self.preview_text.setFrameShape(QtGui.QFrame.StyledPanel) @@ -85,6 +101,11 @@ class Ui_MainWindow(object): 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) From 2b78252fc378b99545149ded7ddc9df2b4701fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 17 Apr 2014 01:43:34 +0200 Subject: [PATCH 13/16] new version --- texter/texter/main.py | 6 +- texter/texter/texter3.ui | 136 +++++++++++++++++++++++++++++++++++-- texter/texter/texter_ui.py | 69 +++++++++++++++---- 3 files changed, 188 insertions(+), 23 deletions(-) diff --git a/texter/texter/main.py b/texter/texter/main.py index 4b9411f..837bde2 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -119,7 +119,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_font_action = None self.live_font_action = None self.preview_size_action = None - self.default_size = 48 + self.default_size = 28 self.default_align_text = "format_align_center" self.preview_actions = list() self.live_actions = list() @@ -378,8 +378,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): 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("/usr/bin/ffserver -f /etc/ffserver.conf", shell=True, close_fds=True) - self.ffmpeg = subprocess.Popen("/usr/bin/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(), global_rect.y()), shell=True, close_fds=True) + 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): diff --git a/texter/texter/texter3.ui b/texter/texter/texter3.ui index 5318dac..bb7834f 100644 --- a/texter/texter/texter3.ui +++ b/texter/texter/texter3.ui @@ -89,19 +89,37 @@ - 769 - 577 + 775 + 578 - 769 - 577 + 775 + 578 + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + @@ -122,6 +140,24 @@ + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + @@ -142,6 +178,24 @@ + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + @@ -167,7 +221,13 @@ BlankCursor - false + true + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff true @@ -200,6 +260,70 @@ 577 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + Qt::ActionsContextMenu @@ -207,7 +331,7 @@ preview text - false + true QFrame::StyledPanel diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py index c6c0bac..730e3c3 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -1,11 +1,12 @@ -#!/usr/bin/env python -# coding=UTF-8 +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'texter3.ui' # -# Generated by pykdeuic4 from texter3.ui on Wed Apr 16 00:07:33 2014 +# Created: Wed Apr 16 20:48:51 2014 +# by: PyQt4 UI code generator 4.10.3 # -# WARNING! All changes to this file will be lost. -from PyKDE4 import kdecore -from PyKDE4 import kdeui +# WARNING! All changes made in this file will be lost! + from PyQt4 import QtCore, QtGui try: @@ -56,30 +57,50 @@ class Ui_MainWindow(object): self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.live_text = KRichTextWidget(self.centralwidget) - self.live_text.setMinimumSize(QtCore.QSize(769, 577)) - self.live_text.setMaximumSize(QtCore.QSize(769, 577)) + 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(False) + 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)) @@ -92,9 +113,29 @@ class Ui_MainWindow(object): 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(769, 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(False) + 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) @@ -113,8 +154,8 @@ class Ui_MainWindow(object): MainWindow.setTabOrder(self.live_text, self.preview_text) def retranslateUi(self, MainWindow): - MainWindow.setWindowTitle(kdecore.i18n(_fromUtf8("4.48 Texter"))) - self.preview_text.setToolTip(kdecore.i18n(_fromUtf8("preview text"))) + MainWindow.setWindowTitle(_translate("MainWindow", "4.48 Texter", None)) + self.preview_text.setToolTip(_translate("MainWindow", "preview text", None)) from PyKDE4.kdeui import KRichTextWidget -import texter +import texter_rc From de19433571ea3925369d9151cdbe41fb14463e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 17 Apr 2014 01:55:00 +0200 Subject: [PATCH 14/16] searching for a segfault when visited by apple computers :) --- ekgplotter/ekgplotter/main.py | 52 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index dc8dfa1..daa01cf 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -138,18 +138,23 @@ class OSCThread(threading.Thread): while self.running: try: reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) - except select.error: + except Exception, e: + print "select error", e pass - 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)) 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" @@ -377,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) @@ -418,16 +423,19 @@ class MyHandler(BaseHTTPRequestHandler): self.thread.join() del self.thread 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] == 32: + if hasattr(self, "thread"): + self.thread.running = False + self.thread.join() + del self.thread + 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): From 21c59656a36574d6bebedf6e6e6434ecdd09ba6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 17 Apr 2014 01:56:08 +0200 Subject: [PATCH 15/16] removed unused method in texter --- texter/texter/main.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/texter/texter/main.py b/texter/texter/main.py index 837bde2..8c827a7 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -402,13 +402,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): return re.sub(" +", " ", text.replace("\n", " ")).strip()[:20] - def title_by_index(self, ix): - for title, (text, index) in self.items.iteritems(): - if index == ix: - return title - return None - - def slot_next_item(self): self.current = (self.text_combo.currentItem() + 1) % len(self.model.text_db) self.text_combo.setCurrentItem(self.current) From 2f08c5529a66bead4f3076fe65184a207bcf32ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 17 Apr 2014 15:33:21 +0200 Subject: [PATCH 16/16] improved exception handling --- ekgplotter/ekgplotter/main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index daa01cf..e4fc94c 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -394,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 @@ -418,18 +418,18 @@ 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: print "ioerror", e, e[0] print dir(e) - if e[0] == 32: - if hasattr(self, "thread"): + if e[0] in (32, 104): + if hasattr(self, "thread") and self.thread is not None: self.thread.running = False self.thread.join() - del self.thread + self.thread = None else: print '-'*40 print 'Exception happened during processing of request from'