Theme background images (Bug #594911)

This commit is contained in:
Jon Tibble 2010-07-12 23:32:46 +01:00
parent 46d561b320
commit 02b33ed660
3 changed files with 12 additions and 3 deletions

View File

@ -130,9 +130,9 @@ class Ui_AmendThemeDialog(object):
self.ImageLineEdit.setObjectName(u'ImageLineEdit')
self.horizontalLayout_2.addWidget(self.ImageLineEdit)
self.ImageToolButton = QtGui.QToolButton(self.ImageFilenameWidget)
icon1 = build_icon(u':/general/general_open.png')
self.ImageToolButton.setIcon(icon1)
self.ImageToolButton.setIcon(build_icon(u':/general/general_open.png'))
self.ImageToolButton.setObjectName(u'ImageToolButton')
self.ImageToolButton.setAutoRaise(True)
self.horizontalLayout_2.addWidget(self.ImageToolButton)
self.BackgroundLayout.setWidget(4, QtGui.QFormLayout.FieldRole,
self.ImageFilenameWidget)

View File

@ -59,7 +59,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
QtCore.QObject.connect(self.ShadowColorPushButton,
QtCore.SIGNAL(u'pressed()'), self.onShadowColorPushButtonClicked)
QtCore.QObject.connect(self.ImageToolButton,
QtCore.SIGNAL(u'pressed()'), self.onImageToolButtonClicked)
QtCore.SIGNAL(u'clicked()'), self.onImageToolButtonClicked)
#Combo boxes
QtCore.QObject.connect(self.BackgroundComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected)

View File

@ -116,6 +116,7 @@ class ThemeManager(QtGui.QWidget):
self.thumbPath = os.path.join(self.path, u'thumbnails')
self.checkThemesExists(self.thumbPath)
self.amendThemeForm.path = self.path
self.oldBackgroundImage = None
# Last little bits of setting up
self.global_theme = unicode(QtCore.QSettings().value(
self.settingsSection + u'/global theme',
@ -187,6 +188,8 @@ class ThemeManager(QtGui.QWidget):
item = self.ThemeListWidget.currentItem()
theme = self.getThemeData(
unicode(item.data(QtCore.Qt.UserRole).toString()))
if theme.background_type == u'image':
self.oldBackgroundImage = theme.background_filename
self.amendThemeForm.loadTheme(theme)
self.saveThemeName = unicode(
item.data(QtCore.Qt.UserRole).toString())
@ -544,6 +547,12 @@ class ThemeManager(QtGui.QWidget):
QtGui.QMessageBox.No)
if result == QtGui.QMessageBox.Yes:
# Save the theme, overwriting the existing theme if necessary.
if image_to and self.oldBackgroundImage and \
image_to != self.oldBackgroundImage:
try:
os.remove(self.oldBackgroundImage)
except OSError:
log.exception(u'Unable to remove old theme background')
outfile = None
try:
outfile = open(theme_file, u'w')