Added downloads bar fg customization, and refactored the download's color-picking.

This commit is contained in:
Austin Anderson 2015-05-25 20:47:16 -04:00
parent 0553094494
commit a8d2dbfdfb
2 changed files with 28 additions and 12 deletions

View File

@ -356,12 +356,16 @@ class DownloadItem(QObject):
if reply.error() != QNetworkReply.NoError: if reply.error() != QNetworkReply.NoError:
QTimer.singleShot(0, lambda: self.error.emit(reply.errorString())) QTimer.singleShot(0, lambda: self.error.emit(reply.errorString()))
def bg_color(self): def get_status_color(self, position):
"""Background color to be shown.""" """Choose an appropriate color for presenting the download's status.
start = config.get('colors', 'downloads.bg.start')
stop = config.get('colors', 'downloads.bg.stop') Args:
system = config.get('colors', 'downloads.bg.system') position: The color type requested, can be 'fg' or 'bg'.
error = config.get('colors', 'downloads.bg.error') """
start = config.get('colors', 'downloads.{}.start'.format(position))
stop = config.get('colors', 'downloads.{}.stop'.format(position))
system = config.get('colors', 'downloads.{}.system'.format(position))
error = config.get('colors', 'downloads.{}.error'.format(position))
if self.error_msg is not None: if self.error_msg is not None:
assert not self.successful assert not self.successful
return error return error
@ -1020,9 +1024,9 @@ class DownloadManager(QAbstractListModel):
if role == Qt.DisplayRole: if role == Qt.DisplayRole:
data = str(item) data = str(item)
elif role == Qt.ForegroundRole: elif role == Qt.ForegroundRole:
data = config.get('colors', 'downloads.fg') data = item.get_status_color('fg')
elif role == Qt.BackgroundRole: elif role == Qt.BackgroundRole:
data = item.bg_color() data = item.get_status_color('bg')
elif role == ModelRole.item: elif role == ModelRole.item:
data = item data = item
elif role == Qt.ToolTipRole: elif role == Qt.ToolTipRole:

View File

@ -930,26 +930,38 @@ def data(readonly=False):
SettingValue(typ.CssColor(), 'green'), SettingValue(typ.CssColor(), 'green'),
"Font color for the matched part of hints."), "Font color for the matched part of hints."),
('downloads.fg',
SettingValue(typ.QtColor(), '#ffffff'),
"Foreground color for downloads."),
('downloads.bg.bar', ('downloads.bg.bar',
SettingValue(typ.QssColor(), 'black'), SettingValue(typ.QssColor(), 'black'),
"Background color for the download bar."), "Background color for the download bar."),
('downloads.fg.start',
SettingValue(typ.QtColor(), '#0000aa'),
"Color gradient start for downloads."),
('downloads.bg.start', ('downloads.bg.start',
SettingValue(typ.QtColor(), '#0000aa'), SettingValue(typ.QtColor(), '#0000aa'),
"Color gradient start for downloads."), "Color gradient start for downloads."),
('downloads.fg.stop',
SettingValue(typ.QtColor(), '#00aa00'),
"Color gradient end for downloads."),
('downloads.bg.stop', ('downloads.bg.stop',
SettingValue(typ.QtColor(), '#00aa00'), SettingValue(typ.QtColor(), '#00aa00'),
"Color gradient end for downloads."), "Color gradient end for downloads."),
('downloads.fg.system',
SettingValue(typ.ColorSystem(), 'rgb'),
"Color gradient interpolation system for downloads."),
('downloads.bg.system', ('downloads.bg.system',
SettingValue(typ.ColorSystem(), 'rgb'), SettingValue(typ.ColorSystem(), 'rgb'),
"Color gradient interpolation system for downloads."), "Color gradient interpolation system for downloads."),
('downloads.fg.error',
SettingValue(typ.QtColor(), 'red'),
"Foreground color for downloads with errors."),
('downloads.bg.error', ('downloads.bg.error',
SettingValue(typ.QtColor(), 'red'), SettingValue(typ.QtColor(), 'red'),
"Background color for downloads with errors."), "Background color for downloads with errors."),