This commit is contained in:
Raoul Snyman 2016-12-16 22:14:18 +02:00
commit 5fbbb1ae9e
12 changed files with 959 additions and 60 deletions

View File

@ -61,9 +61,8 @@ def source_group(inputs, source_text):
""" """
groupdict = {} groupdict = {}
keydict = {} keydict = {}
checklist = inputs key = inputs[0][0]
key = checklist[0][0] for item in inputs:
for item in checklist:
if item[0] == key: if item[0] == key:
groupdict[item] = source_text[item] groupdict[item] = source_text[item]
continue continue
@ -75,7 +74,7 @@ def source_group(inputs, source_text):
return keydict return keydict
def Build_Tab(group, source_key, default, projector, projectordb, edit=False): def build_tab(group, source_key, default, projector, projectordb, edit=False):
""" """
Create the radio button page for a tab. Create the radio button page for a tab.
Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs. Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
@ -174,7 +173,7 @@ class FingerTabBarWidget(QtWidgets.QTabBar):
:param width: Remove default width parameter in kwargs :param width: Remove default width parameter in kwargs
:param height: Remove default height parameter in kwargs :param height: Remove default height parameter in kwargs
""" """
self.tabSize = QtWidgets.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25)) self.tabSize = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs) QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs)
def paintEvent(self, event): def paintEvent(self, event):
@ -275,7 +274,7 @@ class SourceSelectTabs(QtWidgets.QDialog):
keys.sort() keys.sort()
if self.edit: if self.edit:
for key in keys: for key in keys:
(tab, button_count, buttonchecked) = Build_Tab(group=self.button_group, (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
source_key={key: self.source_group[key]}, source_key={key: self.source_group[key]},
default=self.projector.source, default=self.projector.source,
projector=self.projector, projector=self.projector,
@ -290,7 +289,7 @@ class SourceSelectTabs(QtWidgets.QDialog):
QtWidgets.QDialogButtonBox.Cancel) QtWidgets.QDialogButtonBox.Cancel)
else: else:
for key in keys: for key in keys:
(tab, button_count, buttonchecked) = Build_Tab(group=self.button_group, (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
source_key={key: self.source_group[key]}, source_key={key: self.source_group[key]},
default=self.projector.source, default=self.projector.source,
projector=self.projector, projector=self.projector,

View File

@ -27,17 +27,6 @@
<link rel="stylesheet" href="/files/jquery.mobile.min.css" /> <link rel="stylesheet" href="/files/jquery.mobile.min.css" />
<link rel="stylesheet" href="/files/openlp.css" /> <link rel="stylesheet" href="/files/openlp.css" />
<link rel="shortcut icon" type="image/x-icon" href="/files/images/favicon.ico"> <link rel="shortcut icon" type="image/x-icon" href="/files/images/favicon.ico">
<script type="text/javascript" src="/files/jquery.min.js"></script>
<script type="text/javascript" src="/files/openlp.js"></script>
<script type="text/javascript" src="/files/jquery.mobile.min.js"></script>
<script type="text/javascript">
translationStrings = {
"go_live": "${go_live}",
"add_to_service": "${add_to_service}",
"no_results": "${no_results}",
"home": "${home}"
}
</script>
</head> </head>
<body> <body>
<div data-role="page" id="home"> <div data-role="page" id="home">
@ -173,5 +162,17 @@
<a href="#" id="add-and-go-to-service" data-role="button">${add_and_go_to_service}</a> <a href="#" id="add-and-go-to-service" data-role="button">${add_and_go_to_service}</a>
</div> </div>
</div> </div>
<script type="text/javascript" src="/files/jquery.min.js"></script>
<script type="text/javascript" src="/files/jquery-migrate.min.js"></script>
<script type="text/javascript" src="/files/jquery.mobile.min.js"></script>
<script type="text/javascript" src="/files/openlp.js"></script>
<script type="text/javascript">
translationStrings = {
"go_live": "${go_live}",
"add_to_service": "${add_to_service}",
"no_results": "${no_results}",
"home": "${home}"
};
</script>
</body> </body>
</html> </html>

View File

@ -0,0 +1,752 @@
/*!
* jQuery Migrate - v1.4.1 - 2016-05-19
* Copyright jQuery Foundation and other contributors
*/
(function( jQuery, window, undefined ) {
// See http://bugs.jquery.com/ticket/13335
// "use strict";
jQuery.migrateVersion = "1.4.1";
var warnedAbout = {};
// List of warnings already given; public read only
jQuery.migrateWarnings = [];
// Set to true to prevent console output; migrateWarnings still maintained
// jQuery.migrateMute = false;
// Show a message on the console so devs know we're active
if ( window.console && window.console.log ) {
window.console.log( "JQMIGRATE: Migrate is installed" +
( jQuery.migrateMute ? "" : " with logging active" ) +
", version " + jQuery.migrateVersion );
}
// Set to false to disable traces that appear with warnings
if ( jQuery.migrateTrace === undefined ) {
jQuery.migrateTrace = true;
}
// Forget any warnings we've already given; public
jQuery.migrateReset = function() {
warnedAbout = {};
jQuery.migrateWarnings.length = 0;
};
function migrateWarn( msg) {
var console = window.console;
if ( !warnedAbout[ msg ] ) {
warnedAbout[ msg ] = true;
jQuery.migrateWarnings.push( msg );
if ( console && console.warn && !jQuery.migrateMute ) {
console.warn( "JQMIGRATE: " + msg );
if ( jQuery.migrateTrace && console.trace ) {
console.trace();
}
}
}
}
function migrateWarnProp( obj, prop, value, msg ) {
if ( Object.defineProperty ) {
// On ES5 browsers (non-oldIE), warn if the code tries to get prop;
// allow property to be overwritten in case some other plugin wants it
try {
Object.defineProperty( obj, prop, {
configurable: true,
enumerable: true,
get: function() {
migrateWarn( msg );
return value;
},
set: function( newValue ) {
migrateWarn( msg );
value = newValue;
}
});
return;
} catch( err ) {
// IE8 is a dope about Object.defineProperty, can't warn there
}
}
// Non-ES5 (or broken) browser; just set the property
jQuery._definePropertyBroken = true;
obj[ prop ] = value;
}
if ( document.compatMode === "BackCompat" ) {
// jQuery has never supported or tested Quirks Mode
migrateWarn( "jQuery is not compatible with Quirks Mode" );
}
var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
oldAttr = jQuery.attr,
valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
function() { return null; },
valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
function() { return undefined; },
rnoType = /^(?:input|button)$/i,
rnoAttrNodeType = /^[238]$/,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
ruseDefault = /^(?:checked|selected)$/i;
// jQuery.attrFn
migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
jQuery.attr = function( elem, name, value, pass ) {
var lowerName = name.toLowerCase(),
nType = elem && elem.nodeType;
if ( pass ) {
// Since pass is used internally, we only warn for new jQuery
// versions where there isn't a pass arg in the formal params
if ( oldAttr.length < 4 ) {
migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
}
if ( elem && !rnoAttrNodeType.test( nType ) &&
(attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
return jQuery( elem )[ name ]( value );
}
}
// Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
// for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
}
// Restore boolHook for boolean property/attribute synchronization
if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
jQuery.attrHooks[ lowerName ] = {
get: function( elem, name ) {
// Align boolean attributes with corresponding properties
// Fall back to attribute presence where some booleans are not supported
var attrNode,
property = jQuery.prop( elem, name );
return property === true || typeof property !== "boolean" &&
( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
name.toLowerCase() :
undefined;
},
set: function( elem, value, name ) {
var propName;
if ( value === false ) {
// Remove boolean attributes when set to false
jQuery.removeAttr( elem, name );
} else {
// value is true since we know at this point it's type boolean and not false
// Set boolean attributes to the same name and set the DOM property
propName = jQuery.propFix[ name ] || name;
if ( propName in elem ) {
// Only set the IDL specifically if it already exists on the element
elem[ propName ] = true;
}
elem.setAttribute( name, name.toLowerCase() );
}
return name;
}
};
// Warn only for attributes that can remain distinct from their properties post-1.9
if ( ruseDefault.test( lowerName ) ) {
migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" );
}
}
return oldAttr.call( jQuery, elem, name, value );
};
// attrHooks: value
jQuery.attrHooks.value = {
get: function( elem, name ) {
var nodeName = ( elem.nodeName || "" ).toLowerCase();
if ( nodeName === "button" ) {
return valueAttrGet.apply( this, arguments );
}
if ( nodeName !== "input" && nodeName !== "option" ) {
migrateWarn("jQuery.fn.attr('value') no longer gets properties");
}
return name in elem ?
elem.value :
null;
},
set: function( elem, value ) {
var nodeName = ( elem.nodeName || "" ).toLowerCase();
if ( nodeName === "button" ) {
return valueAttrSet.apply( this, arguments );
}
if ( nodeName !== "input" && nodeName !== "option" ) {
migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
}
// Does not return so that setAttribute is also used
elem.value = value;
}
};
var matched, browser,
oldInit = jQuery.fn.init,
oldFind = jQuery.find,
oldParseJSON = jQuery.parseJSON,
rspaceAngle = /^\s*</,
rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
// Note: XSS check is done below after string is trimmed
rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
// $(html) "looks like html" rule change
jQuery.fn.init = function( selector, context, rootjQuery ) {
var match, ret;
if ( selector && typeof selector === "string" ) {
if ( !jQuery.isPlainObject( context ) &&
(match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
// This is an HTML string according to the "old" rules; is it still?
if ( !rspaceAngle.test( selector ) ) {
migrateWarn("$(html) HTML strings must start with '<' character");
}
if ( match[ 3 ] ) {
migrateWarn("$(html) HTML text after last tag is ignored");
}
// Consistently reject any HTML-like string starting with a hash (gh-9521)
// Note that this may break jQuery 1.6.x code that otherwise would work.
if ( match[ 0 ].charAt( 0 ) === "#" ) {
migrateWarn("HTML string cannot start with a '#' character");
jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
}
// Now process using loose rules; let pre-1.8 play too
// Is this a jQuery context? parseHTML expects a DOM element (#178)
if ( context && context.context && context.context.nodeType ) {
context = context.context;
}
if ( jQuery.parseHTML ) {
return oldInit.call( this,
jQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||
context || document, true ), context, rootjQuery );
}
}
}
ret = oldInit.apply( this, arguments );
// Fill in selector and context properties so .live() works
if ( selector && selector.selector !== undefined ) {
// A jQuery object, copy its properties
ret.selector = selector.selector;
ret.context = selector.context;
} else {
ret.selector = typeof selector === "string" ? selector : "";
if ( selector ) {
ret.context = selector.nodeType? selector : context || document;
}
}
return ret;
};
jQuery.fn.init.prototype = jQuery.fn;
jQuery.find = function( selector ) {
var args = Array.prototype.slice.call( arguments );
// Support: PhantomJS 1.x
// String#match fails to match when used with a //g RegExp, only on some strings
if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
// First see if qS thinks it's a valid selector, if so avoid a false positive
try {
document.querySelector( selector );
} catch ( err1 ) {
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
return "[" + attr + op + "\"" + value + "\"]";
} );
// If the regexp *may* have created an invalid selector, don't update it
// Note that there may be false alarms if selector uses jQuery extensions
try {
document.querySelector( selector );
migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
args[ 0 ] = selector;
} catch ( err2 ) {
migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
}
}
}
return oldFind.apply( this, args );
};
// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
var findProp;
for ( findProp in oldFind ) {
if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
jQuery.find[ findProp ] = oldFind[ findProp ];
}
}
// Let $.parseJSON(falsy_value) return null
jQuery.parseJSON = function( json ) {
if ( !json ) {
migrateWarn("jQuery.parseJSON requires a valid JSON string");
return null;
}
return oldParseJSON.apply( this, arguments );
};
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
// Don't clobber any existing jQuery.browser in case it's different
if ( !jQuery.browser ) {
matched = jQuery.uaMatch( navigator.userAgent );
browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
jQuery.browser = browser;
}
// Warn if the code tries to get jQuery.browser
migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
// jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat");
migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" );
migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" );
jQuery.sub = function() {
function jQuerySub( selector, context ) {
return new jQuerySub.fn.init( selector, context );
}
jQuery.extend( true, jQuerySub, this );
jQuerySub.superclass = this;
jQuerySub.fn = jQuerySub.prototype = this();
jQuerySub.fn.constructor = jQuerySub;
jQuerySub.sub = this.sub;
jQuerySub.fn.init = function init( selector, context ) {
var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );
return instance instanceof jQuerySub ?
instance :
jQuerySub( instance );
};
jQuerySub.fn.init.prototype = jQuerySub.fn;
var rootjQuerySub = jQuerySub(document);
migrateWarn( "jQuery.sub() is deprecated" );
return jQuerySub;
};
// The number of elements contained in the matched element set
jQuery.fn.size = function() {
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
return this.length;
};
var internalSwapCall = false;
// If this version of jQuery has .swap(), don't false-alarm on internal uses
if ( jQuery.swap ) {
jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
if ( oldHook ) {
jQuery.cssHooks[ name ].get = function() {
var ret;
internalSwapCall = true;
ret = oldHook.apply( this, arguments );
internalSwapCall = false;
return ret;
};
}
});
}
jQuery.swap = function( elem, options, callback, args ) {
var ret, name,
old = {};
if ( !internalSwapCall ) {
migrateWarn( "jQuery.swap() is undocumented and deprecated" );
}
// Remember the old values, and insert the new ones
for ( name in options ) {
old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
ret = callback.apply( elem, args || [] );
// Revert the old values
for ( name in options ) {
elem.style[ name ] = old[ name ];
}
return ret;
};
// Ensure that $.ajax gets the new parseJSON defined in core.js
jQuery.ajaxSetup({
converters: {
"text json": jQuery.parseJSON
}
});
var oldFnData = jQuery.fn.data;
jQuery.fn.data = function( name ) {
var ret, evt,
elem = this[0];
// Handles 1.7 which has this behavior and 1.8 which doesn't
if ( elem && name === "events" && arguments.length === 1 ) {
ret = jQuery.data( elem, name );
evt = jQuery._data( elem, name );
if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
migrateWarn("Use of jQuery.fn.data('events') is deprecated");
return evt;
}
}
return oldFnData.apply( this, arguments );
};
var rscriptType = /\/(java|ecma)script/i;
// Since jQuery.clean is used internally on older versions, we only shim if it's missing
if ( !jQuery.clean ) {
jQuery.clean = function( elems, context, fragment, scripts ) {
// Set context per 1.8 logic
context = context || document;
context = !context.nodeType && context[0] || context;
context = context.ownerDocument || context;
migrateWarn("jQuery.clean() is deprecated");
var i, elem, handleScript, jsTags,
ret = [];
jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
// Complex logic lifted directly from jQuery 1.8
if ( fragment ) {
// Special handling of each script element
handleScript = function( elem ) {
// Check if we consider it executable
if ( !elem.type || rscriptType.test( elem.type ) ) {
// Detach the script and store it in the scripts array (if provided) or the fragment
// Return truthy to indicate that it has been handled
return scripts ?
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
fragment.appendChild( elem );
}
};
for ( i = 0; (elem = ret[i]) != null; i++ ) {
// Check if we're done after handling an executable script
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
// Append to fragment and handle embedded scripts
fragment.appendChild( elem );
if ( typeof elem.getElementsByTagName !== "undefined" ) {
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
// Splice the scripts into ret after their former ancestor and advance our index beyond them
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
i += jsTags.length;
}
}
}
}
return ret;
};
}
var eventAdd = jQuery.event.add,
eventRemove = jQuery.event.remove,
eventTrigger = jQuery.event.trigger,
oldToggle = jQuery.fn.toggle,
oldLive = jQuery.fn.live,
oldDie = jQuery.fn.die,
oldLoad = jQuery.fn.load,
ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
hoverHack = function( events ) {
if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
return events;
}
if ( rhoverHack.test( events ) ) {
migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
}
return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
};
// Event props removed in 1.9, put them back if needed; no practical way to warn them
if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
}
// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
if ( jQuery.event.dispatch ) {
migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
}
// Support for 'hover' pseudo-event and ajax event warnings
jQuery.event.add = function( elem, types, handler, data, selector ){
if ( elem !== document && rajaxEvent.test( types ) ) {
migrateWarn( "AJAX events should be attached to document: " + types );
}
eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
};
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
};
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
jQuery.fn[ name ] = function() {
var args = Array.prototype.slice.call( arguments, 0 );
// If this is an ajax load() the first arg should be the string URL;
// technically this could also be the "Anything" arg of the event .load()
// which just goes to show why this dumb signature has been deprecated!
// jQuery custom builds that exclude the Ajax module justifiably die here.
if ( name === "load" && typeof args[ 0 ] === "string" ) {
return oldLoad.apply( this, args );
}
migrateWarn( "jQuery.fn." + name + "() is deprecated" );
args.splice( 0, 0, name );
if ( arguments.length ) {
return this.bind.apply( this, args );
}
// Use .triggerHandler here because:
// - load and unload events don't need to bubble, only applied to window or image
// - error event should not bubble to window, although it does pre-1.7
// See http://bugs.jquery.com/ticket/11820
this.triggerHandler.apply( this, args );
return this;
};
});
jQuery.fn.toggle = function( fn, fn2 ) {
// Don't mess with animation or css toggles
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
return oldToggle.apply( this, arguments );
}
migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
// Save reference to arguments for access in closure
var args = arguments,
guid = fn.guid || jQuery.guid++,
i = 0,
toggler = function( event ) {
// Figure out which function to execute
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
// Make sure that clicks stop
event.preventDefault();
// and execute the function
return args[ lastToggle ].apply( this, arguments ) || false;
};
// link all the functions, so any of them can unbind this click handler
toggler.guid = guid;
while ( i < args.length ) {
args[ i++ ].guid = guid;
}
return this.click( toggler );
};
jQuery.fn.live = function( types, data, fn ) {
migrateWarn("jQuery.fn.live() is deprecated");
if ( oldLive ) {
return oldLive.apply( this, arguments );
}
jQuery( this.context ).on( types, this.selector, data, fn );
return this;
};
jQuery.fn.die = function( types, fn ) {
migrateWarn("jQuery.fn.die() is deprecated");
if ( oldDie ) {
return oldDie.apply( this, arguments );
}
jQuery( this.context ).off( types, this.selector || "**", fn );
return this;
};
// Turn global events into document-triggered events
jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
if ( !elem && !rajaxEvent.test( event ) ) {
migrateWarn( "Global events are undocumented and deprecated" );
}
return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
};
jQuery.each( ajaxEvents.split("|"),
function( _, name ) {
jQuery.event.special[ name ] = {
setup: function() {
var elem = this;
// The document needs no shimming; must be !== for oldIE
if ( elem !== document ) {
jQuery.event.add( document, name + "." + jQuery.guid, function() {
jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );
});
jQuery._data( this, name, jQuery.guid++ );
}
return false;
},
teardown: function() {
if ( this !== document ) {
jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
}
return false;
}
};
}
);
jQuery.event.special.ready = {
setup: function() {
if ( this === document ) {
migrateWarn( "'ready' event is deprecated" );
}
}
};
var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
oldFnFind = jQuery.fn.find;
jQuery.fn.andSelf = function() {
migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
return oldSelf.apply( this, arguments );
};
jQuery.fn.find = function( selector ) {
var ret = oldFnFind.apply( this, arguments );
ret.context = this.context;
ret.selector = this.selector ? this.selector + " " + selector : selector;
return ret;
};
// jQuery 1.6 did not support Callbacks, do not warn there
if ( jQuery.Callbacks ) {
var oldDeferred = jQuery.Deferred,
tuples = [
// action, add listener, callbacks, .then handlers, final state
[ "resolve", "done", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), "resolved" ],
[ "reject", "fail", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), "rejected" ],
[ "notify", "progress", jQuery.Callbacks("memory"),
jQuery.Callbacks("memory") ]
];
jQuery.Deferred = function( func ) {
var deferred = oldDeferred(),
promise = deferred.promise();
deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments;
migrateWarn( "deferred.pipe() is deprecated" );
return jQuery.Deferred(function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) {
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
// deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject })
// deferred.progress(function() { bind to newDefer or newDefer.notify })
deferred[ tuple[1] ](function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise()
.done( newDefer.resolve )
.fail( newDefer.reject )
.progress( newDefer.notify );
} else {
newDefer[ tuple[ 0 ] + "With" ](
this === promise ? newDefer.promise() : this,
fn ? [ returned ] : arguments
);
}
});
});
fns = null;
}).promise();
};
deferred.isResolved = function() {
migrateWarn( "deferred.isResolved is deprecated" );
return deferred.state() === "resolved";
};
deferred.isRejected = function() {
migrateWarn( "deferred.isRejected is deprecated" );
return deferred.state() === "rejected";
};
if ( func ) {
func.call( deferred, deferred );
}
return deferred;
};
}
})( jQuery, window );

