diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 660b0c9f5..c1d6a4da8 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -281,18 +281,23 @@ class ServiceItem(RegistryProperties): self.raw_footer = [] self.foot_text = '
'.join([_f for _f in self.raw_footer if _f]) - def add_from_image(self, path, title, background=None): + def add_from_image(self, path, title, background=None, thumbnail=None): """ Add an image slide to the service item. :param path: The directory in which the image file is located. :param title: A title for the slide in the service item. :param background: + :param thumbnail: Optional alternative thumbnail """ if background: self.image_border = background self.service_item_type = ServiceItemType.Image - self._raw_frames.append({'title': title, 'path': path}) + if thumbnail: + self._raw_frames.append({'title': title, 'path': path, 'image': thumbnail}) + self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border) + else: + self._raw_frames.append({'title': title, 'path': path}) self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border) self._new_item() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 51d285f1d..5467d117d 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -288,13 +288,13 @@ class PresentationMediaItem(MediaManagerItem): os.path.join(doc.get_temp_folder(), 'mainslide001.png')): doc.load_presentation() i = 1 - image_file = 'mainslide%03d.png' % i - image = os.path.join(doc.get_temp_folder(), image_file) + image = os.path.join(doc.get_temp_folder(), 'mainslide%03d.png' % i) + thumbnail = os.path.join(doc.get_thumbnail_folder(), 'slide%d.png' % i) while os.path.isfile(image): - service_item.add_from_image(image, name) + service_item.add_from_image(image, name, thumbnail=thumbnail) i += 1 - image_file = 'mainslide%03d.png' % i - image = os.path.join(doc.get_temp_folder(), image_file) + image = os.path.join(doc.get_temp_folder(), 'mainslide%03d.png' % i) + thumbnail = os.path.join(doc.get_thumbnail_folder(), 'slide%d.png' % i) service_item.add_capability(ItemCapabilities.HasThumbnails) doc.close_presentation() return True diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 80eaf22e8..718bf15bf 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -120,21 +120,6 @@ ${prev} ${next} -
- ${settings} -
- - -
-
-

${settings}

-
-
- Display thumbnails: -
- Yes - No -
diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 4b6c7f935..5dd8cee0e 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -98,7 +98,7 @@ window.OpenLP = { if (slide["notes"]) text += ("
" + slide["notes"] + "
"); text = text.replace(/\n/g, '
'); - if (slide["img"] && OpenLP.showThumbnails) + if (slide["img"]) text += ""; var li = $("
  • ").append( $("").html(text)); @@ -251,17 +251,6 @@ window.OpenLP = { } ); }, - displayThumbnails: function (event) { - event.preventDefault(); - var target = $(event.target); - OpenLP.showThumbnails = target.text() == "No" ? false : true; - var dt = new Date(); - dt.setTime(dt.getTime() + 365 * 24 * 60 * 60 * 1000); - document.cookie = "displayThumbs=" + OpenLP.showThumbnails + "; expires=" + - dt.toGMTString() + "; path=/"; - OpenLP.loadController(); - $("#settings").dialog("close"); - }, search: function (event) { event.preventDefault(); var query = OpenLP.escapeString($("#search-text").val()) @@ -341,24 +330,12 @@ window.OpenLP = { }, escapeString: function (string) { return string.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") - }, - showThumbnails: false + } } // Initial jQueryMobile options $(document).bind("mobileinit", function(){ $.mobile.defaultDialogTransition = "none"; $.mobile.defaultPageTransition = "none"; - var cookies = document.cookie; - if( cookies ) - { - var allcookies = cookies.split(";") - for(ii = 0; ii < allcookies.length; ii++) - { - var parts = allcookies[ii].split("="); - if(parts.length == 2 && parts[0] == "displayThumbs") - OpenLP.showThumbnails = (parts[1]=='true'); - } - } }); // Service Manager $("#service-manager").live("pagebeforeshow", OpenLP.loadService); @@ -378,8 +355,6 @@ $("#controller-blank").live("click", OpenLP.blankDisplay); $("#controller-theme").live("click", OpenLP.themeDisplay); $("#controller-desktop").live("click", OpenLP.desktopDisplay); $("#controller-show").live("click", OpenLP.showDisplay); -$("#display-thumbnails").live("click", OpenLP.displayThumbnails); -$("#dont-display-thumbnails").live("click", OpenLP.displayThumbnails); // Alerts $("#alert-submit").live("click", OpenLP.showAlert); // Search diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index 577f2b272..6d835257c 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -503,7 +503,8 @@ class HttpRouter(RegistryProperties): item['tag'] = str(index + 1) item['text'] = str(frame['text']) item['html'] = str(frame['html']) - elif current_item.is_image(): + elif current_item.is_image() and not frame['image'] and Settings().value('remotes/thumbnails'): + # and not frame['title'].endswith('pdf') and not frame['title'].endswith('xps'): item['tag'] = str(index + 1) thumbnail_path = os.path.sep + os.path.join('images', 'thumbnails', frame['title']) item['img'] = urllib.request.pathname2url(thumbnail_path) @@ -515,9 +516,11 @@ class HttpRouter(RegistryProperties): item['title'] = str(frame['display_title']) if current_item.is_capable(ItemCapabilities.HasNotes): item['notes'] = str(frame['notes']) - if current_item.is_capable(ItemCapabilities.HasThumbnails): + if current_item.is_capable(ItemCapabilities.HasThumbnails) and \ + Settings().value('remotes/thumbnails'): # If the file is under our app directory tree send the portion after the match data_path = AppLocation.get_data_path() + print(frame) if frame['image'][0:len(data_path)] == data_path: item['img'] = urllib.request.pathname2url(frame['image'][len(data_path):]) item['text'] = str(frame['title']) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 4db25cfc2..1092a03d2 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -62,6 +62,9 @@ class RemoteTab(SettingsTab): self.twelve_hour_check_box = QtGui.QCheckBox(self.server_settings_group_box) self.twelve_hour_check_box.setObjectName('twelve_hour_check_box') self.server_settings_layout.addRow(self.twelve_hour_check_box) + self.thumbnails_check_box = QtGui.QCheckBox(self.server_settings_group_box) + self.thumbnails_check_box.setObjectName('thumbnails_check_box') + self.server_settings_layout.addRow(self.thumbnails_check_box) self.left_layout.addWidget(self.server_settings_group_box) self.http_settings_group_box = QtGui.QGroupBox(self.left_column) self.http_settings_group_box.setObjectName('http_settings_group_box') @@ -163,6 +166,7 @@ class RemoteTab(SettingsTab): self.left_layout.addStretch() self.right_layout.addStretch() self.twelve_hour_check_box.stateChanged.connect(self.on_twelve_hour_check_box_changed) + self.thumbnails_check_box.stateChanged.connect(self.on_thumbnails_check_box_changed) self.address_edit.textChanged.connect(self.set_urls) self.port_spin_box.valueChanged.connect(self.set_urls) self.https_port_spin_box.valueChanged.connect(self.set_urls) @@ -176,6 +180,7 @@ class RemoteTab(SettingsTab): self.stage_url_label.setText(translate('RemotePlugin.RemoteTab', 'Stage view URL:')) self.live_url_label.setText(translate('RemotePlugin.RemoteTab', 'Live view URL:')) self.twelve_hour_check_box.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format')) + self.thumbnails_check_box.setText(translate('RemotePlugin.RemoteTab', 'Show thumbnails of non-text slides in remote and stage view.')) self.android_app_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Android App')) self.qr_description_label.setText( translate('RemotePlugin.RemoteTab', 'Scan the QR code or click