Beispiel #1
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setWindowTitle("Audiolog Music Organizer")
        self.confDialog = ConfigurationDialog(self)

        self.directoryPathsToScan = []
        self.running = False

        # Load icons
        iconsPath = os.path.join(os.path.dirname(__file__), "..", "..",
                                 "icons")
        playIcon = QIcon(os.path.join(iconsPath, "play.png"))
        pauseIcon = QIcon(os.path.join(iconsPath, "pause.png"))
        stopIcon = QIcon(os.path.join(iconsPath, "stop.png"))
        confIcon = QIcon(os.path.join(iconsPath, "configure.png"))
        logIcon = QIcon(os.path.join(iconsPath, "log.png"))

        # Menu and Status Bars
        self.setMenuBar(MenuBar(self))
        self.statusBar = self.statusBar()

        # Top-Level Frame
        self.topLevelFrame = QFrame(self)

        # Graphics Frame
        self.graphicsFrame = GraphicsFrame(self.topLevelFrame)

        # Paths Frame
        self.pathsFrame = PathsFrame(self.topLevelFrame)

        # Button Frame
        self.buttonFrame = QFrame(self.topLevelFrame)
        self.flowButton = QPushButton("Start", icon=playIcon)
        self.stopButton = QPushButton("Stop", icon=stopIcon)
        self.confButton = QPushButton("Configure...", icon=confIcon)
        self.logButton = QPushButton("Show Log", icon=logIcon, checkable=True)
        self.stopButton.setEnabled(False)

        self.connect(self.flowButton, SIGNAL("clicked(bool)"), self.manageFlow)
        self.connect(self.stopButton, SIGNAL("clicked(bool)"), self.stop)
        self.connect(self.confButton, SIGNAL("clicked(bool)"),
                     self.confDialog.show)
        self.connect(self.logButton, SIGNAL("clicked(bool)"), self.toggleLog)
        self.connect(flowcontrol.emitter, SIGNAL("RunEnded"), self.runEnded)

        buttonLayout = QHBoxLayout(self.buttonFrame)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.flowButton, 3)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.stopButton, 3)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.confButton, 3)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.logButton, 3)
        buttonLayout.addStretch(1)

        # Stop Button Menu (Now and Cleanly)
        stopNow = QAction("Now", self.stopButton)
        stopCleanly = QAction("After Current Directory", self.stopButton)
        self.connect(stopNow, SIGNAL("triggered()"), self.stop)
        self.connect(stopCleanly, SIGNAL("triggered()"),
                     partial(self.stop, True))

        stopMenu = QMenu(self.stopButton)
        stopMenu.addAction(stopNow)
        stopMenu.addAction(stopCleanly)
        self.stopButton.setMenu(stopMenu)

        # Log Frame
        self.logFrame = LogFrame(self.topLevelFrame)
        self.logFrame.setSizePolicy(QSizePolicy.MinimumExpanding,
                                    QSizePolicy.MinimumExpanding)
        self.logFrame.hide()

        # Top-Level Frame Layout
        layout = QVBoxLayout(self.topLevelFrame)
        layout.addWidget(self.graphicsFrame)
        layout.addWidget(self.pathsFrame)
        layout.addWidget(self.buttonFrame)
        layout.addWidget(self.logFrame)

        # Makes window shrink back down again after log is hidden.
        layout.setSizeConstraint(QLayout.SetFixedSize)
        self.layout().setSizeConstraint(QLayout.SetFixedSize)

        self.setCentralWidget(self.topLevelFrame)