X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=main_window.py;h=02eaa8b78c35397183047e6e391ed0a1f03a4504;hp=6f033d6af2cb88fd19500cc268dc41f5b3aa6f6b;hb=bfa2d7e7b048794a95590ee79ba41aa861835cfa;hpb=e897998f0634d3518f069846c62592fe43dc63bf
diff --git a/main_window.py b/main_window.py
index 6f033d6..02eaa8b 100644
--- a/main_window.py
+++ b/main_window.py
@@ -2,12 +2,15 @@
# 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 generate_dialog as gend
import biaweb_db
-import sys
class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
def __init__ (self):
@@ -18,7 +21,9 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
# refresh the category list
def repopulate_categories (self):
recs = biaweb_db.get_categories (self.current_db)
- if not recs:
+
+ # check with False because None is returned when no records exist
+ if recs == False:
PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in getting the categories")
return
@@ -30,7 +35,9 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
# refresh the articles list
def repopulate_articles (self, catid=None):
recs = biaweb_db.get_articles (self.current_db, catid)
- if not recs:
+
+ # check with False because None is returned when no records exist
+ if recs == False:
PyQt4.QtGui.QMessageBox.critical (self, "Error", "SQLite 3 error in getting the articles")
return
@@ -172,7 +179,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 +217,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, self.current_db)
+ 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 ()
@@ -347,6 +363,23 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
else:
PyQt4.QtGui.QMessageBox.critical (self, "Error", "System or SQLite 3 error in creating database")
+ # when generate site menu is triggered
+ def onGenerateSite (self):
+ if self.current_db is None:
+ PyQt4.QtGui.QMessageBox.critical (self, "Error",
+ "Cannot generate site. You need to create or open a website first")
+ else:
+ # run the generate site dialog
+ gendlg = gend.GenerateDialog (self, self.current_db)
+ gendlg.exec_ ()
+
+ # about menu is triggered
+ def onAbout (self):
+ PyQt4.QtGui.QMessageBox.about (self, "BiaWeb Qt",
+ "A static website/weblog content management system
\
+Copyright (C) 2010 Harishankar
\
+Licensed under GNU/GPL v3")
+
# file quit is clicked
def onFileQuit (self):
sys.exit (0)