Skip to content

Commit 51f8154

Browse files
committed
Merge branch 'develop' into opencv
2 parents 6e93c29 + ff3dfd5 commit 51f8154

File tree

8 files changed

+353
-94
lines changed

8 files changed

+353
-94
lines changed

src/timeline/app.js

+5-16
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
*/
2828

2929
// Initialize Angular application
30-
/*global App, timeline, angular*/
31-
var timeline = null;
30+
/*global App, angular, timeline, init_mixin*/
3231
var App = angular.module("openshot-timeline", ["ui.bootstrap", "ngAnimate"]);
3332

3433

@@ -37,18 +36,8 @@ $(document).ready(function () {
3736

3837
var body_object = $("body");
3938

40-
// Check for Qt Integration
41-
new QWebChannel(qt.webChannelTransport, function (channel) {
42-
timeline = channel.objects.timeline;
43-
timeline.qt_log("INFO", "Qt Ready");
44-
45-
// Only enable Qt once Angular as initialized
46-
angular.element(document).ready(function () {
47-
timeline.qt_log("INFO", "Angular Ready");
48-
body_object.scope().enableQt();
49-
});
50-
51-
});
39+
// Initialize Qt Mixin (WebEngine or WebKit)
40+
init_mixin();
5241

5342
/// Capture window resize event, and resize scrollable divs (i.e. track container)
5443
$(window).resize(function () {
@@ -64,8 +53,8 @@ $(document).ready(function () {
6453

6554
track_controls.height(new_track_height);
6655
$("#scrolling_tracks").height(new_track_height);
67-
body_object.scope().playhead_height = $("#track-container").height();
68-
$(".playhead-line").height(body_object.scope().playhead_height);
56+
body_object.scope().playhead_height = $("#track-container").height();
57+
$(".playhead-line").height(body_object.scope().playhead_height);
6958
});
7059

7160
// Bind to keydown event (to detect SHIFT)

src/timeline/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<script type="text/javascript" src="media/js/angular-animate.min.js"></script>
1818

1919
<!-- OpenShot JavaScript Sources -->
20-
<script type="text/javascript" src="js/qwebchannel.js"></script>
20+
{{MIXIN_JS_INCLUDE}}
2121
<script type="text/javascript" src="app.js"></script>
2222
<script type="text/javascript" src="js/functions.js"></script>
2323
<script type="text/javascript" src="js/controllers.js"></script>

src/timeline/js/mixin_webengine.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @file
3+
* @brief JavaScript file to initialize QtWebEngine JS mixin
4+
* @author Jonathan Thomas <[email protected]>
5+
*
6+
* @section LICENSE
7+
*
8+
* Copyright (c) 2008-2018 OpenShot Studios, LLC
9+
* <http://www.openshotstudios.com/>. This file is part of
10+
* OpenShot Video Editor, an open-source project dedicated to
11+
* delivering high quality video editing and animation solutions to the
12+
* world. For more information visit <http://www.openshot.org/>.
13+
*
14+
* OpenShot Video Editor is free software: you can redistribute it
15+
* and/or modify it under the terms of the GNU General Public License
16+
* as published by the Free Software Foundation, either version 3 of the
17+
* License, or (at your option) any later version.
18+
*
19+
* OpenShot Video Editor is distributed in the hope that it will be
20+
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU General Public License
25+
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
/*global timeline, angular, QWebChannel*/
29+
var timeline = null;
30+
31+
function init_mixin() {
32+
33+
// Check for Qt Integration
34+
var channel = new QWebChannel(qt.webChannelTransport, function (channel) {
35+
timeline = channel.objects.timeline;
36+
timeline.qt_log("INFO", "Qt Ready");
37+
38+
// Only enable Qt once Angular as initialized
39+
angular.element(document).ready(function () {
40+
timeline.qt_log("INFO", "Angular Ready");
41+
$("body").scope().enableQt();
42+
});
43+
44+
});
45+
46+
}

src/timeline/js/mixin_webkit.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @file
3+
* @brief JavaScript file to initialize QtWebKit JS mixin
4+
* @author Jonathan Thomas <[email protected]>
5+
*
6+
* @section LICENSE
7+
*
8+
* Copyright (c) 2008-2018 OpenShot Studios, LLC
9+
* <http://www.openshotstudios.com/>. This file is part of
10+
* OpenShot Video Editor, an open-source project dedicated to
11+
* delivering high quality video editing and animation solutions to the
12+
* world. For more information visit <http://www.openshot.org/>.
13+
*
14+
* OpenShot Video Editor is free software: you can redistribute it
15+
* and/or modify it under the terms of the GNU General Public License
16+
* as published by the Free Software Foundation, either version 3 of the
17+
* License, or (at your option) any later version.
18+
*
19+
* OpenShot Video Editor is distributed in the hope that it will be
20+
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU General Public License
25+
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
/*global timeline, qt, angular*/
29+
30+
function init_mixin() {
31+
32+
// Only enable Qt once Angular as initialized
33+
angular.element(document).ready(function () {
34+
if (typeof timeline !== "undefined") {
35+
timeline.qt_log("INFO", "Qt Ready");
36+
$("body").scope().enableQt();
37+
}
38+
timeline.qt_log("INFO", "Angular Ready");
39+
});
40+
41+
}

src/windows/main_window.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -284,31 +284,33 @@ def create_lock_file(self):
284284
self.clear_all_thumbnails()
285285

286286
# Write lock file (try a few times if failure)
287-
attempts = 5
288-
while attempts > 0:
287+
for attempt in range(5):
289288
try:
290289
# Create lock file
291290
with open(lock_path, 'w') as f:
292291
f.write(lock_value)
292+
log.debug("Wrote value {} to lock file {}".format(
293+
lock_value, lock_path))
293294
break
294-
except Exception:
295-
log.debug('Failed to write lock file (attempt: %s)' % attempts)
296-
attempts -= 1
295+
except OSError:
296+
log.debug('Failed to write lock file (attempt: {})'.format(
297+
attempt), exc_info=1)
297298
sleep(0.25)
298299

299300
def destroy_lock_file(self):
300301
"""Destroy the lock file"""
301302
lock_path = os.path.join(info.USER_PATH, ".lock")
302303

303304
# Remove file (try a few times if failure)
304-
attempts = 5
305-
while attempts > 0:
305+
for attempt in range(5):
306306
try:
307307
os.remove(lock_path)
308+
log.debug("Removed lock file {}".format(lock_path))
308309
break
309-
except Exception:
310-
log.debug('Failed to destroy lock file (attempt: %s)' % attempts)
311-
attempts -= 1
310+
except FileNotFoundError:
311+
break
312+
except OSError:
313+
log.debug('Failed to destroy lock file (attempt: %s)' % attempt, exc_info=1)
312314
sleep(0.25)
313315

314316
def tail_file(self, f, n, offset=None):

src/windows/preferences.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,13 @@ def Populate(self, filter=""):
297297
value_list.remove(value_item)
298298

299299
# Remove hardware mode items which cannot decode the example video
300+
log.debug("Preparing to test hardware decoding: %s" % (value_list))
300301
for value_item in list(value_list):
301302
v = value_item["value"]
302-
if not self.testHardwareDecode(v, 0) and \
303-
not self.testHardwareDecode(v, 1):
303+
if not self.testHardwareDecode(value_list, v, 0) and \
304+
not self.testHardwareDecode(value_list, v, 1):
304305
value_list.remove(value_item)
306+
log.debug("Completed hardware decoding testing")
305307

306308
# Replace %s dropdown values for hardware acceleration
307309
if param["setting"] in ("graca_number_en", "graca_number_de"):
@@ -536,10 +538,11 @@ def dropdown_index_changed(self, widget, param, index):
536538
# Check for restart
537539
self.check_for_restart(param)
538540

539-
def testHardwareDecode(self, decoder, decoder_card="0"):
541+
def testHardwareDecode(self, all_decoders, decoder, decoder_card="0"):
540542
"""Test specific settings for hardware decode, so the UI can remove unsupported options."""
541543
is_supported = False
542544
example_media = os.path.join(info.RESOURCES_PATH, "hardware-example.mp4")
545+
decoder_name = next(item for item in all_decoders if item["value"] == str(decoder)).get("name", "Unknown")
543546

544547
# Persist decoder card results
545548
if decoder_card not in self.hardware_tests_cards:
@@ -552,6 +555,9 @@ def testHardwareDecode(self, decoder, decoder_card="0"):
552555
# Keep track of previous settings
553556
current_decoder = openshot.Settings.Instance().HARDWARE_DECODER
554557
current_decoder_card = openshot.Settings.Instance().HW_DE_DEVICE_SET
558+
current_decoder_name = \
559+
next(item for item in all_decoders if item["value"] == str(current_decoder)).get("name", "Unknown")
560+
log.debug("Current hardware decoder: %s (%s-%s)" % (current_decoder_name, current_decoder, current_decoder_card))
555561

556562
try:
557563
# Temp override hardware settings (to test them)
@@ -566,17 +572,21 @@ def testHardwareDecode(self, decoder, decoder_card="0"):
566572
reader.Open()
567573

568574
# Test decoded pixel values for a valid decode (based on hardware-example.mp4)
575+
log.debug("Testing hardware decoder: %s (%s-%s)" % (decoder_name, decoder, decoder_card))
569576
if reader.GetFrame(0).CheckPixel(0, 0, 2, 133, 255, 255, 5):
570577
is_supported = True
571578
self.hardware_tests_cards[decoder_card].append(int(decoder))
579+
log.debug("Successful hardware decoder! %s (%s-%s)" % (decoder_name, decoder, decoder_card))
572580
else:
573-
log.warning("CheckPixel failed testing hardware decoding in preferences (i.e. wrong color found): %s-%s" % (decoder, decoder_card))
581+
log.debug("CheckPixel failed testing hardware decoding (i.e. wrong color found): %s (%s-%s)" %
582+
(decoder_name, decoder, decoder_card))
574583

575584
reader.Close()
576585
clip.Close()
577586

578587
except:
579-
log.warning("Exception trying to test hardware decoding in preferences (this is expected): %s-%s" % (decoder, decoder_card))
588+
log.debug("Exception trying to test hardware decoding (this is expected): %s (%s-%s)" %
589+
(decoder_name, decoder, decoder_card))
580590

581591
# Resume current settings
582592
openshot.Settings.Instance().HARDWARE_DECODER = current_decoder

0 commit comments

Comments
 (0)