Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
BluABK committed Apr 5, 2019
2 parents c3d2ea4 + 7530f84 commit 94001e0
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 79 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Current

v0.6.1
- Removed no longer necessary pixel size hacks from config.
- Made VideoTile element line height configurable.
- Reworked VideoTile element QLabel ellison logic; QLabel width * modifier (0.28) * lines.
- Reworked VideoTile element QLabel height logic; Set height equal to line amount and add some newline
spacing for unicode.
- Changed VideoTile layout from VBox to Grid, because grid is not plagued by forced padding between all items.
- Changed broken update_font to an elide_text function and made VideoTile classes override setText to make ellison
default.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6
0.6.1
19 changes: 9 additions & 10 deletions config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ last_theme =
[GridView]
show_watched = False
show_dismissed = False
elided_text_modifier_title = 0.87
title_tile_pixel_size_modifier = 0.29
elided_text_modifier_channel = 0.95
title_tile_max_height_modifier = 0.21
channel_title_tile_pixel_size_modifier = 0.85
channel_title_tile_max_height_modifier = 0.08
elided_text_modifier_date = 0.95
date_tile_pixel_size_modifier = 0.85
date_tile_max_height_modifier = 0.08
title_tile_font_weight = 2
elided_text_modifier_title = 0.28
elided_text_modifier_channel = 0.28
elided_text_modifier_date = 0.28
elided_text_unicode_weight_modifier = 0.0075
tile_unicode_line_height_offset = 1.99
tile_line_spacing = 7
tile_title_lines = 2
tile_channel_lines = 1
tile_date_lines = 1
title_tile_font_weight = Bold
timedelta_format = $HH:$MM:$SS ago
timedelta_format_days = $d days, $HH:$MM:$SS ago
timedelta_format_months = $m months, $d d, $HH:$MM:$SS ago
Expand Down
17 changes: 8 additions & 9 deletions sane_yt_subfeed/config_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@
'GridView': {
'show_watched': 'False',
'show_dismissed': 'False',
'elided_text_modifier_title': '0.87',
'title_tile_pixel_size_modifier': '0.29',
'elided_text_modifier_channel': '0.95',
'title_tile_max_height_modifier': '0.21',
'channel_title_tile_pixel_size_modifier': '0.85',
'channel_title_tile_max_height_modifier': '0.08',
'elided_text_modifier_date': '0.95',
'date_tile_pixel_size_modifier': '0.85',
'date_tile_max_height_modifier': '0.08',
'elided_text_modifier_title': '0.28',
'elided_text_modifier_channel': '0.28',
'elided_text_modifier_date': '0.28',
'elided_text_unicode_weight_modifier': '0.0075',
'tile_unicode_line_height_offset': '1.99',
'tile_line_spacing': '7',
'tile_title_lines': '2',
'tile_channel_lines': '1',
'tile_date_lines': '1',
'title_tile_font_weight': 'Bold',
'timedelta_format': '$HH:$MM:$SS ago',
'timedelta_format_days': '$d days, $HH:$MM:$SS ago',
Expand Down
43 changes: 19 additions & 24 deletions sane_yt_subfeed/gui/views/config_view/views/config_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,35 +117,30 @@ def add_config_tab_views(self):
unchecked_kwargs=[{'tab': 'Download'}, None, None, None, None])
self.add_option_line_edit('Title elided text multiplier',
'GridView', 'elided_text_modifier_title', cfg_validator=QDoubleValidator())
self.add_option_line_edit('Title pixel size multiplier',
'GridView', 'title_tile_pixel_size_modifier', cfg_validator=QDoubleValidator())
self.add_option_line_edit('Title max height multiplier',
'GridView', 'title_tile_max_height_modifier',
cfg_validator=QDoubleValidator())

