Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished aliasing modifications & merged theme changes/ #111

Merged
merged 4 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ Example user interface using the Breeze and BreezeDark stylesheets side-by-side.
</tbody>
</table>

Alternative themes - Change QTableWidget hover behavior to highlight whole row, instead of individual cells.

<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><img src="./assets/dark-blue.png" alt="Dark blue standard demo" ></td>
<td><img src="./assets/dark-blue-alt.png" alt="Dark blue alt demo" ></td>
</tr>
</tbody>
</table>

For an extensive view of screenshots of the theme, see the [gallery](assets/gallery.md).

# Customization
Expand Down
Binary file added assets/dark-blue-alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dark-blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def parse_args(argv=None):
parser.add_argument(
'--styles',
help='comma-separate list of styles to configure. pass `all` to build all themes',
default='light,dark',
default='light-blue,dark-blue',
)
parser.add_argument(
'--extensions',
Expand Down Expand Up @@ -335,7 +335,10 @@ def write_qrc(config, qt_dist):
for style in config['themes'].keys():
files = os.listdir(f'{qt_dist}/{style}')
resources += [f'{style}/{i}' for i in files]
resources += ['dark-blue/stylesheet.qss', 'light-blue/stylesheet.qss']
if 'dark-blue' in config['themes'].keys():
resources.append('dark/stylesheet.qss')
if 'light-blue' in config['themes'].keys():
resources.append('light/stylesheet.qss')

qrc_path = config['resource']
if not os.path.isabs(qrc_path):
Expand Down Expand Up @@ -412,11 +415,12 @@ def configure(args):
for style in config['themes']:
configure_style(config, style, str(args.output_dir))

# create aliases for our light and dark styles to light-blue and dark-blue
# FIXME: Invert the order: light should be an alias of light-blue, etc.
for theme in ('dark', 'light'):
# Create aliases for our light-blue and dark-blue styles to light and dark.
# Only create aliases if light-blue and/or dark-blue are to be built.
themes = [theme for theme in args.styles if theme in ('dark-blue', 'light-blue')]
for theme in themes:
source = args.output_dir / theme / 'stylesheet.qss'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be improved to use a set but it's fine as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. When you say it could be improved using a set , do you mean as below? If so, what's the benefit to this over using a list comprehension with a tuple? I guess sets are slightly more efficient but is that the only difference in this context? Sorry, probably a noob question!

themes = {theme for theme in args.styles if theme in {'dark-blue', 'light-blue'}}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did something like this:

set(args.styles) & {'dark-blue', 'light-blue'}

It uses set intersection to grab the overlap between the two. Technically a bit slower but the performance really doesn't matter: it's very easy to read and can be extended pretty well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good info, thanks. I didn't know set intersection was available in Python so easily. Thanks

destination = args.output_dir / f'{theme}-blue' / 'stylesheet.qss'
destination = args.output_dir / theme.split('-')[0] / 'stylesheet.qss'
destination.parent.mkdir(exist_ok=True)
shutil.copy2(source, destination)

Expand Down
Loading
Loading