Example #1
0
    def __init__(self, opts, log, cover_data=None, toc=None):
        from calibre.gui2 import must_use_qt
        must_use_qt()
        QObject.__init__(self)

        self.logger = self.log = log
        self.mathjax_dir = P('mathjax', allow_user_override=False)
        current_log(log)
        self.opts = opts
        self.cover_data = cover_data
        self.paged_js = None
        self.toc = toc

        self.loop = QEventLoop()
        self.view = QWebView()
        self.page = Page(opts, self.log)
        self.view.setPage(self.page)
        self.view.setRenderHints(QPainter.Antialiasing
                                 | QPainter.TextAntialiasing
                                 | QPainter.SmoothPixmapTransform)
        self.view.loadFinished.connect(self.render_html,
                                       type=Qt.QueuedConnection)
        self.view.loadProgress.connect(self.load_progress)
        self.ignore_failure = None
        self.hang_check_timer = t = QTimer(self)
        t.timeout.connect(self.hang_check)
        t.setInterval(1000)

        for x in (Qt.Horizontal, Qt.Vertical):
            self.view.page().mainFrame().setScrollBarPolicy(
                x, Qt.ScrollBarAlwaysOff)
        self.report_progress = lambda x, y: x
        self.current_section = ''
        self.current_tl_section = ''
Example #2
0
 def __init__(self, parent):
     QObject.__init__(self, parent)
     self._parent = parent
     self.VERSION = parent.VERSION
     self._home = os.path.expanduser('~')
     self._key_directory = os.path.join(self._home, '.brickton', 'keys')
     self._file_directory = os.path.join(self._home, '.brickton', 'files')
     self._export_directory = os.path.join(self._home, '.brickton',
                                           'exports')
     self._used_key_directory = os.path.join(self._home, '.brickton',
                                             'used_keys')
     for directory in [
             self._key_directory, self._file_directory,
             self._export_directory, self._used_key_directory
     ]:
         if not os.path.exists(directory):
             os.makedirs(directory)
     # Sorting items
     self._all_keys = set()
     self._sender_subset = set()
     self._receiver_subset = set()
     self._selected_subset = set()
     self.sender_identities = set()
     self.receiver_identities = set()
     # Key thread cancellations.
     self._cancellations = []
     # Sort keys for communication
     self._outbound_keys = []
     self._inbound_keys = []
Example #3
0
    def __init__(self, opts, log, cover_data=None, toc=None):
        from calibre.gui2 import must_use_qt
        must_use_qt()
        QObject.__init__(self)

        self.logger = self.log = log
        self.opts = opts
        self.cover_data = cover_data
        self.paged_js = None
        self.toc = toc

        self.loop = QEventLoop()
        self.view = QWebView()
        self.page = Page(opts, self.log)
        self.view.setPage(self.page)
        self.view.setRenderHints(QPainter.Antialiasing|
                    QPainter.TextAntialiasing|QPainter.SmoothPixmapTransform)
        self.view.loadFinished.connect(self.render_html,
                type=Qt.QueuedConnection)
        for x in (Qt.Horizontal, Qt.Vertical):
            self.view.page().mainFrame().setScrollBarPolicy(x,
                    Qt.ScrollBarAlwaysOff)
        self.report_progress = lambda x, y: x
        self.current_section = ''
        self.current_tl_section = ''
Example #4
0
 def __init__(self, parent=None):
     QObject.__init__(self, parent)
     self.count = 0
     self.items = []
     self.is_available = False
     self._bus = None
     self.connect_to_snw()
Example #5
0
    def truncate(self):
        sender = QObject()
        sender_object = sender.sender().objectName()
        print(sender_object)
        selection = self.listView_xasproject.selectedIndexes()
        if selection != []:
            for indx, obj in enumerate(selection):
                print(indx)
                ds = self.xasproject._datasets[selection[indx].row()]
                print(ds.name)
                energy = ds.energy
                mu = ds.mu
                indx_energy_to_truncate_at = (
                    np.abs(energy -
                           float(self.lineEdit_truncate_at.text()))).argmin()

                if sender_object == 'pushButton_truncate_below':
                    ds.energy = energy[indx_energy_to_truncate_at:]
                    ds.mu = mu[indx_energy_to_truncate_at:]

                elif sender_object == 'pushButton_truncate_above':
                    ds.energy = energy[0:indx_energy_to_truncate_at]

                    ds.mu = mu[0:indx_energy_to_truncate_at:]
                ds.update_larch()
                self.xasproject._datasets[selection[indx].row()] = ds
Example #6
0
    def __init__(self, opts, log, cover_data=None, toc=None):
        from calibre.gui2 import must_use_qt
        must_use_qt()
        QObject.__init__(self)

        self.logger = self.log = log
        self.mathjax_dir = P('mathjax', allow_user_override=False)
        current_log(log)
        self.opts = opts
        self.cover_data = cover_data
        self.paged_js = None
        self.toc = toc

        self.loop = QEventLoop()
        self.view = QWebView()
        self.page = Page(opts, self.log)
        self.view.setPage(self.page)
        self.view.setRenderHints(QPainter.Antialiasing|QPainter.TextAntialiasing|QPainter.SmoothPixmapTransform)
        self.view.loadFinished.connect(self.render_html,
                type=Qt.QueuedConnection)
        self.view.loadProgress.connect(self.load_progress)
        self.ignore_failure = None
        self.hang_check_timer = t = QTimer(self)
        t.timeout.connect(self.hang_check)
        t.setInterval(1000)

        for x in (Qt.Horizontal, Qt.Vertical):
            self.view.page().mainFrame().setScrollBarPolicy(x,
                    Qt.ScrollBarAlwaysOff)
        self.report_progress = lambda x, y: x
        self.current_section = ''
        self.current_tl_section = ''