self.add_option_line_edit('Title lines to display', 'GridView', 'tile_title_lines',
cfg_validator=QIntValidator())
self.add_option_combobox('Title text font weight', 'GridView', 'title_tile_font_weight',
TILE_TITLE_FONT_WEIGHTS)
self.add_option_info(None, None) # Line spacer
self.add_option_line_edit('Channel elided text multiplier',
'GridView', 'elided_text_modifier_channel', cfg_validator=QDoubleValidator())
self.add_option_line_edit('Channel pixel size multiplier',
'GridView', 'channel_title_tile_pixel_size_modifier',
cfg_validator=QDoubleValidator())
self.add_option_line_edit('Channel max height multiplier',
'GridView', 'channel_title_tile_max_height_modifier',
cfg_validator=QDoubleValidator())

self.add_option_line_edit('Channel Title lines to display', 'GridView', 'tile_channel_lines',
cfg_validator=QIntValidator())
self.add_option_info(None, None) # Line spacer
self.add_option_line_edit('Date elided text multiplier',
'GridView', 'elided_text_modifier_date', cfg_validator=QDoubleValidator())
self.add_option_line_edit('Date pixel size multiplier',
'GridView', 'date_tile_pixel_size_modifier', cfg_validator=QDoubleValidator())
self.add_option_line_edit('Date max height multiplier',
'GridView', 'date_tile_max_height_modifier',
cfg_validator=QDoubleValidator())

