Exemplo n.º 1
0
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Expanding)

        self.control = Controller()

        self.centralWidget = CentralWidget(self.control)
        self.setCentralWidget(self.centralWidget)

        self.createActions()
        self.createMenus()

        self.control.start()
Exemplo n.º 2
0
class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Expanding)

        self.control = Controller()

        self.centralWidget = CentralWidget(self.control)
        self.setCentralWidget(self.centralWidget)

        self.createActions()
        self.createMenus()

        self.control.start()

    def createActions(self):
        self.exitAct = QtGui.QAction("E&xit", self)
        self.exitAct.setShortcut("Ctrl+Q")
        self.exitAct.setStatusTip("Exit the application")
        self.connect(self.exitAct, QtCore.SIGNAL("triggered()"),
                     self, QtCore.SLOT("close()"))

        self.openDBAct = QtGui.QAction("&Open database...", self)
        self.openDBAct.setShortcut("Ctrl+O")
        self.openDBAct.setStatusTip("Open a database file")
        self.connect(self.openDBAct, QtCore.SIGNAL("triggered()"),
                     self.control.loadDB)

        self.actionSortByAlpha = QtGui.QAction("Sort tags alphabetically", self)
        self.actionSortByAlpha.setCheckable(True)
        self.connect(self.actionSortByAlpha, QtCore.SIGNAL("triggered()"),
                        self.centralWidget.taglist.sortModeChanged)

        self.actionOpenWith = QtGui.QAction("Open with...", self)

        self.actionCopyImagePath = QtGui.QAction("Copy image path", self)
        self.actionCopyImagePath.setShortcut("Ctrl+C")

        self.actionAbout = QtGui.QAction("About", self)
        self.actionAbout.setStatusTip("Show an about box.")
        self.connect(self.actionAbout, QtCore.SIGNAL("activated()"),
                     self.slotAbout)

        self.actionAboutQt = QtGui.QAction("About &Qt", self)
        self.actionAboutQt.setStatusTip("Show an about box for Qt.")
        self.connect(self.actionAboutQt, QtCore.SIGNAL("activated()"),
                     self.slotAboutQt)

    def createMenus(self):
        # File menu
        self.fileMenu = self.menuBar().addMenu("&File")
        self.fileMenu.addAction(self.openDBAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.exitAct)

        # Edit menu
        self.editMenu = self.menuBar().addMenu("&Edit")
        self.editMenu.addAction(self.actionOpenWith)
        self.editMenu.addAction(self.actionCopyImagePath)
        self.editMenu.addAction(self.actionSortByAlpha)


        # Help menu
        self.helpMenu = self.menuBar().addMenu("&Help")
        self.helpMenu.addAction(self.actionAboutQt)
        self.helpMenu.addAction(self.actionAbout)

    def slotAbout(self):
        QtGui.QMessageBox.about(self,
                            "ragtag",
                            "<h1>Ragtag</h1>"
                            "A simple, tag-based image collection browser<br/>"
                            "<a href='https://github.com/ijanos/ragtag'>"
                            "https://github.com/ijanos/ragtag</a>")

    def slotAboutQt(self):
        QtGui.QMessageBox.aboutQt(self)

    def sizeHint(self):
        return QtCore.QSize(1900,700)