Example #7
0
    def __init__(self, parent, db):
        QObject.__init__(self, parent)
        self.internet_connection_failed = False
        self._parent = parent
        self.no_internet_msg = _('Cannot download news as no internet connection '
                'is active')
        self.no_internet_dialog = d = error_dialog(self._parent,
                self.no_internet_msg, _('No internet connection'),
                show_copy_button=False)
        d.setModal(False)

        self.recipe_model = RecipeModel()
        self.db = db
        self.lock = QMutex(QMutex.Recursive)
        self.download_queue = set()

        self.news_menu = QMenu()
        self.news_icon = QIcon(I('news.png'))
        self.scheduler_action = QAction(QIcon(I('scheduler.png')), _('Schedule news download'), self)
        self.news_menu.addAction(self.scheduler_action)
        self.scheduler_action.triggered[bool].connect(self.show_dialog)
        self.cac = QAction(QIcon(I('user_profile.png')), _('Add or edit a custom news source'), self)
        self.cac.triggered[bool].connect(self.customize_feeds)
        self.news_menu.addAction(self.cac)
        self.news_menu.addSeparator()
        self.all_action = self.news_menu.addAction(
                _('Download all scheduled news sources'),
                self.download_all_scheduled)

        self.timer = QTimer(self)
        self.timer.start(int(self.INTERVAL * 60 * 1000))
        self.timer.timeout.connect(self.check)
        self.oldest = gconf['oldest_news']
        QTimer.singleShot(5 * 1000, self.oldest_check)
Example #8
0
    def __init__(self, opts, log, cover_data=None, toc=None):
        from calibre.gui2 import must_use_qt
        must_use_qt()
        QObject.__init__(self)

        self.logger = self.log = log
        current_log(log)
        self.opts = opts
        self.cover_data = cover_data
        self.paged_js = None
        self.toc = toc

        self.loop = QEventLoop()
        self.view = QWebView()
        self.page = Page(opts, self.log)
        self.view.setPage(self.page)
        self.view.setRenderHints(QPainter.Antialiasing
                                 | QPainter.TextAntialiasing
                                 | QPainter.SmoothPixmapTransform)
        self.view.loadFinished.connect(self.render_html,
                                       type=Qt.QueuedConnection)
        for x in (Qt.Horizontal, Qt.Vertical):
            self.view.page().mainFrame().setScrollBarPolicy(
                x, Qt.ScrollBarAlwaysOff)
        self.report_progress = lambda x, y: x
        self.current_section = ''
        self.current_tl_section = ''
Example #9
0
 def __init__(self, gui, ids, callback):
     from calibre.gui2.dialogs.progress import ProgressDialog
     QObject.__init__(self, gui)
     self.model = gui.library_view.model()
     self.ids = ids
     self.permanent = False
     if can_recycle and len(ids) > 100:
         if question_dialog(
                 gui, _('Are you sure?'), '<p>' +
                 _('You are trying to delete %d books. '
                   'Sending so many files to the Recycle'
                   ' Bin <b>can be slow</b>. Should calibre skip the'
                   ' Recycle Bin? If you click Yes the files'
                   ' will be <b>permanently deleted</b>.') % len(ids)):
             self.permanent = True
     self.gui = gui
     self.failures = []
     self.deleted_ids = []
     self.callback = callback
     single_shot(self.delete_one)
     self.pd = ProgressDialog(_('Deleting...'),
                              parent=gui,
                              cancelable=False,
                              min=0,
                              max=len(self.ids),
                              icon='trash.png')
     self.pd.setModal(True)
     self.pd.show()
Example #10
0
 def __init__(self, textedit, spell):
     QObject.__init__(self)
     self._current_word = ""
     self._textedit = textedit
     self._spell = spell
     self._enabled = self._spell.enabled()
     self._current_lang = "ENG"
Example #11
0
 def __init__(self, func, queued=True, parent=None):
     QObject.__init__(self, parent)
     self.func = func
     typ = Qt.QueuedConnection
     if not queued:
         typ = Qt.AutoConnection if queued is None else Qt.DirectConnection
     self.dispatch_signal.connect(self.dispatch, type=typ)
Example #12
0
    def __init__(self, parent, db, callback, rows, path, opts,
            spare_server=None):
        QObject.__init__(self, parent)
        self.pd = ProgressDialog(_('Saving...'), parent=parent)
        self.spare_server = spare_server
        self.db = db
        self.opts = opts
        self.pd.setModal(True)
        self.pd.show()
        self.pd.set_min(0)
        self.pd.set_msg(_('Collecting data, please wait...'))
        self._parent = parent
        self.callback = callback
        self.callback_called = False
        self.rq = Queue()
        self.ids = [x for x in map(db.id, [r.row() for r in rows]) if x is not None]
        self.pd_max = len(self.ids)
        self.pd.set_max(0)
        self.pd.value = 0
        self.failures = set([])

        from calibre.ebooks.metadata.worker import SaveWorker
        self.worker = SaveWorker(self.rq, db, self.ids, path, self.opts,
                spare_server=self.spare_server)
        self.pd.canceled_signal.connect(self.canceled)
        self.continue_updating = True
        single_shot(self.update)
