Пример #1
0
 def new_album(self):
     dialog = QtWidgets.QDialog(parent=self)
     dialog.setWindowTitle(self.tr('Create new Facebook album'))
     dialog.setLayout(QtWidgets.QFormLayout())
     name = SingleLineEdit(spell_check=True)
     dialog.layout().addRow(self.tr('Title'), name)
     message = MultiLineEdit(spell_check=True)
     dialog.layout().addRow(self.tr('Description'), message)
     location = SingleLineEdit(spell_check=True)
     dialog.layout().addRow(self.tr('Location'), location)
     privacy = QtWidgets.QComboBox()
     for display_name, value in (
         (self.tr('Only me'), '{value: "SELF"}'),
         (self.tr('All friends'), '{value: "ALL_FRIENDS"}'),
         (self.tr('Friends of friends'), '{value: "FRIENDS_OF_FRIENDS"}'),
         (self.tr('Friends + networks'), '{value: "NETWORKS_FRIENDS"}'),
         (self.tr('Everyone'), '{value: "EVERYONE"}'),
     ):
         privacy.addItem(display_name, value)
     dialog.layout().addRow(self.tr('Privacy'), privacy)
     button_box = QtWidgets.QDialogButtonBox(
         QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
     button_box.accepted.connect(dialog.accept)
     button_box.rejected.connect(dialog.reject)
     dialog.layout().addRow(button_box)
     if dialog.exec_() != QtWidgets.QDialog.Accepted:
         return
     if not self.authorise('write'):
         self.refresh(force=True)
         return
     name = name.toPlainText().strip()
     if not name:
         return
     data = {'name': name}
     message = message.toPlainText().strip()
     if message:
         data['message'] = message
     location = location.toPlainText().strip()
     if location:
         data['location'] = location
     data['privacy'] = privacy.itemData(privacy.currentIndex())
     try:
         album = self.session.post('https://graph.facebook.com/me/albums',
                                   data=data)
     except Exception as ex:
         self.logger.error(str(ex))
         self.refresh(force=True)
         return
     self.load_user_data(album_id=album['id'])
Пример #2
0
 def __init__(self, *args, **kw):
     super(LocationInfo, self).__init__(*args, **kw)
     layout = QtWidgets.QGridLayout()
     self.setLayout(layout)
     layout.setContentsMargins(0, 0, 0, 0)
     self.members = {}
     for key in ('sublocation', 'city', 'province_state', 'country_name',
                 'country_code', 'world_region'):
         self.members[key] = SingleLineEdit()
         self.members[key].editingFinished.connect(self.editing_finished)
     self.members['country_code'].setMaximumWidth(40)
     for j, text in enumerate((
             translate('AddressTab', 'Street'),
             translate('AddressTab', 'City'),
             translate('AddressTab', 'Province'),
             translate('AddressTab', 'Country'),
             translate('AddressTab', 'Region'),
     )):
         label = QtWidgets.QLabel(text)
         label.setAlignment(Qt.AlignRight)
         layout.addWidget(label, j, 0)
     layout.addWidget(self.members['sublocation'], 0, 1, 1, 2)
     layout.addWidget(self.members['city'], 1, 1, 1, 2)
     layout.addWidget(self.members['province_state'], 2, 1, 1, 2)
     layout.addWidget(self.members['country_name'], 3, 1)
     layout.addWidget(self.members['country_code'], 3, 2)
     layout.addWidget(self.members['world_region'], 4, 1, 1, 2)
     layout.setRowStretch(5, 1)
Пример #3
0
 def __init__(self, *arg, **kw):
     super(KeywordsEditor, self).__init__(*arg, **kw)
     self.config_store = QtWidgets.QApplication.instance().config_store
     self.league_table = defaultdict(int)
     for keyword, score in eval(
             self.config_store.get('descriptive', 'keywords',
                                   '{}')).items():
         self.league_table[keyword] = score
     layout = QtWidgets.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
     # line edit box
     self.edit = SingleLineEdit(spell_check=True)
     layout.addWidget(self.edit)
     # favourites drop down
     self.favourites = ComboBox()
     self.update_favourites()
     self.favourites.setFixedWidth(self.favourites.title_width())
     self.favourites.currentIndexChanged.connect(self.add_favourite)
     layout.addWidget(self.favourites)
     # adopt child widget methods and signals
     self.get_value = self.edit.get_value
     self.set_value = self.edit.set_value
     self.set_multiple = self.edit.set_multiple
     self.is_multiple = self.edit.is_multiple
     self.editingFinished = self.edit.editingFinished
Пример #4
0
 def new_set(self):
     dialog = QtWidgets.QDialog(parent=self)
     dialog.setWindowTitle(translate('FlickrTab',
                                     'Create new Flickr album'))
     dialog.setLayout(QtWidgets.QFormLayout())
     title = SingleLineEdit(spell_check=True)
     dialog.layout().addRow(translate('FlickrTab', 'Title'), title)
     description = MultiLineEdit(spell_check=True)
     dialog.layout().addRow(translate('FlickrTab', 'Description'),
                            description)
     dialog.layout().addRow(
         QtWidgets.QLabel(
             translate('FlickrTab',
                       'Album will be created when photos are uploaded')))
     button_box = QtWidgets.QDialogButtonBox(
         QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
     button_box.accepted.connect(dialog.accept)
     button_box.rejected.connect(dialog.reject)
     dialog.layout().addRow(button_box)
     if dialog.exec_() != QtWidgets.QDialog.Accepted:
         return
     title = title.toPlainText()
     if not title:
         return
     description = description.toPlainText()
     widget = self.upload_config.add_set(title, description, None, index=0)
     widget.setChecked(True)
Пример #5
0
 def __init__(self, **kw):
     super(KeywordsEditor, self).__init__()
     self.config_store = QtWidgets.QApplication.instance().config_store
     self.league_table = {}
     for keyword, score in self.config_store.get('descriptive', 'keywords',
                                                 {}).items():
         if isinstance(score, int):
             # old style keyword list
             self.league_table[keyword] = date.min.isoformat(), score // 50
         else:
             # new style keyword list
             self.league_table[keyword] = score
     layout = QtWidgets.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
     # line edit box
     self.edit = SingleLineEdit(**kw)
     layout.addWidget(self.edit)
     # favourites drop down
     self.favourites = ComboBox()
     self.favourites.addItem(translate('DescriptiveTab', '<favourites>'))
     self.favourites.setFixedWidth(
         self.favourites.minimumSizeHint().width())
     self.update_favourites()
     self.favourites.currentIndexChanged.connect(self.add_favourite)
     layout.addWidget(self.favourites)
     # adopt child widget methods and signals
     self.get_value = self.edit.get_value
     self.set_value = self.edit.set_value
     self.set_multiple = self.edit.set_multiple
     self.is_multiple = self.edit.is_multiple
     self.editingFinished = self.edit.editingFinished
Пример #6
0
 def __init__(self, *args, **kw):
     super(LocationInfo, self).__init__(*args, **kw)
     layout = QtWidgets.QGridLayout()
     self.setLayout(layout)
     layout.setContentsMargins(0, 0, 0, 0)
     self.members = {}
     for key in ('SubLocation', 'City', 'ProvinceState', 'CountryName',
                 'CountryCode', 'WorldRegion'):
         self.members[key] = SingleLineEdit(
             length_check=ImageMetadata.max_bytes(key))
         self.members[key].editingFinished.connect(self.editing_finished)
     self.members['CountryCode'].setMaximumWidth(
         width_for_text(self.members['CountryCode'], 'W' * 4))
     self.members['SubLocation'].setToolTip(
         translate('AddressTab', 'Enter the name of the sublocation.'))
     self.members['City'].setToolTip(
         translate('AddressTab', 'Enter the name of the city.'))
     self.members['ProvinceState'].setToolTip(
         translate('AddressTab',
                   'Enter the name of the province or state.'))
     self.members['CountryName'].setToolTip(
         translate('AddressTab', 'Enter the name of the country.'))
     self.members['CountryCode'].setToolTip(
         translate(
             'AddressTab',
             'Enter the 2 or 3 letter ISO 3166 country code of the country.'
         ))
     self.members['WorldRegion'].setToolTip(
         translate('AddressTab', 'Enter the name of the world region.'))
     for j, text in enumerate((
             translate('AddressTab', 'Street'),
             translate('AddressTab', 'City'),
             translate('AddressTab', 'Province'),
             translate('AddressTab', 'Country'),
             translate('AddressTab', 'Region'),
     )):
         label = QtWidgets.QLabel(text)
         label.setAlignment(Qt.AlignRight)
         layout.addWidget(label, j, 0)
     layout.addWidget(self.members['SubLocation'], 0, 1, 1, 2)
     layout.addWidget(self.members['City'], 1, 1, 1, 2)
     layout.addWidget(self.members['ProvinceState'], 2, 1, 1, 2)
     layout.addWidget(self.members['CountryName'], 3, 1)
     layout.addWidget(self.members['CountryCode'], 3, 2)
     layout.addWidget(self.members['WorldRegion'], 4, 1, 1, 2)
     layout.setRowStretch(5, 1)
Пример #7
0
 def __init__(self, image_list, *arg, **kw):
     super(TabWidget, self).__init__(*arg, **kw)
     self.config_store = QtWidgets.QApplication.instance().config_store
     self.image_list = image_list
     self.form = QtWidgets.QFormLayout()
     self.setLayout(self.form)
     # construct widgets
     self.widgets = {}
     # title
     self.widgets['title'] = SingleLineEdit(spell_check=True)
     self.widgets['title'].editingFinished.connect(self.new_title)
     self.form.addRow(translate('DescriptiveTab', 'Title / Object Name'),
                      self.widgets['title'])
     # description
     self.widgets['description'] = MultiLineEdit(spell_check=True)
     self.widgets['description'].editingFinished.connect(
         self.new_description)
     self.form.addRow(translate('DescriptiveTab', 'Description / Caption'),
                      self.widgets['description'])
     # keywords
     self.widgets['keywords'] = KeywordsEditor()
     self.widgets['keywords'].editingFinished.connect(self.new_keywords)
     self.form.addRow(translate('DescriptiveTab', 'Keywords'),
                      self.widgets['keywords'])
     self.image_list.image_list_changed.connect(self.image_list_changed)
     # rating
     self.widgets['rating'] = RatingWidget()
     self.widgets['rating'].editing_finished.connect(self.new_rating)
     self.form.addRow(translate('DescriptiveTab', 'Rating'),
                      self.widgets['rating'])
     # copyright
     self.widgets['copyright'] = LineEditWithAuto()
     self.widgets['copyright'].editingFinished.connect(self.new_copyright)
     self.widgets['copyright'].autoComplete.connect(self.auto_copyright)
     self.form.addRow(translate('DescriptiveTab', 'Copyright'),
                      self.widgets['copyright'])
     # creator
     self.widgets['creator'] = LineEditWithAuto()
     self.widgets['creator'].editingFinished.connect(self.new_creator)
     self.widgets['creator'].autoComplete.connect(self.auto_creator)
     self.form.addRow(translate('DescriptiveTab', 'Creator / Artist'),
                      self.widgets['creator'])
     # disable until an image is selected
     self.setEnabled(False)
Пример #8
0
 def __init__(self, **kw):
     super(LineEditWithAuto, self).__init__()
     self._is_multiple = False
     layout = QtWidgets.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
     # line edit box
     self.edit = SingleLineEdit(**kw)
     layout.addWidget(self.edit)
     # auto complete button
     self.auto = QtWidgets.QPushButton(translate('DescriptiveTab', 'Auto'))
     layout.addWidget(self.auto)
     # adopt child widget methods and signals
     self.set_value = self.edit.set_value
     self.get_value = self.edit.get_value
     self.set_multiple = self.edit.set_multiple
     self.is_multiple = self.edit.is_multiple
     self.editingFinished = self.edit.editingFinished
     self.autoComplete = self.auto.clicked
Пример #9
0
 def __init__(self, *args, **kw):
     super(LocationWidgets, self).__init__(*args, **kw)
     self.members = {
         'sublocation': SingleLineEdit(),
         'city': SingleLineEdit(),
         'province_state': SingleLineEdit(),
         'country_name': SingleLineEdit(),
         'country_code': SingleLineEdit(),
         'world_region': SingleLineEdit(),
     }
     self.members['sublocation'].editingFinished.connect(
         self.new_sublocation)
     self.members['city'].editingFinished.connect(self.new_city)
     self.members['province_state'].editingFinished.connect(
         self.new_province_state)
     self.members['country_name'].editingFinished.connect(
         self.new_country_name)
     self.members['country_code'].editingFinished.connect(
         self.new_country_code)
     self.members['world_region'].editingFinished.connect(
         self.new_world_region)
     self.members['country_code'].setMaximumWidth(40)
Пример #10
0
 def __init__(self, *arg, **kw):
     super(EditSettings, self).__init__(*arg, **kw)
     self.config_store = QtWidgets.QApplication.instance().config_store
     self.setWindowTitle(self.tr('Photini: settings'))
     self.setLayout(QtWidgets.QVBoxLayout())
     # main dialog area
     scroll_area = QtWidgets.QScrollArea()
     self.layout().addWidget(scroll_area)
     panel = QtWidgets.QWidget()
     panel.setLayout(QtWidgets.QFormLayout())
     panel.layout().setRowWrapPolicy(
         max(QtWidgets.QFormLayout.WrapLongRows,
             panel.layout().rowWrapPolicy()))
     # apply & cancel buttons
     self.button_box = QtWidgets.QDialogButtonBox(
         QtWidgets.QDialogButtonBox.Apply
         | QtWidgets.QDialogButtonBox.Cancel)
     self.button_box.clicked.connect(self.button_clicked)
     self.layout().addWidget(self.button_box)
     # copyright holder name
     self.copyright_name = SingleLineEdit(spell_check=True)
     self.copyright_name.set_value(
         self.config_store.get('user', 'copyright_name', ''))
     panel.layout().addRow(self.tr('Copyright holder name'),
                           self.copyright_name)
     # copyright text
     self.copyright_text = SingleLineEdit(spell_check=True)
     self.copyright_text.set_value(
         self.config_store.get('user', 'copyright_text', ''))
     self.copyright_text.setMinimumWidth(
         width_for_text(self.copyright_text, 'x' * 50))
     panel.layout().addRow(self.tr('Copyright text'), self.copyright_text)
     # creator name
     self.creator_name = SingleLineEdit(spell_check=True)
     self.creator_name.set_value(
         self.config_store.get('user', 'creator_name', ''))
     panel.layout().addRow(self.tr('Creator name'), self.creator_name)
     # IPTC data
     force_iptc = eval(self.config_store.get('files', 'force_iptc',
                                             'False'))
     self.write_iptc = QtWidgets.QCheckBox(self.tr('Always write'))
     self.write_iptc.setChecked(force_iptc)
     panel.layout().addRow(self.tr('IPTC metadata'), self.write_iptc)
     # sidecar files
     if_mode = eval(self.config_store.get('files', 'image', 'True'))
     sc_mode = self.config_store.get('files', 'sidecar', 'auto')
     if not if_mode:
         sc_mode = 'always'
     self.sc_always = QtWidgets.QRadioButton(self.tr('Always create'))
     self.sc_always.setChecked(sc_mode == 'always')
     panel.layout().addRow(self.tr('Sidecar files'), self.sc_always)
     self.sc_auto = QtWidgets.QRadioButton(self.tr('Create if necessary'))
     self.sc_auto.setChecked(sc_mode == 'auto')
     self.sc_auto.setEnabled(if_mode)
     panel.layout().addRow('', self.sc_auto)
     self.sc_delete = QtWidgets.QRadioButton(
         self.tr('Delete when possible'))
     self.sc_delete.setChecked(sc_mode == 'delete')
     self.sc_delete.setEnabled(if_mode)
     panel.layout().addRow('', self.sc_delete)
     # image file locking
     self.write_if = QtWidgets.QCheckBox(self.tr('(when possible)'))
     self.write_if.setChecked(if_mode)
     self.write_if.clicked.connect(self.new_write_if)
     panel.layout().addRow(self.tr('Write to image file'), self.write_if)
     # preserve file timestamps
     keep_time = eval(
         self.config_store.get('files', 'preserve_timestamps', 'False'))
     self.keep_time = QtWidgets.QCheckBox()
     self.keep_time.setChecked(keep_time)
     panel.layout().addRow(self.tr('Preserve file timestamps'),
                           self.keep_time)
     # add panel to scroll area after its size is known
     scroll_area.setWidget(panel)
Пример #11
0
 def __init__(self, image_list, parent=None):
     super(PhotiniMap, self).__init__(parent)
     self.logger = logging.getLogger(self.__class__.__name__)
     self.app = QtWidgets.QApplication.instance()
     self.config_store = self.app.config_store
     self.image_list = image_list
     self.script_dir = pkg_resources.resource_filename(
         'photini', 'data/' + self.__class__.__name__.lower() + '/')
     self.drag_icon = QtGui.QPixmap(
         os.path.join(self.script_dir, 'grey_marker.png'))
     self.search_string = None
     self.map_loaded = False
     self.marker_images = {}
     self.map_status = {}
     self.setChildrenCollapsible(False)
     left_side = QtWidgets.QWidget()
     self.addWidget(left_side)
     self.grid = QtWidgets.QGridLayout()
     self.grid.setContentsMargins(0, 0, 0, 0)
     self.grid.setRowStretch(6, 1)
     self.grid.setColumnStretch(1, 1)
     left_side.setLayout(self.grid)
     # map
     self.map = WebView()
     self.map.setPage(WebPage(parent=self.map))
     if QtWebEngineWidgets:
         self.web_channel = QtWebChannel.QWebChannel()
         self.map.page().setWebChannel(self.web_channel)
         self.web_channel.registerObject('python', self)
     else:
         self.map.page().setLinkDelegationPolicy(
             QtWebKitWidgets.QWebPage.DelegateAllLinks)
         self.map.page().linkClicked.connect(self.link_clicked)
         self.map.page().mainFrame().javaScriptWindowObjectCleared.connect(
             self.java_script_window_object_cleared)
     self.map.setAcceptDrops(False)
     self.map.drop_text.connect(self.drop_text)
     self.addWidget(self.map)
     # search
     self.grid.addWidget(
         QtWidgets.QLabel(translate('PhotiniMap', 'Search:')), 0, 0)
     self.edit_box = QtWidgets.QComboBox()
     self.edit_box.setMinimumWidth(200)
     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)
     self.grid.addWidget(self.edit_box, 0, 1)
     # latitude & longitude
     self.grid.addWidget(
         QtWidgets.QLabel(translate('PhotiniMap', 'Lat, long:')), 1, 0)
     self.coords = SingleLineEdit()
     self.coords.editingFinished.connect(self.new_coords)
     self.coords.setEnabled(False)
     self.grid.addWidget(self.coords, 1, 1)
     # convert lat/lng to location info
     self.auto_location = QtWidgets.QPushButton(
         translate('PhotiniMap', 'Lat, long -> location'))
     self.auto_location.setEnabled(False)
     self.auto_location.clicked.connect(self.get_address)
     self.grid.addWidget(self.auto_location, 2, 1)
     # location info
     self.location_info = LocationInfo()
     self.location_info['taken'].new_value.connect(self.new_location_taken)
     self.location_info['shown'].new_value.connect(self.new_location_shown)
     self.location_info.swap.clicked.connect(self.swap_locations)
     self.location_info.setEnabled(False)
     self.grid.addWidget(self.location_info, 3, 0, 1, 2)
     # load map button
     self.load_map = QtWidgets.QPushButton(
         translate('PhotiniMap', '\nLoad map\n'))
     self.load_map.clicked.connect(self.initialise)
     self.grid.addWidget(self.load_map, 7, 0, 1, 2)
     # other init
     self.image_list.image_list_changed.connect(self.image_list_changed)
     self.splitterMoved.connect(self.new_split)
Пример #12
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)
Пример #13
0
 def data_form(self):
     widgets = {}
     scrollarea = QtWidgets.QScrollArea()
     scrollarea.setFrameStyle(QtWidgets.QFrame.NoFrame)
     scrollarea.setWidgetResizable(True)
     form = QtWidgets.QWidget()
     form.setLayout(QtWidgets.QFormLayout())
     # creator
     widgets['creator'] = SingleLineEdit(
         length_check=ImageMetadata.max_bytes('creator'),
         spell_check=True,
         multi_string=True)
     widgets['creator'].setToolTip(
         translate('OwnerTab',
                   'Enter the name of the person that created this image.'))
     form.layout().addRow(translate('OwnerTab', 'Creator'),
                          widgets['creator'])
     # creator title
     widgets['creator_title'] = SingleLineEdit(
         length_check=ImageMetadata.max_bytes('creator_title'),
         spell_check=True,
         multi_string=True)
     widgets['creator_title'].setToolTip(
         translate(
             'OwnerTab',
             'Enter the job title of the person listed in the Creator field.'
         ))
     form.layout().addRow(translate('OwnerTab', "Creator's Jobtitle"),
                          widgets['creator_title'])
     # credit line
     widgets['credit_line'] = SingleLineEdit(
         length_check=ImageMetadata.max_bytes('credit_line'),
         spell_check=True)
     widgets['credit_line'].setToolTip(
         translate(
             'OwnerTab',
             'Enter who should be credited when this image is published.'))
     form.layout().addRow(translate('OwnerTab', 'Credit Line'),
                          widgets['credit_line'])
     # copyright
     widgets['copyright'] = SingleLineEdit(
         length_check=ImageMetadata.max_bytes('copyright'),
         spell_check=True)
     widgets['copyright'].setToolTip(
         translate(
             'OwnerTab', 'Enter a notice on the current owner of the'
             ' copyright for this image, such as "©2008 Jane Doe".'))
     form.layout().addRow(translate('OwnerTab', 'Copyright Notice'),
                          widgets['copyright'])
     # usage terms
     widgets['usageterms'] = SingleLineEdit(
         length_check=ImageMetadata.max_bytes('usageterms'),
         spell_check=True)
     widgets['usageterms'].setToolTip(
         translate(
             'OwnerTab',
             'Enter instructions on how this image can legally be used.'))
     form.layout().addRow(translate('OwnerTab', 'Rights Usage Terms'),
                          widgets['usageterms'])
     # special instructions
     widgets['instructions'] = SingleLineEdit(
         length_check=ImageMetadata.max_bytes('instructions'),
         spell_check=True)
     widgets['instructions'].setToolTip(
         translate(
             'OwnerTab', 'Enter information about embargoes, or other'
             ' restrictions not covered by the Rights Usage Terms field.'))
     form.layout().addRow(translate('OwnerTab', 'Instructions'),
                          widgets['instructions'])
     ## contact information
     contact_group = QtWidgets.QGroupBox()
     contact_group.setLayout(QtWidgets.QFormLayout())
     # email addresses
     widgets['CiEmailWork'] = SingleLineEdit()
     widgets['CiEmailWork'].setToolTip(
         translate(
             'OwnerTab', 'Enter the work email address(es) for the person'
             ' that created this image, such as [email protected].'))
     contact_group.layout().addRow(translate('OwnerTab', 'Email(s)'),
                                   widgets['CiEmailWork'])
     # URLs
     widgets['CiUrlWork'] = SingleLineEdit()
     widgets['CiUrlWork'].setToolTip(
         translate(
             'OwnerTab', 'Enter the work Web URL(s) for the person'
             ' that created this image, such as http://www.domain.com/.'))
     contact_group.layout().addRow(translate('OwnerTab', 'Web URL(s)'),
                                   widgets['CiUrlWork'])
     # phone numbers
     widgets['CiTelWork'] = SingleLineEdit()
     widgets['CiTelWork'].setToolTip(
         translate(
             'OwnerTab', 'Enter the work phone number(s) for the person'
             ' that created this image, using the international format,'
             ' such as +1 (123) 456789.'))
     contact_group.layout().addRow(translate('OwnerTab', 'Phone(s)'),
                                   widgets['CiTelWork'])
     # address
     widgets['CiAdrExtadr'] = MultiLineEdit(
         length_check=ImageMetadata.max_bytes('contact_info'),
         spell_check=True)
     widgets['CiAdrExtadr'].setToolTip(
         translate('OwnerTab',
                   'Enter address for the person that created this image.'))
     contact_group.layout().addRow(translate('OwnerTab', 'Address'),
                                   widgets['CiAdrExtadr'])
     # city
     widgets['CiAdrCity'] = SingleLineEdit(spell_check=True)
     widgets['CiAdrCity'].setToolTip(
         translate(
             'OwnerTab', 'Enter the city for the address of the person'
             ' that created this image.'))
     contact_group.layout().addRow(translate('OwnerTab', 'City'),
                                   widgets['CiAdrCity'])
     # postcode
     widgets['CiAdrPcode'] = SingleLineEdit()
     widgets['CiAdrPcode'].setToolTip(
         translate(
             'OwnerTab',
             'Enter the postal code for the address of the person'
             ' that created this image.'))
     contact_group.layout().addRow(translate('OwnerTab', 'Postal Code'),
                                   widgets['CiAdrPcode'])
     # region
     widgets['CiAdrRegion'] = SingleLineEdit(spell_check=True)
     widgets['CiAdrRegion'].setToolTip(
         translate(
             'OwnerTab', 'Enter the state for the address of the person'
             ' that created this image.'))
     contact_group.layout().addRow(translate('OwnerTab', 'State/Province'),
                                   widgets['CiAdrRegion'])
     # country
     widgets['CiAdrCtry'] = SingleLineEdit(spell_check=True)
     widgets['CiAdrCtry'].setToolTip(
         translate(
             'OwnerTab',
             'Enter the country name for the address of the person'
             ' that created this image.'))
     contact_group.layout().addRow(translate('OwnerTab', 'Country'),
                                   widgets['CiAdrCtry'])
     form.layout().addRow(translate('OwnerTab', 'Contact Information'),
                          contact_group)
     scrollarea.setWidget(form)
     return scrollarea, widgets
