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 4, 2019
2 parents 5756190 + 3806e8c commit 24d9035
Show file tree
Hide file tree
Showing 41 changed files with 4,034 additions and 264 deletions.
39 changes: 39 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
Current

v0.6.0
- Added attrib original_text in VideoTile elements to save the unedited text before ellison overwrites it forever.
- Tuned all the pixel size, ellison and max size values to work with the new VideoTime system.
- Made all the new max size and ellison settings configurable.
- Fixed ellison inconsistency and mismatch issues by creating a function get_unicode_weight which calculates a
"width-weight" for unicode characters, and then that weight is subtracted from the ellison modifier.
- Changed VideoTile sizing logic to use a maximum size instead of fixed size, which fixed the issue with QLabel text
going OOB.
- Added debug tile coloring for padding debug.
- Made channel title and date text pixel size configurable
- Made title text weight configurable (Normal, DemiBold, Bold).
- Merged configurable database type and location into one single option 'url'.
- Fixed bug where timestamp wouldn't show the correct level, due to accidentally being offset by 1.
- Made config inform about which options require restart. Also: rearranged some options.
- Fixed broken thumbnail tooltip feature.
- Moved get_default_player from playback to super (VideoTile).
- Cleaned up keyboard modifiers code a bit.
- Fixed bad function signatures.
- Made player an optional kwarg in open_in_player()
- Refactored some strings.
- Deprecated and deleted config_play_video function.
- Made Subfeed context menu options on par with Playback's (alt players etc, mark watched, play w/o mark watched, etc...).
- Fixed buggy implementation of mousePressEvent in Subfeed that listened to *all* mouse events, not just LeftButton (whoops!).
- Added Playback's MidButton decrease_prio/mark_downloaded functionality to Subfeed.
- Created a function open_in_browser that properly opens a url in the web browser.
- Added some pydoc here and there.
- Made open_in_player compatible with being served URLs as well as file paths.
- Deprecated and deleted 'use_url_as_path' config hotfix.
- Added "restart may be required" signifier to config options w/o bindings.
- Fixed bug where timedelta years weren't subtracted by 10 when showing decades.
- Made youtube-dl an optional dependency, and removed tqdm entirely.
- Added in stock BreezeStyleSheets and made them load instead of the windows modded ones if you're on Linux. Also added
a missing README.md.
- Added toolbar icon size modifier for use on High DPI displays.
- Implemented actions and kwargs bindings in GenericLineEdit.
- Tweaked Elided text modifier for video title to perfection (if text is bolded or otherwise it will cut off a little
sooner than this perfection, but that's why it's been made user configurable).
- Explicitly set progress bars to blue instead of assuming it would be the default (varies with QStyle and QPalette).
- Fixed issue #5 (Launched players would quit along with Sane) by pre-pending 'nohup' to Popen arguments (if Linux).
- Changed timedelta formatting delimiter from % to $ due to shortcomings in ConfigParser (%% is an escaped percent sign,
so config parser finds it, but it doesn't actually do anything, but % isn't a valid string interpolation. so it fails.
Expand Down
2 changes: 0 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ requests = ">=2.20.0"
requests-oauthlib = "==1.0.0"
rsa = "==3.4.2"
six = "==1.11.0"
tqdm = "==4.23.4"
uritemplate = "==3.0.0"
"urllib3" = "==1.23"
watchdog = "==0.8.3"
Expand All @@ -38,7 +37,6 @@ Pillow = "==5.2.0"
"PyQt5" = "==5.11.2"
"PyQt5-sip" = "==4.19.11"
SQLAlchemy = "==1.2.10"
youtube_dl = "*"

[dev-packages]

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ This code is primarily tested on the following platforms:
* Python 3.6 and above: `pip install -r requirements.txt`
* Python 3.5 and below: `pip install -r requirements-py35.txt` _(NB: Will likely be deprecated in near future)_

### 2a. Optional requirements:
youtube-dl and watchdog (video directory monitoring)
* Any Python version: `pip install -r optional-requirements.txt`

### 3. Set up OAuth and API keys (pick _one_ option).
OAuth is required for access to your own youtube account (like retrieving subscriptions list).
For anything else API keys is usually what gets used.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.1
0.6
18 changes: 12 additions & 6 deletions config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ cached_subs = True
start_with_stored_videos = False
channels_limit = -1
use_playlistitems = True
disable_tqdm = True
disable_tooltips = False
show_grab_method = False
show_unimplemented_gui = False
display_all_exceptions = False
color_tile_elements = False

[Gui]
launch_gui = True
Expand All @@ -38,6 +38,7 @@ keep_thumb_ar = True
enable_auto_copy_to_clipboard = False
bgcolor =
darkmode_icons = False
toolbar_icon_size_modifier = 1

[Theme]
last_style =
Expand All @@ -46,10 +47,17 @@ last_theme =
[GridView]
show_watched = False
show_dismissed = False
title_tile_pixel_size = 0.40
elided_text_modifier_title = 1.75
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_unicode_weight_modifier = 0.0075
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 Expand Up @@ -88,7 +96,6 @@ img_threads = 200
enabled = False
yt_file_path =
disable_dir_listener = False
use_url_as_path = False
default_watch_prio = 10

[Youtube-dl]
Expand Down Expand Up @@ -145,6 +152,5 @@ log_level = 1
logging_port = 19996

[Database]
type = sqlite:///
location = <path>/permanents.db
url = sqlite:///<path>/permanents.db

1 change: 1 addition & 0 deletions optional-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
youtube-dl>=2019.1.30.1
2 changes: 0 additions & 2 deletions requirements-py35.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ requests-oauthlib==1.0.0
rsa==3.4.2
six==1.11.0
SQLAlchemy==1.2.10
tqdm==4.23.4
uritemplate==3.0.0
urllib3==1.23
watchdog==0.8.3
youtube-dl==2018.7.29
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ rsa==3.4.2
#-e git+git@github.com:BluABK/sane-subfeed.git@f165de62cf16d343f388dce64a61de29545847fb#egg=Sane_Subscription_Feed
six==1.11.0
SQLAlchemy==1.2.10
tqdm==4.23.4
uritemplate==3.0.0
urllib3==1.23
watchdog==0.8.3
youtube-dl==2019.1.30.1
26 changes: 16 additions & 10 deletions sane_yt_subfeed/config_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
'start_with_stored_videos': 'False',
'channels_limit': '-1',
'use_playlistitems': 'True',
'disable_tqdm': 'True',
'disable_tooltips': 'False',
'show_grab_method': 'False',
'show_unimplemented_gui': 'False',
'display_all_exceptions': 'False'
'display_all_exceptions': 'False',
'color_tile_elements': 'False'
},
'Gui': {
'launch_gui': 'True',
Expand All @@ -56,7 +56,8 @@
'keep_thumb_ar': 'True',
'enable_auto_copy_to_clipboard': 'False',
'bgcolor': "",
'darkmode_icons': 'False'
'darkmode_icons': 'False',
'toolbar_icon_size_modifier': '1'
},
'Theme': {
'last_style': "",
Expand All @@ -65,10 +66,17 @@
'GridView': {
'show_watched': 'False',
'show_dismissed': 'False',
'title_tile_pixel_size': '0.40',
'elided_text_modifier_title': '1.75',
'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': 'Bold',
'elided_text_unicode_weight_modifier': '0.0075',
'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 Expand Up @@ -107,7 +115,6 @@
'enabled': 'False',
'yt_file_path': "",
'disable_dir_listener': 'False',
'use_url_as_path': 'False',
'default_watch_prio': '10'
},
'Youtube-dl': {
Expand Down Expand Up @@ -163,8 +170,7 @@
'logging_port': '19996'
},
'Database': {
'type': 'sqlite:///',
'location': os.path.join(OS_PATH, 'resources', 'permanents.db')
'url': 'sqlite:///{}'.format(os.path.join(OS_PATH, 'resources', 'permanents.db'))
}
}

