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
19 from string
import Template
21 from main_window
import MainWindow
22 from common
import ORGNAME
, APPNAME
, appIcon
23 from mpclient
import MPClient
24 from settings_wg
import SettingsWidget
25 from connect_wg
import ConnectWidget
29 class NephilimApp(QtGui
.QApplication
):
31 # those don't change while the program is running
32 """main window object"""
36 """"plugins interface"""
44 """connection window"""
48 def __init__(self
, argv
):
49 QtGui
.QApplication
.__init
__(self
, argv
)
51 self
.setApplicationName(APPNAME
)
52 self
.setOrganizationName(ORGNAME
)
53 self
.setWindowIcon(QtGui
.QIcon(appIcon
))
60 self
.mpclient
= MPClient(self
)
63 self
.settings
= QtCore
.QSettings(self
)
65 #init connection window
66 self
._connect
_win
= ConnectWidget()
69 self
.main_win
= MainWindow(self
.mpclient
)
72 show_settings
= False # are there new plugins?
73 self
.plugins
= plugins
.Plugins(self
.main_win
, self
.mpclient
)
74 for plugin
in self
.plugins
.plugins():
75 if self
.settings
.value(plugin
.name
+ '/load') == None:
77 if int(self
.settings
.value(plugin
.name
+ '/load', 0)):
78 self
.plugins
.load(plugin
.name
)
80 self
.aboutToQuit
.connect(self
._cleanup
)
84 self
.show_settings_win()
85 self
.main_win
.restore_layout()
86 self
._connect
_win
.monitor()
88 QtGui
.QApplication
.exec_()
91 def show_settings_win(self
):
92 if not self
._settings
_win
:
93 self
._settings
_win
= SettingsWidget(self
.mpclient
, self
.plugins
)
95 self
._settings
_win
.show()
96 self
._settings
_win
.raise_()
98 def show_connect_win(self
):
99 self
._connect
_win
.monitor()
101 def expand_tags(self
, str):
102 replacements
= {'musicdir' : self
.settings
.value('MPD/music_dir')}
104 ret
= ret
.safe_substitute(replacements
)
110 for plugin
in self
.plugins
.loaded_plugins():
113 self
.main_win
.on_quit()