Пример #14
0
 def __init__(self, image_list, *arg, **kw):
     super(TabWidget, self).__init__(*arg, **kw)
     self.config_store = QtWidgets.QApplication.instance().config_store
     self.image_list = image_list
     self.form = QtWidgets.QFormLayout()
     self.setLayout(QtWidgets.QVBoxLayout())
     self.layout().addLayout(self.form)
     self.layout().addStretch(1)
     # construct widgets
     self.widgets = {}
     # title
     self.widgets['title'] = SingleLineEdit(
         spell_check=True, length_check=ImageMetadata.max_bytes('title'))
     self.widgets['title'].setToolTip(
         translate(
             'DescriptiveTab',
             'Enter a short verbal and human readable name'
             ' for the image, this may be the file name.'))
     self.widgets['title'].editingFinished.connect(self.new_title)
     self.form.addRow(translate('DescriptiveTab', 'Title / Object Name'),
                      self.widgets['title'])
     # description
     self.widgets['description'] = MultiLineEdit(
         spell_check=True,
         length_check=ImageMetadata.max_bytes('description'))
     self.widgets['description'].setToolTip(
         translate(
             'DescriptiveTab', 'Enter a "caption" describing the who, what,'
             ' and why of what is happening in this image,\nthis might include'
             ' names of people, and/or their role in the action that is taking'
             ' place within the image.'))
     self.widgets['description'].editingFinished.connect(
         self.new_description)
     self.form.addRow(translate('DescriptiveTab', 'Description / Caption'),
                      self.widgets['description'])
     # keywords
     self.widgets['keywords'] = KeywordsEditor(
         spell_check=True,
         length_check=ImageMetadata.max_bytes('keywords'),
         multi_string=True)
     self.widgets['keywords'].setToolTip(
         translate(
             'DescriptiveTab',
             'Enter any number of keywords, terms or phrases'
             ' used to express the subject matter in the image.'
             '\nSeparate them with ";" characters.'))
     self.widgets['keywords'].editingFinished.connect(self.new_keywords)
     self.form.addRow(translate('DescriptiveTab', 'Keywords'),
                      self.widgets['keywords'])
     self.image_list.image_list_changed.connect(self.image_list_changed)
     # rating
     self.widgets['rating'] = RatingWidget()
     self.widgets['rating'].editing_finished.connect(self.new_rating)
     self.form.addRow(translate('DescriptiveTab', 'Rating'),
                      self.widgets['rating'])
     # copyright
     self.widgets['copyright'] = LineEditWithAuto(
         length_check=ImageMetadata.max_bytes('copyright'))
     self.widgets['copyright'].setToolTip(
         translate(
             'OwnerTab', 'Enter a notice on the current owner of the'
             ' copyright for this image, such as "©2008 Jane Doe".'))
     self.widgets['copyright'].editingFinished.connect(self.new_copyright)
     self.widgets['copyright'].autoComplete.connect(self.auto_copyright)
     self.form.addRow(translate('DescriptiveTab', 'Copyright'),
                      self.widgets['copyright'])
     # creator
     self.widgets['creator'] = LineEditWithAuto(
         length_check=ImageMetadata.max_bytes('creator'), multi_string=True)
     self.widgets['creator'].setToolTip(
         translate('OwnerTab',
                   'Enter the name of the person that created this image.'))
     self.widgets['creator'].editingFinished.connect(self.new_creator)
     self.widgets['creator'].autoComplete.connect(self.auto_creator)
     self.form.addRow(translate('DescriptiveTab', 'Creator / Artist'),
                      self.widgets['creator'])
     # disable until an image is selected
     self.setEnabled(False)
