Skip to content

Commit

Permalink
Improved partitioning of actions in the menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbhaley committed Jan 9, 2025
1 parent 96725ce commit 9485438
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/calibre/gui2/actions/all_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ def add_action(menu, display_name):
ma.setEnabled(act.qaction.isEnabled())

# Finally the real work, building the action menu. Partition long lists
# of actions into sublists of some arbitrary length.
# of actions into mostly-equal-length sublists of some arbitrary length.
def partition(names):
count_in_partition = 10 # arbitrary
if len(names) >= count_in_partition:
partition_count = len(names) // (count_in_partition - 1)
max_in_partition = 10 # arbitrary
if len(names) >= max_in_partition:
partition_count = ceil(len(names) / max_in_partition)
step = int(ceil(len(names) / partition_count))
for first in range(0, len(names), step):
last = min(first + step - 1, len(names) - 1)
Expand Down

0 comments on commit 9485438

Please sign in to comment.