Added the template editor dialog
authorHarishankar <v.harishankar@gmail.com>
Mon, 29 Nov 2010 08:13:18 +0000 (13:43 +0530)
committerHarishankar <v.harishankar@gmail.com>
Mon, 29 Nov 2010 08:13:18 +0000 (13:43 +0530)
Added the template editor dialog to the project. Still need
to implement its functionality though

article_dialog.py
article_dialog.ui
main_window.py
main_window.ui
templates_dialog.py [new file with mode: 0644]
templates_dialog.ui [new file with mode: 0644]
ui_article_dialog.py
ui_main_window.py
ui_templates_dialog.py [new file with mode: 0644]

index 740692c..6b51e70 100644 (file)
@@ -9,6 +9,8 @@ class ArticleDialog (PyQt4.QtGui.QDialog, ui_article_dialog.Ui_ArticleDialog):
        def __init__ (self, parent):
                PyQt4.QtGui.QDialog.__init__ (self, parent)
                self.setupUi (self)
        def __init__ (self, parent):
                PyQt4.QtGui.QDialog.__init__ (self, parent)
                self.setupUi (self)
+               # set window to be able to be maximized or minimized
+               self.setWindowFlags (PyQt4.QtCore.Qt.Window)
                # set the code highlighter to the document
                self.hltext = highlighter.SimpleHtmlHighlighter (self.content.document ())
 
                # set the code highlighter to the document
                self.hltext = highlighter.SimpleHtmlHighlighter (self.content.document ())
 
index 1e8557c..f83647b 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>654</width>
+    <width>750</width>
     <height>548</height>
    </rect>
   </property>
     <height>548</height>
    </rect>
   </property>
      </property>
     </widget>
    </item>
      </property>
     </widget>
    </item>
-   <item row="2" column="3" colspan="19">
-    <widget class="QPlainTextEdit" name="summary">
-     <property name="verticalScrollBarPolicy">
-      <enum>Qt::ScrollBarAlwaysOn</enum>
-     </property>
-     <property name="tabChangesFocus">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
    <item row="3" column="0" colspan="4">
     <widget class="QLabel" name="label_5">
      <property name="font">
    <item row="3" column="0" colspan="4">
     <widget class="QLabel" name="label_5">
      <property name="font">
@@ -654,6 +644,34 @@ p, li { white-space: pre-wrap; }
      </property>
     </widget>
    </item>
      </property>
     </widget>
    </item>
+   <item row="2" column="3" colspan="19">
+    <widget class="QPlainTextEdit" name="summary">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>40</height>
+      </size>
+     </property>
+     <property name="maximumSize">
+      <size>
+       <width>16777215</width>
+       <height>75</height>
+      </size>
+     </property>
+     <property name="verticalScrollBarPolicy">
+      <enum>Qt::ScrollBarAlwaysOn</enum>
+     </property>
+     <property name="tabChangesFocus">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <tabstops>
   </layout>
  </widget>
  <tabstops>
index 6f033d6..32e39f9 100644 (file)
@@ -2,12 +2,14 @@
 # Main Window class
 
 import PyQt4
 # Main Window class
 
 import PyQt4
+import sys
+
 import ui_main_window
 import site_configuration_dialog as scd
 import category_dialog as catd
 import article_dialog as artd
 import ui_main_window
 import site_configuration_dialog as scd
 import category_dialog as catd
 import article_dialog as artd
+import templates_dialog as tpld
 import biaweb_db
 import biaweb_db
-import sys
 
 class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
        def __init__ (self):
 
 class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
        def __init__ (self):
@@ -172,7 +174,7 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
                        catid = self.get_selected_item_id (self.categories)
                        self.repopulate_articles (catid)
 
                        catid = self.get_selected_item_id (self.categories)
                        self.repopulate_articles (catid)
 
