Пример #1
0
    def setupUI(self):
        # UI signals
        self.searchButton.clicked.connect(self.startSearch)
        self.queryBox.returnPressed.connect(self.startSearch)
        self.zoomSlider.sliderMoved.connect(self.sliderMove)
        self.listWidget.itemEntered.connect(self.itemOver)
        self.listWidget.itemSelectionChanged.connect(self.selectionChanged)
        self.listWidget.itemDoubleClicked.connect(self.doubleClicked)
        self.infoLabel.linkActivated.connect(self.tagSelected)

        # UI event overrides
        self.infoDock.resizeEvent = self.updatePreview

        # UI settings
        pixels = self.zoomSlider.value() * self.SLIDER_MULT
        self.zoomSlider.setToolTip("Size: %i pixels" % pixels)
        self.listWidget.setDragEnabled(False)

        # Add clear button on queryBox
        self.clearButton = QtGui.QPushButton(self.queryBox)
        self.clearButton.setVisible(False)
        self.clearButton.setStyleSheet("QPushButton { border: none; padding: 0px; }")
        self.clearButton.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
        icon = QtGui.QIcon(utils.find_resource(__name__, "ui/query-clear.png"))
        self.clearButton.setIcon(icon)
        self.clearButton.clicked.connect(self.queryBox.clear)
        self.queryBox.textChanged.connect(self.updateClearButton)
        layout = QtGui.QHBoxLayout(self.queryBox)
        self.queryBox.setLayout(layout)
        layout.addStretch()
        layout.addWidget(self.clearButton)

        # add a keyboard shortcut to toggle visibility of the info panel
        shortcut = QtGui.QShortcut(QtGui.QKeySequence("F11"), self)
        shortcut.activated.connect(self.toggleInfoPanel)
Пример #2
0
 def __init__(self, parent=None):
     QtGui.QMainWindow.__init__(self, parent)
     self.ui = uic.loadUi(utils.find_resource(__name__, "ui/danbooru.ui"), self)
     self.setupUI()
     self.loadSettings()
     self.setupThumbnailWorker()
Пример #3
0
        self.thumb.wait()

        self.statusLabel.setText(self.tr("Processing..."))
        self.thumb.setData(query, self.db)

        size = self.zoomSlider.value() * self.SLIDER_MULT
        self.listWidget.setIconSize(QtCore.QSize(size, size))
        self.thumb.start()

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)

    locale = getlocale()
    if locale[0]:
        translator = QtCore.QTranslator(app)
        try:
            resource = utils.find_resource(__file__, "danbooru_gui-%s.qm" % locale[0])
            if translator.load(resource):
                app.installTranslator(translator)
        except Exception:
            try:
                resource = utils.find_resource(__file__, "danbooru_gui-%s.qm" % locale[0].split("_")[0])
                if translator.load(resource):
                    app.installTranslator(translator)
            except Exception:
                pass

    w = DanbooruGUI()
    w.show()
    sys.exit(app.exec_())