Example #1
0
 def __init__(self, name, *arg, **kw):
     super(ConfigStore, self).__init__(name, *arg, **kw)
     QtCore.QCoreApplication.instance().aboutToQuit.connect(self.save)
     self.timer = QtCore.QTimer(self)
     self.timer.setSingleShot(True)
     self.timer.setInterval(3000)
     self.timer.timeout.connect(self.save)
Example #2
0
 def __init__(self, *args, **kwds):
     super(GeocoderBase, self).__init__(*args, **kwds)
     self.app = QtWidgets.QApplication.instance()
     self.block_timer = QtCore.QTimer(self)
     self.block_timer.setInterval(self.interval)
     self.block_timer.setSingleShot(True)
     self.query_cache = OrderedDict()
Example #3
0
 def __init__(self, *arg, **kw):
     super(OpenStreetMap, self).__init__(*arg, **kw)
     self.block_timer = QtCore.QTimer(self)
     self.block_timer.setInterval(10000)
     self.block_timer.setSingleShot(True)
     self.block_timer.timeout.connect(self.enable_search)
     self.api_key = key_store.get('opencagedata', 'api_key')
Example #4
0
    def __init__(self, *arg, **kw):
        self.upload_config = PicasaUploadConfig()
        super(PicasaUploader, self).__init__(self.upload_config, *arg, **kw)
##        self.upload_config.delete_album.connect(self.delete_album)
##        self.upload_config.new_album.connect(self.new_album)
        self.upload_config.select_album.connect(self.select_album)
##        self.upload_config.update_album.connect(self.update_album)
        QtWidgets.QApplication.instance().aboutToQuit.connect(self.save_changes)
        self.service_name = self.tr('Google Photos')
        self.image_types = {
            'accepted': ('image/bmp', 'image/gif', 'image/jpeg', 'image/png'),
            'rejected': '*',
            }
        # timer to store album data after it's edited
        self.album_changed = False
        self.timer = QtCore.QTimer(self)
        self.timer.setSingleShot(True)
        self.timer.setInterval(5000)
        self.timer.timeout.connect(self.save_changes)
Example #5
0
 def __init__(self, name, *arg, **kw):
     super(ConfigStore, self).__init__(*arg, **kw)
     QtCore.QCoreApplication.instance().aboutToQuit.connect(self.shutdown)
     self.config = RawConfigParser()
     if hasattr(appdirs, 'user_config_dir'):
         config_dir = appdirs.user_config_dir('photini')
     else:
         config_dir = appdirs.user_data_dir('photini')
     if not os.path.isdir(config_dir):
         os.makedirs(config_dir, mode=stat.S_IRWXU)
     self.file_name = os.path.join(config_dir, name + '.ini')
     if os.path.isfile(self.file_name):
         if six.PY2:
             self.config.readfp(open(self.file_name, 'r'))
         else:
             self.config.readfp(open(self.file_name, 'r', encoding='utf-8'))
     self.timer = QtCore.QTimer(self)
     self.timer.setSingleShot(True)
     self.timer.setInterval(3000)
     self.timer.timeout.connect(self.save)
     self.has_section = self.config.has_section
