Allow deleting saved profiles from toolbar button

This commit is contained in:
Kovid Goyal 2024-02-22 11:31:20 +05:30
parent 4fb575d8fe
commit fec7d8bddf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -370,12 +370,24 @@ class ActionsToolBar(ToolBar):
a(profile_name)
m.addSeparator()
m.addAction(_('Save current settings as a profile')).triggered.connect(self.save_profile)
if len(self.profiles) > 1:
s = m.addMenu(_('Delete saved profile...'))
for pname in self.profiles:
if pname != '__default__':
a = s.addAction(pname)
a.setObjectName(f'profile-delete-action:{pname}')
a.triggered.connect(self.profile_delete_triggerred)
def profile_switch_triggered(self):
key = self.sender().objectName().partition(':')[-1]
profile = self.profiles[key]
self.web_view.profile_op('apply-profile', key, profile)
def profile_delete_triggerred(self):
key = self.sender().objectName().partition(':')[-1]
from calibre.gui2.viewer.config import save_viewer_profile
save_viewer_profile(key, None, 'viewer:')
def save_profile(self):
name, ok = QInputDialog.getText(self, _('Enter name of profile to create'), _('&Name of profile'))
if ok: