mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improved partitioning of actions in the menu.
This commit is contained in:
parent
96725ce841
commit
94854384ae
@ -135,11 +135,11 @@ class AllGUIActions(InterfaceAction):
|
|||||||
ma.setEnabled(act.qaction.isEnabled())
|
ma.setEnabled(act.qaction.isEnabled())
|
||||||
|
|
||||||
# Finally the real work, building the action menu. Partition long lists
|
# 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):
|
def partition(names):
|
||||||
count_in_partition = 10 # arbitrary
|
max_in_partition = 10 # arbitrary
|
||||||
if len(names) >= count_in_partition:
|
if len(names) >= max_in_partition:
|
||||||
partition_count = len(names) // (count_in_partition - 1)
|
partition_count = ceil(len(names) / max_in_partition)
|
||||||
step = int(ceil(len(names) / partition_count))
|
step = int(ceil(len(names) / partition_count))
|
||||||
for first in range(0, len(names), step):
|
for first in range(0, len(names), step):
|
||||||
last = min(first + step - 1, len(names) - 1)
|
last = min(first + step - 1, len(names) - 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user