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
Exemple #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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Deepin Technology Co., Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

import sys

from PyQt5 import QtCore

from safe_timer import SafeTimer

def timerCallback():
    print("timer callback")
    #sys.exit(0)
    #QtCore.QCoreApplication.instance().exit(0)

if __name__ == '__main__':
    app = QtCore.QCoreApplication([])
#    t = SafeTimer()
#    t.setInterval(1)
#    t.setRepeat(2)
#    t.timeout.connect(timerCallback)
#    t.start()
    SafeTimer.singleShot(1, timerCallback)
    app.exec_()
Exemple #4
0
#
# Copyright (C) 2015 Deepin Technology Co., Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

import sys

from PyQt5 import QtCore

from safe_timer import SafeTimer


def timerCallback():
    print("timer callback")
    #sys.exit(0)
    #QtCore.QCoreApplication.instance().exit(0)


if __name__ == '__main__':
    app = QtCore.QCoreApplication([])
    #    t = SafeTimer()
    #    t.setInterval(1)
    #    t.setRepeat(2)
    #    t.timeout.connect(timerCallback)
    #    t.start()
    SafeTimer.singleShot(1, timerCallback)
    app.exec_()