Example #13
0
    def __init__(self, parent=None, config_name='shortcuts/main'):
        QObject.__init__(self, parent)

        self.config = JSONConfig(config_name)
        self.shortcuts = OrderedDict()
        self.keys_map = {}
        self.groups = {}
Example #14
0
    def __init__(self, source, single_book_per_directory=True, db=None, parent=None, callback=None, pool=None, list_of_archives=False):
        if not validate_source(source, parent):
            return
        QObject.__init__(self, parent)
        self.single_book_per_directory = single_book_per_directory
        self.ignore_opf = False
        self.list_of_archives = list_of_archives
        self.callback = callback
        self.add_formats_to_existing = prefs['add_formats_to_existing']
        self.do_one_signal.connect(self.tick, type=Qt.QueuedConnection)
        self.pool = pool
        self.pd = ProgressDialog(_('Adding books...'), _('Scanning for files...'), min=0, max=0, parent=parent, icon='add_book.png')
        self.db = getattr(db, 'new_api', None)
        if self.db is not None:
            self.dbref = weakref.ref(db)
        self.source = source
        self.tdir = PersistentTemporaryDirectory('_add_books')
        self.scan_error = None
        self.file_groups = OrderedDict()
        self.abort_scan = False
        self.duplicates = []
        self.report = []
        self.items = []
        self.added_book_ids = set()
        self.merged_books = set()
        self.added_duplicate_info = set()
        self.pd.show()

        self.scan_thread = Thread(target=self.scan, name='ScanBooks')
        self.scan_thread.daemon = True
        self.scan_thread.start()
        self.do_one = self.monitor_scan
        self.do_one_signal.emit()
        if DEBUG:
            self.start_time = time.time()
Example #15
0
    def __init__(self, book_ids, db, opts, root, parent=None, spare_server=None):
        QObject.__init__(self, parent)
        if parent is not None:
            setattr(parent, 'no_gc_%s' % id(self), self)
        self.db = db.new_api
        self.plugboards = self.db.pref('plugboards', {})
        self.template_functions = self.db.pref('user_template_functions', [])
        load_user_template_functions('', self.template_functions)
        self.collected_data = {}
        self.metadata_data = {}
        self.errors = defaultdict(list)
        self._book_id_data = {}
        self.all_book_ids = frozenset(book_ids)
        self.pd = ProgressDialog(_('Saving %d books...') % len(self.all_book_ids), _('Collecting metadata...'), min=0, max=0, parent=parent, icon='save.png')
        self.do_one_signal.connect(self.tick, type=Qt.QueuedConnection)
        self.do_one = self.do_one_collect
        self.ids_to_collect = iter(self.all_book_ids)
        self.plugboard_cache = {}
        self.tdir = PersistentTemporaryDirectory('_save_to_disk')
        self.server = spare_server

        self.pd.show()
        self.root, self.opts, self.path_length = sanitize_args(root, opts)
        self.do_one_signal.emit()
        if DEBUG:
            self.start_time = time.time()
Example #16
0
 def __init__(self,
              tab_main,
              name,
              ip,
              port,
              mnPrivKey,
              hwAcc,
              collateral=None,
              isTestnet=False,
              *args,
              **kwargs):
     QObject.__init__(self, *args, **kwargs)
     if collateral is None:
         collateral = {}
     self.tab_main = tab_main
     self.name = name
     self.ip = ip
     self.port = str(port)
     self.mnPrivKey = wif_to_privkey(mnPrivKey)
     self.mnWIF = mnPrivKey
     self.mnPubKey = bitcoin.privkey_to_pubkey(self.mnPrivKey)
     self.hwAcc = hwAcc
     self.spath = collateral['spath']
     self.nodePath = "%d'/0/%d" % (self.hwAcc, self.spath)
     self.collateral = collateral
     self.isTestnet = isTestnet
     self.currHeight = 0
     Masternode.mnCount += 1
     printOK("Initializing MNode with collateral: %s" % self.nodePath)
Example #17
0
 def __init__(self, view):
     QObject.__init__(self, view)
     self.state = State()
     self.last_swipe_hold_update = None
     self.state.swiped.connect(self.handle_swipe)
     self.state.tapped.connect(self.handle_tap)
     self.state.swiping.connect(self.handle_swiping)
     self.state.tap_hold_started.connect(
         partial(self.handle_tap_hold, 'start'))
     self.state.tap_hold_updated.connect(
         partial(self.handle_tap_hold, 'update'))
     self.state.tap_hold_finished.connect(
         partial(self.handle_tap_hold, 'end'))
     self.state.swipe_hold_started.connect(
         partial(self.handle_swipe_hold, 'start'))
     self.state.swipe_hold_updated.connect(
         partial(self.handle_swipe_hold, 'update'))
     self.state.swipe_hold_finished.connect(
         partial(self.handle_swipe_hold, 'end'))
     self.state.pinched.connect(self.handle_pinch)
     self.evmap = {
         QEvent.TouchBegin: 'start',
         QEvent.TouchUpdate: 'update',
         QEvent.TouchEnd: 'end'
     }
