Пример #1
0
    def runWithArguments(self, arguments):
        for _context in self.contexts:
            if _context.isActive():
                return 1

        argValues = processArguments(arguments)
        delay = argValues["delay"]

        savePathValue = argValues["savePath"]

        context = AppContext(argValues)
        if savePathValue != "":
            pic_name = os.path.basename(savePathValue)
            if pic_name == "":
                return 1
            else:
                if not os.path.exists(os.path.dirname(savePathValue)):
                    return 1

        context.settings = self._createContextSettings()
        context.finished.connect(self._contextFinished)
        context.needSound.connect(self._contextNeedSound)
        context.needOSD.connect(self._contextNeedOSD)
        self.contexts.append(context)

        if delay > 0:
            notificationsInterface.notify(
                _("Deepin Screenshot"),
                _("Deepin Screenshot will start after %s seconds.") % delay)
            '''If run the program frequently, the QTimer sometimes do not invoke the event, so replace QTimer with SafeTimer'''
            SafeTimer.singleShot(delay, context.main)
        else:
            context.main()

        return 0
Пример #2
0
    def runWithArguments(self, arguments):
        for _context in self.contexts:
            if _context.isActive():
                return 1

        argValues = processArguments(arguments)
        delay = argValues["delay"]

        savePathValue = argValues["savePath"]

        context = AppContext(argValues)
        if savePathValue != "":
            pic_name = os.path.basename(savePathValue)
            if pic_name == "":
                return 1
            else :
                if not os.path.exists(os.path.dirname(savePathValue)):
                    return 1

        context.settings = self._createContextSettings()
        context.finished.connect(self._contextFinished)
        context.needSound.connect(self._contextNeedSound)
        context.needOSD.connect(self._contextNeedOSD)
        self.contexts.append(context)

        if delay > 0:
            notificationsInterface.notify(_("Deepin Screenshot"),
            _("Deepin Screenshot will start after %s seconds.") % delay)
            '''If run the program frequently, the QTimer sometimes do not invoke the event, so replace QTimer with SafeTimer'''
            SafeTimer.singleShot(delay, context.main)
        else:
            context.main()

        return 0
Пример #3
0
def savePixmap(pixmap, fileName):
    global _notificationId
    global _fileSaveLocation
    pixmap.save(fileName)

    _fileSaveLocation = fileName
    _notificationId = notificationsInterface.notify("Deepin Screenshot", _fileSaveLocation, [ACTION_ID_OPEN, _("View")])
Пример #4
0
def copyPixmap(pixmap):
    global _notificationId
    clipboard = QApplication.clipboard()
    clipboard.clear()
    clipboard.setPixmap(pixmap)

    _notificationId = notificationsInterface.notify("Deepin Screenshot", _("Picture has been saved to clipboard"))
Пример #5
0
 def _notify(self, *args, **kwargs):
     noNotificationValue = self.argValues["noNotification"]
     if noNotificationValue:
         self.finished.emit()
     else:
         return notificationsInterface.notify(_("Deepin Screenshot"), *args,
                                              **kwargs)
Пример #6
0
 def _notify(self, *args, **kwargs):
     noNotificationValue = self.argValues["noNotification"]
     if noNotificationValue:
         self.finished.emit()
     else:
         self._waitNotificationTimer.start()
         time.sleep(1)
         return notificationsInterface.notify(_("Deepin Screenshot"),
                                              *args, **kwargs)
Пример #7
0
 def _notify(self, *args, **kwargs):
     noNotificationValue = self.argValues["noNotification"]
     if noNotificationValue:
         self.finished.emit()
     else:
         self._waitNotificationTimer.start()
         time.sleep(1)
         return notificationsInterface.notify(_("Deepin Screenshot"), *args,
                                              **kwargs)
    def runWithArguments(self, arguments):
        for _context in self.contexts:
            if _context.isActive():
                return

        argValues = processArguments(arguments)
        delay = argValues["delay"]

        self._sound = QSound(SOUND_FILE)
        self._sound.setLoops(1)

        context = AppContext(argValues)
        context.settings = self._createContextSettings()
        context.finished.connect(self._contextFinished)
        context.needSound.connect(self._contextNeedSound)
        context.needOSD.connect(self._contextNeedOSD)
        self.contexts.append(context)

        if delay > 0:
            notificationsInterface.notify(_("Deepin Screenshot"),
            _("Deepin Screenshot will start after %s seconds.") % delay)

        QTimer.singleShot(max(0, delay * 1000), context.main)
Пример #9
0
    fullscreenOption = QCommandLineOption(["f", "fullscreen"],
        "Take a screenshot of the whole screen")
    topWindowOption = QCommandLineOption(["w", "top-window"],
        "Take a screenshot of the most top window")
    savePathOption = QCommandLineOption(["s", "save-path"],
        "Specify a path to save the screenshot", "PATH")
    startFromDesktopOption = QCommandLineOption(["i", "icon"],
        "Indicate that this program's started by clicking desktop file.")

    parser.addOption(delayOption)
    parser.addOption(fullscreenOption)
    parser.addOption(topWindowOption)
    parser.addOption(savePathOption)
    parser.addOption(startFromDesktopOption)
    parser.process(app)

    delayValue = int(parser.value(delayOption) or 0)
    fullscreenValue = bool(parser.isSet(fullscreenOption) or False)
    topWindowValue = bool(parser.isSet(topWindowOption) or False)
    savePathValue = str(parser.value(savePathOption) or "")
    startFromDesktopValue = bool(parser.isSet(startFromDesktopOption) or False)

    if is_service_exist():
        notificationsInterface.notify("Deepin Screenshot",
            _("Deepin Screenshot has been started!"))
    else:
        QTimer.singleShot(max(0, delayValue * 1000), main)

        signal.signal(signal.SIGINT, signal.SIG_DFL)
        sys.exit(app.exec_())