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
24 from connect_wg
import ConnectWidget
27 class NephilimApp(QtGui
.QApplication
):
44 def __init__(self
, argv
):
45 QtGui
.QApplication
.__init
__(self
, argv
)
47 self
.setApplicationName(APPNAME
)
48 self
.setOrganizationName(ORGNAME
)
49 self
.setWindowIcon(QtGui
.QIcon(appIcon
))
53 self
.mpclient
= MPClient()
56 self
.settings
= QtCore
.QSettings()
58 #init connection window
59 self
.__connect
_win
= ConnectWidget()
62 self
.main_win
= winMain(self
.mpclient
)
65 show_settings
= False # are there new plugins?
66 self
.plugins
= plugins
.Plugins(self
.main_win
, self
.mpclient
)
67 for plugin
in self
.plugins
.plugins():
68 if self
.settings
.value(plugin
.name
+ '/load') == None:
70 if self
.settings
.value(plugin
.name
+ '/load', QtCore
.QVariant(True)).toBool():
71 self
.plugins
.load(plugin
.name
)
73 self
.connect(self
, QtCore
.SIGNAL('aboutToQuit()'), self
.__cleanup
)
77 self
.show_settings_win()
78 self
.main_win
.restore_layout()
79 self
.__connect
_win
.monitor()
81 QtGui
.QApplication
.exec_()
85 for plugin
in self
.plugins
.loaded_plugins():
88 self
.main_win
.on_quit()
91 def show_settings_win(self
):
92 if not self
.__settings
_win
:
93 self
.__settings
_win
= SettingsWidget(self
.mpclient
, self
.plugins
)
95 self
.connect(self
.__settings
_win
, QtCore
.SIGNAL('destroyed()'), self
.__del
_settings
_win
)
96 self
.__settings
_win
.show()
97 self
.__settings
_win
.raise_()
98 def show_connect_win(self
):
99 self
.__connect
_win
.monitor()
101 def __del_settings_win(self
):
102 self
.__settings
_win
= None
104 def expand_tags(self
, str):
106 ret
= ret
.replace('$musicdir', self
.settings
.value('MPD/music_dir').toString())