Example #18
0
    def __init__(self, book_ids, db, opts, root, parent=None, pool=None):
        QObject.__init__(self, parent)
        self.db = db.new_api
        self.plugboards = self.db.pref('plugboards', {})
        self.template_functions = self.db.pref('user_template_functions', [])
        load_user_template_functions('', self.template_functions)
        self.collected_data = {}
        self.errors = defaultdict(list)
        self._book_id_data = {}
        self.all_book_ids = frozenset(book_ids)
        self.pd = ProgressDialog(_('Saving %d books...') %
                                 len(self.all_book_ids),
                                 _('Collecting metadata...'),
                                 min=0,
                                 max=0,
                                 parent=parent,
                                 icon='save.png')
        self.do_one_signal.connect(self.tick, type=Qt.QueuedConnection)
        self.do_one = self.do_one_collect
        self.ids_to_collect = iter(self.all_book_ids)
        self.tdir = PersistentTemporaryDirectory('_save_to_disk')
        self.pool = pool

        self.pd.show()
        self.root, self.opts, self.path_length = sanitize_args(root, opts)
        self.do_one_signal.emit()
        if DEBUG:
            self.start_time = time.time()
    def fix_rois(self):
        sender = QObject()
        sender_object = sender.sender().objectName()
        indx_ch = sender_object[11]

        if sender.sender().isChecked():
            for jj in range(2):
                # repeat to make sure no values are forced
                for indx_roi in range(self.num_rois):
                    for indx_lo_hi in range(2):
                        spinbox_name_ch1 = self.spinbox_roi.format(
                            1, indx_roi + 1, self.lo_hi[indx_lo_hi])
                        spinbox_object_ch1 = getattr(self, spinbox_name_ch1)
                        value = spinbox_object_ch1.value()
                        spinbox_name = self.spinbox_roi.format(
                            indx_ch, indx_roi + 1, self.lo_hi[indx_lo_hi])
                        spinbox_object = getattr(self, spinbox_name)
                        spinbox_object.setValue(value)
                        spinbox_object.setEnabled(False)
        else:
            for indx_roi in range(self.num_rois):
                for indx_lo_hi in range(2):
                    spinbox_name = self.spinbox_roi.format(
                        indx_ch, indx_roi + 1, self.lo_hi[indx_lo_hi])
                    spinbox_object = getattr(self, spinbox_name)
                    spinbox_object.setEnabled(True)
Example #20
0
    def __init__(self, config, proxy="", port=0, database_manager=None):
        QObject.__init__(self)
        self.app = QApplication(sys.argv)
        self._network_access_manager = None  #QNetworkAccessManager(self)
        self.user = None
        self.proxy = proxy
        self.port = port
        self.config = config
        self.database_manager = database_manager
        self.domain_handler = None
        self.process_with_login = False
        self.async_request_handler = AsyncRequestHandler(self.database_manager)

        self._event_executor = EventExecutor(
            self,
            proxy,
            port,
            crawl_speed=config.process_speed,
            network_access_manager=self._network_access_manager)
        self._dynamic_analyzer = MainAnalyzer(
            self,
            proxy,
            port,
            crawl_speed=config.process_speed,
            network_access_manager=self._network_access_manager)
        self._form_handler = FormHandler(
            self,
            proxy,
            port,
            crawl_speed=config.process_speed,
            network_access_manager=self._network_access_manager)

        self.cookie_num = -1
        self.interactive_login_form_search = False
Example #21
0
    def __init__(self, source, single_book_per_directory=True, db=None, parent=None, callback=None, pool=None, list_of_archives=False):
        if not validate_source(source, parent):
            return
        QObject.__init__(self, parent)
        self.single_book_per_directory = single_book_per_directory
        self.ignore_opf = False
        self.list_of_archives = list_of_archives
        self.callback = callback
        self.add_formats_to_existing = prefs['add_formats_to_existing']
        self.do_one_signal.connect(self.tick, type=Qt.QueuedConnection)
        self.pool = pool
        self.pd = ProgressDialog(_('Adding books...'), _('Scanning for files...'), min=0, max=0, parent=parent, icon='add_book.png')
        self.db = getattr(db, 'new_api', None)
        if self.db is not None:
            self.dbref = weakref.ref(db)
        self.source = source
        self.tdir = PersistentTemporaryDirectory('_add_books')
        self.scan_error = None
        self.file_groups = OrderedDict()
        self.abort_scan = False
        self.duplicates = []
        self.report = []
        self.items = []
        self.added_book_ids = set()
        self.merged_books = set()
        self.added_duplicate_info = set()
        self.pd.show()

        self.scan_thread = Thread(target=self.scan, name='ScanBooks')
        self.scan_thread.daemon = True
        self.scan_thread.start()
        self.do_one = self.monitor_scan
        self.do_one_signal.emit()
        if DEBUG:
            self.start_time = time.time()
Example #22
0
    def __init__(self, opts, log, cover_data=None, toc=None):
        from calibre.gui2 import must_use_qt
        from calibre.utils.podofo import get_podofo
        must_use_qt()
        QObject.__init__(self)

        self.logger = self.log = log
        self.podofo = get_podofo()
        self.doc = self.podofo.PDFDoc()

        self.loop = QEventLoop()
        self.view = QWebView()
        self.page = Page(opts, self.log)
        self.view.setPage(self.page)
        self.view.setRenderHints(QPainter.Antialiasing|QPainter.TextAntialiasing|QPainter.SmoothPixmapTransform)
        self.view.loadFinished.connect(self._render_html,
                type=Qt.QueuedConnection)
        for x in (Qt.Horizontal, Qt.Vertical):
            self.view.page().mainFrame().setScrollBarPolicy(x,
                    Qt.ScrollBarAlwaysOff)
        self.render_queue = []
        self.combine_queue = []
        self.tmp_path = PersistentTemporaryDirectory(u'_pdf_output_parts')

        self.opts = opts
        self.cover_data = cover_data
        self.paged_js = None
        self.toc = toc