self.add_option_line_edit('Elided text UTF-8 weight modifier', 'GridView',
self.add_option_line_edit('Date lines to display', 'GridView', 'tile_date_lines',
cfg_validator=QIntValidator())
self.add_option_info(None, None) # Line spacer
self.add_option_line_edit('Line spacing for tile elements<br/>'
'(tip: decrement this if you increment lines)', 'GridView', 'tile_line_spacing',
QDoubleValidator())
self.add_option_line_edit('Unicode line height offset (UTF > ASCII linebreaks)', 'GridView',
'tile_unicode_line_height_offset', cfg_validator=QDoubleValidator())
self.add_option_line_edit('Elided text UTF-8 weight modifier<br/>'
'(Set this to 0 if using phantomstyle)', 'GridView',
'elided_text_unicode_weight_modifier', cfg_validator=QDoubleValidator())

self.add_option_combobox('Tile title text font weight', 'GridView', 'title_tile_font_weight',
TILE_TITLE_FONT_WEIGHTS)

self.add_option_info(None, None) # Line spacer
self.add_option_line_edit('Date format for: videos uploaded'
' less than a day ago', 'GridView', 'timedelta_format')
self.add_option_line_edit('Date format for: videos uploaded'
Expand Down
50 changes: 42 additions & 8 deletions sane_yt_subfeed/gui/views/grid_view/channel_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,71 @@ class ChannelTile(QLabel):
def __init__(self, text, parent):
QLabel.__init__(self, text)
self.parent = parent
# Elided overwrites the original, so we need to keep a copy

# Elided overwrites the original, so we need to keep a copy.
self.original_text = text

self.setMaximumHeight(self.parent.height() * read_config('GridView', 'channel_title_tile_max_height_modifier'))
# Get font metrics/info.
metrics = QFontMetrics(self.font())

self.setWordWrap(True)
# Set up font.
t_font: QFont = self.font()
t_font.setStyleHint(QFont.Helvetica) # FIXME: Make font configurable
t_font.setFixedPitch(True)

# Lines of text to show (determines height of title text item).
lines = read_config('GridView', 'tile_channel_lines')

# Offset the unicode because it has tall characters and its line spacing is thus larger than ASCII's.
#
# If set to 2 there will be 1px clearing beneath unicode,
# but ASCII will show 1px of its supposedly cut-off next line.
unicode_height_offset = read_config('GridView', 'tile_unicode_line_height_offset') # = 1.99

# Set height equal to lines and add some newline spacing for unicode.
self.setFixedHeight((metrics.height() * lines) + (unicode_height_offset * lines))

# Set alignment and enable word wrapping so the text newlines instead of continuing OOB
self.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
self.setWordWrap(True)

t_font = self.font()
t_font.setStyleHint(QFont.Helvetica)
t_font.setPixelSize(self.height() * read_config('GridView', 'channel_title_tile_pixel_size_modifier'))
# Set own font to the new modified one.
self.setFont(t_font)

# Finally, set the text string.
self.setText(text)

def elide_text(self, p_str):
"""
Elide text based on configurable values.
:param p_str: Text.
:return: Elided text.
"""
# Get font metrics/info.
metrics = QFontMetrics(self.font())
# If the string text is wider than width, return an elided version of the string

# Get latest configurable values
elided_modifier = read_config('GridView', 'elided_text_modifier_channel')
lines = read_config('GridView', 'tile_channel_lines')
unicode_weight_modifier = read_config('GridView', 'elided_text_unicode_weight_modifier')

# Non-ASCII needs to be elided at an earlier width.
elided_modifier -= get_unicode_weight(p_str, unicode_weight_modifier)

elided = metrics.elidedText(p_str, Qt.ElideRight, self.width() * elided_modifier)
# If the string text is wider than width, return an elided version of the string
elided = metrics.elidedText(p_str, Qt.ElideRight, self.width() * elided_modifier * lines)

return elided

def setText(self, p_str, elided=True):
"""
Override parent's function to explicitly set ellison, then call parent.
:param p_str: Text.
:param elided: Whether or not to set ellison.
"""
self.original_text = p_str
if elided:
p_str = self.elide_text(p_str)

# Call parent to set modified text the standard way.
super().setText(p_str)
50 changes: 42 additions & 8 deletions sane_yt_subfeed/gui/views/grid_view/date_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,71 @@ class DateTile(QLabel):
def __init__(self, text, parent):
QLabel.__init__(self, text)
self.parent = parent
# Elided overwrites the original, so we need to keep a copy

# Elided overwrites the original, so we need to keep a copy.
self.original_text = text

self.setMaximumHeight(self.parent.height() * read_config('GridView', 'date_tile_max_height_modifier'))
# Get font metrics/info.
metrics = QFontMetrics(self.font())

self.setWordWrap(True)
# Set up font.
t_font: QFont = self.font()
t_font.setStyleHint(QFont.Helvetica) # FIXME: Make font configurable
t_font.setFixedPitch(True)

# Lines of text to show (determines height of title text item).
lines = read_config('GridView', 'tile_date_lines')

# Offset the unicode because it has tall characters and its line spacing is thus larger than ASCII's.
#
# If set to 2 there will be 1px clearing beneath unicode,
# but ASCII will show 1px of its supposedly cut-off next line.
unicode_height_offset = read_config('GridView', 'tile_unicode_line_height_offset') # = 1.99

# Set height equal to lines and add some newline spacing for unicode.
self.setFixedHeight((metrics.height() * lines) + (unicode_height_offset * lines))

# Set alignment and enable word wrapping so the text newlines instead of continuing OOB
self.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
self.setWordWrap(True)

t_font = self.font()
t_font.setStyleHint(QFont.Helvetica)
t_font.setPixelSize(self.height() * read_config('GridView', 'date_tile_pixel_size_modifier'))
# Set own font to the new modified one.
self.setFont(t_font)

# Finally, set the text string.
self.setText(text)

def elide_text(self, p_str):
"""
Elide text based on configurable values.
:param p_str: Text.
:return: Elided text.
"""
# Get font metrics/info.
metrics = QFontMetrics(self.font())
# If the string text is wider than width, return an elided version of the string

# Get latest configurable values
elided_modifier = read_config('GridView', 'elided_text_modifier_date')
lines = read_config('GridView', 'tile_date_lines')
unicode_weight_modifier = read_config('GridView', 'elided_text_unicode_weight_modifier')

# Non-ASCII needs to be elided at an earlier width.
elided_modifier -= get_unicode_weight(p_str, unicode_weight_modifier)

elided = metrics.elidedText(p_str, Qt.ElideRight, self.width() * elided_modifier)
# If the string text is wider than width, return an elided version of the string
elided = metrics.elidedText(p_str, Qt.ElideRight, self.width() * elided_modifier * lines)

return elided

def setText(self, p_str, elided=True):
"""
Override parent's function to explicitly set ellison, then call parent.
:param p_str: Text.
:param elided: Whether or not to set ellison.
"""
self.original_text = p_str
if elided:
p_str = self.elide_text(p_str)

# Call parent to set modified text the standard way.
super().setText(p_str)
53 changes: 43 additions & 10 deletions sane_yt_subfeed/gui/views/grid_view/title_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,72 @@ class TitleTile(QLabel):
def __init__(self, text, parent):
QLabel.__init__(self, text)
self.parent = parent
# Elided overwrites the original, so we need to keep a copy
self.original_text = text

self.setMaximumHeight(self.parent.height() * read_config('GridView', 'title_tile_max_height_modifier'))
# Elided overwrites the original, so we need to keep a copy.
self.original_text = text

self.setWordWrap(True)
self.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
# Get font metrics/info.
metrics = QFontMetrics(self.font())

t_font = self.font()
# Set up font.
t_font: QFont = self.font()
t_font.setWeight(TILE_TITLE_FONT_WEIGHTS_MAP[read_config('GridView', 'title_tile_font_weight')])
t_font.setStyleHint(QFont.Helvetica)
t_font.setStyleHint(QFont.Helvetica) # FIXME: Make font configurable
t_font.setFixedPitch(True)
t_font.setPixelSize(self.height() * read_config('GridView', 'title_tile_pixel_size_modifier'))

# Lines of text to show (determines height of title text item).
lines = read_config('GridView', 'tile_title_lines')

# Offset the unicode because it has tall characters and its line spacing is thus larger than ASCII's.
#
# If set to 2 there will be 1px clearing beneath unicode,
# but ASCII will show 1px of its supposedly cut-off next line.
unicode_height_offset = read_config('GridView', 'tile_unicode_line_height_offset') # = 1.99

# Set height equal to lines and add some newline spacing for unicode.
self.setFixedHeight((metrics.height() * lines) + (unicode_height_offset * lines))

# Set alignment and enable word wrapping so the text newlines instead of continuing OOB.
self.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
self.setWordWrap(True)

# Set own font to the new modified one.
self.setFont(t_font)

# Finally, set the text string.
self.setText(text)

def elide_text(self, p_str):
"""
Elide text based on configurable values.
:param p_str: Text.
:return: Elided text.
"""
# Get font metrics/info.
metrics = QFontMetrics(self.font())
# If the string text is wider than width, return an elided version of the string

# Get latest configurable values
elided_modifier = read_config('GridView', 'elided_text_modifier_title')
lines = read_config('GridView', 'tile_title_lines')
unicode_weight_modifier = read_config('GridView', 'elided_text_unicode_weight_modifier')

# Non-ASCII needs to be elided at an earlier width.
elided_modifier -= get_unicode_weight(p_str, unicode_weight_modifier)

elided = metrics.elidedText(p_str, Qt.ElideRight, self.width() * elided_modifier)
# If the string text is wider than width, return an elided version of the string
elided = metrics.elidedText(p_str, Qt.ElideRight, self.width() * elided_modifier * lines)

return elided

def setText(self, p_str, elided=True):
"""
Override parent's function to explicitly set ellison, then call parent.
:param p_str: Text.
:param elided: Whether or not to set ellison.
"""
self.original_text = p_str
if elided:
p_str = self.elide_text(p_str)

# Call parent to set modified text the standard way.
super().setText(p_str)
Loading

0 comments on commit 94001e0

Please sign in to comment.