diff options
author | jerous <jerous@gmail.com> | 2008-06-19 16:22:58 +0200 |
---|---|---|
committer | jerous <jerous@gmail.com> | 2008-06-19 16:22:58 +0200 |
commit | 6e537b9c3728e4eea7ba0d4b14d76bdf32d119e5 (patch) | |
tree | ae610e17cb17f97c1e3771300b268cde260ed2f3 /winMain.py | |
parent | 5f2db6585fe707c6eaa90e4c32c484a2cacbc3f5 (diff) |
layout menu is updated when loading/unloading dock widgets
Diffstat (limited to 'winMain.py')
-rw-r--r-- | winMain.py | 66 |
1 files changed, 37 insertions, 29 deletions
@@ -28,6 +28,7 @@ class winMain(QtGui.QMainWindow): " menus" mConnect=None mDisconnect=None + mLayout=None " connection window" wConnect=None @@ -41,19 +42,8 @@ class winMain(QtGui.QMainWindow): QtGui.QWidget.__init__(self, parent) self.setWindowTitle("montypc - An MPD client") - self.plugins={} - newPlugins=False # are there new plugins? - for p in plugins.listPlugins(): - pkg,name=p[0],p[1] - # WARNING - dirty hack ahead! - plugin=eval('%s.%s'%(pkg,name))(self) - newPlugins=newPlugins|(settings.get('%s.load'%(plugin.getName(True)), None)==None) - self.plugins[plugin.getName().lower()]=plugin - if settings.get('%s.load'%(plugin.getName(True)), '1')=='1': - # load new plugins by default - plugin.load() self.wConnect=winConnect() - + self.statusBar() # create a statusbar mBar=self.menuBar() # create a menubar # menu file @@ -77,24 +67,22 @@ class winMain(QtGui.QMainWindow): m.addAction("Settings", self.showWinSettings).setIcon(QtGui.QIcon('gfx/gtk-preferences.svg')) # menu layout - m=mBar.addMenu("Layout") - m.setTearOffEnabled(True) - m.addAction('Save layout', self.saveLayout) - m.addAction('Restore layout', self.restoreLayout) - m.addSeparator() - # create checkable menu - a=QtGui.QAction('Show titlebars', self) - a.setCheckable(True) - a.setChecked(settings.get('winMain.show.titlebars', '1')=='1') - self.toggleTitleBars(a.isChecked()) - self.connect(a, QtCore.SIGNAL('toggled(bool)'), self.toggleTitleBars) - m.addAction(a) - m.addSeparator() - # can not use iterators, as that gives some creepy error 'bout c++ - actions=self.createPopupMenu().actions() - for i in xrange(len(actions)): - m.addAction(actions[i]) + self.mLayout=mBar.addMenu("Layout") + self.mLayout.setTearOffEnabled(True) + self.plugins={} + newPlugins=False # are there new plugins? + for p in plugins.listPlugins(): + pkg,name=p[0],p[1] + # WARNING - dirty hack ahead! + plugin=eval('%s.%s'%(pkg,name))(self) + newPlugins=newPlugins|(settings.get('%s.load'%(plugin.getName(True)), None)==None) + self.plugins[plugin.getName().lower()]=plugin + if settings.get('%s.load'%(plugin.getName(True)), '1')=='1': + # load new plugins by default + plugin.load() + + self.updateLayoutMenu() self.setDockOptions(QtGui.QMainWindow.AllowNestedDocks \ |QtGui.QMainWindow.AllowTabbedDocks \ |QtGui.QMainWindow.VerticalTabs) @@ -126,6 +114,24 @@ class winMain(QtGui.QMainWindow): self.showWinSettings() doEvents() + def updateLayoutMenu(self): + self.mLayout.clear() + self.mLayout.addAction('Save layout', self.saveLayout) + self.mLayout.addAction('Restore layout', self.restoreLayout) + self.mLayout.addSeparator() + # create checkable menu + a=QtGui.QAction('Show titlebars', self) + a.setCheckable(True) + a.setChecked(settings.get('winMain.show.titlebars', '1')=='1') + self.toggleTitleBars(a.isChecked()) + self.connect(a, QtCore.SIGNAL('toggled(bool)'), self.toggleTitleBars) + self.mLayout.addAction(a) + self.mLayout.addSeparator() + # can not use iterators, as that gives some creepy error 'bout c++ + actions=self.createPopupMenu().actions() + for i in xrange(len(actions)): + self.mLayout.addAction(actions[i]) + def toggleTitleBars(self, val): if val: settings.set('winMain.show.titlebars', '1') @@ -147,10 +153,12 @@ class winMain(QtGui.QMainWindow): if dock: self.docks.append(dock) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock) + self.updateLayoutMenu() def removeDock(self, dock): if dock: self.docks.remove(dock) self.removeDockWidget(dock) + self.updateLayoutMenu() mMenuVisible=None def createPopupMenu(self): |