new smaller design

This commit is contained in:
Stefan Kögl 2014-04-11 10:11:13 +02:00
parent 3e14468463
commit 3a12ff7dc5
2 changed files with 542 additions and 539 deletions

View File

@ -17,25 +17,26 @@ class MainWindow(MainWindowBase, MainWindowForm):
# setup the ui # setup the ui
self.setupUi(self) 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_private_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff))
self.edit_action_collection = KActionCollection(self) self.edit_action_collection = KActionCollection(self)
self.edit_private_text.createActions(self.edit_action_collection) self.edit_private_text.createActions(self.edit_action_collection)
for action in self.edit_action_collection.actions(): for action in self.edit_action_collection.actions():
self.toolBar.addAction(action) self.toolBar.addAction(action)
self.current_text = None
print dir(self) self.current_title = None
self.current_index = None
self.is_published = False
self.tabWidget.currentChanged.connect(self.slot_toggleToolbox) self.tabWidget.currentChanged.connect(self.slot_toggleToolbox)
self.add_button.clicked.connect(self.slot_addText) self.add_button.clicked.connect(self.slot_addText)
self.save_button.clicked.connect(self.slot_save) self.save_button.clicked.connect(self.slot_save)
self.publish_button.clicked.connect(self.slot_publish) self.publish_button.toggled.connect(self.slot_toggle_publish)
self.clear_button.clicked.connect(self.slot_clear)
self.remove_item_button.clicked.connect(self.slot_removeItem) self.remove_item_button.clicked.connect(self.slot_removeItem)
self.edit_item_selection.activated.connect(self.slot_editLoadItem) self.edit_item_selection.activated.connect(self.slot_editLoadItem)
self.item_list.currentRowChanged.connect(self.slot_showLoadItem) self.item_list.currentRowChanged.connect(self.slot_showLoadItem)
self.auto_publish_checkbox.toggled.connect(self.slot_toggle_publish)
self.items = dict() self.items = dict()
self.slot_load() self.slot_load()
@ -45,8 +46,10 @@ class MainWindow(MainWindowBase, MainWindowForm):
self.previous_button.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Backspace)) self.previous_button.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Backspace))
self.previous_button.clicked.connect(self.slot_previous_item) self.previous_button.clicked.connect(self.slot_previous_item)
def slot_next_item(self): def slot_next_item(self):
print "slot_next_item" print "slot_next_item"
print "current_title", self.current_title, self.current_text
index = (self.item_list.currentRow() + 1) % self.item_list.count() index = (self.item_list.currentRow() + 1) % self.item_list.count()
self.item_list.setCurrentRow(index) self.item_list.setCurrentRow(index)
self.edit_item_selection.setCurrentIndex(index) self.edit_item_selection.setCurrentIndex(index)
@ -55,6 +58,7 @@ class MainWindow(MainWindowBase, MainWindowForm):
def slot_previous_item(self): def slot_previous_item(self):
print "slot_previous_item" print "slot_previous_item"
print "current_title", self.current_title, self.current_text
index = (self.item_list.currentRow() - 1) % self.item_list.count() index = (self.item_list.currentRow() - 1) % self.item_list.count()
self.item_list.setCurrentRow(index) self.item_list.setCurrentRow(index)
self.edit_item_selection.setCurrentIndex(index) self.edit_item_selection.setCurrentIndex(index)
@ -62,6 +66,8 @@ class MainWindow(MainWindowBase, MainWindowForm):
self.slot_showLoadItem(index) self.slot_showLoadItem(index)
def slot_toggleToolbox(self, index): def slot_toggleToolbox(self, index):
print "slot_toggleToolbox"
print "current_title", self.current_title, self.current_text
if index == 0: if index == 0:
self.toolBar.setEnabled(True) self.toolBar.setEnabled(True)
else: else:
@ -74,10 +80,30 @@ class MainWindow(MainWindowBase, MainWindowForm):
#animation.setEndValue(QRect(250, 250, 100, 30)); #animation.setEndValue(QRect(250, 250, 100, 30));
#animation.start(); #animation.start();
print "slot_publish" 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): def slot_clear(self):
print "slot_clear"
print "current_title", self.current_title, self.current_text
self.show_public_text.clear() self.show_public_text.clear()
self.is_published = False
def slot_removeItem(self): def slot_removeItem(self):
text = self.edit_item_selection.currentText() text = self.edit_item_selection.currentText()
@ -85,7 +111,14 @@ class MainWindow(MainWindowBase, MainWindowForm):
title = text.split(": ")[1] title = text.split(": ")[1]
del self.items[title] del self.items[title]
self.edit_item_selection.removeItem(index) 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): def slot_editLoadItem(self, index):
print "slot_editLoadItem", index print "slot_editLoadItem", index
@ -99,15 +132,17 @@ class MainWindow(MainWindowBase, MainWindowForm):
def slot_showLoadItem(self, index): def slot_showLoadItem(self, index):
public_rect = self.show_public_text.geometry() public_rect = self.show_public_text.geometry()
global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) 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) item = self.item_list.item(index)
print "item", item
if item is None: if item is None:
return return
title = item.text() self.current_title = item.text()
text, index = self.items[title] self.current_text, self.current_index = self.items[self.current_title]
self.show_private_text.setHtml(text) print "current_title", self.current_title, self.current_text
if self.auto_publish_checkbox.isChecked(): 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): def title_by_index(self, ix):
for title, (text, index) in self.items.iteritems(): for title, (text, index) in self.items.iteritems():
@ -169,11 +204,11 @@ class MainWindow(MainWindowBase, MainWindowForm):
self.edit_item_selection.setCurrentIndex(0) self.edit_item_selection.setCurrentIndex(0)
self.item_list.setCurrentRow(0) self.item_list.setCurrentRow(0)
title, text, position = data[0] self.current_title, self.current_text, self.current_index = data[0]
self.edit_private_text.setTextOrHtml(text)
self.show_private_text.setTextOrHtml(text) self.edit_private_text.setTextOrHtml(self.current_text)
self.item_position_input.setValue(position) self.item_position_input.setValue(self.current_index)
self.item_title.setText(title) self.item_title.setText(self.current_title)

