Added about box and application icon
[biaweb_qt.git] / main_window.py
index 32e39f9..02eaa8b 100644 (file)
@@ -9,6 +9,7 @@ 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
 
 class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
@@ -20,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
 
@@ -32,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
 
@@ -218,7 +223,7 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
                        PyQt4.QtGui.QMessageBox.critical (self, "Error",
                                                                "Cannot edit templates. You need to create or open a website first")
                else:
-                       tdlg = tpld.TemplatesDialog (self)
+                       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
@@ -358,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",
+                       "<b>A static website/weblog content management system</b><br /><br />\
+Copyright (C) 2010 <a href=\"http://www.harishankar.org\">Harishankar</a><br />\
+Licensed under GNU/GPL v3")
+
        # file quit is clicked
        def onFileQuit (self):
                sys.exit (0)