Icone per il menù

Leonardo Robol [2009-06-20 16:49]
Icone per il menù
Filename
songbook-editor.py
ui/images/apri.png
ui/images/esci.png
ui/images/save.png
ui/interface.py
ui/interface.ui
diff --git a/songbook-editor.py b/songbook-editor.py
index 34f3299..a457a8f 100755
--- a/songbook-editor.py
+++ b/songbook-editor.py
@@ -39,6 +39,8 @@ class interface(QtGui.QMainWindow):
         self.connect(self.ui.list_songs, QtCore.SIGNAL("currentTextChanged ( QString )"), self.item_selected)
         self.connect(self.ui.btn_new_song, QtCore.SIGNAL("clicked()"), self.new_song)
         self.connect(self.ui.btn_delete_song, QtCore.SIGNAL("clicked()"), self.delete_item_from_list)
+        self.connect(self.ui.btn_list_move_down, QtCore.SIGNAL("clicked()"), self.list_move_down)
+        self.connect(self.ui.btn_list_move_up, QtCore.SIGNAL("clicked()"), self.list_move_up)

         # Menu File
         self.connect(self.ui.actionSalva, QtCore.SIGNAL("activated()"), self.save_songbook)
@@ -92,6 +94,12 @@ class interface(QtGui.QMainWindow):

         return newsong

+    def get_active_song_in_list(self):
+        newsong = self.get_active_song()
+        for song in self.song_db:
+            if( (song.title == newsong.title) ):
+                return song
+
     # Add a new song in the db, and update the list
     def add_song_to_db(self, song):
         self.song_db.append(song)
@@ -112,6 +120,33 @@ class interface(QtGui.QMainWindow):
         if(need_new_song):
             self.add_song_to_db(song_to_save)

+    def get_item_from_song(self, song):
+        self.list_update()
+        ind = self.song_db.index(song)
+        return self.ui.list_songs.item(ind)
+
+    def list_move_up(self):
+        song = self.get_active_song_in_list()
+        ind = self.song_db.index(song)
+        if(ind == 0):
+            return
+        self.song_db.pop(ind)
+        self.song_db.insert(ind-1, song)
+        self.list_update()
+        self.ui.list_songs.setItemSelected(self.get_item_from_song(song), 1)
+
+    def list_move_down(self):
+        song = self.get_active_song_in_list()
+        ind = self.song_db.index(song)
+        if(ind == len(self.song_db)):
+            return
+        self.song_db.pop(ind)
+        self.song_db.insert(ind+1, song)
+        self.list_update()
+        self.ui.list_songs.setItemSelected(self.get_item_from_song(song), 1)
+
+
+
     # Export song to a rcs file
     def save_song_to_file(self):
         filename = QtGui.QFileDialog.getSaveFileName(self, "Salva Canzone", "", "Canzoni di RobolCanzoniere (*.rcs)")
@@ -140,6 +175,8 @@ class interface(QtGui.QMainWindow):
             handle = open(filename, 'r')
             buf = handle.read().decode("utf-8")
             handle.close()
+        else:
+            return
         song_list = buf.split(self.sep_song)
         self.song_db = []
         for raw_song in song_list:
diff --git a/ui/images/apri.png b/ui/images/apri.png
new file mode 100644
index 0000000..8872ebe
Binary files /dev/null and b/ui/images/apri.png differ
diff --git a/ui/images/esci.png b/ui/images/esci.png
new file mode 100644
index 0000000..7ea55cc
Binary files /dev/null and b/ui/images/esci.png differ
diff --git a/ui/images/save.png b/ui/images/save.png
new file mode 100644
index 0000000..47c6fc2
Binary files /dev/null and b/ui/images/save.png differ
diff --git a/ui/interface.py b/ui/interface.py
index 1b252b3..8825455 100644
--- a/ui/interface.py
+++ b/ui/interface.py
@@ -2,7 +2,7 @@

 # Form implementation generated from reading ui file 'interface.ui'
 #
-# Created: Sat Jun 20 17:44:08 2009
+# Created: Sat Jun 20 18:49:32 2009
 #      by: PyQt4 UI code generator 4.4.4
 #
 # WARNING! All changes made in this file will be lost!
