2 # -*- coding: utf-8 -*-
7 from PyQt4
.QtCore
import QFile
, QIODevice
8 from PyQt4
.QtXml
import QDomDocument
9 from PyKDE4
.kdecore
import i18n
10 from PyKDE4
.kdeui
import KMessageBox
, KXmlGuiWindow
11 import shared
, ui_mainw
15 class KlaudiaMainW(KXmlGuiWindow
, ui_mainw
.Ui_KlaudiaMainW
):
16 def __init__(self
, *args
):
17 KXmlGuiWindow
.__init
__(self
, *args
)
20 # Load a project if an argument is given
21 if (shared
.OpenFolder
):
22 url
= shared
.OpenFolder
23 if (path
.exists(url
+"/project.klaudia")):
25 shared
.setIconFromFolder(url
)
27 KMessageBox
.sorry(self
, i18n("The Klaudia project cannot be loaded!"), i18n("Sorry"))
32 filename
= QFile(shared
.p_folder
+"/project.klaudia")
33 if not filename
.open(QIODevice
.ReadOnly
):
35 if not xml
.setContent(filename
):
39 # Check if project file is not corrupted
40 content
= xml
.documentElement()
41 if (content
.tagName() != "KLAUDIA"):
44 # Get values from XML - the big code
45 node
= content
.firstChild()
46 while not node
.isNull():
47 if (node
.toElement().tagName() == "Properties"):
48 properties
= node
.toElement().firstChild()
49 while not properties
.isNull():
50 name
= properties
.toElement().tagName()
51 text
= properties
.toElement().text()
52 if (name
== "Name"): shared
.p_name
= text
53 elif (name
== "Author"): shared
.p_author
= text
54 elif (name
== "Composer"): shared
.p_composer
= text
55 elif (name
== "Album"): shared
.p_album
= text
56 elif (name
== "Track"): shared
.p_track
= text
57 elif (name
== "BPM"): shared
.p_bpm
= text
58 elif (name
== "Time-Start"): shared
.p_time_start
= text
59 elif (name
== "Time-End"): shared
.p_time_end
= text
60 properties
= properties
.nextSibling()
61 node
= node
.nextSibling()