1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <cassert>
#include <qmessagebox.h>
#include <qaction.h>
#include <QMainWindow>
#include "screenshotplugincontainer.h"
// NUtil
#include "helpers.h"
// NApplication
#include "applicationfactory.h"
#include "runcommand.h"
// NPlugin
#include <iprovider.h>
#include <plugincontainer.h>
#include <iprogressobserver.h>
#include "screenshotplugin.h"
#include "screenshotpluginfactory.h"
#include <globals.h>
extern "C"
{
NPlugin::PluginContainer* new_screenshotplugin()
{
return new NPlugin::ScreenshotPluginContainer;
}
NPlugin::PluginInformation get_pluginInformation()
{
return NPlugin::PluginInformation("screenshotplugin", toString(NPackageSearch::VERSION), "Benjamin Mesing");
}
}
/** Initialize the plugin. */
__attribute__ ((constructor)) void init()
{
}
// __attribute__ ((destructor)) void fini()
// {
// /* code here is executed just before dlclose() unloads the module */
// }
namespace NPlugin
{
ScreenshotPluginContainer::ScreenshotPluginContainer()
{
_pScreenshotPlugin = 0;
addPlugin("ScreenshotPlugin");
_screenshotEnabled=true;
}
ScreenshotPluginContainer::~ScreenshotPluginContainer()
{
unloadAllPlugins();
}
/////////////////////////////////////////////////////
// PluginContainer Interface
/////////////////////////////////////////////////////
bool ScreenshotPluginContainer::init(IProvider* pProvider)
{
BasePluginContainer::init(pProvider, ScreenshotPluginFactory::getInstance());
if (screenshotEnabled())
{
// use dynamic cast here because of the virtual base class
// (static_cast is not allowed there)
_pScreenshotPlugin = dynamic_cast<ScreenshotPlugin*>(requestPlugin("ScreenshotPlugin"));
}
else
{
provider()->reportError(
tr("Screenshots not supported" ),
tr("Screenshots not supported")
);
return false;
}
return screenshotEnabled();
}
/////////////////////////////////////////////////////
// Helper Methods
/////////////////////////////////////////////////////
void ScreenshotPluginContainer::setScreenshotEnabled(bool enabled)
{
_screenshotEnabled = enabled;
}
} // namespace NPlugin
|