@@ -158,6 +158,9 @@ class Ui_MainWindow(object):
         self.horizontalLayout_2.addWidget(self.btn_create_pdf)
         self.gridLayout.addLayout(self.horizontalLayout_2, 2, 1, 2, 1)
         self.label_6 = QtGui.QLabel(self.gridLayoutWidget)
+        font = QtGui.QFont()
+        font.setPointSize(10)
+        self.label_6.setFont(font)
         self.label_6.setTextFormat(QtCore.Qt.RichText)
         self.label_6.setAlignment(QtCore.Qt.AlignCenter)
         self.label_6.setObjectName("label_6")
@@ -180,12 +183,21 @@ class Ui_MainWindow(object):
         self.statusbar.setObjectName("statusbar")
         MainWindow.setStatusBar(self.statusbar)
         self.actionApri = QtGui.QAction(MainWindow)
+        icon2 = QtGui.QIcon()
+        icon2.addPixmap(QtGui.QPixmap("ui/images/apri.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+        self.actionApri.setIcon(icon2)
         self.actionApri.setObjectName("actionApri")
         self.actionEsci = QtGui.QAction(MainWindow)
         self.actionEsci.setObjectName("actionEsci")
         self.actionSalva = QtGui.QAction(MainWindow)
+        icon3 = QtGui.QIcon()
+        icon3.addPixmap(QtGui.QPixmap("ui/images/save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+        self.actionSalva.setIcon(icon3)
         self.actionSalva.setObjectName("actionSalva")
         self.actionEsci_2 = QtGui.QAction(MainWindow)
+        icon4 = QtGui.QIcon()
+        icon4.addPixmap(QtGui.QPixmap("ui/images/esci.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+        self.actionEsci_2.setIcon(icon4)
         self.actionEsci_2.setObjectName("actionEsci_2")
         self.actionSalva_canzone = QtGui.QAction(MainWindow)
         self.actionSalva_canzone.setObjectName("actionSalva_canzone")
@@ -231,12 +243,12 @@ class Ui_MainWindow(object):
         self.label_6.setText(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
 "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
 "p, li { white-space: pre-wrap; }\n"
-"</style></head><body style=\" font-family:\'Droid Sans\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
+"</style></head><body style=\" font-family:\'Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
 "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">Lista Canzoni</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
         self.label_7.setText(QtGui.QApplication.translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
 "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
 "p, li { white-space: pre-wrap; }\n"
-"</style></head><body style=\" font-family:\'Droid Sans\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
+"</style></head><body style=\" font-family:\'Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
 "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">Canzone selezionata</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
         self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "File", None, QtGui.QApplication.UnicodeUTF8))
         self.menuCanzoniere.setTitle(QtGui.QApplication.translate("MainWindow", "Canzoniere", None, QtGui.QApplication.UnicodeUTF8))
diff --git a/ui/interface.ui b/ui/interface.ui
index 9e8b503..8fe0a64 100644
--- a/ui/interface.ui
+++ b/ui/interface.ui
@@ -242,11 +242,16 @@
      </item>
      <item row="0" column="0">
       <widget class="QLabel" name="label_6">
+       <property name="font">
+        <font>
+         <pointsize>10</pointsize>
+        </font>
+       </property>
        <property name="text">
         <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Droid Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Lista Canzoni&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
        </property>
        <property name="textFormat">
@@ -263,7 +268,7 @@ p, li { white-space: pre-wrap; }
         <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Droid Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Canzone selezionata&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
        </property>
       </widget>
@@ -311,6 +316,10 @@ p, li { white-space: pre-wrap; }
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
   <action name="actionApri">
+   <property name="icon">
+    <iconset>
+     <normaloff>ui/images/apri.png</normaloff>ui/images/apri.png</iconset>
+   </property>
    <property name="text">
     <string>Apri</string>
    </property>
@@ -321,11 +330,19 @@ p, li { white-space: pre-wrap; }
    </property>
   </action>
   <action name="actionSalva">
+   <property name="icon">
+    <iconset>
+     <normaloff>ui/images/save.png</normaloff>ui/images/save.png</iconset>
+   </property>
    <property name="text">
     <string>Salva</string>
    </property>
   </action>
   <action name="actionEsci_2">
+   <property name="icon">
+    <iconset>
+     <normaloff>ui/images/esci.png</normaloff>ui/images/esci.png</iconset>
+   </property>
    <property name="text">
     <string>Esci</string>
    </property>
ViewGit