Expand Down Expand Up @@ -211,9 +217,9 @@
config_sample_parser = ConfigParser()
for section in DEFAULTS:
if section == 'Database':
# Mask database location so it's not included in sample ini file
# Mask database path so it's not included in sample ini file
modified_section = copy.deepcopy(DEFAULTS[section])
modified_section['location'] = '<path>/permanents.db'
modified_section['url'] = 'sqlite:///<path>/permanents.db'
config_sample_parser[section] = modified_section
else:
config_sample_parser[section] = DEFAULTS[section]
Expand Down
2 changes: 2 additions & 0 deletions sane_yt_subfeed/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RESTART_REQUIRED_SIGNIFIER = '<b>*</b>' # ' <b><font color=gold>*</font></b>'
HEXADECIMAL_COLOR_REGEX = '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$'
3 changes: 3 additions & 0 deletions sane_yt_subfeed/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# FIXME: imp*
# from sane_yt_subfeed.controller.listeners import *
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication

from sane_yt_subfeed.config_handler import read_config
Expand All @@ -17,6 +18,8 @@ def __init__(self):
self.logger = create_logger(__name__)

def run(self):
# Enable Qt built-in High DPI scaling attribute (must be set *before* creating a QApplication!)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)

self.logger.info("Running Controller instance")
Expand Down
6 changes: 5 additions & 1 deletion sane_yt_subfeed/controller/view_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from PyQt5.QtCore import QThread
from PyQt5.QtCore import QThread, Qt
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import QProgressBar
from sqlalchemy import asc, desc, false, or_
from sqlalchemy.dialects import postgresql
Expand Down Expand Up @@ -212,6 +213,9 @@ def create_progressbar_on_statusbar(self, parent):
:return:
"""
self.status_bar_progress = QProgressBar(parent=parent)
palette = QPalette(self.status_bar_progress.palette())
palette.setColor(QPalette.Highlight, QColor(24, 68, 91).lighter(200))
self.status_bar_progress.setPalette(palette)
self.status_bar_listener = ProgressBarListener(self, self.status_bar_progress)
self.status_bar_thread = QThread()
self.status_bar_thread.setObjectName('status_bar_thread')
Expand Down
7 changes: 3 additions & 4 deletions sane_yt_subfeed/database/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@


OS_PATH = os.path.dirname(__file__)
DB_PATH = read_config('Database', 'location', literal_eval=False)
DB_TYPE = read_config('Database', 'type', literal_eval=False)
DB_URL = read_config('Database', 'url', literal_eval=False)

engine = create_engine('{}{}'.format(DB_TYPE, DB_PATH), convert_unicode=True)
logger.info("Created DB engine: {}{}, convert_unicode=True".format(DB_TYPE, DB_PATH))
engine = create_engine(DB_URL, convert_unicode=True)
logger.info("Created DB engine: {}, convert_unicode=True".format(DB_URL))
db_session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine))
logger.info("Created DB session")
PermanentBase = declarative_base()
Expand Down
47 changes: 41 additions & 6 deletions sane_yt_subfeed/gui/main_window/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import json
from PyQt5.QtCore import QFile, QTextStream, QRegExp
from PyQt5.QtGui import QIcon, QRegExpValidator
from PyQt5.QtWidgets import QApplication, QMainWindow, qApp, QStackedWidget, QStyleFactory, QFileDialog
from PyQt5.QtWidgets import QApplication, QMainWindow, qApp, QStackedWidget, QStyleFactory, QFileDialog, QStyle, \
QProxyStyle
from subprocess import check_output

# Project internal libs
Expand All @@ -30,7 +31,7 @@
from sane_yt_subfeed.gui.main_window.toolbar import Toolbar
from sane_yt_subfeed.gui.main_window.toolbar_action import SaneToolBarAction
from sane_yt_subfeed.gui.themes import themes
from sane_yt_subfeed.gui.themes.themes import THEMES_LIST, QSTYLES_AVAILABLE
from sane_yt_subfeed.gui.themes.themes import THEMES_AVAILABLE, QSTYLES_AVAILABLE
from sane_yt_subfeed.gui.views.about_view.about_view import AboutView
from sane_yt_subfeed.gui.views.config_view.config_view_tabs import ConfigViewTabs
from sane_yt_subfeed.gui.views.config_view.config_window import ConfigWindow
Expand Down Expand Up @@ -101,6 +102,18 @@
QMAINWINDOW_DIMENSIONS = [770, 700]


class EnbiggenedToolbarStyle(QProxyStyle):
pass

def pixelMetric(self, QStyle_PixelMetric, option=None, widget=None):
if QStyle_PixelMetric == QStyle.PM_ToolBarIconSize:
return QProxyStyle.pixelMetric(self,
QStyle_PixelMetric, option,
widget) * read_config('Gui', 'toolbar_icon_size_modifier')
else:
return QProxyStyle.pixelMetric(self, QStyle_PixelMetric, option, widget)


class MainWindow(QMainWindow):
# noinspection PyArgumentList
def __init__(self, app: QApplication, main_model: MainModel, dimensions=None, position=None):
Expand All @@ -116,7 +129,10 @@ def __init__(self, app: QApplication, main_model: MainModel, dimensions=None, po
# Set the exception hook to be wrapped by the Exception Handler
sys.excepthook = self.exceptionHandler.handler

self.themes_list = THEMES_LIST
if sys.platform.startswith('linux'):
self.themes_list = THEMES_AVAILABLE['linux']
else:
self.themes_list = THEMES_AVAILABLE['windows']
self.bgcolor = read_config('Gui', 'bgcolor', literal_eval=False)
self.darkmode = read_config('Gui', 'darkmode_icons')

Expand Down Expand Up @@ -145,6 +161,8 @@ def __init__(self, app: QApplication, main_model: MainModel, dimensions=None, po
# Declare theming
self.current_theme = None
self.current_theme_idx = 0
self.current_style = None
self.update_toolbar_size()
self.hotkey_ctrl_down = False

# Declare MainWindow things
Expand Down Expand Up @@ -968,10 +986,11 @@ def set_theme(self, theme, stylesheet=True):
theme_stream = QTextStream(theme_file)
self.app.setStyleSheet(theme_stream.readAll())
set_config('Theme', 'last_theme', theme)
self.current_theme = theme
else:
self.app.setStyle(QStyleFactory.create(theme))
set_config('Theme', 'last_style', theme)
self.current_theme = theme
self.current_style = theme

def set_theme_native(self):
"""
Expand All @@ -981,10 +1000,16 @@ def set_theme_native(self):
self.set_theme(None)

def set_theme_breeze_dark(self):
self.set_theme(themes.BREEZE_DARK)
if sys.platform.startswith('linux'):
self.set_theme(themes.BREEZE_DARK)
else: # Windows
self.set_theme(themes.BREEZE_DARK_WINDOWS_MOD)

def set_theme_breeze_light(self):
self.set_theme(themes.BREEZE_LIGHT)
if sys.platform.startswith('linux'):
self.set_theme(themes.BREEZE_LIGHT)
else: # Windows
self.set_theme(themes.BREEZE_LIGHT_WINDOWS_MOD)

def add_available_qstyles_to_menu(self, menu, subsubmenu=False):
"""
Expand All @@ -1008,6 +1033,16 @@ def set_qstyle(self, q_style):
"""
self.set_theme(q_style, stylesheet=False)

def update_toolbar_size(self):
"""
Sets toolbar enbiggened qstyle
:param q_style:
:return:
"""
source_style = 'Fusion' # self.current_style
enbiggened_style = EnbiggenedToolbarStyle(self.current_style)
self.setStyle(enbiggened_style)

def cycle_themes(self):
"""
Cycles through the available themes.
Expand Down
Loading

0 comments on commit 24d9035

Please sign in to comment.