Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not self.item_list:
return
x = origin.x() + left
y = origin.y() + top
for n, item in enumerate(self.item_list):
i, j = n % columns, n // columns
item.setGeometry(QtCore.QRect(
QtCore.QPoint(x + (i * item_w), y + (j * item_h)), item_size))
self.scroll_area.set_multi_row(multi_row)
class ImageList(QtWidgets.QWidget):
image_list_changed = QtCore.pyqtSignal()
new_metadata = QtCore.pyqtSignal(bool)
selection_changed = QtCore.pyqtSignal(list)
sort_order_changed = QtCore.pyqtSignal()
def __init__(self, parent=None):
super(ImageList, self).__init__(parent)
self.app = QtWidgets.QApplication.instance()
self.drag_icon = None
self.images = []
self.last_selected = None
self.selection_anchor = None
self.thumb_size = int(
self.app.config_store.get('controls', 'thumb_size', '80'))
layout = QtWidgets.QGridLayout()
layout.setSpacing(0)
layout.setRowStretch(0, 1)
layout.setColumnStretch(3, 1)
self.setLayout(layout)
layout.setContentsMargins(0, 0, 0, 0)
def read(self, size):
if self._callback:
self._callback(self._f.tell() * 100 // self.len)
if self._closing.is_set():
raise UploadAborted()
return self._f.read(size)
# delegate all other attributes to file object
def __getattr__(self, name):
return getattr(self._f, name)
class UploadWorker(QtCore.QObject):
finished = QtCore.pyqtSignal()
upload_error = QtCore.pyqtSignal(six.text_type, six.text_type)
upload_progress = QtCore.pyqtSignal(float, six.text_type)
def __init__(self, session_factory, upload_list, *args, **kwds):
super(UploadWorker, self).__init__(*args, **kwds)
self.session_factory = session_factory
self.upload_list = upload_list
self.fileobj = None
@QtCore.pyqtSlot()
@catch_all
def start(self):
session = self.session_factory()
session.connect()
upload_count = 0
while upload_count < len(self.upload_list):
image, convert, params = self.upload_list[upload_count]
name = os.path.basename(image.path)
width_hint += columns * item_w
height_hint += rows * item_h
self.size_hint = QtCore.QSize(width_hint, height_hint)
if not self.item_list:
return
x = origin.x() + left
y = origin.y() + top
for n, item in enumerate(self.item_list):
i, j = n % columns, n // columns
item.setGeometry(QtCore.QRect(
QtCore.QPoint(x + (i * item_w), y + (j * item_h)), item_size))
self.scroll_area.set_multi_row(multi_row)
class ImageList(QtWidgets.QWidget):
image_list_changed = QtCore.pyqtSignal()
new_metadata = QtCore.pyqtSignal(bool)
selection_changed = QtCore.pyqtSignal(list)
sort_order_changed = QtCore.pyqtSignal()
def __init__(self, parent=None):
super(ImageList, self).__init__(parent)
self.app = QtWidgets.QApplication.instance()
self.drag_icon = None
self.images = []
self.last_selected = None
self.selection_anchor = None
self.thumb_size = int(
self.app.config_store.get('controls', 'thumb_size', '80'))
layout = QtWidgets.QGridLayout()
layout.setSpacing(0)
layout.setRowStretch(0, 1)
QtWidgets.QShortcut(QtGui.QKeySequence.SelectAll,
self.scroll_area, self.select_all)
# sort key selector
layout.addWidget(QtWidgets.QLabel(self.tr('sort by: ')), 1, 0)
self.sort_name = QtWidgets.QRadioButton(self.tr('file name'))
self.sort_name.clicked.connect(self._new_sort_order)
layout.addWidget(self.sort_name, 1, 1)
self.sort_date = QtWidgets.QRadioButton(self.tr('date taken'))
layout.addWidget(self.sort_date, 1, 2)
self.sort_date.clicked.connect(self._new_sort_order)
if eval(self.app.config_store.get('controls', 'sort_date', 'False')):
self.sort_date.setChecked(True)
else:
self.sort_name.setChecked(True)
# size selector
layout.addWidget(QtWidgets.QLabel(self.tr('thumbnail size: ')), 1, 4)
self.size_slider = QtWidgets.QSlider(Qt.Horizontal)
self.size_slider.setTracking(False)
self.size_slider.setRange(4, 9)
self.size_slider.setPageStep(1)
self.size_slider.setValue(self.thumb_size / 20)
self.size_slider.setTickPosition(QtWidgets.QSlider.TicksBelow)
width = self.size_slider.sizeHint().width()
self.size_slider.setMinimumWidth(width * 7 // 4)
self.size_slider.valueChanged.connect(self._new_thumb_size)
layout.addWidget(self.size_slider, 1, 5)
@QtCore.pyqtSlot(int)
@catch_all
def switch_album(self, index):
self.select_album.emit(self.albums.itemData(index))
@QtCore.pyqtSlot()
@catch_all
def _clicked(self):
self.new_link.emit(self.name)
@QtCore.pyqtSlot()
@catch_all
def editing_finished(self):
self.new_value.emit(self, self.get_value())
@catch_all
def start(self):
session = self.session_factory()
session.connect()
upload_count = 0
while upload_count < len(self.upload_list):
image, convert, params = self.upload_list[upload_count]
name = os.path.basename(image.path)
self.upload_progress.emit(0.0, '{} ({}/{}) %p%'.format(
name, 1 + upload_count, len(self.upload_list)))
if convert:
path = convert(image)
else:
path = image.path
with open(path, 'rb') as f:
self.fileobj = FileObjWithCallback(f, self.progress)
try:
@catch_all
def file_copied(self, info, status):
if not info:
# copier thread has finished
self.move_button.set_checked(False)
self.copy_button.set_checked(False)
self.file_copier = None
self.file_copier_thread.quit()
if self.last_file_copied[0]:
self.config_store.set(self.config_section, 'last_transfer',
self.last_file_copied[1].isoformat(' '))
self.image_list.done_opening(self.last_file_copied[0])
self.list_files()
return
if status != 'ok':
self._fail()
return
self.image_list = image_list
name = self.__module__.split('.')[-1]
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.geocoder = self.get_geocoder()
self.setLayout(QtWidgets.QHBoxLayout())
## left side
left_side = QtWidgets.QGridLayout()
# latitude & longitude
self.coords = LatLongDisplay(self.image_list)
left_side.addWidget(self.coords.label, 0, 0)
self.coords.changed.connect(self.new_coords)
left_side.addWidget(self.coords, 0, 1)
# altitude
label = QtWidgets.QLabel(translate('MapTabsAll', 'Altitude'))
label.setAlignment(Qt.AlignRight)
left_side.addWidget(label, 1, 0)
self.altitude = DoubleSpinBox()
self.altitude.setSuffix(' m')
self.altitude.new_value.connect(self.new_altitude)
left_side.addWidget(self.altitude, 1, 1)
if hasattr(self.geocoder, 'get_altitude'):
self.altitude_button = QtWidgets.QPushButton(
translate('MapTabsAll', 'Get altitude from map'))