File diff suppressed because one or more lines are too long

View File

@ -345,40 +345,42 @@ $(document).bind("mobileinit", function(){
$.mobile.defaultPageTransition = "none"; $.mobile.defaultPageTransition = "none";
}); });
// Service Manager // Service Manager
$("#service-manager").live("pagebeforeshow", OpenLP.loadService); $("#service-manager").on("pagebeforeshow", OpenLP.loadService);
$("#service-refresh").live("click", OpenLP.loadService); $("#service-refresh").on("click", OpenLP.loadService);
$("#service-next").live("click", OpenLP.nextItem); $("#service-next").on("click", OpenLP.nextItem);
$("#service-previous").live("click", OpenLP.previousItem); $("#service-previous").on("click", OpenLP.previousItem);
$("#service-blank").live("click", OpenLP.blankDisplay); $("#service-blank").on("click", OpenLP.blankDisplay);
$("#service-theme").live("click", OpenLP.themeDisplay); $("#service-theme").on("click", OpenLP.themeDisplay);
$("#service-desktop").live("click", OpenLP.desktopDisplay); $("#service-desktop").on("click", OpenLP.desktopDisplay);
$("#service-show").live("click", OpenLP.showDisplay); $("#service-show").on("click", OpenLP.showDisplay);
// Slide Controller // Slide Controller
$("#slide-controller").live("pagebeforeshow", OpenLP.loadController); $("#slide-controller").on("pagebeforeshow", OpenLP.loadController);
$("#controller-refresh").live("click", OpenLP.loadController); $("#controller-refresh").on("click", OpenLP.loadController);
$("#controller-next").live("click", OpenLP.nextSlide); $("#controller-next").on("click", OpenLP.nextSlide);
$("#controller-previous").live("click", OpenLP.previousSlide); $("#controller-previous").on("click", OpenLP.previousSlide);
$("#controller-blank").live("click", OpenLP.blankDisplay); $("#controller-blank").on("click", OpenLP.blankDisplay);
$("#controller-theme").live("click", OpenLP.themeDisplay); $("#controller-theme").on("click", OpenLP.themeDisplay);
$("#controller-desktop").live("click", OpenLP.desktopDisplay); $("#controller-desktop").on("click", OpenLP.desktopDisplay);
$("#controller-show").live("click", OpenLP.showDisplay); $("#controller-show").on("click", OpenLP.showDisplay);
// Alerts // Alerts
$("#alert-submit").live("click", OpenLP.showAlert); $("#alert-submit").on("click", OpenLP.showAlert);
// Search // Search
$("#search-submit").live("click", OpenLP.search); $("#search-submit").on("click", OpenLP.search);
$("#search-text").live("keypress", function(event) { $("#search-text").on("keypress", function(event) {
if (event.which == 13) if (event.which == 13)
{ {
OpenLP.search(event); OpenLP.search(event);
} }
}); });
$("#go-live").live("click", OpenLP.goLive); $("#go-live").on("click", OpenLP.goLive);
$("#add-to-service").live("click", OpenLP.addToService); $("#add-to-service").on("click", OpenLP.addToService);
$("#add-and-go-to-service").live("click", OpenLP.addAndGoToService); $("#add-and-go-to-service").on("click", OpenLP.addAndGoToService);
// Poll the server twice a second to get any updates. // Poll the server twice a second to get any updates.
$.ajaxSetup({cache: false}); $.ajaxSetup({cache: false});
$("#search").live("pageinit", function (event) { console.log("hook");
$("#search").on("pageinit", function (event) {
console.log("Page init!");
OpenLP.getSearchablePlugins(); OpenLP.getSearchablePlugins();
}); });
setInterval("OpenLP.pollServer();", 500); setInterval(OpenLP.pollServer, 500);
OpenLP.pollServer(); OpenLP.pollServer();