Пример #15
0
 def __init__(self, *arg, **kw):
     super(EditSettings, self).__init__(*arg, **kw)
     self.config_store = QtWidgets.QApplication.instance().config_store
     self.setWindowTitle(self.tr('Photini: settings'))
     self.setLayout(QtWidgets.QVBoxLayout())
     # main dialog area
     scroll_area = QtWidgets.QScrollArea()
     self.layout().addWidget(scroll_area)
     panel = QtWidgets.QWidget()
     panel.setLayout(QtWidgets.QFormLayout())
     panel.layout().setRowWrapPolicy(
         max(QtWidgets.QFormLayout.WrapLongRows,
             panel.layout().rowWrapPolicy()))
     # apply & cancel buttons
     self.button_box = QtWidgets.QDialogButtonBox(
         QtWidgets.QDialogButtonBox.Apply
         | QtWidgets.QDialogButtonBox.Cancel)
     self.button_box.clicked.connect(self.button_clicked)
     self.layout().addWidget(self.button_box)
     # copyright holder name
     self.copyright_name = SingleLineEdit(spell_check=True)
     self.copyright_name.set_value(
         self.config_store.get('user', 'copyright_name', ''))
     panel.layout().addRow(self.tr('Copyright holder name'),
                           self.copyright_name)
     # copyright text
     self.copyright_text = SingleLineEdit(spell_check=True)
     self.copyright_text.set_value(
         self.config_store.get('user', 'copyright_text', ''))
     self.copyright_text.setMinimumWidth(
         width_for_text(self.copyright_text, 'x' * 50))
     panel.layout().addRow(self.tr('Copyright text'), self.copyright_text)
     # creator name
     self.creator_name = SingleLineEdit(spell_check=True)
     self.creator_name.set_value(
         self.config_store.get('user', 'creator_name', ''))
     panel.layout().addRow(self.tr('Creator name'), self.creator_name)
     # IPTC data
     force_iptc = self.config_store.get('files', 'force_iptc', False)
     self.write_iptc = QtWidgets.QCheckBox(self.tr('Always write'))
     self.write_iptc.setChecked(force_iptc)
     panel.layout().addRow(self.tr('IPTC-IIM metadata'), self.write_iptc)
     # show IPTC-IIM length limits
     length_warning = self.config_store.get('files', 'length_warning', True)
     self.length_warning = QtWidgets.QCheckBox(
         self.tr('Show IPTC-IIM length limits'))
     self.length_warning.setChecked(length_warning)
     panel.layout().addRow('', self.length_warning)
     # sidecar files
     if_mode = self.config_store.get('files', 'image', True)
     sc_mode = self.config_store.get('files', 'sidecar', 'auto')
     if not if_mode:
         sc_mode = 'always'
     button_group = QtWidgets.QButtonGroup(parent=self)
     self.sc_always = QtWidgets.QRadioButton(self.tr('Always create'))
     button_group.addButton(self.sc_always)
     self.sc_always.setChecked(sc_mode == 'always')
     panel.layout().addRow(self.tr('Sidecar files'), self.sc_always)
     self.sc_auto = QtWidgets.QRadioButton(self.tr('Create if necessary'))
     button_group.addButton(self.sc_auto)
     self.sc_auto.setChecked(sc_mode == 'auto')
     self.sc_auto.setEnabled(if_mode)
     panel.layout().addRow('', self.sc_auto)
     self.sc_delete = QtWidgets.QRadioButton(
         self.tr('Delete when possible'))
     button_group.addButton(self.sc_delete)
     self.sc_delete.setChecked(sc_mode == 'delete')
     self.sc_delete.setEnabled(if_mode)
     panel.layout().addRow('', self.sc_delete)
     # image file locking
     self.write_if = QtWidgets.QCheckBox(self.tr('(when possible)'))
     self.write_if.setChecked(if_mode)
     self.write_if.clicked.connect(self.new_write_if)
     panel.layout().addRow(self.tr('Write to image file'), self.write_if)
     # preserve file timestamps
     keep_time = self.config_store.get('files', 'preserve_timestamps',
                                       'now')
     if isinstance(keep_time, bool):
         # old config format
         keep_time = ('now', 'keep')[keep_time]
     button_group = QtWidgets.QButtonGroup(parent=self)
     self.keep_time = QtWidgets.QRadioButton(self.tr('Keep original'))
     button_group.addButton(self.keep_time)
     self.keep_time.setChecked(keep_time == 'keep')
     panel.layout().addRow(self.tr('File timestamps'), self.keep_time)
     self.time_taken = QtWidgets.QRadioButton(
         self.tr('Set to when photo was taken'))
     button_group.addButton(self.time_taken)
     self.time_taken.setChecked(keep_time == 'taken')
     panel.layout().addRow('', self.time_taken)
     button = QtWidgets.QRadioButton(self.tr('Set to when file is saved'))
     button_group.addButton(button)
     button.setChecked(keep_time == 'now')
     panel.layout().addRow('', button)
     # add panel to scroll area after its size is known
     scroll_area.setWidget(panel)