-       # when configuration menu is activated
+       # when configuration menu is triggered
        def onConfiguration (self):
                if self.current_db is None:
                        PyQt4.QtGui.QMessageBox.critical (self, "Error",
        def onConfiguration (self):
                if self.current_db is None:
                        PyQt4.QtGui.QMessageBox.critical (self, "Error",
@@ -210,6 +212,15 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
                                        PyQt4.QtGui.QMessageBox.critical (self, "Error",
                                                                                        "SQLite 3 error in updating configuration")
 
                                        PyQt4.QtGui.QMessageBox.critical (self, "Error",
                                                                                        "SQLite 3 error in updating configuration")
 
+       # when templates menu is triggered
+       def onTemplates (self):
+               if self.current_db is None:
+                       PyQt4.QtGui.QMessageBox.critical (self, "Error",
+                                                               "Cannot edit templates. You need to create or open a website first")
+               else:
+                       tdlg = tpld.TemplatesDialog (self)
+                       tdlg.exec_ ()
+
        # function to get the category or article ID from current selected item in a tree widget
        def get_selected_item_id (self, twidget):
                selitems = twidget.selectedItems ()
        # function to get the category or article ID from current selected item in a tree widget
        def get_selected_item_id (self, twidget):
                selitems = twidget.selectedItems ()
index 1709029..bbdfa1f 100644 (file)
     </hint>
    </hints>
   </connection>
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>actionTemplates</sender>
+   <signal>triggered()</signal>
+   <receiver>MainWindow</receiver>
+   <slot>onTemplates()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>398</x>
+     <y>258</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>onFileNew()</slot>
  </connections>
  <slots>
   <slot>onFileNew()</slot>
   <slot>onArticleDelete()</slot>
   <slot>onCategoryItemActivated()</slot>
   <slot>onArticleItemActivated()</slot>
   <slot>onArticleDelete()</slot>
   <slot>onCategoryItemActivated()</slot>
   <slot>onArticleItemActivated()</slot>
+  <slot>onTemplates()</slot>
  </slots>
 </ui>
  </slots>
 </ui>
diff --git a/templates_dialog.py b/templates_dialog.py
new file mode 100644 (file)
index 0000000..7d8fbf0
--- /dev/null
@@ -0,0 +1,12 @@
+# BiaWeb Website content manager (c) 2010 V.Harishankar
+# Templates dialog class
+
+import PyQt4
+import ui_templates_dialog
+import highlighter
+
+class TemplatesDialog (PyQt4.QtGui.QDialog, ui_templates_dialog.Ui_TemplatesDialog):
+       def __init__ (self, master):
+               PyQt4.QtGui.QDialog.__init__ (self, master)
+               self.setupUi (self)
+               self.setWindowFlags (PyQt4.QtCore.Qt.Window)
diff --git a/templates_dialog.ui b/templates_dialog.ui
new file mode 100644 (file)
index 0000000..2b9be0a
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TemplatesDialog</class>
+ <widget class="QDialog" name="TemplatesDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>751</width>
+    <height>535</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Template Editor</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Template</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QComboBox" name="templates">
+     <property name="minimumSize">
+      <size>
+       <width>250</width>
+       <height>0</height>
+      </size>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="2">
+    <widget class="QPushButton" name="edit">
+     <property name="toolTip">
+      <string>Click to edit the
+selected template</string>
+     </property>
+     <property name="text">
+      <string>&amp;Edit</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3">
+    <widget class="QPushButton" name="pushButton">
+     <property name="toolTip">
+      <string>Save the template
+modified below</string>
+     </property>
+     <property name="text">
+      <string>&amp;Save</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="4">
+    <widget class="QPlainTextEdit" name="template_text">
+     <property name="font">
+      <font>
+       <family>Monospace</family>
+      </font>
+     </property>
+     <property name="tabChangesFocus">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="3">
+    <widget class="QPushButton" name="close">
+     <property name="text">
+      <string>&amp;Close</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>templates</tabstop>
+  <tabstop>edit</tabstop>
+  <tabstop>pushButton</tabstop>
+  <tabstop>template_text</tabstop>
+  <tabstop>close</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>close</sender>
+   <signal>clicked()</signal>
+   <receiver>TemplatesDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>515</x>
+     <y>383</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>288</x>
+     <y>206</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 6267265..31de583 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'article_dialog.ui'
 #
 
 # Form implementation generated from reading ui file 'article_dialog.ui'
 #
-# Created: Mon Nov 29 11:37:34 2010
+# Created: Mon Nov 29 13:35:38 2010
 #      by: PyQt4 UI code generator 4.7.4
 #
 # WARNING! All changes made in this file will be lost!
 #      by: PyQt4 UI code generator 4.7.4
 #
 # WARNING! All changes made in this file will be lost!
@@ -12,7 +12,7 @@ from PyQt4 import QtCore, QtGui
 class Ui_ArticleDialog(object):
     def setupUi(self, ArticleDialog):
         ArticleDialog.setObjectName("ArticleDialog")
 class Ui_ArticleDialog(object):
     def setupUi(self, ArticleDialog):
         ArticleDialog.setObjectName("ArticleDialog")
-        ArticleDialog.resize(654, 548)
+        ArticleDialog.resize(750, 548)
         ArticleDialog.setAutoFillBackground(False)
         ArticleDialog.setSizeGripEnabled(True)
         ArticleDialog.setModal(True)
         ArticleDialog.setAutoFillBackground(False)
         ArticleDialog.setSizeGripEnabled(True)
         ArticleDialog.setModal(True)
@@ -45,11 +45,6 @@ class Ui_ArticleDialog(object):
         self.label_3.setFont(font)
         self.label_3.setObjectName("label_3")
         self.gridLayout.addWidget(self.label_3, 2, 0, 1, 3)
         self.label_3.setFont(font)
         self.label_3.setObjectName("label_3")
         self.gridLayout.addWidget(self.label_3, 2, 0, 1, 3)
-        self.summary = QtGui.QPlainTextEdit(ArticleDialog)
-        self.summary.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
-        self.summary.setTabChangesFocus(True)
-        self.summary.setObjectName("summary")
-        self.gridLayout.addWidget(self.summary, 2, 3, 1, 19)
         self.label_5 = QtGui.QLabel(ArticleDialog)
         font = QtGui.QFont()
         font.setWeight(75)
         self.label_5 = QtGui.QLabel(ArticleDialog)
         font = QtGui.QFont()
         font.setWeight(75)
@@ -257,6 +252,18 @@ class Ui_ArticleDialog(object):
         self.content.setTabChangesFocus(True)
         self.content.setObjectName("content")
         self.gridLayout.addWidget(self.content, 5, 0, 1, 22)
         self.content.setTabChangesFocus(True)
         self.content.setObjectName("content")
         self.gridLayout.addWidget(self.content, 5, 0, 1, 22)
+        self.summary = QtGui.QPlainTextEdit(ArticleDialog)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
+        sizePolicy.setHorizontalStretch(0)
+        sizePolicy.setVerticalStretch(0)
+        sizePolicy.setHeightForWidth(self.summary.sizePolicy().hasHeightForWidth())
+        self.summary.setSizePolicy(sizePolicy)
+        self.summary.setMinimumSize(QtCore.QSize(0, 40))
+        self.summary.setMaximumSize(QtCore.QSize(16777215, 75))
+        self.summary.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
+        self.summary.setTabChangesFocus(True)
+        self.summary.setObjectName("summary")
+        self.gridLayout.addWidget(self.summary, 2, 3, 1, 19)
 
         self.retranslateUi(ArticleDialog)
         QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), ArticleDialog.accept)
 
         self.retranslateUi(ArticleDialog)
         QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), ArticleDialog.accept)