Example #23
0
 def __init__(self, parent):
     QObject.__init__(self, parent)
     self._parent = parent
     self.VERSION = parent.VERSION
     self._home = os.path.expanduser('~')
     self._key_directory = os.path.join(self._home,
                                        '.brickton',
                                        'keys')
     self._file_directory = os.path.join(self._home,
                                         '.brickton',
                                         'files')
     self._export_directory = os.path.join(self._home,
                                          '.brickton',
                                          'exports')
     self._used_key_directory = os.path.join(self._home,
                                             '.brickton',
                                             'used_keys')
     for directory in [self._key_directory,
                       self._file_directory,
                       self._export_directory,
                       self._used_key_directory]:
         if not os.path.exists(directory):
             os.makedirs(directory)
     # Sorting items
     self._all_keys = set()
     self._sender_subset = set()
     self._receiver_subset = set()
     self._selected_subset = set()
     self.sender_identities = set()
     self.receiver_identities = set()
     # Key thread cancellations.
     self._cancellations = []
     # Sort keys for communication
     self._outbound_keys = []
     self._inbound_keys = []
Example #24
0
    def __init__(self, parent=None, config_name='shortcuts/main'):
        QObject.__init__(self, parent)

        self.config = JSONConfig(config_name)
        self.shortcuts = OrderedDict()
        self.keys_map = {}
        self.groups = {}
Example #25
0
 def set_mfc_cart_flow(self):
     sender = QObject()
     sender_object = sender.sender()
     sender_name = sender_object.objectName()
     value = sender_object.value()
     indx_mfc = int(re.findall(r'\d+', sender_name)[0])
     self.mfcs[indx_mfc - 1].sp.set(value)
Example #26
0
    def __init__(self, opts, log, cover_data=None, toc=None):
        from calibre.gui2 import must_use_qt
        from calibre.utils.podofo import get_podofo
        must_use_qt()
        QObject.__init__(self)

        self.logger = self.log = log
        self.podofo = get_podofo()
        self.doc = self.podofo.PDFDoc()

        self.loop = QEventLoop()
        self.view = QWebView()
        self.page = Page(opts, self.log)
        self.view.setPage(self.page)
        self.view.setRenderHints(QPainter.Antialiasing
                                 | QPainter.TextAntialiasing
                                 | QPainter.SmoothPixmapTransform)
        self.view.loadFinished.connect(self._render_html,
                                       type=Qt.QueuedConnection)
        for x in (Qt.Horizontal, Qt.Vertical):
            self.view.page().mainFrame().setScrollBarPolicy(
                x, Qt.ScrollBarAlwaysOff)
        self.render_queue = []
        self.combine_queue = []
        self.tmp_path = PersistentTemporaryDirectory(u'_pdf_output_parts')

        self.opts = opts
        self.cover_data = cover_data
        self.paged_js = None
        self.toc = toc
Example #27
0
    def __init__(self, parent, db):
        QObject.__init__(self, parent)
        self.internet_connection_failed = False
        self._parent = parent
        self.no_internet_msg = _('Cannot download news as no internet connection '
                'is active')
        self.no_internet_dialog = d = error_dialog(self._parent,
                self.no_internet_msg, _('No internet connection'),
                show_copy_button=False)
        d.setModal(False)

        self.recipe_model = RecipeModel()
        self.db = db
        self.lock = QMutex(QMutex.Recursive)
        self.download_queue = set([])

        self.news_menu = QMenu()
        self.news_icon = QIcon(I('news.png'))
        self.scheduler_action = QAction(QIcon(I('scheduler.png')), _('Schedule news download'), self)
        self.news_menu.addAction(self.scheduler_action)
        self.scheduler_action.triggered[bool].connect(self.show_dialog)
        self.cac = QAction(QIcon(I('user_profile.png')), _('Add a custom news source'), self)
        self.cac.triggered[bool].connect(self.customize_feeds)
        self.news_menu.addAction(self.cac)
        self.news_menu.addSeparator()
        self.all_action = self.news_menu.addAction(
                _('Download all scheduled news sources'),
                self.download_all_scheduled)

        self.timer = QTimer(self)
        self.timer.start(int(self.INTERVAL * 60 * 1000))
        self.timer.timeout.connect(self.check)
        self.oldest = gconf['oldest_news']
        QTimer.singleShot(5 * 1000, self.oldest_check)
Example #28
0
 def __init__(self, *args, **kwargs):
     QObject.__init__(self, *args, **kwargs)
     # Device Lock for threads
     self.lock = threading.Lock()
     printDbg("Creating HW device class")
     self.initDevice()
     # Connect signal
     self.sig_progress.connect(self.updateSigProgress)
Example #29
0
 def set_flow_rates(self):
     sender = QObject()
     sender_object = sender.sender()
     sender_name = sender_object.objectName()
     # print(sender_name)
     indx_ch, indx_mnf = re.findall(r'\d+', sender_name)
     value = sender_object.value()
     self.ghs['channels'][indx_ch][f'mfc{indx_mnf}_sp'].set(value)
