From 0182823c70c5e1ddf7b8343903201a85e1885e9e Mon Sep 17 00:00:00 2001 From: Harishankar Date: Sat, 10 Dec 2011 12:05:16 +0530 Subject: [PATCH] Added META-INFO to export template Added META-INFO file to export template folder in order to assist the end user to use the correct file extension in the export as dialog box. --- biacv_exporter.py | 9 +++++++++ biacv_lang.py | 1 - biacv_mainwindow.py | 15 ++++++++------- templates/default_fodt/META-INFO | 2 ++ templates/default_xhtml/META-INFO | 2 ++ 5 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 templates/default_fodt/META-INFO create mode 100644 templates/default_xhtml/META-INFO diff --git a/biacv_exporter.py b/biacv_exporter.py index 2f9b522..1edb0e0 100644 --- a/biacv_exporter.py +++ b/biacv_exporter.py @@ -10,6 +10,8 @@ import os.path class BiaCVExporter: def __init__ (self): self.data = {} + self.exporter_name = "" + self.export_filter = "" # set the document data def set_data (self, data): @@ -210,6 +212,12 @@ class BiaCVExporter: # set the template directory and the files within def set_template_directory (self, templatedir): + # load the meta file for exporter title and name + file_meta = os.path.join (templatedir, "META-INFO") + lst_file_meta = (codecs.open (file_meta, 'r', "utf-8").read ()).splitlines () + self.exporter_name = lst_file_meta[0] + self.export_filter = lst_file_meta[1] + # set the template file names # main document template @@ -232,6 +240,7 @@ class BiaCVExporter: self.lang_strings = lang_str.splitlines () + # set the output file def set_output (self, output): self.file_output = output diff --git a/biacv_lang.py b/biacv_lang.py index c9cf4e4..8f1c44c 100644 --- a/biacv_lang.py +++ b/biacv_lang.py @@ -11,7 +11,6 @@ CONFIRM_DISCARD_SAVE = "There are unsaved changes in current document. Do you wi ERROR_DATE = "There is a problem with the date range selected." SAVE_TITLE = "Save File As" OPEN_TITLE = "Open File" -EXPORT_TITLE = "Export As" OPEN_TEMPLATE_TITLE = "Choose Export Template directory" ABOUT_TITLE = "About BiaCV" ABOUT_TEXT = """BiaCV - A resume creator/editor diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index a68652c..ec74b82 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -45,13 +45,6 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): if templatedir == "": return - # get the output file path - outputfile = PyQt4.QtGui.QFileDialog.getSaveFileName (self, - lang.EXPORT_TITLE) - - if outputfile == "": - return - # create a new exporter object exp = exporter.BiaCVExporter () @@ -61,6 +54,14 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): # set the template directory exp.set_template_directory (unicode (templatedir.toUtf8(), "utf-8")) + # get the output file path + outputfile = PyQt4.QtGui.QFileDialog.getSaveFileName (self, + exp.exporter_name, filter=exp.export_filter) + + if outputfile == "": + return + + # set the output file exp.set_output (unicode (outputfile.toUtf8(), "utf-8")) diff --git a/templates/default_fodt/META-INFO b/templates/default_fodt/META-INFO new file mode 100644 index 0000000..10878f6 --- /dev/null +++ b/templates/default_fodt/META-INFO @@ -0,0 +1,2 @@ +Export as Flat OpenDocument Text +FODT file(*.fodt);;All files(*.*) \ No newline at end of file diff --git a/templates/default_xhtml/META-INFO b/templates/default_xhtml/META-INFO new file mode 100644 index 0000000..467840c --- /dev/null +++ b/templates/default_xhtml/META-INFO @@ -0,0 +1,2 @@ +Export as XHTML +XHTML file(*.html);;All files(*.*) \ No newline at end of file -- 2.20.1