示例#1
0
	def __init__ (self, app):
		QMainWindow.__init__ (self)
		self.app = app

		self.innerName = ""
		
		self.setWindowTitle ("MP")

		self.setWindowState (Qt.WindowMaximized)
		
		#self.resize (800, 600)
		
		self.menuBar ().addMenu (_("&File")).addAction (_("Rearrange window contents")).triggered.connect (lambda:self.layoutOuter.setRearrangeable (not self.layoutOuter.rearrangeable ()))
		
		self.toolbar = self.addToolBar ("blub")
		self.toolbar.addAction (QIcon ("images/play.png"), _("Play")).triggered.connect (self.app.playpause)
		self.toolbar.addAction (QIcon ("images/skip.png"), _("Skip")).triggered.connect (self.app.skip)
		
		self.setupPlayingWidget ()
		self.toolbar.addWidget (self.playingWidget).setVisible (True)

		self.mainbox = QVBoxLayout ()
		self.central = QWidget ()
		self.central.setLayout (self.mainbox)
		self.setCentralWidget (self.central)

		self.layoutOuter = QRearrangeableLayout (app)
		self.layoutOuterBox = QHBoxLayout ()
		self.layoutOuterBox.setContentsMargins (QMargins (0, 0, 0, 0))
		self.layoutOuter.setLayout (self.layoutOuterBox)
		self.mainbox.addWidget (self.layoutOuter)

		self.layoutInner = QRearrangeableLayout (app)
		self.layoutInnerBox = QHBoxLayout ()
		self.layoutInnerBox.setContentsMargins (QMargins (0, 0, 0, 0))
		self.layoutInner.setLayout (self.layoutInnerBox)
		#self.layoutOuterBox.addWidget (self.layoutInner)

		# Navigation widget
		#self.navigation = Navigation.Navigation (self.app)

		# Loader
		self.loaderOuter = QRearrangeableLayoutLoader (self.layoutOuter)
		self.loaderInner = QRearrangeableLayoutLoader (self.layoutInner)

		self.loaderOuter.registerWidget ("innerLayout", self.layoutInner)

		self.show ()
示例#2
0
class MainWindow (QMainWindow):
	
	def __init__ (self, app):
		QMainWindow.__init__ (self)
		self.app = app

		self.innerName = ""
		
		self.setWindowTitle ("MP")

		self.setWindowState (Qt.WindowMaximized)
		
		#self.resize (800, 600)
		
		self.menuBar ().addMenu (_("&File")).addAction (_("Rearrange window contents")).triggered.connect (lambda:self.layoutOuter.setRearrangeable (not self.layoutOuter.rearrangeable ()))
		
		self.toolbar = self.addToolBar ("blub")
		self.toolbar.addAction (QIcon ("images/play.png"), _("Play")).triggered.connect (self.app.playpause)
		self.toolbar.addAction (QIcon ("images/skip.png"), _("Skip")).triggered.connect (self.app.skip)
		
		self.setupPlayingWidget ()
		self.toolbar.addWidget (self.playingWidget).setVisible (True)

		self.mainbox = QVBoxLayout ()
		self.central = QWidget ()
		self.central.setLayout (self.mainbox)
		self.setCentralWidget (self.central)

		self.layoutOuter = QRearrangeableLayout (app)
		self.layoutOuterBox = QHBoxLayout ()
		self.layoutOuterBox.setContentsMargins (QMargins (0, 0, 0, 0))
		self.layoutOuter.setLayout (self.layoutOuterBox)
		self.mainbox.addWidget (self.layoutOuter)

		self.layoutInner = QRearrangeableLayout (app)
		self.layoutInnerBox = QHBoxLayout ()
		self.layoutInnerBox.setContentsMargins (QMargins (0, 0, 0, 0))
		self.layoutInner.setLayout (self.layoutInnerBox)
		#self.layoutOuterBox.addWidget (self.layoutInner)

		# Navigation widget
		#self.navigation = Navigation.Navigation (self.app)

		# Loader
		self.loaderOuter = QRearrangeableLayoutLoader (self.layoutOuter)
		self.loaderInner = QRearrangeableLayoutLoader (self.layoutInner)

		self.loaderOuter.registerWidget ("innerLayout", self.layoutInner)

		self.show ()


	def load (self):
		self.loaderOuter.load (os.getenv ("HOME") + '/.mp/layoutOuter.xml')


	def closeEvent (self, event):
		if self.innerName != "":
			self.loaderInner.save (os.getenv ("HOME") + '/.mp/layouts/' + self.innerName + '.xml')
		self.loaderOuter.save (os.getenv ("HOME") + '/.mp/layoutOuter.xml')


	def setInnerLayout (self, name, initialCreate):

		if name == self.innerName:
			return

		# save old layout
		if self.innerName != "":
			self.loaderInner.save (os.getenv ("HOME") + '/.mp/layouts/' + self.innerName + '.xml')

		try:
			self.loaderInner.load (os.getenv ("HOME") + '/.mp/layouts/' + name + '.xml')
		except (IOError):
			widget = initialCreate ()

			self.layoutInner.layout ().removeItem (self.layoutInner.layout ().itemAt (0))
			self.layoutInner.layout ().addWidget (widget)

		self.innerName = name


	def setupPlayingWidget (self):
		
		self.playingWidget = QLabel (_("Stopped"))
		self.playingWidget.setMargin (5)
		
		self.app.trackChanged.connect (self.updatePlayingWidget)
	
	def updatePlayingWidget (self, track):
		
		if track == None:
			text = _("Stopped")
		else:
			text = _("Currently playing:") + " " + track
		
		self.playingWidget.setText (text)

	"""