View File

@ -112,13 +112,13 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
""" """
objects = self.manager.get_all_objects(cls, order_by_ref=cls.name) objects = self.manager.get_all_objects(cls, order_by_ref=cls.name)
combo.clear() combo.clear()
combo.addItem('')
for obj in objects: for obj in objects:
row = combo.count() row = combo.count()
combo.addItem(obj.name) combo.addItem(obj.name)
cache.append(obj.name) cache.append(obj.name)
combo.setItemData(row, obj.id) combo.setItemData(row, obj.id)
set_case_insensitive_completer(cache, combo) set_case_insensitive_completer(cache, combo)
combo.setEditText('')
def _add_author_to_list(self, author, author_type): def _add_author_to_list(self, author, author_type):
""" """
@ -345,7 +345,6 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
""" """
authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name) authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name)
self.authors_combo_box.clear() self.authors_combo_box.clear()
self.authors_combo_box.addItem('')
self.authors = [] self.authors = []
for author in authors: for author in authors:
row = self.authors_combo_box.count() row = self.authors_combo_box.count()
@ -353,6 +352,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
self.authors_combo_box.setItemData(row, author.id) self.authors_combo_box.setItemData(row, author.id)
self.authors.append(author.display_name) self.authors.append(author.display_name)
set_case_insensitive_completer(self.authors, self.authors_combo_box) set_case_insensitive_completer(self.authors, self.authors_combo_box)
self.authors_combo_box.setEditText('')
# Types # Types
self.author_types_combo_box.clear() self.author_types_combo_box.clear()
@ -379,10 +379,10 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
Load the themes into a combobox. Load the themes into a combobox.
""" """
self.theme_combo_box.clear() self.theme_combo_box.clear()
self.theme_combo_box.addItem('')
self.themes = theme_list self.themes = theme_list
self.theme_combo_box.addItems(theme_list) self.theme_combo_box.addItems(theme_list)
set_case_insensitive_completer(self.themes, self.theme_combo_box) set_case_insensitive_completer(self.themes, self.theme_combo_box)
self.theme_combo_box.setEditText('')
def load_media_files(self): def load_media_files(self):
""" """
@ -422,7 +422,6 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
self.load_songbooks() self.load_songbooks()
self.load_media_files() self.load_media_files()
self.theme_combo_box.setEditText('') self.theme_combo_box.setEditText('')
self.theme_combo_box.setCurrentIndex(0)
# it's a new song to preview is not possible # it's a new song to preview is not possible
self.preview_button.setVisible(False) self.preview_button.setVisible(False)
@ -571,7 +570,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
self.manager.save_object(author) self.manager.save_object(author)
self._add_author_to_list(author, author_type) self._add_author_to_list(author, author_type)
self.load_authors() self.load_authors()
self.authors_combo_box.setCurrentIndex(0) self.authors_combo_box.setEditText('')
else: else:
return return
elif item > 0: elif item > 0:
@ -582,7 +581,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.')) message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.'))
else: else:
self._add_author_to_list(author, author_type) self._add_author_to_list(author, author_type)
self.authors_combo_box.setCurrentIndex(0) self.authors_combo_box.setEditText('')
else: else:
QtWidgets.QMessageBox.warning( QtWidgets.QMessageBox.warning(
self, UiStrings().NISs, self, UiStrings().NISs,
@ -646,7 +645,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
topic_item.setData(QtCore.Qt.UserRole, topic.id) topic_item.setData(QtCore.Qt.UserRole, topic.id)
self.topics_list_view.addItem(topic_item) self.topics_list_view.addItem(topic_item)
self.load_topics() self.load_topics()
self.topics_combo_box.setCurrentIndex(0) self.topics_combo_box.setEditText('')
else: else:
return return
elif item > 0: elif item > 0:
@ -659,7 +658,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
topic_item = QtWidgets.QListWidgetItem(str(topic.name)) topic_item = QtWidgets.QListWidgetItem(str(topic.name))
topic_item.setData(QtCore.Qt.UserRole, topic.id) topic_item.setData(QtCore.Qt.UserRole, topic.id)
self.topics_list_view.addItem(topic_item) self.topics_list_view.addItem(topic_item)
self.topics_combo_box.setCurrentIndex(0) self.topics_combo_box.setEditText('')
else: else:
QtWidgets.QMessageBox.warning( QtWidgets.QMessageBox.warning(
self, UiStrings().NISs, self, UiStrings().NISs,
@ -689,7 +688,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
self.manager.save_object(songbook) self.manager.save_object(songbook)
self.add_songbook_entry_to_list(songbook.id, songbook.name, self.songbook_entry_edit.text()) self.add_songbook_entry_to_list(songbook.id, songbook.name, self.songbook_entry_edit.text())
self.load_songbooks() self.load_songbooks()
self.songbooks_combo_box.setCurrentIndex(0) self.songbooks_combo_box.setEditText('')
self.songbook_entry_edit.clear() self.songbook_entry_edit.clear()
else: else:
return return
@ -701,7 +700,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
message=translate('SongsPlugin.EditSongForm', 'This Songbook is already in the list.')) message=translate('SongsPlugin.EditSongForm', 'This Songbook is already in the list.'))
else: else:
self.add_songbook_entry_to_list(songbook.id, songbook.name, self.songbook_entry_edit.text()) self.add_songbook_entry_to_list(songbook.id, songbook.name, self.songbook_entry_edit.text())
self.songbooks_combo_box.setCurrentIndex(0) self.songbooks_combo_box.setEditText('')
self.songbook_entry_edit.clear() self.songbook_entry_edit.clear()
else: else:
QtWidgets.QMessageBox.warning( QtWidgets.QMessageBox.warning(

View File

@ -0,0 +1,83 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2016 OpenLP Developers #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
:mod: `tests.functional.openlp_core_ui.test_projectorsourceform` module
Tests for the Projector Source Select form.
"""
from PyQt5 import QtCore
from openlp.core.ui.projector.sourceselectform import FingerTabBarWidget, source_group
def test_source_group():
"""
Test the source_group() method
"""
# GIVEN: A list of inputs and source text
inputs = [
'vga1', 'vga2',
'hdmi1', 'hdmi2'
]
source_text = {
'vga1': 'VGA 1',
'vga2': 'VGA 2',
'hdmi1': 'HDMI 1',
'hdmi2': 'HDMI 2'
}
# WHEN: source_group() is called
result = source_group(inputs, source_text)
# THEN: the resultant dictionary should be correct
expected_dict = {
'v': {'vga1': 'VGA 1', 'vga2': 'VGA 2'},
'h': {'hdmi1': 'HDMI 1', 'hdmi2': 'HDMI 2'}
}
assert result == expected_dict, result
def test_finger_tab_bar_widget():
"""
Test that the FingerTabBarWidget is initialised correctly
"""
# GIVEN: A FinderTabBarWidget class
# WHEN: An instance of the FingerTabBarWidget is created
widget = FingerTabBarWidget()
# THEN: It should havea tabSize of 100x25
assert widget.tabSize == QtCore.QSize(100, 25)
def test_finger_tab_bar_widget_with_kwargs():
"""
Test that the FingerTabBarWidget is initialised correctly from kwargs
"""
# GIVEN: A FinderTabBarWidget class and some arguments
width = 300
height = 100
# WHEN: An instance of the FingerTabBarWidget is created
widget = FingerTabBarWidget(width=width, height=height)
# THEN: It should havea tabSize of 100x25
assert widget.tabSize == QtCore.QSize(width, height)

View File

@ -76,3 +76,34 @@ class TestEditSongForm(TestCase, TestMixin):
# THEN they should be valid # THEN they should be valid
self.assertTrue(valid, "The tags list should be valid") self.assertTrue(valid, "The tags list should be valid")
@patch('openlp.plugins.songs.forms.editsongform.set_case_insensitive_completer')
def test_load_objects(self, mocked_set_case_insensitive_completer):
"""
Test the _load_objects() method
"""
# GIVEN: A song edit form and some mocked stuff
mocked_class = MagicMock()
mocked_class.name = 'Author'
mocked_combo = MagicMock()
mocked_combo.count.return_value = 0
mocked_cache = MagicMock()
mocked_object = MagicMock()
mocked_object.name = 'Charles'
mocked_object.id = 1
mocked_manager = MagicMock()
mocked_manager.get_all_objects.return_value = [mocked_object]
self.edit_song_form.manager = mocked_manager
# WHEN: _load_objects() is called
self.edit_song_form._load_objects(mocked_class, mocked_combo, mocked_cache)
# THEN: All the correct methods should have been called
self.edit_song_form.manager.get_all_objects.assert_called_once_with(mocked_class, order_by_ref='Author')
mocked_combo.clear.assert_called_once_with()
mocked_combo.count.assert_called_once_with()
mocked_combo.addItem.assert_called_once_with('Charles')
mocked_cache.append.assert_called_once_with('Charles')
mocked_combo.setItemData.assert_called_once_with(0, 1)
mocked_set_case_insensitive_completer.assert_called_once_with(mocked_cache, mocked_combo)
mocked_combo.setEditText.assert_called_once_with('')

View File

@ -24,19 +24,17 @@
Tests for the Projector Source Select form. Tests for the Projector Source Select form.
""" """
import logging
log = logging.getLogger(__name__)
log.debug('test_projectorsourceform loaded')
import os import os
import time
from unittest import TestCase from unittest import TestCase
from unittest.mock import patch
from PyQt5.QtWidgets import QDialog from PyQt5.QtWidgets import QDialog
from tests.functional import patch
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
from tests.resources.projector.data import TEST_DB, TEST1_DATA from tests.resources.projector.data import TEST_DB, TEST1_DATA
from openlp.core.common import Registry, Settings from openlp.core.common import Registry
from openlp.core.lib.projector.db import ProjectorDB, Projector from openlp.core.lib.projector.db import ProjectorDB, Projector
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle
@ -49,7 +47,7 @@ def build_source_dict():
:returns: dictionary of valid PJLink source codes grouped by PJLink source group :returns: dictionary of valid PJLink source codes grouped by PJLink source group
""" """
test_group = {} test_group = {}
for group in PJLINK_DEFAULT_SOURCES.keys(): for group in PJLINK_DEFAULT_SOURCES:
test_group[group] = {} test_group[group] = {}
for key in PJLINK_DEFAULT_CODES: for key in PJLINK_DEFAULT_CODES:
test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key] test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key]
@ -86,8 +84,8 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
Delete all C++ objects at end so we don't segfault. Delete all C++ objects at end so we don't segfault.
""" """
self.projectordb.session.close() self.projectordb.session.close()
del(self.projectordb) del self.projectordb
del(self.projector) del self.projector
retries = 0 retries = 0
while retries < 5: while retries < 5:
try: try:

View File

@ -28,6 +28,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
from openlp.core.common import Registry from openlp.core.common import Registry
from openlp.core.ui.shortcutlistform import ShortcutListForm from openlp.core.ui.shortcutlistform import ShortcutListForm
from openlp.core.ui.shortcutlistdialog import CaptureShortcutButton, ShortcutTreeWidget
from tests.interfaces import MagicMock, patch from tests.interfaces import MagicMock, patch
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -227,3 +228,34 @@ class TestShortcutform(TestCase, TestMixin):
mocked_action_shortcuts.assert_called_with(mocked_action) mocked_action_shortcuts.assert_called_with(mocked_action)
mocked_refresh_shortcut_list.assert_called_with() mocked_refresh_shortcut_list.assert_called_with()
mocked_set_text.assert_called_with('Esc') mocked_set_text.assert_called_with('Esc')
def test_key_press_event():
"""
Test the keyPressEvent method
"""
# GIVEN: A checked button and a mocked event
button = CaptureShortcutButton()
button.setChecked(True)
mocked_event = MagicMock()
mocked_event.key.return_value = QtCore.Qt.Key_Space
# WHEN: keyPressEvent is called with an event that should be ignored
button.keyPressEvent(mocked_event)
# THEN: The ignore() method on the event should have been called
mocked_event.ignore.assert_called_once_with()
def test_keyboard_search():
"""
Test the keyboardSearch method of the ShortcutTreeWidget
"""
# GIVEN: A ShortcutTreeWidget
widget = ShortcutTreeWidget()
# WHEN: keyboardSearch() is called
widget.keyboardSearch('')
# THEN: Nothing happens
assert True

View File

View File