Example #30
0
 def __init__(self, page):
     QObject.__init__(self, page)
     self._signals = json.dumps(tuple({k for k, v in iteritems(self.__class__.__dict__) if isinstance(v, pyqtSignal)}))
     self._signals_registered = False
     page.titleChanged.connect(self._title_changed)
     for k, v in iteritems(self.__class__.__dict__):
         if isinstance(v, to_js):
             v.name = k
Example #31
0
 def __init__(self, control_tab, timer_off=3, timer_on=7, *args, **kwargs):
     QObject.__init__(self, *args, **kwargs)
     self.shutdown_flag = Event()
     self.control_tab = control_tab
     self.timer_off = timer_off  #delay when not connected
     self.timer_on = timer_on    #delay when connected
     self.ctrl_obj = CtrlObject()
     self.ctrl_obj.finish = False
Example #32
0
 def __init__(self, *args, **kwargs):
     QObject.__init__(self, *args, **kwargs)
     # Device Lock for threads
     self.lock = threading.RLock()
     self.status = 0
     self.dongle = None
     printDbg("Creating HW device class")
     # Connect signal
     self.sig_progress.connect(self.updateSigProgress)
Example #33
0
 def __init__(self, num, **kw):
     QObject.__init__(self, parent=kw.get('parent'))
     self.context_menu = None
     self.is_visible = True
     self.tool_tip = ''
     self._icon = QIcon()
     self.show_menu.connect(self._show_menu, type=Qt.QueuedConnection)
     kw['num'] = num
     self.dbus = StatusNotifierItemAPI(self, **kw)
Example #34
0
 def __init__(self, parent, message_board, color_selection):
     QObject.__init__(self, parent)
     self._message_board = message_board
     self._current_widget = None
     self._color_count = 10
     self._selecting_color = (220 / 255, 240 / 255, 247 / 255)
     self._colors = color_selection.colors(self._color_count)
     self._link_count = 0
     self._link_groups = []
Example #35
0
 def __init__(self, app):
     QObject.__init__(self, app)
     self._app = app
     self._ui = app.ui_main_window
     self._km = app.key_manager
     self._client = app.client
     self._server = app.server
     self._codec = app.codec
     self._role = None
Example #36
0
    def __init__(self):
        QObject.__init__(self)

        if not QApplication.instance():  # pragma: no cover
            os.environ['XDG_SESSION_TYPE'] = ""
            self._app = QApplication(sys.argv)
            install_translators()
        else:
            self._app = QApplication.instance()
Example #37
0
    def __init__(self, config, seralize_books_function, timeout):
        Thread.__init__(self)
        QObject.__init__(self)

        self.daemon = True
        self.config = config
        self.seralize_books = seralize_books_function
        self.timeout = timeout
        self._run = True
Example #38
0
    def __init__(self, config, seralize_books_function, timeout):
        Thread.__init__(self)
        QObject.__init__(self)

        self.daemon = True
        self.config = config
        self.seralize_books = seralize_books_function
        self.timeout = timeout
        self._run = True
Example #39
0
 def __init__(self, name, value, minval, maxval, step, format="%s: %.1f"):
     QObject.__init__(self)
     self.name, self.value, self.minval, self.maxval, self.step, self.format = \
         name, value, minval, maxval, step, format
     self._default = value
     self._wlabel = None
     self._wreset = None
     self._wslider = None
     self._wslider_timer = None
Example #40
0
    def __init__(self, db, logger, book_ids):
        QObject.__init__(self)

        self.db = db
        self.logger = logger
        self.book_ids = book_ids
        self.api_key = prefs['api_key']
        self.reply = None
        self.canceled = False
Example #41
0
 def __init__(self, app):
     QObject.__init__(self, app)
     self._app = app
     self._ui = app.ui_main_window
     self._km = app.key_manager
     self._client = app.client
     self._server = app.server
     self._codec = app.codec
     self._role = None
Example #42
0
 def __init__(self, size=10 * 1024 * 1024):
     QObject.__init__(self)
     self._state = QWebEngineDownloadItem.DownloadRequested
     self._received = self._total = -1
     FakeDownloadItem.idc += 1
     self._id = FakeDownloadItem.idc
     self._size = size
     self.fname = '%s.epub' % self.id()
     self.mimeType = lambda: mimetypes.guess_type(self.fname)[0]
     QTimer.singleShot(100, self._tick)
Example #43
0
 def __init__(self, opts, args, actions, listener, app, gui_debug=None):
     self.startup_time = monotonic()
     self.timed_print('Starting up...')
     self.opts, self.args, self.listener, self.app = opts, args, listener, app
     self.gui_debug = gui_debug
     self.actions = actions
     self.main = None
     QObject.__init__(self)
     self.splash_screen = None
     self.timer = QTimer.singleShot(1, self.initialize)
Example #44
0
    def __init__(self, parent, debug=False):
        QObject.__init__(self, parent)
        self.debug = debug

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.check)

        self.threshold = gc.get_threshold()
        gc.disable()
        self.timer.start(self.INTERVAL)
Example #45
0
 def __init__(self, input_handler_chain=False):   
     QObject.__init__(self)                
     
     self.sim_env = None
     self.monitored = []
     self.t_period = 1
     self.sample_time = 0.5  # Sample time in which the information is read from the objects
     self._show_time = True
     self._last_run_elements = RefList()
     self._init_input_handlers(input_handler_chain)
