2 # Copyright (C) 2009 Anton Khirnov <wyskas@gmail.com>
4 # Nephilim is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # Nephilim is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
18 from PyQt4
import QtGui
, QtCore
20 from winMain
import winMain
21 from misc
import ORGNAME
, APPNAME
, appIcon
22 from mpclient
import MPClient
23 from settings_wg
import SettingsWidget
26 class NephilimApp(QtGui
.QApplication
):
41 def __init__(self
, argv
):
42 QtGui
.QApplication
.__init
__(self
, argv
)
44 self
.setApplicationName(APPNAME
)
45 self
.setOrganizationName(ORGNAME
)
46 self
.setWindowIcon(QtGui
.QIcon(appIcon
))
50 self
.mpclient
= MPClient()
53 self
.settings
= QtCore
.QSettings()
56 self
.main_win
= winMain()
59 show_settings
= False # are there new plugins?
60 self
.plugins
= plugins
.Plugins(self
.main_win
, self
.mpclient
)
61 for plugin
in self
.plugins
.plugins():
62 if self
.settings
.value(plugin
.name() + '/load') == None:
64 if self
.settings
.value(plugin
.name() + '/load', QtCore
.QVariant(True)).toBool():
65 self
.plugins
.load(plugin
.name())
67 self
.connect(self
, QtCore
.SIGNAL('aboutToQuit()'), self
.__cleanup
)
70 self
.show_settings_win()
71 self
.main_win
.restore_layout()
72 QtGui
.QApplication
.exec_()
76 for plugin
in self
.plugins
.loaded_plugins():
79 self
.main_win
.on_quit()
82 def show_settings_win(self
):
83 if not self
.__settings
_win
:
84 self
.__settings
_win
= SettingsWidget(self
.mpclient
, self
.plugins
)
86 self
.connect(self
.__settings
_win
, QtCore
.SIGNAL('destroyed()'), self
.__del
_settings
_win
)
87 self
.__settings
_win
.show()
88 self
.__settings
_win
.raise_()
90 def __del_settings_win(self
):
91 self
.__settings
_win
= None
93 def expand_tags(self
, str):
95 ret
= ret
.replace('$musicdir', self
.settings
.value('MPD/music_dir').toString())