forked from openlp/openlp
- Enhanced 'choose group' dialog layout (thanks Raoul)
- Revert back to old QListWidget and use QTreeWidget only for images plugin - Renamed dialogs to comply to coding standards - Added image group icon - Enabled animation on image groups - Removed special 'Imported' folder and allow toplevel images instead
This commit is contained in:
parent
adb7aac7cf
commit
3717e7fa20
@ -390,6 +390,7 @@ from uistrings import UiStrings
|
|||||||
from eventreceiver import Receiver
|
from eventreceiver import Receiver
|
||||||
from screen import ScreenList
|
from screen import ScreenList
|
||||||
from settings import Settings
|
from settings import Settings
|
||||||
|
from listwidgetwithdnd import ListWidgetWithDnD
|
||||||
from treewidgetwithdnd import TreeWidgetWithDnD
|
from treewidgetwithdnd import TreeWidgetWithDnD
|
||||||
from formattingtags import FormattingTags
|
from formattingtags import FormattingTags
|
||||||
from spelltextedit import SpellTextEdit
|
from spelltextedit import SpellTextEdit
|
||||||
|
117
openlp/core/lib/listwidgetwithdnd.py
Normal file
117
openlp/core/lib/listwidgetwithdnd.py
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
||||||
|
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
||||||
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||||
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
||||||
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
||||||
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||||
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
||||||
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# 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 #
|
||||||
|
###############################################################################
|
||||||
|
"""
|
||||||
|
Extend QListWidget to handle drag and drop functionality
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.lib import Receiver
|
||||||
|
|
||||||
|
|
||||||
|
class ListWidgetWithDnD(QtGui.QListWidget):
|
||||||
|
"""
|
||||||
|
Provide a list widget to store objects and handle drag and drop events
|
||||||
|
"""
|
||||||
|
def __init__(self, parent=None, name=u''):
|
||||||
|
"""
|
||||||
|
Initialise the list widget
|
||||||
|
"""
|
||||||
|
QtGui.QListWidget.__init__(self, parent)
|
||||||
|
self.mimeDataText = name
|
||||||
|
assert(self.mimeDataText)
|
||||||
|
|
||||||
|
def activateDnD(self):
|
||||||
|
"""
|
||||||
|
Activate DnD of widget
|
||||||
|
"""
|
||||||
|
self.setAcceptDrops(True)
|
||||||
|
self.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
|
||||||
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd' % self.mimeDataText),
|
||||||
|
self.parent().loadFile)
|
||||||
|
|
||||||
|
def mouseMoveEvent(self, event):
|
||||||
|
"""
|
||||||
|
Drag and drop event does not care what data is selected as the recipient will use events to request the data
|
||||||
|
move just tell it what plugin to call
|
||||||
|
"""
|
||||||
|
if event.buttons() != QtCore.Qt.LeftButton:
|
||||||
|
event.ignore()
|
||||||
|
return
|
||||||
|
if not self.selectedItems():
|
||||||
|
event.ignore()
|
||||||
|
return
|
||||||
|
drag = QtGui.QDrag(self)
|
||||||
|
mimeData = QtCore.QMimeData()
|
||||||
|
drag.setMimeData(mimeData)
|
||||||
|
mimeData.setText(self.mimeDataText)
|
||||||
|
drag.start(QtCore.Qt.CopyAction)
|
||||||
|
|
||||||
|
def dragEnterEvent(self, event):
|
||||||
|
"""
|
||||||
|
When something is dragged into this object, check if you should be able to drop it in here.
|
||||||
|
"""
|
||||||
|
if event.mimeData().hasUrls():
|
||||||
|
event.accept()
|
||||||
|
else:
|
||||||
|
event.ignore()
|
||||||
|
|
||||||
|
def dragMoveEvent(self, event):
|
||||||
|
"""
|
||||||
|
Make an object droppable, and set it to copy the contents of the object, not move it.
|
||||||
|
"""
|
||||||
|
if event.mimeData().hasUrls():
|
||||||
|
event.setDropAction(QtCore.Qt.CopyAction)
|
||||||
|
event.accept()
|
||||||
|
else:
|
||||||
|
event.ignore()
|
||||||
|
|
||||||
|
def dropEvent(self, event):
|
||||||
|
"""
|
||||||
|
Receive drop event check if it is a file and process it if it is.
|
||||||
|
|
||||||
|
``event``
|
||||||
|
Handle of the event pint passed
|
||||||
|
"""
|
||||||
|
if event.mimeData().hasUrls():
|
||||||
|
event.setDropAction(QtCore.Qt.CopyAction)
|
||||||
|
event.accept()
|
||||||
|
files = []
|
||||||
|
for url in event.mimeData().urls():
|
||||||
|
localFile = url.toLocalFile()
|
||||||
|
if os.path.isfile(localFile):
|
||||||
|
files.append(localFile)
|
||||||
|
elif os.path.isdir(localFile):
|
||||||
|
listing = os.listdir(localFile)
|
||||||
|
for file in listing:
|
||||||
|
files.append(os.path.join(localFile, file))
|
||||||
|
Receiver.send_message(u'%s_dnd' % self.mimeDataText, files)
|
||||||
|
else:
|
||||||
|
event.ignore()
|
@ -35,7 +35,7 @@ import re
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, Receiver, TreeWidgetWithDnD, \
|
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, Receiver, ListWidgetWithDnD, \
|
||||||
ServiceItemContext, Settings, Registry, UiStrings, build_icon, translate
|
ServiceItemContext, Settings, Registry, UiStrings, build_icon, translate
|
||||||
from openlp.core.lib.searchedit import SearchEdit
|
from openlp.core.lib.searchedit import SearchEdit
|
||||||
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
||||||
@ -213,7 +213,8 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
Creates the main widget for listing items the media item is tracking
|
Creates the main widget for listing items the media item is tracking
|
||||||
"""
|
"""
|
||||||
# Add the List widget
|
# Add the List widget
|
||||||
self.listView = TreeWidgetWithDnD(self, self.plugin.name)
|
self.listView = ListWidgetWithDnD(self, self.plugin.name)
|
||||||
|
self.listView.setSpacing(1)
|
||||||
self.listView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
self.listView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
self.listView.setAlternatingRowColors(True)
|
self.listView.setAlternatingRowColors(True)
|
||||||
self.listView.setObjectName(u'%sListView' % self.plugin.name)
|
self.listView.setObjectName(u'%sListView' % self.plugin.name)
|
||||||
@ -372,9 +373,9 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
names = []
|
names = []
|
||||||
full_list = []
|
full_list = []
|
||||||
for count in range(self.listView.topLevelItemCount()):
|
for count in range(self.listView.count()):
|
||||||
names.append(self.listView.topLevelItem(count).text(0))
|
names.append(self.listView.item(count).text())
|
||||||
full_list.append(self.listView.topLevelItem(count).data(0, QtCore.Qt.UserRole))
|
full_list.append(self.listView.item(count).data(QtCore.Qt.UserRole))
|
||||||
duplicates_found = False
|
duplicates_found = False
|
||||||
files_added = False
|
files_added = False
|
||||||
for file_path in files:
|
for file_path in files:
|
||||||
@ -413,9 +414,9 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
count = 0
|
count = 0
|
||||||
file_list = []
|
file_list = []
|
||||||
while count < self.listView.topLevelItemCount():
|
while count < self.listView.count():
|
||||||
bitem = self.listView.topLevelItem(count)
|
bitem = self.listView.item(count)
|
||||||
filename = bitem.data(0, QtCore.Qt.UserRole)
|
filename = bitem.data(QtCore.Qt.UserRole)
|
||||||
file_list.append(filename)
|
file_list.append(filename)
|
||||||
count += 1
|
count += 1
|
||||||
return file_list
|
return file_list
|
||||||
@ -523,8 +524,8 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Create a media item from an item id.
|
Create a media item from an item id.
|
||||||
"""
|
"""
|
||||||
item = QtGui.QTreeWidgetItem()
|
item = QtGui.QListWidgetItem()
|
||||||
item.setData(0, QtCore.Qt.UserRole, item_id)
|
item.setData(QtCore.Qt.UserRole, item_id)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def onAddClick(self):
|
def onAddClick(self):
|
||||||
@ -597,16 +598,15 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Checks if the listView is empty and adds a "No Search Results" item.
|
Checks if the listView is empty and adds a "No Search Results" item.
|
||||||
"""
|
"""
|
||||||
if self.listView.topLevelItemCount():
|
if self.listView.count():
|
||||||
return
|
return
|
||||||
message = translate('OpenLP.MediaManagerItem', 'No Search Results')
|
message = translate('OpenLP.MediaManagerItem', 'No Search Results')
|
||||||
item = QtGui.QTreeWidgetItem(message)
|
item = QtGui.QListWidgetItem(message)
|
||||||
item.setText(0, message)
|
|
||||||
item.setFlags(QtCore.Qt.NoItemFlags)
|
item.setFlags(QtCore.Qt.NoItemFlags)
|
||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setItalic(True)
|
font.setItalic(True)
|
||||||
item.setFont(0, font)
|
item.setFont(font)
|
||||||
self.listView.addTopLevelItem(item)
|
self.listView.addItem(item)
|
||||||
|
|
||||||
def _getIdOfItemToGenerate(self, item, remoteItem):
|
def _getIdOfItemToGenerate(self, item, remoteItem):
|
||||||
"""
|
"""
|
||||||
@ -623,7 +623,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
if item is None:
|
if item is None:
|
||||||
return False
|
return False
|
||||||
item_id = item.data(0, QtCore.Qt.UserRole)
|
item_id = item.data(QtCore.Qt.UserRole)
|
||||||
else:
|
else:
|
||||||
item_id = remoteItem
|
item_id = remoteItem
|
||||||
else:
|
else:
|
||||||
@ -638,7 +638,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
if self.autoSelectId == -1:
|
if self.autoSelectId == -1:
|
||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
if item:
|
if item:
|
||||||
self.autoSelectId = item.data(0, QtCore.Qt.UserRole)
|
self.autoSelectId = item.data(QtCore.Qt.UserRole)
|
||||||
|
|
||||||
def search(self, string, showError=True):
|
def search(self, string, showError=True):
|
||||||
"""
|
"""
|
||||||
|
@ -50,6 +50,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
|
|||||||
self.header().close()
|
self.header().close()
|
||||||
self.defaultIndentation = self.indentation()
|
self.defaultIndentation = self.indentation()
|
||||||
self.setIndentation(0)
|
self.setIndentation(0)
|
||||||
|
self.setAnimated(True)
|
||||||
assert(self.mimeDataText)
|
assert(self.mimeDataText)
|
||||||
|
|
||||||
def activateDnD(self):
|
def activateDnD(self):
|
||||||
@ -126,3 +127,13 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget):
|
|||||||
Receiver.send_message(u'%s_dnd_internal' % self.mimeDataText, self.itemAt(event.pos()))
|
Receiver.send_message(u'%s_dnd_internal' % self.mimeDataText, self.itemAt(event.pos()))
|
||||||
else:
|
else:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
|
|
||||||
|
# Convenience methods for emulating a QListWidget. This helps keeping MediaManagerItem simple.
|
||||||
|
def addItem(self, item):
|
||||||
|
self.addTopLevelItem(item)
|
||||||
|
|
||||||
|
def count(self):
|
||||||
|
return self.topLevelItemCount()
|
||||||
|
|
||||||
|
def item(self, index):
|
||||||
|
return self.topLevelItem(index)
|
||||||
|
@ -76,7 +76,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
Check if the first item is a second bible item or not.
|
Check if the first item is a second bible item or not.
|
||||||
"""
|
"""
|
||||||
bitem = self.listView.topLevelItem(0)
|
bitem = self.listView.item(0)
|
||||||
if not bitem.flags() & QtCore.Qt.ItemIsSelectable:
|
if not bitem.flags() & QtCore.Qt.ItemIsSelectable:
|
||||||
# The item is the "No Search Results" item.
|
# The item is the "No Search Results" item.
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
@ -95,7 +95,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.displayResults(bible, second_bible)
|
self.displayResults(bible, second_bible)
|
||||||
|
|
||||||
def _decodeQtObject(self, bitem, key):
|
def _decodeQtObject(self, bitem, key):
|
||||||
reference = bitem.data(0, QtCore.Qt.UserRole)
|
reference = bitem.data(QtCore.Qt.UserRole)
|
||||||
obj = reference[unicode(key)]
|
obj = reference[unicode(key)]
|
||||||
return unicode(obj).strip()
|
return unicode(obj).strip()
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id)
|
self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id)
|
||||||
if not self.advancedLockButton.isChecked():
|
if not self.advancedLockButton.isChecked():
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
if self.listView.topLevelItemCount() != 0:
|
if self.listView.count() != 0:
|
||||||
self.__checkSecondBible(bible, second_bible)
|
self.__checkSecondBible(bible, second_bible)
|
||||||
elif self.search_results:
|
elif self.search_results:
|
||||||
self.displayResults(bible, second_bible)
|
self.displayResults(bible, second_bible)
|
||||||
@ -691,7 +691,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.second_search_results = bibles[second_bible].get_verses(text)
|
self.second_search_results = bibles[second_bible].get_verses(text)
|
||||||
if not self.quickLockButton.isChecked():
|
if not self.quickLockButton.isChecked():
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
if self.listView.topLevelItemCount() != 0 and self.search_results:
|
if self.listView.count() != 0 and self.search_results:
|
||||||
self.__checkSecondBible(bible, second_bible)
|
self.__checkSecondBible(bible, second_bible)
|
||||||
elif self.search_results:
|
elif self.search_results:
|
||||||
self.displayResults(bible, second_bible)
|
self.displayResults(bible, second_bible)
|
||||||
@ -707,7 +707,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
items = self.buildDisplayResults(bible, second_bible, self.search_results)
|
items = self.buildDisplayResults(bible, second_bible, self.search_results)
|
||||||
for bible_verse in items:
|
for bible_verse in items:
|
||||||
self.listView.addTopLevelItem(bible_verse)
|
self.listView.addItem(bible_verse)
|
||||||
self.listView.selectAll()
|
self.listView.selectAll()
|
||||||
self.search_results = {}
|
self.search_results = {}
|
||||||
self.second_search_results = {}
|
self.second_search_results = {}
|
||||||
@ -766,9 +766,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
second_version)
|
second_version)
|
||||||
else:
|
else:
|
||||||
bible_text = u'%s %d%s%d (%s)' % (book, verse.chapter, verse_separator, verse.verse, version)
|
bible_text = u'%s %d%s%d (%s)' % (book, verse.chapter, verse_separator, verse.verse, version)
|
||||||
bible_verse = QtGui.QTreeWidgetItem(bible_text)
|
bible_verse = QtGui.QListWidgetItem(bible_text)
|
||||||
bible_verse.setText(0, bible_text)
|
bible_verse.setData(QtCore.Qt.UserRole, data)
|
||||||
bible_verse.setData(0, QtCore.Qt.UserRole, data)
|
|
||||||
items.append(bible_verse)
|
items.append(bible_verse)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@ -972,7 +971,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def createItemFromId(self, item_id):
|
def createItemFromId(self, item_id):
|
||||||
item = QtGui.QTreeWidgetItem()
|
item = QtGui.QListWidgetItem()
|
||||||
bible = self.quickVersionComboBox.currentText()
|
bible = self.quickVersionComboBox.currentText()
|
||||||
search_results = self.plugin.manager.get_verses(bible, item_id, False)
|
search_results = self.plugin.manager.get_verses(bible, item_id, False)
|
||||||
items = self.buildDisplayResults(bible, u'', search_results)
|
items = self.buildDisplayResults(bible, u'', search_results)
|
||||||
|
@ -103,10 +103,9 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
custom_slides.sort()
|
custom_slides.sort()
|
||||||
for custom_slide in custom_slides:
|
for custom_slide in custom_slides:
|
||||||
custom_name = QtGui.QTreeWidgetItem(custom_slide.title)
|
custom_name = QtGui.QListWidgetItem(custom_slide.title)
|
||||||
custom_name.setText(0, custom_slide.title)
|
custom_name.setData(QtCore.Qt.UserRole, custom_slide.id)
|
||||||
custom_name.setData(0, QtCore.Qt.UserRole, custom_slide.id)
|
self.listView.addItem(custom_name)
|
||||||
self.listView.addTopLevelItem(custom_name)
|
|
||||||
# Auto-select the custom.
|
# Auto-select the custom.
|
||||||
if custom_slide.id == self.autoSelectId:
|
if custom_slide.id == self.autoSelectId:
|
||||||
self.listView.setCurrentItem(custom_name)
|
self.listView.setCurrentItem(custom_name)
|
||||||
@ -149,7 +148,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
item_id = item.data(0, QtCore.Qt.UserRole)
|
item_id = item.data(QtCore.Qt.UserRole)
|
||||||
self.edit_custom_form.loadCustom(item_id, False)
|
self.edit_custom_form.loadCustom(item_id, False)
|
||||||
self.edit_custom_form.exec_()
|
self.edit_custom_form.exec_()
|
||||||
self.autoSelectId = -1
|
self.autoSelectId = -1
|
||||||
|
@ -34,28 +34,61 @@ from openlp.core.lib.ui import create_button_box
|
|||||||
|
|
||||||
|
|
||||||
class Ui_ChooseGroupDialog(object):
|
class Ui_ChooseGroupDialog(object):
|
||||||
|
"""
|
||||||
|
The UI for the "Choose Image Group" form.
|
||||||
|
"""
|
||||||
def setupUi(self, choose_group_dialog):
|
def setupUi(self, choose_group_dialog):
|
||||||
|
"""
|
||||||
|
Set up the UI.
|
||||||
|
|
||||||
|
``choose_group_dialog``
|
||||||
|
The form object (not the class).
|
||||||
|
"""
|
||||||
choose_group_dialog.setObjectName(u'choose_group_dialog')
|
choose_group_dialog.setObjectName(u'choose_group_dialog')
|
||||||
choose_group_dialog.resize(440, 119)
|
choose_group_dialog.resize(399, 119)
|
||||||
self.choose_group_layout = QtGui.QFormLayout(choose_group_dialog)
|
self.choose_group_layout = QtGui.QFormLayout(choose_group_dialog)
|
||||||
self.choose_group_layout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
|
self.choose_group_layout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
|
||||||
self.choose_group_layout.setMargin(8)
|
self.choose_group_layout.setMargin(8)
|
||||||
self.choose_group_layout.setSpacing(8)
|
self.choose_group_layout.setSpacing(8)
|
||||||
|
self.choose_group_layout.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||||
self.choose_group_layout.setObjectName(u'choose_group_layout')
|
self.choose_group_layout.setObjectName(u'choose_group_layout')
|
||||||
self.group_question_label = QtGui.QLabel(choose_group_dialog)
|
self.group_question_label = QtGui.QLabel(choose_group_dialog)
|
||||||
self.group_question_label.setWordWrap(True)
|
self.group_question_label.setWordWrap(True)
|
||||||
self.group_question_label.setObjectName(u'group_question_label')
|
self.group_question_label.setObjectName(u'group_question_label')
|
||||||
self.choose_group_layout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.group_question_label)
|
self.choose_group_layout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.group_question_label)
|
||||||
|
self.nogroup_radio_button = QtGui.QRadioButton(choose_group_dialog)
|
||||||
|
self.nogroup_radio_button.setChecked(True)
|
||||||
|
self.nogroup_radio_button.setObjectName(u'nogroup_radio_button')
|
||||||
|
self.choose_group_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.nogroup_radio_button)
|
||||||
|
self.existing_radio_button = QtGui.QRadioButton(choose_group_dialog)
|
||||||
|
self.existing_radio_button.setChecked(False)
|
||||||
|
self.existing_radio_button.setObjectName(u'existing_radio_button')
|
||||||
|
self.choose_group_layout.setWidget(3, QtGui.QFormLayout.LabelRole, self.existing_radio_button)
|
||||||
self.group_combobox = QtGui.QComboBox(choose_group_dialog)
|
self.group_combobox = QtGui.QComboBox(choose_group_dialog)
|
||||||
self.group_combobox.setObjectName(u'group_combobox')
|
self.group_combobox.setObjectName(u'group_combobox')
|
||||||
self.choose_group_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.group_combobox)
|
self.choose_group_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.group_combobox)
|
||||||
|
self.new_radio_button = QtGui.QRadioButton(choose_group_dialog)
|
||||||
|
self.new_radio_button.setChecked(False)
|
||||||
|
self.new_radio_button.setObjectName(u'new_radio_button')
|
||||||
|
self.choose_group_layout.setWidget(4, QtGui.QFormLayout.LabelRole, self.new_radio_button)
|
||||||
|
self.new_group_edit = QtGui.QLineEdit(choose_group_dialog)
|
||||||
|
self.new_group_edit.setObjectName(u'new_group_edit')
|
||||||
|
self.choose_group_layout.setWidget(4, QtGui.QFormLayout.FieldRole, self.new_group_edit)
|
||||||
self.group_button_box = create_button_box(choose_group_dialog, u'buttonBox', [u'ok'])
|
self.group_button_box = create_button_box(choose_group_dialog, u'buttonBox', [u'ok'])
|
||||||
self.choose_group_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.group_button_box)
|
self.choose_group_layout.setWidget(5, QtGui.QFormLayout.FieldRole, self.group_button_box)
|
||||||
|
|
||||||
self.retranslateUi(choose_group_dialog)
|
self.retranslateUi(choose_group_dialog)
|
||||||
QtCore.QMetaObject.connectSlotsByName(choose_group_dialog)
|
QtCore.QMetaObject.connectSlotsByName(choose_group_dialog)
|
||||||
|
|
||||||
def retranslateUi(self, choose_group_dialog):
|
def retranslateUi(self, choose_group_dialog):
|
||||||
choose_group_dialog.setWindowTitle(translate('ImagePlugin.ChooseGroupForm', 'Choose group'))
|
"""
|
||||||
self.group_question_label.setText(translate('ImagePlugin.ChooseGroupForm',
|
Translate the UI on the fly.
|
||||||
'To which group do you want these images to be added?'))
|
|
||||||
|
``choose_group_dialog``
|
||||||
|
The form object (not the class).
|
||||||
|
"""
|
||||||
|
choose_group_dialog.setWindowTitle(translate('ImagePlugin.ChooseGroupForm', 'Select Image Group'))
|
||||||
|
self.group_question_label.setText(translate('ImagePlugin.ChooseGroupForm', 'Add images to group:'))
|
||||||
|
self.nogroup_radio_button.setText(translate('ImagePlugin.ChooseGroupForm', 'No group'))
|
||||||
|
self.existing_radio_button.setText(translate('ImagePlugin.ChooseGroupForm', 'Existing group'))
|
||||||
|
self.new_radio_button.setText(translate('ImagePlugin.ChooseGroupForm', 'New group'))
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import translate
|
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
|
||||||
from openlp.plugins.images.forms.choosegroupdialog import Ui_ChooseGroupDialog
|
from openlp.plugins.images.forms.choosegroupdialog import Ui_ChooseGroupDialog
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, SettingsManager, translate, \
|
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, SettingsManager, translate, \
|
||||||
check_item_selected, check_directory_exists, Receiver, create_thumb, validate_thumb, ServiceItemContext, Settings, \
|
check_item_selected, check_directory_exists, Receiver, create_thumb, validate_thumb, ServiceItemContext, Settings, \
|
||||||
UiStrings
|
StringContent, TreeWidgetWithDnD, UiStrings
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
||||||
from openlp.core.utils import AppLocation, delete_file, locale_compare, get_images_filter
|
from openlp.core.utils import AppLocation, delete_file, locale_compare, get_images_filter
|
||||||
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm
|
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm
|
||||||
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
|
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
|
||||||
@ -55,10 +55,10 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.quickPreviewAllowed = True
|
self.quickPreviewAllowed = True
|
||||||
self.hasSearch = True
|
self.hasSearch = True
|
||||||
self.manager = plugin.manager
|
self.manager = plugin.manager
|
||||||
self.choosegroupform = ChooseGroupForm(self)
|
self.choose_group_form = ChooseGroupForm(self)
|
||||||
self.addgroupform = AddGroupForm(self)
|
self.add_group_form = AddGroupForm(self)
|
||||||
self.fill_groups_combobox(self.choosegroupform.group_combobox)
|
self.fill_groups_combobox(self.choose_group_form.group_combobox)
|
||||||
self.fill_groups_combobox(self.addgroupform.parent_group_combobox)
|
self.fill_groups_combobox(self.add_group_form.parent_group_combobox)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
|
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
|
||||||
# Allow DnD from the desktop
|
# Allow DnD from the desktop
|
||||||
self.listView.activateDnD()
|
self.listView.activateDnD()
|
||||||
@ -106,7 +106,63 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
initial_load=True)
|
initial_load=True)
|
||||||
|
|
||||||
def addListViewToToolBar(self):
|
def addListViewToToolBar(self):
|
||||||
MediaManagerItem.addListViewToToolBar(self)
|
"""
|
||||||
|
Creates the main widget for listing items the media item is tracking.
|
||||||
|
This method overloads MediaManagerItem.addListViewToToolBar
|
||||||
|
"""
|
||||||
|
# Add the List widget
|
||||||
|
self.listView = TreeWidgetWithDnD(self, self.plugin.name)
|
||||||
|
self.listView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
|
self.listView.setAlternatingRowColors(True)
|
||||||
|
self.listView.setObjectName(u'%sTreeView' % self.plugin.name)
|
||||||
|
# Add to pageLayout
|
||||||
|
self.pageLayout.addWidget(self.listView)
|
||||||
|
# define and add the context menu
|
||||||
|
self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||||
|
if self.hasEditIcon:
|
||||||
|
create_widget_action(self.listView,
|
||||||
|
text=self.plugin.getString(StringContent.Edit)[u'title'],
|
||||||
|
icon=u':/general/general_edit.png',
|
||||||
|
triggers=self.onEditClick)
|
||||||
|
create_widget_action(self.listView, separator=True)
|
||||||
|
if self.hasDeleteIcon:
|
||||||
|
create_widget_action(self.listView,
|
||||||
|
text=self.plugin.getString(StringContent.Delete)[u'title'],
|
||||||
|
icon=u':/general/general_delete.png',
|
||||||
|
shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteClick)
|
||||||
|
create_widget_action(self.listView, separator=True)
|
||||||
|
create_widget_action(self.listView,
|
||||||
|
text=self.plugin.getString(StringContent.Preview)[u'title'],
|
||||||
|
icon=u':/general/general_preview.png',
|
||||||
|
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
|
||||||
|
triggers=self.onPreviewClick)
|
||||||
|
create_widget_action(self.listView,
|
||||||
|
text=self.plugin.getString(StringContent.Live)[u'title'],
|
||||||
|
icon=u':/general/general_live.png',
|
||||||
|
shortcuts=[QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter,
|
||||||
|
QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return],
|
||||||
|
triggers=self.onLiveClick)
|
||||||
|
create_widget_action(self.listView,
|
||||||
|
text=self.plugin.getString(StringContent.Service)[u'title'],
|
||||||
|
icon=u':/general/general_add.png',
|
||||||
|
shortcuts=[QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal],
|
||||||
|
triggers=self.onAddClick)
|
||||||
|
if self.addToServiceItem:
|
||||||
|
create_widget_action(self.listView, separator=True)
|
||||||
|
create_widget_action(self.listView,
|
||||||
|
text=translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'),
|
||||||
|
icon=u':/general/general_add.png',
|
||||||
|
triggers=self.onAddEditClick)
|
||||||
|
self.addCustomContextActions()
|
||||||
|
# Create the context menu and add all actions from the listView.
|
||||||
|
self.menu = QtGui.QMenu()
|
||||||
|
self.menu.addActions(self.listView.actions())
|
||||||
|
QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||||
|
self.onDoubleClicked)
|
||||||
|
QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'itemSelectionChanged()'),
|
||||||
|
self.onSelectionChange)
|
||||||
|
QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'customContextMenuRequested(QPoint)'),
|
||||||
|
self.contextMenu)
|
||||||
self.listView.addAction(self.replaceAction)
|
self.listView.addAction(self.replaceAction)
|
||||||
|
|
||||||
def addStartHeaderBar(self):
|
def addStartHeaderBar(self):
|
||||||
@ -148,6 +204,9 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
item_data = row_item.data(0, QtCore.Qt.UserRole)
|
item_data = row_item.data(0, QtCore.Qt.UserRole)
|
||||||
if isinstance(item_data, ImageFilenames):
|
if isinstance(item_data, ImageFilenames):
|
||||||
delete_file(os.path.join(self.servicePath, row_item.text(0)))
|
delete_file(os.path.join(self.servicePath, row_item.text(0)))
|
||||||
|
if item_data.group_id == 0:
|
||||||
|
self.listView.takeTopLevelItem(self.listView.indexOfTopLevelItem(row_item))
|
||||||
|
else:
|
||||||
row_item.parent().removeChild(row_item)
|
row_item.parent().removeChild(row_item)
|
||||||
self.manager.delete_object(ImageFilenames, row_item.data(0, QtCore.Qt.UserRole).id)
|
self.manager.delete_object(ImageFilenames, row_item.data(0, QtCore.Qt.UserRole).id)
|
||||||
elif isinstance(item_data, ImageGroups):
|
elif isinstance(item_data, ImageGroups):
|
||||||
@ -163,13 +222,8 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.listView.takeTopLevelItem(self.listView.indexOfTopLevelItem(row_item))
|
self.listView.takeTopLevelItem(self.listView.indexOfTopLevelItem(row_item))
|
||||||
else:
|
else:
|
||||||
row_item.parent().removeChild(row_item)
|
row_item.parent().removeChild(row_item)
|
||||||
self.fill_groups_combobox(self.choosegroupform.group_combobox)
|
self.fill_groups_combobox(self.choose_group_form.group_combobox)
|
||||||
self.fill_groups_combobox(self.addgroupform.parent_group_combobox)
|
self.fill_groups_combobox(self.add_group_form.parent_group_combobox)
|
||||||
elif item_data == u'Imported':
|
|
||||||
QtGui.QMessageBox.information(self, translate('ImagePlugin.MediaItem', 'Can\'t delete group'),
|
|
||||||
translate('ImagePlugin.MediaItem', 'The Imported group is a special group and can not be '
|
|
||||||
'deleted. It will disappear when it doesn\'t contain any images anymore.'),
|
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
@ -177,14 +231,16 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def add_sub_groups(self, group_list, parent_group_id):
|
def add_sub_groups(self, group_list, parent_group_id):
|
||||||
"""
|
"""
|
||||||
Recursively add subgroups to the given parent group
|
Recursively add subgroups to the given parent group in a QTreeWidget
|
||||||
"""
|
"""
|
||||||
image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id)
|
image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id)
|
||||||
image_groups.sort(cmp=locale_compare, key=lambda group_object: group_object.group_name)
|
image_groups.sort(cmp=locale_compare, key=lambda group_object: group_object.group_name)
|
||||||
|
folder_icon = build_icon(u':/images/image_group.png')
|
||||||
for image_group in image_groups:
|
for image_group in image_groups:
|
||||||
group = QtGui.QTreeWidgetItem()
|
group = QtGui.QTreeWidgetItem()
|
||||||
group.setText(0, image_group.group_name)
|
group.setText(0, image_group.group_name)
|
||||||
group.setData(0, QtCore.Qt.UserRole, image_group)
|
group.setData(0, QtCore.Qt.UserRole, image_group)
|
||||||
|
group.setIcon(0, folder_icon)
|
||||||
if parent_group_id is 0:
|
if parent_group_id is 0:
|
||||||
self.listView.addTopLevelItem(group)
|
self.listView.addTopLevelItem(group)
|
||||||
else:
|
else:
|
||||||
@ -252,14 +308,8 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
item_name.setToolTip(0, imageFile.filename)
|
item_name.setToolTip(0, imageFile.filename)
|
||||||
item_name.setData(0, QtCore.Qt.UserRole, imageFile)
|
item_name.setData(0, QtCore.Qt.UserRole, imageFile)
|
||||||
if imageFile.group_id is 0:
|
if imageFile.group_id is 0:
|
||||||
if 0 not in group_items:
|
self.listView.addTopLevelItem(item_name)
|
||||||
# The 'Imported' group is only displayed when there are files that were imported from the
|
else:
|
||||||
# configuration file
|
|
||||||
imported_group = QtGui.QTreeWidgetItem()
|
|
||||||
imported_group.setText(0, translate('ImagePlugin.MediaItem', 'Imported'))
|
|
||||||
imported_group.setData(0, QtCore.Qt.UserRole, u'Imported')
|
|
||||||
self.listView.insertTopLevelItem(0, imported_group)
|
|
||||||
group_items[0] = imported_group
|
|
||||||
group_items[imageFile.group_id].addChild(item_name)
|
group_items[imageFile.group_id].addChild(item_name)
|
||||||
if not initial_load:
|
if not initial_load:
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
@ -285,19 +335,36 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
Add new images to the database. This method is called when adding images using the Add button or DnD.
|
Add new images to the database. This method is called when adding images using the Add button or DnD.
|
||||||
"""
|
"""
|
||||||
if self.manager.get_object_count(ImageGroups) == 0:
|
|
||||||
QtGui.QMessageBox.warning(self, translate('ImagePlugin.MediaItem', 'No image groups'),
|
|
||||||
translate('ImagePlugin.MediaItem', 'No image groups exist yet. Please create one before adding images.'),
|
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
|
||||||
self.loadFullList(self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename),
|
|
||||||
initial_load=initial_load)
|
|
||||||
return
|
|
||||||
if target_group is None:
|
if target_group is None:
|
||||||
# Ask which group the images should be saved in
|
# Ask which group the images should be saved in
|
||||||
if self.choosegroupform.exec_():
|
if self.manager.get_object_count(ImageGroups) == 0:
|
||||||
group_id = self.choosegroupform.group_combobox.itemData(
|
self.choose_group_form.nogroup_radio_button.setChecked(True)
|
||||||
self.choosegroupform.group_combobox.currentIndex(), QtCore.Qt.UserRole)
|
self.choose_group_form.existing_radio_button.setChecked(False)
|
||||||
|
self.choose_group_form.new_radio_button.setChecked(False)
|
||||||
|
self.choose_group_form.existing_radio_button.setDisabled(True)
|
||||||
|
self.choose_group_form.group_combobox.setDisabled(True)
|
||||||
|
else:
|
||||||
|
self.choose_group_form.nogroup_radio_button.setChecked(True)
|
||||||
|
self.choose_group_form.existing_radio_button.setChecked(False)
|
||||||
|
self.choose_group_form.new_radio_button.setChecked(False)
|
||||||
|
self.choose_group_form.existing_radio_button.setDisabled(False)
|
||||||
|
self.choose_group_form.group_combobox.setDisabled(False)
|
||||||
|
if self.choose_group_form.exec_():
|
||||||
|
if self.choose_group_form.nogroup_radio_button.isChecked():
|
||||||
|
# User chose 'No group'
|
||||||
|
parent_group = ImageGroups()
|
||||||
|
parent_group.id = 0
|
||||||
|
elif self.choose_group_form.existing_radio_button.isChecked():
|
||||||
|
# User chose 'Existing group'
|
||||||
|
group_id = self.choose_group_form.group_combobox.itemData(
|
||||||
|
self.choose_group_form.group_combobox.currentIndex(), QtCore.Qt.UserRole)
|
||||||
parent_group = self.manager.get_object_filtered(ImageGroups, ImageGroups.id == group_id)
|
parent_group = self.manager.get_object_filtered(ImageGroups, ImageGroups.id == group_id)
|
||||||
|
elif self.choose_group_form.new_radio_button.isChecked():
|
||||||
|
# User chose 'New group'
|
||||||
|
parent_group = ImageGroups()
|
||||||
|
parent_group.parent_id = 0
|
||||||
|
parent_group.group_name = self.choose_group_form.new_group_edit.text()
|
||||||
|
self.manager.save_object(parent_group)
|
||||||
else:
|
else:
|
||||||
parent_group = target_group.data(0, QtCore.Qt.UserRole)
|
parent_group = target_group.data(0, QtCore.Qt.UserRole)
|
||||||
if isinstance(parent_group, ImageFilenames):
|
if isinstance(parent_group, ImageFilenames):
|
||||||
@ -313,7 +380,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
imageFile = ImageFilenames()
|
imageFile = ImageFilenames()
|
||||||
imageFile.group_id = parent_group.id
|
imageFile.group_id = parent_group.id
|
||||||
imageFile.filename = unicode(filename)
|
imageFile.filename = unicode(filename)
|
||||||
success = self.manager.save_object(imageFile)
|
self.manager.save_object(imageFile)
|
||||||
self.loadFullList(self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename),
|
self.loadFullList(self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename),
|
||||||
initial_load=initial_load, open_group=parent_group)
|
initial_load=initial_load, open_group=parent_group)
|
||||||
|
|
||||||
@ -430,32 +497,20 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
groups = self.manager.get_all_objects(ImageGroups, ImageGroups.group_name == newGroup.group_name)
|
groups = self.manager.get_all_objects(ImageGroups, ImageGroups.group_name == newGroup.group_name)
|
||||||
return self.__checkObject(groups, newGroup, edit)
|
return self.__checkObject(groups, newGroup, edit)
|
||||||
|
|
||||||
def onFileClick(self):
|
|
||||||
"""
|
|
||||||
Called when the user clicks the 'Load images' button. This method is overloaded from MediaManagerItem.
|
|
||||||
"""
|
|
||||||
if self.manager.get_object_count(ImageGroups) == 0:
|
|
||||||
QtGui.QMessageBox.warning(self, translate('ImagePlugin.MediaItem', 'No image groups'),
|
|
||||||
translate('ImagePlugin.MediaItem', 'No image groups exist yet. Please create one before adding images.'),
|
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
|
||||||
else:
|
|
||||||
# At least one group exists, so we run the regular file adding code
|
|
||||||
MediaManagerItem.onFileClick(self)
|
|
||||||
|
|
||||||
def onAddGroupClick(self):
|
def onAddGroupClick(self):
|
||||||
"""
|
"""
|
||||||
Called to add a new group
|
Called to add a new group
|
||||||
"""
|
"""
|
||||||
if self.addgroupform.exec_(show_top_level_group=True):
|
if self.add_group_form.exec_(show_top_level_group=True):
|
||||||
new_group = ImageGroups.populate(parent_id=self.addgroupform.parent_group_combobox.itemData(
|
new_group = ImageGroups.populate(parent_id=self.add_group_form.parent_group_combobox.itemData(
|
||||||
self.addgroupform.parent_group_combobox.currentIndex(), QtCore.Qt.UserRole),
|
self.add_group_form.parent_group_combobox.currentIndex(), QtCore.Qt.UserRole),
|
||||||
group_name=self.addgroupform.name_edit.text())
|
group_name=self.add_group_form.name_edit.text())
|
||||||
if self.checkGroupName(new_group):
|
if self.checkGroupName(new_group):
|
||||||
if self.manager.save_object(new_group):
|
if self.manager.save_object(new_group):
|
||||||
self.loadFullList(self.manager.get_all_objects(ImageFilenames,
|
self.loadFullList(self.manager.get_all_objects(ImageFilenames,
|
||||||
order_by_ref=ImageFilenames.filename))
|
order_by_ref=ImageFilenames.filename))
|
||||||
self.fill_groups_combobox(self.choosegroupform.group_combobox)
|
self.fill_groups_combobox(self.choose_group_form.group_combobox)
|
||||||
self.fill_groups_combobox(self.addgroupform.parent_group_combobox)
|
self.fill_groups_combobox(self.add_group_form.parent_group_combobox)
|
||||||
else:
|
else:
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
message=translate('ImagePlugin.AddGroupForm', 'Could not add the new group.'))
|
message=translate('ImagePlugin.AddGroupForm', 'Could not add the new group.'))
|
||||||
|
@ -147,7 +147,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
if check_item_selected(self.listView,
|
if check_item_selected(self.listView,
|
||||||
translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')):
|
translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')):
|
||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
filename = item.data(0, QtCore.Qt.UserRole)
|
filename = item.data(QtCore.Qt.UserRole)
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
service_item = ServiceItem()
|
service_item = ServiceItem()
|
||||||
service_item.title = u'webkit'
|
service_item.title = u'webkit'
|
||||||
@ -171,7 +171,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
item = self.listView.currentItem()
|
item = self.listView.currentItem()
|
||||||
if item is None:
|
if item is None:
|
||||||
return False
|
return False
|
||||||
filename = item.data(0, QtCore.Qt.UserRole)
|
filename = item.data(QtCore.Qt.UserRole)
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
if not remote:
|
if not remote:
|
||||||
# File is no longer present
|
# File is no longer present
|
||||||
@ -253,7 +253,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
row_list = [item.row() for item in self.listView.selectedIndexes()]
|
row_list = [item.row() for item in self.listView.selectedIndexes()]
|
||||||
row_list.sort(reverse=True)
|
row_list.sort(reverse=True)
|
||||||
for row in row_list:
|
for row in row_list:
|
||||||
self.listView.takeTopLevelItem(row)
|
self.listView.takeItem(row)
|
||||||
Settings().setValue(self.settingsSection + u'/media files', self.getFileList())
|
Settings().setValue(self.settingsSection + u'/media files', self.getFileList())
|
||||||
|
|
||||||
def loadList(self, media, target_group=None):
|
def loadList(self, media, target_group=None):
|
||||||
@ -264,27 +264,24 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
track_info = QtCore.QFileInfo(track)
|
track_info = QtCore.QFileInfo(track)
|
||||||
if not os.path.exists(track):
|
if not os.path.exists(track):
|
||||||
filename = os.path.split(unicode(track))[1]
|
filename = os.path.split(unicode(track))[1]
|
||||||
item_name = QtGui.QTreeWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
item_name.setText(0, filename)
|
item_name.setIcon(ERROR)
|
||||||
item_name.setIcon(0, ERROR)
|
item_name.setData(QtCore.Qt.UserRole, track)
|
||||||
item_name.setData(0, QtCore.Qt.UserRole, track)
|
|
||||||
elif track_info.isFile():
|
elif track_info.isFile():
|
||||||
filename = os.path.split(unicode(track))[1]
|
filename = os.path.split(unicode(track))[1]
|
||||||
item_name = QtGui.QTreeWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
item_name.setText(0, filename)
|
|
||||||
if u'*.%s' % (filename.split(u'.')[-1].lower()) in self.media_controller.audio_extensions_list:
|
if u'*.%s' % (filename.split(u'.')[-1].lower()) in self.media_controller.audio_extensions_list:
|
||||||
item_name.setIcon(0, AUDIO)
|
item_name.setIcon(AUDIO)
|
||||||
else:
|
else:
|
||||||
item_name.setIcon(0, VIDEO)
|
item_name.setIcon(VIDEO)
|
||||||
item_name.setData(0, QtCore.Qt.UserRole, track)
|
item_name.setData(QtCore.Qt.UserRole, track)
|
||||||
else:
|
else:
|
||||||
filename = os.path.split(unicode(track))[1]
|
filename = os.path.split(unicode(track))[1]
|
||||||
item_name = QtGui.QTreeWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
item_name.setText(0, filename)
|
item_name.setIcon(build_icon(DVDICON))
|
||||||
item_name.setIcon(0, build_icon(DVDICON))
|
item_name.setData(QtCore.Qt.UserRole, track)
|
||||||
item_name.setData(0, QtCore.Qt.UserRole, track)
|
item_name.setToolTip(track)
|
||||||
item_name.setToolTip(0, track)
|
self.listView.addItem(item_name)
|
||||||
self.listView.addTopLevelItem(item_name)
|
|
||||||
|
|
||||||
def getList(self, type=MediaType.Audio):
|
def getList(self, type=MediaType.Audio):
|
||||||
media = Settings().value(self.settingsSection + u'/media files')
|
media = Settings().value(self.settingsSection + u'/media files')
|
||||||
|
@ -164,12 +164,11 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
continue
|
continue
|
||||||
filename = os.path.split(unicode(file))[1]
|
filename = os.path.split(unicode(file))[1]
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
item_name = QtGui.QTreeWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
item_name.setText(0, filename)
|
item_name.setIcon(build_icon(ERROR))
|
||||||
item_name.setIcon(0, build_icon(ERROR))
|
item_name.setData(QtCore.Qt.UserRole, file)
|
||||||
item_name.setData(0, QtCore.Qt.UserRole, file)
|
item_name.setToolTip(file)
|
||||||
item_name.setToolTip(0, file)
|
self.listView.addItem(item_name)
|
||||||
self.listView.addTopLevelItem(item_name)
|
|
||||||
else:
|
else:
|
||||||
if titles.count(filename) > 0:
|
if titles.count(filename) > 0:
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
@ -202,12 +201,11 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
critical_error_message_box(UiStrings().UnsupportedFile,
|
critical_error_message_box(UiStrings().UnsupportedFile,
|
||||||
translate('PresentationPlugin.MediaItem', 'This type of presentation is not supported.'))
|
translate('PresentationPlugin.MediaItem', 'This type of presentation is not supported.'))
|
||||||
continue
|
continue
|
||||||
item_name = QtGui.QTreeWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
item_name.setText(0, filename)
|
item_name.setData(QtCore.Qt.UserRole, file)
|
||||||
item_name.setData(0, QtCore.Qt.UserRole, file)
|
item_name.setIcon(icon)
|
||||||
item_name.setIcon(0, icon)
|
item_name.setToolTip(file)
|
||||||
item_name.setToolTip(0, file)
|
self.listView.addItem(item_name)
|
||||||
self.listView.addTopLevelItem(item_name)
|
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
@ -233,7 +231,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
for row in row_list:
|
for row in row_list:
|
||||||
self.listView.takeTopLevelItem(row)
|
self.listView.takeItem(row)
|
||||||
Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList())
|
Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList())
|
||||||
|
|
||||||
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
def generateSlideData(self, service_item, item=None, xmlVersion=False,
|
||||||
|
@ -226,10 +226,9 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
author_list = [author.display_name for author in song.authors]
|
author_list = [author.display_name for author in song.authors]
|
||||||
song_title = unicode(song.title)
|
song_title = unicode(song.title)
|
||||||
song_detail = u'%s (%s)' % (song_title, create_separated_list(author_list))
|
song_detail = u'%s (%s)' % (song_title, create_separated_list(author_list))
|
||||||
song_name = QtGui.QTreeWidgetItem(song_detail)
|
song_name = QtGui.QListWidgetItem(song_detail)
|
||||||
song_name.setText(0, song_detail)
|
song_name.setData(QtCore.Qt.UserRole, song.id)
|
||||||
song_name.setData(0, QtCore.Qt.UserRole, song.id)
|
self.listView.addItem(song_name)
|
||||||
self.listView.addTopLevelItem(song_name)
|
|
||||||
# Auto-select the item if name has been set
|
# Auto-select the item if name has been set
|
||||||
if song.id == self.autoSelectId:
|
if song.id == self.autoSelectId:
|
||||||
self.listView.setCurrentItem(song_name)
|
self.listView.setCurrentItem(song_name)
|
||||||
@ -244,10 +243,9 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
if song.temporary:
|
if song.temporary:
|
||||||
continue
|
continue
|
||||||
song_detail = u'%s (%s)' % (author.display_name, song.title)
|
song_detail = u'%s (%s)' % (author.display_name, song.title)
|
||||||
song_name = QtGui.QTreeWidgetItem(song_detail)
|
song_name = QtGui.QListWidgetItem(song_detail)
|
||||||
song_name.setText(0, song_detail)
|
song_name.setData(QtCore.Qt.UserRole, song.id)
|
||||||
song_name.setData(0, QtCore.Qt.UserRole, song.id)
|
self.listView.addItem(song_name)
|
||||||
self.listView.addTopLevelItem(song_name)
|
|
||||||
|
|
||||||
def displayResultsBook(self, searchresults, song_number=False):
|
def displayResultsBook(self, searchresults, song_number=False):
|
||||||
log.debug(u'display results Book')
|
log.debug(u'display results Book')
|
||||||
@ -262,10 +260,9 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
if song_number and not song_number in song.song_number:
|
if song_number and not song_number in song.song_number:
|
||||||
continue
|
continue
|
||||||
song_detail = u'%s - %s (%s)' % (book.name, song.song_number, song.title)
|
song_detail = u'%s - %s (%s)' % (book.name, song.song_number, song.title)
|
||||||
song_name = QtGui.QTreeWidgetItem(song_detail)
|
song_name = QtGui.QListWidgetItem(song_detail)
|
||||||
song_name.setText(0, song_detail)
|
song_name.setData(QtCore.Qt.UserRole, song.id)
|
||||||
song_name.setData(0, QtCore.Qt.UserRole, song.id)
|
self.listView.addItem(song_name)
|
||||||
self.listView.addTopLevelItem(song_name)
|
|
||||||
|
|
||||||
def onClearTextButtonClick(self):
|
def onClearTextButtonClick(self):
|
||||||
"""
|
"""
|
||||||
@ -344,7 +341,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
log.debug(u'onEditClick')
|
log.debug(u'onEditClick')
|
||||||
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
||||||
self.editItem = self.listView.currentItem()
|
self.editItem = self.listView.currentItem()
|
||||||
item_id = self.editItem.data(0, QtCore.Qt.UserRole)
|
item_id = self.editItem.data(QtCore.Qt.UserRole)
|
||||||
self.editSongForm.loadSong(item_id, False)
|
self.editSongForm.loadSong(item_id, False)
|
||||||
self.editSongForm.exec_()
|
self.editSongForm.exec_()
|
||||||
self.autoSelectId = -1
|
self.autoSelectId = -1
|
||||||
@ -393,7 +390,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
log.debug(u'onCloneClick')
|
log.debug(u'onCloneClick')
|
||||||
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
if check_item_selected(self.listView, UiStrings().SelectEdit):
|
||||||
self.editItem = self.listView.currentItem()
|
self.editItem = self.listView.currentItem()
|
||||||
item_id = self.editItem.data(0, QtCore.Qt.UserRole)
|
item_id = self.editItem.data(QtCore.Qt.UserRole)
|
||||||
old_song = self.plugin.manager.get_object(Song, item_id)
|
old_song = self.plugin.manager.get_object(Song, item_id)
|
||||||
song_xml = self.openLyrics.song_to_xml(old_song)
|
song_xml = self.openLyrics.song_to_xml(old_song)
|
||||||
new_song = self.openLyrics.xml_to_song(song_xml)
|
new_song = self.openLyrics.xml_to_song(song_xml)
|
||||||
|
BIN
resources/images/image_group.png
Normal file
BIN
resources/images/image_group.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -22,6 +22,7 @@
|
|||||||
<file>song_book_edit.png</file>
|
<file>song_book_edit.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="images">
|
<qresource prefix="images">
|
||||||
|
<file>image_group.png</file>
|
||||||
<file>image_new_group.png</file>
|
<file>image_new_group.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="bibles">
|
<qresource prefix="bibles">
|
||||||
|
Loading…
Reference in New Issue
Block a user