Example #46
0
 def __init__(self, **kw):
     global _sni_count
     QObject.__init__(self, parent=kw.get('parent'))
     self.context_menu = None
     self.is_visible = True
     self.tool_tip = ''
     self._icon = QApplication.instance().windowIcon()
     self.show_menu.connect(self._show_menu, type=Qt.QueuedConnection)
     _sni_count += 1
     kw['num'] = _sni_count
     self.dbus_api = StatusNotifierItemAPI(self, **kw)
Example #47
0
    def __init__(self, parent=None):
        QObject.__init__(self, parent)
        self.free = [-1, -1, -1]
        self.count = 0
        self.location_actions = QActionGroup(self)
        self.location_actions.setExclusive(True)
        self.current_location = 'library'
        self._mem = []
        self.tooltips = {}

        self.all_actions = []

        def ac(name, text, icon, tooltip):
            icon = QIcon(I(icon))
            ac = self.location_actions.addAction(icon, text)
            setattr(self, 'location_'+name, ac)
            ac.setAutoRepeat(False)
            ac.setCheckable(True)
            receiver = partial(self._location_selected, name)
            ac.triggered.connect(receiver)
            self.tooltips[name] = tooltip

            m = QMenu(parent)
            self._mem.append(m)
            a = m.addAction(icon, tooltip)
            a.triggered.connect(receiver)
            if name != 'library':
                self._mem.append(a)
                a = m.addAction(QIcon(I('eject.png')), _('Eject this device'))
                a.triggered.connect(self._eject_requested)
                self._mem.append(a)
                a = m.addAction(QIcon(I('config.png')), _('Configure this device'))
                a.triggered.connect(self._configure_requested)
                self._mem.append(a)
                a = m.addAction(QIcon(I('sync.png')), _('Update cached metadata on device'))
                a.triggered.connect(lambda x : self.update_device_metadata.emit())
                self._mem.append(a)

            else:
                ac.setToolTip(tooltip)
            ac.setMenu(m)
            ac.calibre_name = name

            self.all_actions.append(ac)
            return ac

        self.library_action = ac('library', _('Library'), 'lt.png',
                _('Show books in calibre library'))
        ac('main', _('Device'), 'reader.png',
                _('Show books in the main memory of the device'))
        ac('carda', _('Card A'), 'sd.png',
                _('Show books in storage card A'))
        ac('cardb', _('Card B'), 'sd.png',
                _('Show books in storage card B'))
Example #48
0
 def __init__(self, iterator, parent):
     QObject.__init__(self, parent)
     self.current_index = 0
     self.iterator = iterator
     self.view = QWebView(self.parent())
     self.mf = mf = self.view.page().mainFrame()
     for x in (Qt.Horizontal, Qt.Vertical):
         mf.setScrollBarPolicy(x, Qt.ScrollBarAlwaysOff)
     self.view.loadFinished.connect(self.load_finished)
     self.paged_js = compiled_coffeescript('ebooks.oeb.display.utils')
     self.paged_js += compiled_coffeescript('ebooks.oeb.display.paged')
Example #49
0
 def __init__(self, path, parent):
     QObject.__init__(self, parent)
     if path and os.path.isdir(path) and os.access(path, os.R_OK | os.W_OK):
         self.watcher = QFileSystemWatcher(self)
         self.worker = Worker(path, self.metadata_read.emit)
         self.watcher.directoryChanged.connect(self.dir_changed, type=Qt.QueuedConnection)
         self.metadata_read.connect(self.add_to_db, type=Qt.QueuedConnection)
         QTimer.singleShot(2000, self.initialize)
         self.auto_convert.connect(self.do_auto_convert, type=Qt.QueuedConnection)
     elif path:
         prints(path, "is not a valid directory to watch for new ebooks, ignoring")
Example #50
0
    def __init__(self, parent, db, ids, nmap):
        QObject.__init__(self, parent)

        self.db, self.ids, self.nmap = db, dict(**ids), dict(**nmap)
        self.critical = {}
        self.number_of_books_added = 0
        self.duplicates = []
        self.names, self.paths, self.infos = [], [], []
        self.input_queue = Queue()
        self.output_queue = Queue()
        self.merged_books = set([])
        self.auto_convert_books = set()
Example #51
0
    def __init__(self, donate_button, location_manager, parent):
        QObject.__init__(self, parent)
        self.donate_button, self.location_manager = (donate_button, location_manager)

        bars = [ToolBar(donate_button, location_manager, parent) for i in range(3)]
        self.main_bars = tuple(bars[:2])
        self.child_bars = tuple(bars[2:])

        self.menu_bar = MenuBar(self.location_manager, self.parent())

        self.apply_settings()
        self.init_bars()
Example #52
0
 def __init__(self, object_path, parent=None, bus=None):
     QObject.__init__(self, parent)
     # Unity barfs is the Event DBUS method does not return immediately, so
     # handle it asynchronously
     self.handle_event_signal.connect(self.handle_event, type=Qt.QueuedConnection)
     self.dbus_api = DBusMenuAPI(self, object_path, bus=bus)
     self.set_status = self.dbus_api.set_status
     self._next_id = 0
     self.action_changed_timer = t = QTimer(self)
     t.setInterval(0), t.setSingleShot(True), t.timeout.connect(self.actions_changed)
     self.layout_changed_timer = t = QTimer(self)
     t.setInterval(0), t.setSingleShot(True), t.timeout.connect(self.layouts_changed)
     self.init_maps()
