~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/extensions/bigbrother/bigbrother.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <kactioncollection.h>
23
23
#include <kcomponentdata.h>
24
24
#include <kfiledialog.h>
25
 
#include <kgenericfactory.h>
 
25
#include <kpluginfactory.h>
26
26
#include <klocale.h>
27
27
#include <kstandarddirs.h>
28
28
 
35
35
#include <recorder/kis_play_info.h>
36
36
#include <recorder/kis_recorded_action.h>
37
37
#include <recorder/kis_recorded_action_factory_registry.h>
 
38
#include <recorder/kis_recorded_action_load_context.h>
 
39
#include <recorder/kis_recorded_action_save_context.h>
38
40
#include <kis_types.h>
39
41
#include <kis_view2.h>
40
42
 
41
43
#include "actionseditor/kis_actions_editor.h"
42
44
#include "actionseditor/kis_actions_editor_dialog.h"
43
 
 
44
 
typedef KGenericFactory<BigBrotherPlugin> BigBrotherPluginFactory;
45
 
K_EXPORT_COMPONENT_FACTORY(kritabigbrother, BigBrotherPluginFactory("krita"))
46
 
 
47
 
 
48
 
BigBrotherPlugin::BigBrotherPlugin(QObject *parent, const QStringList &)
 
45
#include <kis_resource_server_provider.h>
 
46
#include <KoResourceServerProvider.h>
 
47
 
 
48
K_PLUGIN_FACTORY(BigBrotherPluginFactory, registerPlugin<BigBrotherPlugin>();)
 
49
K_EXPORT_PLUGIN(BigBrotherPluginFactory("krita"))
 
50
 
 
51
class RecordedActionSaveContext : public KisRecordedActionSaveContext {
 
52
    public:
 
53
        virtual void saveGradient(const KoAbstractGradient* ) {}
 
54
        virtual void savePattern(const KisPattern* ) {}
 
55
};
 
56
 
 
57
class RecordedActionLoadContext : public KisRecordedActionLoadContext {
 
58
    public:
 
59
        virtual KoAbstractGradient* gradient(const QString& name) const
 
60
        {
 
61
            return KoResourceServerProvider::instance()->gradientServer()->getResourceByName(name);
 
62
        }
 
63
        virtual KisPattern* pattern(const QString& name) const
 
64
        {
 
65
            return KisResourceServerProvider::instance()->patternServer()->getResourceByName(name);
 
66
        }
 
67
};
 
68
 
 
69
BigBrotherPlugin::BigBrotherPlugin(QObject *parent, const QVariantList &)
49
70
        : KParts::Plugin(parent), m_recorder(0)
50
71
{
51
72
    if (parent->inherits("KisView2")) {
128
149
 
129
150
    // Create recorder
130
151
    m_recorder = new KisMacro();
131
 
    connect(m_view->image()->actionRecorder(), SIGNAL(addedAction(const KisRecordedAction&)), m_recorder, SLOT(addAction(const KisRecordedAction&)));
 
152
    connect(m_view->image()->actionRecorder(), SIGNAL(addedAction(const KisRecordedAction&)),
 
153
            m_recorder, SLOT(addAction(const KisRecordedAction&)));
132
154
}
133
155
 
134
156
void BigBrotherPlugin::slotStopRecordingMacro()
147
169
 
148
170
KisMacro* BigBrotherPlugin::openMacro(KUrl* url)
149
171
{
 
172
 
 
173
    Q_UNUSED(url);
 
174
 
150
175
    QString filename = KFileDialog::getOpenFileName(KUrl(), "*.krarec|Recorded actions (*.krarec)", m_view);
 
176
    RecordedActionLoadContext loadContext;
151
177
    if (!filename.isNull()) {
152
178
        QDomDocument doc;
153
179
        QFile f(filename);
166
192
            if (!docElem.isNull() && docElem.tagName() == "RecordedActions") {
167
193
                dbgPlugins << "Load the macro";
168
194
                KisMacro* m = new KisMacro();
169
 
                m->fromXML(docElem);
 
195
                m->fromXML(docElem, &loadContext);
170
196
                return m;
171
197
            } else {
172
198
                // TODO error message
184
210
    if (!filename.isNull()) {
185
211
        QDomDocument doc;
186
212
        QDomElement e = doc.createElement("RecordedActions");
187
 
 
188
 
        macro->toXML(doc, e);
 
213
        RecordedActionSaveContext context;
 
214
        macro->toXML(doc, e, &context);
189
215
 
190
216
        doc.appendChild(e);
191
217
        QFile f(filename);