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 main_window
import MainWindow
21 from common
import ORGNAME
, APPNAME
, appIcon
22 from mpclient
import MPClient
23 from settings_wg
import SettingsWidget
24 from connect_wg
import ConnectWidget
28 class NephilimApp(QtGui
.QApplication
):
30 # those don't change while the program is running
31 """main window object"""
35 """"plugins interface"""
43 """connection window"""
47 def __init__(self
, argv
):
48 QtGui
.QApplication
.__init
__(self
, argv
)
50 self
.setApplicationName(APPNAME
)
51 self
.setOrganizationName(ORGNAME
)
52 self
.setWindowIcon(QtGui
.QIcon(appIcon
))
59 self
.mpclient
= MPClient(self
)
62 self
.settings
= QtCore
.QSettings(self
)
64 #init connection window
65 self
._connect
_win
= ConnectWidget()
68 self
.main_win
= MainWindow(self
.mpclient
)
71 show_settings
= False # are there new plugins?
72 self
.plugins
= plugins
.Plugins(self
.main_win
, self
.mpclient
)
73 for plugin
in self
.plugins
.plugins():
74 if self
.settings
.value(plugin
.name
+ '/load') == None:
76 if int(self
.settings
.value(plugin
.name
+ '/load', 0)):
77 self
.plugins
.load(plugin
.name
)
79 self
.aboutToQuit
.connect(self
._cleanup
)
83 self
.show_settings_win()
84 self
.main_win
.restore_layout()
85 self
._connect
_win
.monitor()
87 QtGui
.QApplication
.exec_()
90 def show_settings_win(self
):
91 if not self
._settings
_win
:
92 self
._settings
_win
= SettingsWidget(self
.mpclient
, self
.plugins
)
94 self
._settings
_win
.show()
95 self
._settings
_win
.raise_()
97 def show_connect_win(self
):
98 self
._connect
_win
.monitor()
100 def expand_tags(self
, str):
102 ret
= ret
.replace('${musicdir}', self
.settings
.value('MPD/music_dir'))
108 for plugin
in self
.plugins
.loaded_plugins():
111 self
.main_win
.on_quit()