summaryrefslogtreecommitdiff
path: root/nephilim/nephilim_app.py
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-06-19 10:49:54 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-06-19 10:49:54 +0200
commit27e27a05b82e4a64123c30cc8261e9e69cd1bea3 (patch)
tree953bc9b71b032929878b4702a9915dfd469b8bff /nephilim/nephilim_app.py
parentcfbaa2bde498f61bde1d565c66742eb5875d8f2c (diff)
Split some parts of winMain into a subclass of QApplication.
Diffstat (limited to 'nephilim/nephilim_app.py')
-rw-r--r--nephilim/nephilim_app.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/nephilim/nephilim_app.py b/nephilim/nephilim_app.py
new file mode 100644
index 0000000..00cb8b4
--- /dev/null
+++ b/nephilim/nephilim_app.py
@@ -0,0 +1,91 @@
+#
+# Copyright (C) 2009 Anton Khirnov <wyskas@gmail.com>
+#
+# Nephilim is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Nephilim is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from PyQt4 import QtGui, QtCore
+
+from winMain import winMain
+from misc import ORGNAME, APPNAME, appIcon
+from mpclient import MPClient
+from settings_wg import SettingsWidget
+import plugins
+
+class NephilimApp(QtGui.QApplication):
+ "main window object"
+ main_win = None
+ "MPD layer"
+ mpclient = None
+ "plugins interface"
+ plugins = None
+ "settings object"
+ settings = None
+ "settings window"
+ settings_win = None
+
+ def __init__(self, argv):
+ QtGui.QApplication.__init__(self, argv)
+
+ self.setApplicationName(APPNAME)
+ self.setOrganizationName(ORGNAME)
+ self.setWindowIcon(QtGui.QIcon(appIcon))
+
+ def exec_(self):
+ #init MPD layer
+ self.mpclient = MPClient()
+
+ #init settings
+ self.settings = QtCore.QSettings()
+
+ #init main window
+ self.main_win = winMain()
+
+ #init plugins
+ show_settings = False # are there new plugins?
+ self.plugins = plugins.Plugins(self.main_win, self.mpclient)
+ for plugin in self.plugins.plugins():
+ if self.settings.value(plugin.name() + '/load') == None:
+ show_settings = True
+ if self.settings.value(plugin.name() + '/load', QtCore.QVariant(True)).toBool():
+ self.plugins.load(plugin.name())
+
+ self.connect(self, QtCore.SIGNAL('aboutToQuit()'), self.cleanup)
+
+ self.main_win.restore_layout()
+ QtGui.QApplication.exec_()
+
+ def cleanup(self):
+ # unload all plugins
+ for plugin in self.plugins.loaded_plugins():
+ plugin.unload()
+
+ self.main_win.on_quit()
+ self.settings.sync()
+
+ def show_settings_win(self):
+ if not self.settings_win:
+ self.settings_win = SettingsWidget(self.mpclient, self.plugins)
+
+ self.connect(self.settings_win, QtCore.SIGNAL('destroyed()'), self.__del_settings_win)
+ self.settings_win.show()
+ self.settings_win.raise_()
+
+ def __del_settings_win(self):
+ self.settings_win = None
+
+ def expand_tags(self, str):
+ ret = str
+ ret = ret.replace('$musicdir', self.settings.value('MPD/music_dir').toString())
+ return ret