mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Allow removal of custom themes
This commit is contained in:
parent
066e783d17
commit
a2342b6c4a
@ -449,7 +449,7 @@ class Property(QWidget):
|
|||||||
class ThemeEditor(Dialog):
|
class ThemeEditor(Dialog):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
Dialog.__init__(self, _('Create/edit custom theme'), 'custom-theme-editor8', parent=parent)
|
Dialog.__init__(self, _('Create/edit custom theme'), 'custom-theme-editor', parent=parent)
|
||||||
|
|
||||||
def setup_ui(self):
|
def setup_ui(self):
|
||||||
self.block_show = False
|
self.block_show = False
|
||||||
@ -472,6 +472,10 @@ class ThemeEditor(Dialog):
|
|||||||
self.add_button = b = QPushButton(QIcon(I('plus.png')), _('Add &new theme'), self)
|
self.add_button = b = QPushButton(QIcon(I('plus.png')), _('Add &new theme'), self)
|
||||||
b.clicked.connect(self.create_new_theme)
|
b.clicked.connect(self.create_new_theme)
|
||||||
h.addWidget(b)
|
h.addWidget(b)
|
||||||
|
|
||||||
|
self.remove_button = b = QPushButton(QIcon(I('minus.png')), _('&Remove theme'), self)
|
||||||
|
b.clicked.connect(self.remove_theme)
|
||||||
|
h.addWidget(b)
|
||||||
h.addStretch(1)
|
h.addStretch(1)
|
||||||
|
|
||||||
self.scroll = s = QScrollArea(self)
|
self.scroll = s = QScrollArea(self)
|
||||||
@ -592,6 +596,8 @@ class ThemeEditor(Dialog):
|
|||||||
c.deleteLater()
|
c.deleteLater()
|
||||||
self.properties = []
|
self.properties = []
|
||||||
name = unicode(self.theme.currentText())
|
name = unicode(self.theme.currentText())
|
||||||
|
if not name:
|
||||||
|
return
|
||||||
data = self.update_theme(name)
|
data = self.update_theme(name)
|
||||||
maxw = 0
|
maxw = 0
|
||||||
for k in sorted(data):
|
for k in sorted(data):
|
||||||
@ -626,6 +632,19 @@ class ThemeEditor(Dialog):
|
|||||||
self.block_show = False
|
self.block_show = False
|
||||||
self.show_theme()
|
self.show_theme()
|
||||||
|
|
||||||
|
def remove_theme(self):
|
||||||
|
name = unicode(self.theme.currentText())
|
||||||
|
if name:
|
||||||
|
tprefs['custom_themes'].pop(name, None)
|
||||||
|
tprefs['custom_themes'] = tprefs['custom_themes']
|
||||||
|
t = self.theme
|
||||||
|
self.block_show = True
|
||||||
|
t.clear(), t.addItems(sorted(custom_theme_names()))
|
||||||
|
if t.count() > 0:
|
||||||
|
t.setCurrentIndex(0)
|
||||||
|
self.block_show = False
|
||||||
|
self.show_theme()
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
g = QApplication.instance().desktop().availableGeometry(self.parent() or self)
|
g = QApplication.instance().desktop().availableGeometry(self.parent() or self)
|
||||||
return QSize(min(1500, g.width() - 25), 650)
|
return QSize(min(1500, g.width() - 25), 650)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user