Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@
"sortOptionTimesPlayedMoreInfo": "Show the times played order option in the sorting dropdown",
"sortOptionYearDescription": "Year",
"sortOptionYearMoreInfo": "Show the year order option in the sorting dropdown. Only affected by the year you manually set in the details view",
"sortOptionAspectRatioDescription": "Aspect Ratio",
"sortOptionAspectRatioMoreInfo": "Show the aspect ratio order option in the sorting dropdown",
"sortOrderDescription": "Sort order",
"sortOrderHint": "Sort order",
"sortOrderMoreInfo": "Show the sort order filter",
Expand Down Expand Up @@ -291,6 +293,7 @@
"sortTime": "Duration",
"sortTimesPlayed": "Times played",
"sortYear": "Year",
"sortAspectRatio": "Aspect ratio",
"tagExclusion": "tags do not have",
"tagIntersection": "tags include",
"tagUnion": "tags include any",
Expand Down
3 changes: 3 additions & 0 deletions i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"sortOptionTimesPlayedMoreInfo": "Afficher l'option de commande des temps joués dans le menu déroulant de tri",
"sortOptionYearDescription": "Année",
"sortOptionYearMoreInfo": "Afficher l’option de l’année dans le menu déroulant de tri. Uniquement affecté par l'année que vous avez définie manuellement dans la vue Détails",
"sortOptionAspectRatioDescription": "Ratio d'aspect",
"sortOptionAspectRatioMoreInfo": "Afficher l'option de ratio d'aspect dans la liste déroulante de tri",
"sortOrderDescription": "Ordre de tri",
"sortOrderHint": "Ordre de tri",
"sortOrderMoreInfo": "Afficher le filtre d'ordre de tri",
Expand Down Expand Up @@ -268,6 +270,7 @@
"sortTime": "Durée",
"sortTimesPlayed": "Fois joué",
"sortYear": "Année",
"sortAspectRatio": "Ratio d'aspect",
"tagExclusion": "les balises n'ont pas",
"tagIntersection": "les tags incluent",
"tagUnion": "les tags incluent",
Expand Down
11 changes: 10 additions & 1 deletion src/app/common/settings-buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const SettingsButtonsGroups: string[][] = [
'sortOptionStar',
'sortOptionYear',
'sortOptionModified',
'sortOptionTags'
'sortOptionTags',
'sortOptionAspectRatio'
],
[
'duplicateLength',
Expand Down Expand Up @@ -620,6 +621,14 @@ export const SettingsButtons: { [s: string]: SettingsButton } = {
title: '',
toggled: false,
},
'sortOptionAspectRatio': {
description: 'BUTTONS.sortOptionAspectRatioDescription',
hidden: false,
iconName: 'icon-checkmark', // this specific icon makes the button only appear in the Settings menu (not in ribbon)
moreInfo: 'BUTTONS.sortOptionAspectRatioMoreInfo',
title: '',
toggled: false,
},
'sortOrder': {
description: 'BUTTONS.sortOrderDescription',
hidden: false,
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/sort-order/sort-order.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<option *ngIf="settingsButtons['sortOptionTags'].toggled" value="tagsDesc">
&#x25BC; {{ 'SIDEBAR.sortTags' | translate }}
</option>
<option *ngIf="settingsButtons['sortOptionAspectRatio'].toggled" value="aspectRatioAsc">
&#x25B2; {{ 'SIDEBAR.sortAspectRatio' | translate }}
</option>
<option *ngIf="settingsButtons['sortOptionAspectRatio'].toggled" value="aspectRatioDesc">
&#x25BC; {{ 'SIDEBAR.sortAspectRatio' | translate }}
</option>
<option value="random">
{{ 'SIDEBAR.sortRandom' | translate }}
</option>
Expand Down
23 changes: 23 additions & 0 deletions src/app/pipes/sorting.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { randomizeArray } from '../../../utility';
export type SortType = 'default'
| 'alphabetAsc'
| 'alphabetDesc'
| 'aspectRatioAsc'
| 'aspectRatioDesc'
| 'hash' // only used by the duplicateFinderPipe
| 'modifiedAsc'
| 'modifiedDesc'
Expand Down Expand Up @@ -99,6 +101,19 @@ export class SortingPipe implements PipeTransform {
}
}

if (property === 'aspectRatio') {
var xAspectRatio = x.width / x.height;
var yAspectRatio = y.width / y.height;

if (xAspectRatio < yAspectRatio) {
if (decreasing) { return 1 } else { return -1;}
} if (xAspectRatio > yAspectRatio) {
if (decreasing) { return -1 } else { return 1;}
} else {
return 0;
}
}

if (decreasing) {
return (x[property]) - (y[property]);
} else {
Expand Down Expand Up @@ -205,6 +220,14 @@ export class SortingPipe implements PipeTransform {
return galleryArray.slice().sort((x: ImageElement, y: ImageElement): any => {
return this.sortFunctionLol(x, y, 'tags', false);
});
} else if (sortingType === 'aspectRatioAsc') {
return galleryArray.slice().sort((x: ImageElement, y: ImageElement): any => {
return this.sortFunctionLol(x, y, 'aspectRatio', false);
});
} else if (sortingType === 'aspectRatioDesc') {
return galleryArray.slice().sort((x: ImageElement, y: ImageElement): any => {
return this.sortFunctionLol(x, y, 'aspectRatio', true);
});
} else {
return galleryArray.slice().sort((x: ImageElement, y: ImageElement): any => {
return this.sortFunctionLol(x, y, 'index', true);
Expand Down