mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Do not show hours when duration is shorter #14
This commit is contained in:
9
clapper_src/controls.js
vendored
9
clapper_src/controls.js
vendored
@@ -27,8 +27,9 @@ class ClapperControls extends Gtk.Box
|
||||
this.currentDuration = 0;
|
||||
this.isPositionDragging = false;
|
||||
|
||||
this.durationFormated = '00:00:00';
|
||||
this.elapsedInitial = '00:00:00/00:00:00';
|
||||
this.showHours = false;
|
||||
this.durationFormatted = '00:00';
|
||||
this.elapsedInitial = '00:00/00:00';
|
||||
this.buttonsArr = [];
|
||||
|
||||
this._addTogglePlayButton();
|
||||
@@ -98,8 +99,8 @@ class ClapperControls extends Gtk.Box
|
||||
{
|
||||
value = value || 0;
|
||||
|
||||
let elapsed = Misc.getFormatedTime(value)
|
||||
+ '/' + this.durationFormated;
|
||||
let elapsed = Misc.getFormattedTime(value, this.showHours)
|
||||
+ '/' + this.durationFormatted;
|
||||
|
||||
this.elapsedButton.set_label(elapsed);
|
||||
}
|
||||
|
@@ -68,13 +68,18 @@ function inhibitForState(state, window)
|
||||
debug(`set prevent suspend to: ${isInhibited}`);
|
||||
}
|
||||
|
||||
function getFormatedTime(time)
|
||||
function getFormattedTime(time, showHours)
|
||||
{
|
||||
let hours = ('0' + Math.floor(time / 3600)).slice(-2);
|
||||
time -= hours * 3600;
|
||||
let hours;
|
||||
|
||||
if(showHours || time >= 3600) {
|
||||
hours = ('0' + Math.floor(time / 3600)).slice(-2);
|
||||
time -= hours * 3600;
|
||||
}
|
||||
let minutes = ('0' + Math.floor(time / 60)).slice(-2);
|
||||
time -= minutes * 60;
|
||||
let seconds = ('0' + Math.floor(time)).slice(-2);
|
||||
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
let parsed = (hours) ? `${hours}:` : '';
|
||||
return parsed + `${minutes}:${seconds}`;
|
||||
}
|
||||
|
@@ -437,8 +437,10 @@ var Widget = GObject.registerClass({
|
||||
return;
|
||||
|
||||
this.controls.currentDuration = duration;
|
||||
this.controls.showHours = (duration >= 3600);
|
||||
|
||||
this.controls.positionAdjustment.set_upper(duration);
|
||||
this.controls.durationFormated = Misc.getFormatedTime(duration);
|
||||
this.controls.durationFormatted = Misc.getFormattedTime(duration);
|
||||
this.controls.updateElapsedLabel();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user