Example #53
0
 def __init__(self, parent):
     QObject.__init__(self, parent)
     self._parent = parent
     self._km = parent.key_manager
     self._codec = parent.codec
     self._VERSION = parent.VERSION
     self._qsocket = QTcpSocket(self)
     self._bytestream = None
     self._other_party = None
     self._this_party = None
     self._ip_address = None
     self._port = None
     self._setup()
Example #54
0
 def __init__(self, parent, db, callback, spare_server=None):
     QObject.__init__(self, parent)
     self.pd = ProgressDialog(_('Adding...'), parent=parent, icon='add_book.png')
     self.pd.setMaximumWidth(min(600, int(available_width()*0.75)))
     self.spare_server = spare_server
     self.db = db
     self.pd.setModal(True)
     self.pd.show()
     self._parent = parent
     self.rfind = self.worker = None
     self.callback = callback
     self.callback_called = False
     self.pd.canceled_signal.connect(self.canceled)
Example #55
0
    def __init__(self,
            # Logging. If None, uses a default log, which does not output
            # debugging info
            log=None,
            # Receives a string and returns True/False. By default, returns
            # True for all strings
            confirm_callback=None,

            # Prompt callback. Receives a msg string and a default value
            # string. Should return the user input value or None if the user
            # canceled the prompt. By default returns None.
            prompt_callback=None,

            # User agent to be used
            user_agent=USER_AGENT,

            # The size (in MB) of the on disk cache. Note that because the disk
            # cache cannot be shared between different instances, we currently
            # use a temporary dir for the cache, which is deleted on
            # program exit. Set to zero to disable cache.
            disk_cache_size=50,

            # Enable Inspect element functionality
            enable_developer_tools=False,

            # Verbosity
            verbosity=0,

            # The default timeout (in seconds)
            default_timeout=30,

            # If True, do not connect to the X server on linux
            headless=True
        ):
        must_use_qt(headless=headless)
        QObject.__init__(self)
        FormsMixin.__init__(self)

        if log is None:
            log = ThreadSafeLog()
        if verbosity:
            log.filter_level = log.DEBUG
        self.log = log
        self.default_timeout = default_timeout

        self.page = WebPage(log, confirm_callback=confirm_callback,
                prompt_callback=prompt_callback, user_agent=user_agent,
                enable_developer_tools=enable_developer_tools,
                parent=self)
        self.nam = NetworkAccessManager(log, disk_cache_size=disk_cache_size, parent=self)
        self.page.setNetworkAccessManager(self.nam)
Example #56
0
        def __init__(self, location_manager, parent):
            QObject.__init__(self, parent)
            f = factory(app_id='com.calibre-ebook.gui')
            self.menu_bar = f.create_window_menubar(parent)
            self.is_native_menubar = self.menu_bar.is_native_menubar
            self.gui = parent

            self.location_manager = location_manager
            self.added_actions = []

            self.donate_action = QAction(_('Donate'), self)
            self.donate_menu = QMenu()
            self.donate_menu.addAction(self.gui.donate_action)
            self.donate_action.setMenu(self.donate_menu)
Example #57
0
 def __init__(self, view):
     QObject.__init__(self, view)
     if touch_supported:
         view.viewport().setAttribute(Qt.WA_AcceptTouchEvents)
     self.state = State()
     self.state.tapped.connect(self.handle_tap, type=Qt.QueuedConnection)  # has to be queued otherwise QApplication.keyboardModifiers() does not work
     self.state.flicking.connect(self.handle_flicking)
     connect_lambda(self.state.tap_hold_started, self, lambda self, tp: self.handle_tap_hold('start', tp))
     connect_lambda(self.state.tap_hold_updated, self, lambda self, tp: self.handle_tap_hold('update', tp))
     connect_lambda(self.state.tap_hold_finished, self, lambda self, tp: self.handle_tap_hold('end', tp))
     self.evmap = {QEvent.TouchBegin: 'start', QEvent.TouchUpdate: 'update', QEvent.TouchEnd: 'end'}
     self.last_tap_at = 0
     if touch_supported:
         self.scroller = QScroller.scroller(view.viewport())
Example #58
0
        def __init__(self, location_manager, parent):
            QObject.__init__(self, parent)
            self.gui = parent

            self.location_manager = location_manager
            self.added_actions = []
            self.last_actions = []

            self.donate_action = QAction(_('Donate'), self)
            self.donate_menu = QMenu()
            self.donate_menu.addAction(self.gui.donate_action)
            self.donate_action.setMenu(self.donate_menu)
            self.refresh_timer = t = QTimer(self)
            t.setInterval(200), t.setSingleShot(True), t.timeout.connect(self.refresh_bar)
Example #59
0
 def __init__(self, **kw):
     global _sni_count
     QObject.__init__(self, parent=kw.get('parent'))
     self.context_menu = None
     self.is_visible = True
     self.tool_tip = ''
     path = I('calibre-tray.png')
     if path and os.path.exists(path):
         self._icon = QIcon(path)
     else:
         self._icon = QApplication.instance().windowIcon()
     self.show_menu.connect(self._show_menu, type=Qt.QueuedConnection)
     _sni_count += 1
     kw['num'] = _sni_count
     self.dbus_api = StatusNotifierItemAPI(self, **kw)