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,12 +239,13 @@ 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.FontMainColorPushButton.setStyleSheet( self.theme.font_main_color = new_color.name()
u'background-color: %s' % unicode(self.theme.font_main_color)) self.FontMainColorPushButton.setStyleSheet(
self.previewTheme() u'background-color: %s' % unicode(self.theme.font_main_color))
self.previewTheme()
def onFontMainSizeSpinBoxChanged(self): def onFontMainSizeSpinBoxChanged(self):
if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value():
@ -332,11 +333,13 @@ 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)
self.FontFooterColorPushButton.setStyleSheet( if new_color.isValid():
'background-color: %s' % unicode(self.theme.font_footer_color)) self.theme.font_footer_color = new_color.name()
self.previewTheme() self.FontFooterColorPushButton.setStyleSheet(
u'background-color: %s' % unicode(self.theme.font_footer_color))
self.previewTheme()
def onFontFooterSizeSpinBoxChanged(self): def onFontFooterSizeSpinBoxChanged(self):
if self.theme.font_footer_proportion != \ if self.theme.font_footer_proportion != \
@ -431,24 +434,29 @@ 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.previewTheme() self.Color2PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_endColor))
self.previewTheme()
# #
#Other Tab #Other Tab
@ -472,11 +480,13 @@ 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.previewTheme() self.OutlineColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_outline_color))
self.previewTheme()
def onShadowCheckBoxChanged(self, value): def onShadowCheckBoxChanged(self, value):
if value == 2: # checked if value == 2: # checked
@ -495,11 +505,13 @@ 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.previewTheme() self.ShadowColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_shadow_color))
self.previewTheme()
def onHorizontalComboBoxSelected(self, currentIndex): def onHorizontalComboBoxSelected(self, currentIndex):
self.theme.display_horizontalAlign = currentIndex self.theme.display_horizontalAlign = currentIndex

View File

@ -214,11 +214,13 @@ 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)
self.BackgroundColorButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % self.bg_color) self.bg_color = new_color.name()
self.updateDisplay() self.BackgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
self.updateDisplay()
def onFontComboBoxClicked(self): def onFontComboBoxClicked(self):
self.updateDisplay() self.updateDisplay()
@ -227,11 +229,13 @@ 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)
self.FontColorButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % self.font_color) self.font_color = new_color.name()
self.updateDisplay() self.FontColorButton.setStyleSheet(
u'background-color: %s' % self.font_color)
self.updateDisplay()
def onTimeoutSpinBoxChanged(self): def onTimeoutSpinBoxChanged(self):
self.timeout = self.TimeoutSpinBox.value() self.timeout = self.TimeoutSpinBox.value()