本文整理汇总了Python中openlp.core.lib.Receiver类的典型用法代码示例。如果您正苦于以下问题:Python Receiver类的具体用法?Python Receiver怎么用?Python Receiver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Receiver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_handler
def add_handler(self, controller, file, hide_mode, slide_no):
"""
Add a handler, which is an instance of a presentation and
slidecontroller combination. If the slidecontroller has a display
then load the presentation.
"""
log.debug(u'Live = %s, add_handler %s' % (self.is_live, file))
self.controller = controller
if self.doc is not None:
self.shutdown()
self.doc = self.controller.add_document(file)
if not self.doc.load_presentation():
# Display error message to user
# Inform slidecontroller that the action failed?
return
self.doc.slidenumber = slide_no
self.hide_mode = hide_mode
if self.is_live:
if hide_mode == HideMode.Screen:
Receiver.send_message(u'live_display_hide', HideMode.Screen)
self.stop()
elif hide_mode == HideMode.Theme:
self.blank(hide_mode)
elif hide_mode == HideMode.Blank:
self.blank(hide_mode)
else:
self.doc.start_presentation()
Receiver.send_message(u'live_display_hide', HideMode.Screen)
self.doc.slidenumber = 1
if slide_no > 1:
self.slide(slide_no)
示例2: save
def save(self):
"""
Save settings to disk.
"""
settings = Settings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'default service enabled', self.service_name_check_box.isChecked())
service_name = self.service_name_edit.text()
preset_is_valid = self.generate_service_name_example()[0]
if service_name == UiStrings().DefaultServiceName or not preset_is_valid:
settings.remove(u'default service name')
self.service_name_edit.setText(service_name)
else:
settings.setValue(u'default service name', service_name)
settings.setValue(u'default service day', self.service_name_day.currentIndex())
settings.setValue(u'default service hour', self.service_name_time.time().hour())
settings.setValue(u'default service minute', self.service_name_time.time().minute())
settings.setValue(u'recent file count', self.recent_spin_box.value())
settings.setValue(u'save current plugin', self.media_plugin_check_box.isChecked())
settings.setValue(u'double click live', self.double_click_live_check_box.isChecked())
settings.setValue(u'single click preview', self.single_click_preview_check_box.isChecked())
settings.setValue(u'expand service item', self.expand_service_item_check_box.isChecked())
settings.setValue(u'enable exit confirmation', self.enable_auto_close_check_box.isChecked())
settings.setValue(u'hide mouse', self.hide_mouse_check_box.isChecked())
settings.setValue(u'x11 bypass wm', self.x11_bypass_check_box.isChecked())
settings.setValue(u'alternate rows', self.alternate_rows_check_box.isChecked())
settings.setValue(u'default color', self.default_color)
settings.setValue(u'default image', self.default_file_edit.text())
settings.setValue(u'slide limits', self.slide_limits)
settings.endGroup()
if self.display_changed:
Receiver.send_message(u'config_screen_changed')
self.display_changed = False
Receiver.send_message(u'slidecontroller_update_slide_limits')
示例3: on_preview_button_clicked
def on_preview_button_clicked(self):
"""
Save the custom item and preview it.
"""
log.debug(u'onPreview')
if self.saveCustom():
Receiver.send_message(u'custom_preview')
示例4: on_data_directory_browse_button_clicked
def on_data_directory_browse_button_clicked(self):
"""
Browse for a new data directory location.
"""
old_root_path = unicode(self.data_directory_label.text())
# Get the new directory location.
new_data_path = QtGui.QFileDialog.getExistingDirectory(
self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path,
options=QtGui.QFileDialog.ShowDirsOnly)
# Set the new data path.
if new_data_path:
new_data_path = os.path.normpath(new_data_path)
if self.current_data_path.lower() == new_data_path.lower():
self.on_data_directory_cancel_button_clicked()
return
else:
return
# Make sure they want to change the data.
answer = QtGui.QMessageBox.question(self,
translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'),
translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP '
'data directory to:\n\n%s\n\n '
'The data directory will be changed when OpenLP is closed.').replace('%s', new_data_path),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No)
if answer != QtGui.QMessageBox.Yes:
return
# Check if data already exists here.
self.check_data_overwrite(new_data_path)
# Save the new location.
Receiver.send_message(u'set_new_data_path', new_data_path)
self.new_data_directory_edit.setText(new_data_path)
self.data_directory_cancel_button.show()
示例5: save
def save(self):
"""
Save the settings. If the tab hasn't been made visible to the user
then there is nothing to do, so exit. This removes the need to
start presentation applications unnecessarily.
"""
if not self.activated:
return
changed = False
for key in self.controllers:
controller = self.controllers[key]
if controller.is_available():
checkbox = self.PresenterCheckboxes[controller.name]
setting_key = self.settingsSection + u'/' + controller.name
if Settings().value(setting_key) != checkbox.checkState():
changed = True
Settings().setValue(setting_key, checkbox.checkState())
if checkbox.isChecked():
controller.start_process()
else:
controller.kill()
setting_key = self.settingsSection + u'/override app'
if Settings().value(setting_key) != self.OverrideAppCheckBox.checkState():
Settings().setValue(setting_key, self.OverrideAppCheckBox.checkState())
changed = True
if changed:
self.parent.reset_supported_suffixes()
Receiver.send_message(u'mediaitem_presentation_rebuild')
Receiver.send_message(u'mediaitem_suffixes')
示例6: create_from_service_item
def create_from_service_item(self, item):
"""
Create a custom slide from a text service item
"""
custom = CustomSlide()
custom.title = item.title
if item.theme:
custom.theme_name = item.theme
else:
custom.theme_name = u''
footer = u' '.join(item.raw_footer)
if footer:
if footer.startswith(item.title):
custom.credits = footer[len(item.title) + 1:]
else:
custom.credits = footer
else:
custom.credits = u''
custom_xml = CustomXMLBuilder()
for (idx, slide) in enumerate(item._raw_frames):
custom_xml.add_verse_to_lyrics(u'custom', unicode(idx + 1), slide['raw_slide'])
custom.text = unicode(custom_xml.extract_xml(), u'utf-8')
self.plugin.manager.save_object(custom)
self.onSearchTextButtonClicked()
if item.name.lower() == u'custom':
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False))
示例7: screen_count_changed
def screen_count_changed(self, changed_screen=-1):
"""
Called when a screen has been added or removed.
``changed_screen``
The screen's number which has been (un)plugged.
"""
# Do not log at start up.
if changed_screen != -1:
log.info(u'screen_count_changed %d' % self.desktop.screenCount())
# Remove unplugged screens.
for screen in copy.deepcopy(self.screen_list):
if screen[u'number'] == self.desktop.screenCount():
self.remove_screen(screen[u'number'])
# Add new screens.
for number in xrange(self.desktop.screenCount()):
if not self.screen_exists(number):
self.add_screen({
u'number': number,
u'size': self.desktop.screenGeometry(number),
u'primary': (self.desktop.primaryScreen() == number)
})
# We do not want to send this message at start up.
if changed_screen != -1:
# Reload setting tabs to apply possible changes.
Receiver.send_message(u'config_screen_changed')
示例8: save
def save(self):
settings = Settings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'background color', self.bg_color)
settings.endGroup()
if self.initial_color != self.bg_color:
Receiver.send_message(u'image_updated')
示例9: __init__
def __init__(self, parent):
QtCore.QObject.__init__(self, parent)
self.screen = None
self.timer_id = 0
self.alertList = []
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_active'), self.generateAlert)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alerts_text'), self.onAlertText)
示例10: save
def save(self):
settings = Settings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'display new chapter', self.show_new_chapters)
settings.setValue(u'display brackets', self.display_style)
settings.setValue(u'verse layout style', self.layout_style)
settings.setValue(u'book name language', self.language_selection)
settings.setValue(u'second bibles', self.second_bibles)
settings.setValue(u'bible theme', self.bible_theme)
if self.verseSeparatorCheckBox.isChecked():
settings.setValue(u'verse separator', self.verseSeparatorLineEdit.text())
else:
settings.remove(u'verse separator')
if self.rangeSeparatorCheckBox.isChecked():
settings.setValue(u'range separator', self.rangeSeparatorLineEdit.text())
else:
settings.remove(u'range separator')
if self.listSeparatorCheckBox.isChecked():
settings.setValue(u'list separator', self.listSeparatorLineEdit.text())
else:
settings.remove(u'list separator')
if self.endSeparatorCheckBox.isChecked():
settings.setValue(u'end separator', self.endSeparatorLineEdit.text())
else:
settings.remove(u'end separator')
update_reference_separators()
Receiver.send_message(u'bibles_load_list')
settings.endGroup()
示例11: reject
def reject(self):
"""
Stop the wizard on cancel button, close button or ESC key.
"""
log.debug(u'Wizard cancelled by user.')
if self.currentPage() == self.progressPage:
Receiver.send_message(u'openlp_stop_wizard')
self.done(QtGui.QDialog.Rejected)
示例12: run
def run(self):
"""
Run the thread.
"""
self.sleep(1)
app_version = get_application_version()
version = check_latest_version(app_version)
if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])):
Receiver.send_message(u'openlp_version_check', u'%s' % version)
示例13: __init__
def __init__(self, name, default_settings, media_item_class=None, settings_tab_class=None, version=None):
"""
This is the constructor for the plugin object. This provides an easy
way for descendent plugins to populate common data. This method *must*
be overridden, like so::
class MyPlugin(Plugin):
def __init__(self):
Plugin.__init__(self, u'MyPlugin', version=u'0.1')
``name``
Defaults to *None*. The name of the plugin.
``default_settings``
A dict containing the plugin's settings. The value to each key is the default value to be used.
``media_item_class``
The class name of the plugin's media item.
``settings_tab_class``
The class name of the plugin's settings tab.
``version``
Defaults to *None*, which means that the same version number is used as OpenLP's version number.
"""
log.debug(u'Plugin %s initialised' % name)
QtCore.QObject.__init__(self)
self.name = name
self.textStrings = {}
self.setPluginTextStrings()
self.nameStrings = self.textStrings[StringContent.Name]
if version:
self.version = version
else:
self.version = get_application_version()[u'version']
self.settingsSection = self.name
self.icon = None
self.mediaItemClass = media_item_class
self.settingsTabClass = settings_tab_class
self.settingsTab = None
self.mediaItem = None
self.weight = 0
self.status = PluginStatus.Inactive
# Add the default status to the default settings.
default_settings[name + u'/status'] = PluginStatus.Inactive
default_settings[name + u'/last directory'] = u''
# Append a setting for files in the mediamanager (note not all plugins
# which have a mediamanager need this).
if media_item_class is not None:
default_settings[u'%s/%s files' % (name, name)] = []
# Add settings to the dict of all settings.
Settings.extend_default_settings(default_settings)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.processAddServiceEvent)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_config_updated' % self.name),
self.configUpdated)
示例14: run
def run(self, args):
"""
Run the OpenLP application.
"""
self.is_event_loop_active = False
# On Windows, the args passed into the constructor are ignored. Not
# very handy, so set the ones we want to use. On Linux and FreeBSD, in
# order to set the WM_CLASS property for X11, we pass "OpenLP" in as a
# command line argument. This interferes with files being passed in as
# command line arguments, so we remove it from the list.
if 'OpenLP' in args:
args.remove('OpenLP')
self.args.extend(args)
# Decide how many screens we have and their size
screens = ScreenList.create(self.desktop())
# First time checks in settings
has_run_wizard = Settings().value(u'general/has run wizard')
if not has_run_wizard:
if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted:
Settings().setValue(u'general/has run wizard', True)
# Correct stylesheet bugs
application_stylesheet = u''
if not Settings().value(u'advanced/alternate rows'):
base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base)
alternate_rows_repair_stylesheet = \
u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n'
application_stylesheet += alternate_rows_repair_stylesheet
if os.name == u'nt':
application_stylesheet += nt_repair_stylesheet
if application_stylesheet:
self.setStyleSheet(application_stylesheet)
show_splash = Settings().value(u'general/show splash')
if show_splash:
self.splash = SplashScreen()
self.splash.show()
# make sure Qt really display the splash screen
self.processEvents()
# start the main app window
self.main_window = MainWindow()
self.main_window.show()
if show_splash:
# now kill the splashscreen
self.splash.finish(self.main_window)
log.debug(u'Splashscreen closed')
# make sure Qt really display the splash screen
self.processEvents()
self.main_window.repaint()
self.processEvents()
if not has_run_wizard:
self.main_window.first_time()
update_check = Settings().value(u'general/update check')
if update_check:
VersionThread(self.main_window).start()
Receiver.send_message(u'live_display_blank_check')
self.main_window.app_startup()
return self.exec_()
示例15: display
def display(self, action):
"""
Hide or show the display screen.
``action``
This is the action, either ``hide`` or ``show``.
"""
Receiver.send_message(u'slidecontroller_toggle_display', action)
return HttpResponse(json.dumps({u'results': {u'success': True}}),
{u'Content-Type': u'application/json'})