From: Harishankar Date: Mon, 29 Nov 2010 08:13:18 +0000 (+0530) Subject: Added the template editor dialog X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=commitdiff_plain;h=c78ebaf4ae0e486c54907edf51159615f2b4f81e Added the template editor dialog Added the template editor dialog to the project. Still need to implement its functionality though --- diff --git a/article_dialog.py b/article_dialog.py index 740692c..6b51e70 100644 --- a/article_dialog.py +++ b/article_dialog.py @@ -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) + # 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 ()) diff --git a/article_dialog.ui b/article_dialog.ui index 1e8557c..f83647b 100644 --- a/article_dialog.ui +++ b/article_dialog.ui @@ -6,7 +6,7 @@ 0 0 - 654 + 750 548 @@ -68,16 +68,6 @@ - - - - Qt::ScrollBarAlwaysOn - - - true - - - @@ -654,6 +644,34 @@ p, li { white-space: pre-wrap; } + + + + + 0 + 0 + + + + + 0 + 40 + + + + + 16777215 + 75 + + + + Qt::ScrollBarAlwaysOn + + + true + + + diff --git a/main_window.py b/main_window.py index 6f033d6..32e39f9 100644 --- a/main_window.py +++ b/main_window.py @@ -2,12 +2,14 @@ # 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 templates_dialog as tpld import biaweb_db -import sys 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) - # 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", @@ -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") + # 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 () diff --git a/main_window.ui b/main_window.ui index 1709029..bbdfa1f 100644 --- a/main_window.ui +++ b/main_window.ui @@ -517,6 +517,22 @@ + + actionTemplates + triggered() + MainWindow + onTemplates() + + + -1 + -1 + + + 398 + 258 + + + onFileNew() @@ -533,5 +549,6 @@ onArticleDelete() onCategoryItemActivated() onArticleItemActivated() + onTemplates() diff --git a/templates_dialog.py b/templates_dialog.py new file mode 100644 index 0000000..7d8fbf0 --- /dev/null +++ b/templates_dialog.py @@ -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 index 0000000..2b9be0a --- /dev/null +++ b/templates_dialog.ui @@ -0,0 +1,103 @@ + + + TemplatesDialog + + + + 0 + 0 + 751 + 535 + + + + Template Editor + + + + + + Template + + + + + + + + 250 + 0 + + + + + + + + Click to edit the +selected template + + + &Edit + + + + + + + Save the template +modified below + + + &Save + + + + + + + + Monospace + + + + true + + + + + + + &Close + + + + + + + templates + edit + pushButton + template_text + close + + + + + close + clicked() + TemplatesDialog + accept() + + + 515 + 383 + + + 288 + 206 + + + + + diff --git a/ui_article_dialog.py b/ui_article_dialog.py index 6267265..31de583 100644 --- a/ui_article_dialog.py +++ b/ui_article_dialog.py @@ -2,7 +2,7 @@ # 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! @@ -12,7 +12,7 @@ from PyQt4 import QtCore, QtGui 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) @@ -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.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) @@ -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.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) diff --git a/ui_main_window.py b/ui_main_window.py index 9bdfe98..80a6898 100644 --- a/ui_main_window.py +++ b/ui_main_window.py @@ -2,7 +2,7 @@ # 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! @@ -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.actionTemplates, QtCore.SIGNAL("triggered()"), MainWindow.onTemplates) 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 index 0000000..6845dc2 --- /dev/null +++ b/ui_templates_dialog.py @@ -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)) +