Default title should start with #1

This commit is contained in:
Kovid Goyal 2019-11-15 11:07:31 +05:30
parent d4dc80c9c4
commit 74d6513287
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -266,8 +266,17 @@ class BookmarkManager(QWidget):
import_current_bookmarks(imported)
def create_new_bookmark(self, pos_data):
base_default_title = _('Bookmark')
all_titles = {bm['title'] for bm in self.get_bookmarks()}
c = 0
while True:
c += 1
default_title = '{} #{}'.format(base_default_title, c)
if default_title not in all_titles:
break
title, ok = QInputDialog.getText(self, _('Add bookmark'),
_('Enter title for bookmark:'), text=_('Bookmark'))
_('Enter title for bookmark:'), text=default_title)
title = unicode_type(title).strip()
if not ok or not title:
return