-
Notifications
You must be signed in to change notification settings - Fork 108
Plugin Overview
ScreenCloud was built to support many different hosting services, while still remaining lightweight at the core. To achieve this, a plugin system is used. Plugins are loaded at runtime and show up in the list of online services.
Plugin support was added in version 1.1.0
and the plugins were written in JavaScript. This implementation had numerous issues and was replaced in 1.1.3
. Plugins are now written in Python with the PythonQt bindings.
ScreenCloud is built using Qt, a C++ GUI toolkit. To add plugin support, PythonQt is used. PyhtonQt provides bindings to parts of the Qt API. This lets you do things like showing buttons or message boxes:
QMessageBox.information(parentWidget, 'This is a Message Box', 'Sample Text.')
Documentation and examples for PythonQt is availalbe here.
ScreenCloud includes a python module that lets plugins interact with the main application. It also provides a few convenience methods.
import ScreenCloud
ScreenCloud comes with a built in debug console that lets you test Python code interactively. To access it, open the Preferences
and press Ctrl+D
on your keyboard (Command+D
on Mac OS X). This can be useful to get information about the Python environment, e.g:
import sys, ScreenCloud
print sys.version_info #Get the Python version
print "\n".join(sys.modules) #Show the available modules
print "\n".join(sys.path) #Where ScreenCloud is looking for python modules
print ScreenCloud.getPluginDir() #Where plugins are installed
Linux: ~/.local/share/data/screencloud/ScreenCloud/plugins/
Mac OS X: ~/Library/Application Support/screencloud/ScreenCloud/plugins
Windows: %localappdata%\screencloud\ScreenCloud\plugins
Each plugin has its own subdirectory in the plugin folder. The name of the directory should not contain spaces or special characters and it must match the shortname
specified in metadata.xml
.
The metadata.xml
file contains basic information about the plugin, including name, shortname and icon.
Here's an example of how it might look like:
<metadata>
<name>Example Plugin</name>
<shortname>example</shortname>
<className>ExampleUploader</className>
<icon>icon.png</icon>
<version>1.0</version>
</metadata>
The main.py
file is loaded and executed when ScreenCloud starts. It must contain a class with the className
from the metadata file. The class must contain three functions that ScreenCloud will call when the plugin is used:
-
isConfigured
should return True if the user has entered all the information required for uploading, otherwise it should return False -
getFilename
should return the default filename to use. -
upload
takes two parameters,screenshot
andname
.-
screenshot
is a QImage containing the screenshot that should be uploaded. -
name
is either the value returned bygetFilename
or a name specified by the user.
-
A minimal example could look like:
import ScreenCloud
class ExampleUploader():
def __init__(self):
pass
def isConfigured(self):
return True
def getFilename(self):
return ScreenCloud.formatFilename("sample filename")
def upload(self, screenshot, name):
return True