Fix QColorDialog usage

This commit is contained in:
Jon Tibble 2010-06-14 14:23:19 +01:00
parent 0558900951
commit a4f0df76cc
2 changed files with 60 additions and 44 deletions

View File

@ -239,9 +239,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onFontMainColorPushButtonClicked(self): def onFontMainColorPushButtonClicked(self):
self.theme.font_main_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.font_main_color), self).name() QtGui.QColor(self.theme.font_main_color), self)
if new_color.isValid():
self.theme.font_main_color = new_color.name()
self.FontMainColorPushButton.setStyleSheet( self.FontMainColorPushButton.setStyleSheet(
u'background-color: %s' % unicode(self.theme.font_main_color)) u'background-color: %s' % unicode(self.theme.font_main_color))
self.previewTheme() self.previewTheme()
@ -332,10 +333,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onFontFooterColorPushButtonClicked(self): def onFontFooterColorPushButtonClicked(self):
self.theme.font_footer_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.font_footer_color), self).name() QtGui.QColor(self.theme.background_color), self)
if new_color.isValid():
self.theme.font_footer_color = new_color.name()
self.FontFooterColorPushButton.setStyleSheet( self.FontFooterColorPushButton.setStyleSheet(
'background-color: %s' % unicode(self.theme.font_footer_color)) u'background-color: %s' % unicode(self.theme.font_footer_color))
self.previewTheme() self.previewTheme()
def onFontFooterSizeSpinBoxChanged(self): def onFontFooterSizeSpinBoxChanged(self):
@ -431,23 +434,28 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def onColor1PushButtonClicked(self): def onColor1PushButtonClicked(self):
if self.theme.background_type == u'solid': if self.theme.background_type == u'solid':
self.theme.background_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_color), self).name() QtGui.QColor(self.theme.background_color), self)
self.Color1PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.background_color)) self.theme.background_color = new_color.name()
self.Color1PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_color))
else: else:
self.theme.background_startColor = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_startColor), self).name() QtGui.QColor(self.theme.background_color), self)
self.Color1PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % \ self.theme.background_startColor = new_color.name()
self.Color1PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_startColor)) unicode(self.theme.background_startColor))
self.previewTheme() self.previewTheme()
def onColor2PushButtonClicked(self): def onColor2PushButtonClicked(self):
self.theme.background_endColor = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_endColor), self).name() QtGui.QColor(self.theme.background_color), self)
self.Color2PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.background_endColor)) self.theme.background_endColor = new_color.name()
self.Color2PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_endColor))
self.previewTheme() self.previewTheme()
# #
@ -472,10 +480,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onOutlineColorPushButtonClicked(self): def onOutlineColorPushButtonClicked(self):
self.theme.display_outline_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.display_outline_color), self).name() QtGui.QColor(self.theme.background_color), self)
self.OutlineColorPushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.display_outline_color)) self.theme.display_outline_color = new_color.name()
self.OutlineColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_outline_color))
self.previewTheme() self.previewTheme()
def onShadowCheckBoxChanged(self, value): def onShadowCheckBoxChanged(self, value):
@ -495,10 +505,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onShadowColorPushButtonClicked(self): def onShadowColorPushButtonClicked(self):
self.theme.display_shadow_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.display_shadow_color), self).name() QtGui.QColor(self.theme.background_color), self)
self.ShadowColorPushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.display_shadow_color)) self.theme.display_shadow_color = new_color.name()
self.ShadowColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_shadow_color))
self.previewTheme() self.previewTheme()
def onHorizontalComboBoxSelected(self, currentIndex): def onHorizontalComboBoxSelected(self, currentIndex):

View File

@ -214,8 +214,10 @@ class AlertsTab(SettingsTab):
translate(u'AlertsPlugin.AlertsTab', u'Bottom')) translate(u'AlertsPlugin.AlertsTab', u'Bottom'))
def onBackgroundColorButtonClicked(self): def onBackgroundColorButtonClicked(self):
self.bg_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.bg_color), self).name() QtGui.QColor(self.theme.background_color), self)
if new_color.isValid():
self.bg_color = new_color.name()
self.BackgroundColorButton.setStyleSheet( self.BackgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color) u'background-color: %s' % self.bg_color)
self.updateDisplay() self.updateDisplay()
@ -227,8 +229,10 @@ class AlertsTab(SettingsTab):
self.location = location self.location = location
def onFontColorButtonClicked(self): def onFontColorButtonClicked(self):
self.font_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.font_color), self).name() QtGui.QColor(self.theme.background_color), self)
if new_color.isValid():
self.font_color = new_color.name()
self.FontColorButton.setStyleSheet( self.FontColorButton.setStyleSheet(
u'background-color: %s' % self.font_color) u'background-color: %s' % self.font_color)
self.updateDisplay() self.updateDisplay()