Example #6
0
 def __init__(self, image_list, parent=None):
     super(PhotiniMap, self).__init__(parent)
     self.app = QtWidgets.QApplication.instance()
     self.image_list = image_list
     self.geocode_cache = OrderedDict()
     name = self.__module__.split('.')[-1]
     self.api_key = key_store.get(name, 'api_key')
     self.search_key = key_store.get('opencage', 'api_key')
     self.script_dir = pkg_resources.resource_filename(
         'photini', 'data/' + name + '/')
     self.drag_icon = QtGui.QPixmap(
         os.path.join(self.script_dir, '../map_pin_grey.png'))
     self.drag_hotspot = 11, 35
     self.search_string = None
     self.map_loaded = False
     self.marker_info = {}
     self.map_status = {}
     self.dropped_images = []
     self.setChildrenCollapsible(False)
     left_side = QtWidgets.QWidget()
     self.addWidget(left_side)
     left_side.setLayout(QtWidgets.QFormLayout())
     left_side.layout().setContentsMargins(0, 0, 0, 0)
     left_side.layout().setFieldGrowthPolicy(
         QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
     # map
     # create handler for calls from JavaScript
     self.call_handler = CallHandler(parent=self)
     self.map = MapWebView(self.call_handler)
     self.map.drop_text.connect(self.drop_text)
     self.map.setAcceptDrops(False)
     self.addWidget(self.map)
     # search
     search_layout = QtWidgets.QFormLayout()
     search_layout.setContentsMargins(0, 0, 0, 0)
     search_layout.setVerticalSpacing(0)
     search_layout.setFieldGrowthPolicy(
         QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
     self.edit_box = ComboBox()
     self.edit_box.setEditable(True)
     self.edit_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert)
     self.edit_box.lineEdit().setPlaceholderText(
         translate('PhotiniMap', '<new search>'))
     self.edit_box.lineEdit().returnPressed.connect(self.search)
     self.edit_box.activated.connect(self.goto_search_result)
     self.clear_search()
     self.edit_box.setEnabled(False)
     search_layout.addRow(translate('PhotiniMap', 'Search'), self.edit_box)
     # search terms and conditions
     terms = self.search_terms()
     if terms:
         search_layout.addRow(*terms)
     left_side.layout().addRow(search_layout)
     if terms:
         divider = QtWidgets.QFrame()
         divider.setFrameStyle(QtWidgets.QFrame.HLine)
         left_side.layout().addRow(divider)
     left_side.layout().addItem(
         QtWidgets.QSpacerItem(1,
                               1000,
                               vPolicy=QtWidgets.QSizePolicy.Expanding))
     # latitude & longitude
     layout = QtWidgets.QHBoxLayout()
     self.coords = SingleLineEdit()
     self.coords.editingFinished.connect(self.new_coords)
     self.coords.setEnabled(False)
     layout.addWidget(self.coords)
     # convert lat/lng to location info
     self.auto_location = QtWidgets.QPushButton(
         translate('PhotiniMap',
                   six.unichr(0x21e8) + ' address'))
     self.auto_location.setFixedHeight(self.coords.height())
     self.auto_location.setEnabled(False)
     self.auto_location.clicked.connect(self.get_address)
     layout.addWidget(self.auto_location)
     left_side.layout().addRow(translate('PhotiniMap', 'Lat, long'), layout)
     # location info
     self.location_widgets = []
     self.location_info = QtWidgets.QTabWidget()
     tab_bar = QTabBar()
     self.location_info.setTabBar(tab_bar)
     tab_bar.context_menu.connect(self.location_tab_context_menu)
     tab_bar.tabMoved.connect(self.location_tab_moved)
     self.location_info.setElideMode(Qt.ElideLeft)
     self.location_info.setMovable(True)
     self.location_info.setEnabled(False)
     left_side.layout().addRow(self.location_info)
     # address lookup (and default search) terms and conditions
     layout = QtWidgets.QHBoxLayout()
     if terms:
         widget = CompactButton(
             self.tr('Address lookup\npowered by OpenCage'))
     else:
         widget = CompactButton(
             self.tr('Search && lookup\npowered by OpenCage'))
     widget.clicked.connect(self.load_tou_opencage)
     layout.addWidget(widget)
     widget = CompactButton(
         self.tr('Geodata © OpenStreetMap\ncontributors'))
     widget.clicked.connect(self.load_tou_osm)
     layout.addWidget(widget)
     left_side.layout().addRow(layout)
     # other init
     self.image_list.image_list_changed.connect(self.image_list_changed)
     self.splitterMoved.connect(self.new_split)
     self.block_timer = QtCore.QTimer(self)
     self.block_timer.setInterval(5000)
     self.block_timer.setSingleShot(True)
     self.block_timer.timeout.connect(self.enable_search)