index 9bdfe98..80a6898 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'main_window.ui'
 #
 
 # Form implementation generated from reading ui file 'main_window.ui'
 #
-# Created: Mon Nov 29 09:09:27 2010
+# Created: Mon Nov 29 13:18:40 2010
 #      by: PyQt4 UI code generator 4.7.4
 #
 # WARNING! All changes made in this file will be lost!
 #      by: PyQt4 UI code generator 4.7.4
 #
 # WARNING! All changes made in this file will be lost!
@@ -137,6 +137,7 @@ class Ui_MainWindow(object):
         QtCore.QObject.connect(self.action_DeleteArticle, QtCore.SIGNAL("triggered()"), MainWindow.onArticleDelete)
         QtCore.QObject.connect(self.categories, QtCore.SIGNAL("itemActivated(QTreeWidgetItem*,int)"), MainWindow.onCategoryItemActivated)
         QtCore.QObject.connect(self.articles, QtCore.SIGNAL("itemActivated(QTreeWidgetItem*,int)"), MainWindow.onArticleItemActivated)
         QtCore.QObject.connect(self.action_DeleteArticle, QtCore.SIGNAL("triggered()"), MainWindow.onArticleDelete)
         QtCore.QObject.connect(self.categories, QtCore.SIGNAL("itemActivated(QTreeWidgetItem*,int)"), MainWindow.onCategoryItemActivated)
         QtCore.QObject.connect(self.articles, QtCore.SIGNAL("itemActivated(QTreeWidgetItem*,int)"), MainWindow.onArticleItemActivated)