View File

@ -10,26 +10,13 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
<string>&amp;Edit</string> <string>&amp;Edit</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
@ -101,10 +88,20 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
<item> <item>
<widget class="KRichTextWidget" name="edit_private_text"> <widget class="KRichTextWidget" name="edit_private_text">
<property name="minimumSize">
<size>
<width>768</width>
<height>576</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>768</width>
<height>576</height>
</size>
</property>
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@ -538,9 +535,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"/> <spacer name="verticalSpacer_2">
</item> <property name="orientation">
</layout> <enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -548,19 +553,59 @@
<attribute name="title"> <attribute name="title">
<string>Sho&amp;w</string> <string>Sho&amp;w</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="next_button">
<property name="text">
<string>Next</string>
</property>
<property name="shortcut">
<string comment=" "/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="previous_button">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="publish_button">
<property name="text">
<string>&amp;Publish</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="auto_publish_checkbox">
<property name="text">
<string>A&amp;uto Publish</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="KRichTextEdit" name="show_public_text"> <widget class="KRichTextEdit" name="show_public_text">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>640</width> <width>768</width>
<height>480</height> <height>576</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>640</width> <width>768</width>
<height>480</height> <height>576</height>
</size> </size>
</property> </property>
<property name="palette"> <property name="palette">
@ -999,61 +1044,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <widget class="KListWidget" name="item_list">
<item>
<widget class="QPushButton" name="next_button">
<property name="text">
<string>Next</string>
</property>
<property name="shortcut">
<string comment=" "/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="previous_button">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="publish_button">
<property name="text">
<string>&amp;Publish</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clear_button">
<property name="text">
<string>&amp;Clear</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="auto_publish_checkbox">
<property name="text">
<string>A&amp;uto Publish</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="KRichTextWidget" name="show_private_text">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>480</height> <height>576</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
<height>480</height> <height>576</height>
</size> </size>
</property> </property>
<property name="palette"> <property name="palette">
@ -1471,64 +1472,31 @@
</disabled> </disabled>
</palette> </palette>
</property> </property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="autoFillBackground"> <property name="autoFillBackground">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="acceptRichText">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_6"> <spacer name="verticalSpacer">
<item> <property name="orientation">
<widget class="QLabel" name="label_7"> <enum>Qt::Vertical</enum>
<property name="text">
<string>Item</string>
</property> </property>
<property name="buddy"> <property name="sizeHint" stdset="0">
<cstring>item_list</cstring> <size>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</widget> </spacer>
</item>
<item>
<widget class="KListWidget" name="item_list"/>
</item> </item>
</layout> </layout>
</item>
</layout>
</item>
</layout>
<zorder>clear_button</zorder>
<zorder>show_private_text</zorder>
<zorder>show_item_selection</zorder>
<zorder>publish_button</zorder>
<zorder>show_public_text</zorder>
<zorder>item_list</zorder>
<zorder>label_7</zorder>
<zorder>item_list</zorder>
<zorder>item_list</zorder>
<zorder>item_list</zorder>
<zorder></zorder>
</widget> </widget>
</widget> </widget>
</item> </item>
</layout> </layout>
<zorder>private_text</zorder>
<zorder>kbuttongroup</zorder>
<zorder>verticalSpacer</zorder>
<zorder>item_title</zorder>
<zorder>edit_item_selection</zorder>
<zorder>tabWidget</zorder>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">