From a438f4a2c33088c2bec69791ecdc971737a78cad Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Fri, 15 May 2009 17:48:06 +0200 Subject: [PATCH] Aggiunta l'interfaccia per gestire le opzioni, che per ora le salva ma non le legge (quindi si apre con i default e non con le attuali) --- options.py | 48 +++++++++++++++++++++++------------------------- options.ui | 43 +++++-------------------------------------- songbook-editor.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 74 insertions(+), 70 deletions(-) diff --git a/options.py b/options.py index cc96075..df65a12 100644 --- a/options.py +++ b/options.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'options.ui' # -# Created: Sun Apr 26 19:19:25 2009 +# Created: Fri May 15 17:06:57 2009 # by: PyQt4 UI code generator 4.4.4 # # WARNING! All changes made in this file will be lost! @@ -26,50 +26,48 @@ class Ui_options(object): self.label_2 = QtGui.QLabel(self.gridLayoutWidget) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1) - self.comboBox = QtGui.QComboBox(self.gridLayoutWidget) - self.comboBox.setObjectName("comboBox") - self.comboBox.addItem(QtCore.QString()) - self.comboBox.addItem(QtCore.QString()) - self.gridLayout.addWidget(self.comboBox, 0, 1, 1, 1) + self.paper_size = QtGui.QComboBox(self.gridLayoutWidget) + self.paper_size.setObjectName("paper_size") + self.paper_size.addItem(QtCore.QString()) + self.paper_size.addItem(QtCore.QString()) + self.gridLayout.addWidget(self.paper_size, 0, 1, 1, 1) self.label_3 = QtGui.QLabel(self.gridLayoutWidget) self.label_3.setObjectName("label_3") self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1) - self.comboBox_2 = QtGui.QComboBox(self.gridLayoutWidget) - self.comboBox_2.setObjectName("comboBox_2") - self.comboBox_2.addItem(QtCore.QString()) - self.comboBox_2.addItem(QtCore.QString()) - self.comboBox_2.addItem(QtCore.QString()) - self.gridLayout.addWidget(self.comboBox_2, 1, 1, 1, 1) + self.type = QtGui.QComboBox(self.gridLayoutWidget) + self.type.setObjectName("type") + self.type.addItem(QtCore.QString()) + self.type.addItem(QtCore.QString()) + self.type.addItem(QtCore.QString()) + self.gridLayout.addWidget(self.type, 1, 1, 1, 1) self.label_4 = QtGui.QLabel(self.gridLayoutWidget) self.label_4.setObjectName("label_4") self.gridLayout.addWidget(self.label_4, 2, 0, 1, 1) - self.lineEdit = QtGui.QLineEdit(self.gridLayoutWidget) - self.lineEdit.setObjectName("lineEdit") - self.gridLayout.addWidget(self.lineEdit, 2, 1, 1, 1) + self.title = QtGui.QLineEdit(self.gridLayoutWidget) + self.title.setObjectName("title") + self.gridLayout.addWidget(self.title, 2, 1, 1, 1) self.label_5 = QtGui.QLabel(self.gridLayoutWidget) self.label_5.setObjectName("label_5") self.gridLayout.addWidget(self.label_5, 3, 0, 1, 1) - self.lineEdit_2 = QtGui.QLineEdit(self.gridLayoutWidget) - self.lineEdit_2.setObjectName("lineEdit_2") - self.gridLayout.addWidget(self.lineEdit_2, 3, 1, 1, 1) + self.subtitle = QtGui.QLineEdit(self.gridLayoutWidget) + self.subtitle.setObjectName("subtitle") + self.gridLayout.addWidget(self.subtitle, 3, 1, 1, 1) self.label = QtGui.QLabel(options) self.label.setGeometry(QtCore.QRect(160, 20, 141, 16)) self.label.setObjectName("label") self.retranslateUi(options) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), options.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), options.reject) QtCore.QMetaObject.connectSlotsByName(options) def retranslateUi(self, options): options.setWindowTitle(QtGui.QApplication.translate("options", "Opzioni LaTeX", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(QtGui.QApplication.translate("options", "Formato", None, QtGui.QApplication.UnicodeUTF8)) - self.comboBox.setItemText(0, QtGui.QApplication.translate("options", "A4 (290mm x 210mm)", None, QtGui.QApplication.UnicodeUTF8)) - self.comboBox.setItemText(1, QtGui.QApplication.translate("options", "A5 (210mm x 145mm)", None, QtGui.QApplication.UnicodeUTF8)) + self.paper_size.setItemText(0, QtGui.QApplication.translate("options", "A4 (290mm x 210mm)", None, QtGui.QApplication.UnicodeUTF8)) + self.paper_size.setItemText(1, QtGui.QApplication.translate("options", "A5 (210mm x 145mm)", None, QtGui.QApplication.UnicodeUTF8)) self.label_3.setText(QtGui.QApplication.translate("options", "Tipo di Canzoniere", None, QtGui.QApplication.UnicodeUTF8)) - self.comboBox_2.setItemText(0, QtGui.QApplication.translate("options", "Testo e accordi", None, QtGui.QApplication.UnicodeUTF8)) - self.comboBox_2.setItemText(1, QtGui.QApplication.translate("options", "Solo Testo", None, QtGui.QApplication.UnicodeUTF8)) - self.comboBox_2.setItemText(2, QtGui.QApplication.translate("options", "Slide", None, QtGui.QApplication.UnicodeUTF8)) + self.type.setItemText(0, QtGui.QApplication.translate("options", "Testo e accordi", None, QtGui.QApplication.UnicodeUTF8)) + self.type.setItemText(1, QtGui.QApplication.translate("options", "Solo Testo", None, QtGui.QApplication.UnicodeUTF8)) + self.type.setItemText(2, QtGui.QApplication.translate("options", "Slide", None, QtGui.QApplication.UnicodeUTF8)) self.label_4.setText(QtGui.QApplication.translate("options", "Titolo", None, QtGui.QApplication.UnicodeUTF8)) self.label_5.setText(QtGui.QApplication.translate("options", "Sottotitolo", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("options", "\n" diff --git a/options.ui b/options.ui index ebbb076..39816c4 100644 --- a/options.ui +++ b/options.ui @@ -47,7 +47,7 @@ - + A4 (290mm x 210mm) @@ -68,7 +68,7 @@ - + Testo e accordi @@ -94,7 +94,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -127,38 +127,5 @@ p, li { white-space: pre-wrap; } - - - buttonBox - accepted() - options - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - options - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/songbook-editor.py b/songbook-editor.py index c43f76a..5624598 100755 --- a/songbook-editor.py +++ b/songbook-editor.py @@ -13,8 +13,9 @@ class interface(QtGui.QMainWindow): self.ui = Ui_MainWindow() self.ui.setupUi(self) - # options dialog - self.opt = None + # options Database + self.opt = {} + self.set_default_options() # Create an empty database of songs... self.song_db = [] @@ -42,6 +43,7 @@ class interface(QtGui.QMainWindow): # Menu Canzoniere self.connect(self.ui.actionEsporta_in_LaTeX, QtCore.SIGNAL("activated()"), self.export_songbook) + self.connect(self.ui.actionOpzioni_LaTeX, QtCore.SIGNAL("activated()"), self.options) # Functions to manage events @@ -241,22 +243,59 @@ class interface(QtGui.QMainWindow): def options(self): # self.opt = option_interface() option.show() - -class option_interface(QtGui.QDialog): + def set_default_options(self): + self.opt["paper_size"] = "A5" + self.opt["title"] = "Canzoniere" + self.opt["subtitle"] = "Autore Sconosciuto" + self.opt["type"] = "tc" ## tc = text and chords, c = only chords, s = slide + + + +class option_interface(QtGui.QWidget): def __init__(self, parent=None): + super(option_interface,self).__init__(parent) self.ui = Ui_options() self.ui.setupUi(self) - self.connect(self.ui.buttonBox, QtCore.SIGNAL("accepted()"), self.accepted) + # Options dictionary + self.paper_size_dic = {"A4":1, "A5":2} + - def accepted(self): - print "ciao" + QtCore.QObject.connect(self.ui.buttonBox, QtCore.SIGNAL("accepted()"), self.ok) + self.connect(self.ui.buttonBox, QtCore.SIGNAL("rejected()"), self.cancel) + + def cancel(self): + self.hide() + + def ok(self): + # Set paper size + if(self.ui.paper_size.currentIndex() == 1): + widget.opt["paper_size"] = "A4" + elif(self.ui.paper_size.currentIndex() == 2): + widget.opt["paper_size"] = "A5" + + # Set songbook type + if(self.ui.type.currentIndex() == 1): + widget.opt["type"] = "tc" + elif(self.ui.type.currentIndex() == 2): + widget.opt["type"] = "c" + elif(self.ui.type.currentIndex() == 3): + widget.opt["type"] == "s" + + # Set songbook title + widget.opt["title"] = unicode(self.ui.title.text()) + # Set songbook subtitle + widget.opt["subtitle"] = unicode(self.ui.subtitle.text()) + + # Hide options + self.hide() if __name__ == "__main__": app = QtGui.QApplication(sys.argv) + option = option_interface() lm = latex_manager() widget = interface(lm) widget.show() -- 2.1.4