+        QtCore.QObject.connect(self.actionTemplates, QtCore.SIGNAL("triggered()"), MainWindow.onTemplates)
         QtCore.QMetaObject.connectSlotsByName(MainWindow)
         MainWindow.setTabOrder(self.categories, self.articles)
 
         QtCore.QMetaObject.connectSlotsByName(MainWindow)
         MainWindow.setTabOrder(self.categories, self.articles)
 
diff --git a/ui_templates_dialog.py b/ui_templates_dialog.py
new file mode 100644 (file)
index 0000000..6845dc2
--- /dev/null
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'templates_dialog.ui'
+#
+# Created: Mon Nov 29 13:37:20 2010
+#      by: PyQt4 UI code generator 4.7.4
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_TemplatesDialog(object):
+    def setupUi(self, TemplatesDialog):
+        TemplatesDialog.setObjectName("TemplatesDialog")
+        TemplatesDialog.resize(751, 535)
+        self.gridLayout = QtGui.QGridLayout(TemplatesDialog)
+        self.gridLayout.setObjectName("gridLayout")
+        self.label = QtGui.QLabel(TemplatesDialog)
+        self.label.setObjectName("label")
+        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
+        self.templates = QtGui.QComboBox(TemplatesDialog)
+        self.templates.setMinimumSize(QtCore.QSize(250, 0))
+        self.templates.setObjectName("templates")
+        self.gridLayout.addWidget(self.templates, 0, 1, 1, 1)
+        self.edit = QtGui.QPushButton(TemplatesDialog)
+        self.edit.setObjectName("edit")
+        self.gridLayout.addWidget(self.edit, 0, 2, 1, 1)
+        self.pushButton = QtGui.QPushButton(TemplatesDialog)
+        self.pushButton.setObjectName("pushButton")
+        self.gridLayout.addWidget(self.pushButton, 0, 3, 1, 1)
+        self.template_text = QtGui.QPlainTextEdit(TemplatesDialog)
+        font = QtGui.QFont()
+        font.setFamily("Monospace")
+        self.template_text.setFont(font)
+        self.template_text.setTabChangesFocus(True)
+        self.template_text.setObjectName("template_text")
+        self.gridLayout.addWidget(self.template_text, 1, 0, 1, 4)
+        self.close = QtGui.QPushButton(TemplatesDialog)
+        self.close.setObjectName("close")
+        self.gridLayout.addWidget(self.close, 2, 3, 1, 1)
+
+        self.retranslateUi(TemplatesDialog)
+        QtCore.QObject.connect(self.close, QtCore.SIGNAL("clicked()"), TemplatesDialog.accept)
+        QtCore.QMetaObject.connectSlotsByName(TemplatesDialog)
+        TemplatesDialog.setTabOrder(self.templates, self.edit)
+        TemplatesDialog.setTabOrder(self.edit, self.pushButton)
+        TemplatesDialog.setTabOrder(self.pushButton, self.template_text)
+        TemplatesDialog.setTabOrder(self.template_text, self.close)
+
+    def retranslateUi(self, TemplatesDialog):
+        TemplatesDialog.setWindowTitle(QtGui.QApplication.translate("TemplatesDialog", "Template Editor", None, QtGui.QApplication.UnicodeUTF8))
+        self.label.setText(QtGui.QApplication.translate("TemplatesDialog", "Template", None, QtGui.QApplication.UnicodeUTF8))
+        self.edit.setToolTip(QtGui.QApplication.translate("TemplatesDialog", "Click to edit the\n"
+"selected template", None, QtGui.QApplication.UnicodeUTF8))
+        self.edit.setText(QtGui.QApplication.translate("TemplatesDialog", "&Edit", None, QtGui.QApplication.UnicodeUTF8))
+        self.pushButton.setToolTip(QtGui.QApplication.translate("TemplatesDialog", "Save the template\n"
+"modified below", None, QtGui.QApplication.UnicodeUTF8))
+        self.pushButton.setText(QtGui.QApplication.translate("TemplatesDialog", "&Save", None, QtGui.QApplication.UnicodeUTF8))
+        self.close.setText(QtGui.QApplication.translate("TemplatesDialog", "&Close", None, QtGui.QApplication.UnicodeUTF8))
+