diff --git a/libs/libkis/Action.cpp b/libs/libkis/Action.cpp index 20a206cb3a..35bf543807 100644 --- a/libs/libkis/Action.cpp +++ b/libs/libkis/Action.cpp @@ -1,128 +1,143 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "Action.h" #include struct Action::Private { Private() {} QAction *action {0}; QString name; QString menu; }; Action::Action(QObject *parent) : QObject(parent) , d(new Private) { d->action = new QAction(this); connect(d->action, SIGNAL(triggered(bool)), SIGNAL(triggered(bool))); } Action::Action(const QString &name, QAction *action, QObject *parent) : QObject(parent) , d(new Private) { d->name = name; d->action = action; connect(d->action, SIGNAL(triggered(bool)), SIGNAL(triggered(bool))); } Action::~Action() { delete d; } QString Action::name() const { return d->name; } void Action::setName(QString value) { d->name = value; } - QString Action::menu() const { return d->menu; } void Action::setMenu(QString value) { d->menu = value; } bool Action::isCheckable() const { + if (!d->action) return false; return d->action->isCheckable(); } void Action::setCheckable(bool value) { + if (!d->action) return; d->action->setCheckable(value); } bool Action::isChecked() const { + if (!d->action) return false; return d->action->isChecked(); } void Action::setChecked(bool value) { + if (!d->action) return; d->action->setChecked(value); } QString Action::shortcut() const { + if (!d->action) return QString(); return d->action->shortcut().toString(); } void Action::setShortcut(QString value) { + if (!d->action) return; d->action->setShortcut(QKeySequence::fromString(value)); } bool Action::isVisible() const { + if (!d->action) return false; return d->action->isVisible(); } void Action::setVisible(bool value) { + if (!d->action) return; d->action->setVisible(value); } bool Action::isEnabled() const { + if (!d->action) return false; return d->action->isEnabled(); } void Action::setEnabled(bool value) { + if (!d->action) return; d->action->setEnabled(value); } +void Action::setToolTip(QString tooltip) +{ + if (!d->action) return; + d->action->setToolTip(tooltip); +} + void Action::trigger() { d->action->trigger(); } diff --git a/libs/libkis/Action.h b/libs/libkis/Action.h index dcc4704db9..7b21ae617e 100644 --- a/libs/libkis/Action.h +++ b/libs/libkis/Action.h @@ -1,83 +1,76 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKIS_ACTION_H #define LIBKIS_ACTION_H #include #include "kritalibkis_export.h" #include "libkis.h" /** * Action */ class KRITALIBKIS_EXPORT Action : public QObject { Q_OBJECT - Q_PROPERTY(QString Name READ name WRITE setName) - Q_PROPERTY(QString Menu READ menu WRITE setMenu) - Q_PROPERTY(bool Checkable READ isCheckable WRITE setCheckable) - Q_PROPERTY(bool Checked READ isChecked WRITE setChecked) - Q_PROPERTY(QString Shortcut READ shortcut WRITE setShortcut) - Q_PROPERTY(bool Visible READ isVisible WRITE setVisible) - Q_PROPERTY(bool Enabled READ isEnabled WRITE setEnabled) - public: explicit Action(QObject *parent = 0); Action(const QString &name, QAction *action, QObject *parent = 0); virtual ~Action(); +public Q_SLOTS: + QString name() const; void setName(QString value); QString menu() const; void setMenu(QString value); bool isCheckable() const; void setCheckable(bool value); bool isChecked() const; void setChecked(bool value); QString shortcut() const; void setShortcut(QString value); bool isVisible() const; void setVisible(bool value); bool isEnabled() const; void setEnabled(bool value); - -public Q_SLOTS: + void setToolTip(QString tooltip); void trigger(); Q_SIGNALS: void triggered(bool); private: struct Private; Private *const d; }; #endif // LIBKIS_ACTION_H diff --git a/libs/libkis/Krita.cpp b/libs/libkis/Krita.cpp index 250258b8f5..be51f2205e 100644 --- a/libs/libkis/Krita.cpp +++ b/libs/libkis/Krita.cpp @@ -1,348 +1,407 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "Krita.h" #include #include +#include +#include + #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include +#include +#include +#include +#include +#include #include "View.h" #include "Document.h" #include "Window.h" #include "ViewExtension.h" #include "DockWidgetFactoryBase.h" #include "Filter.h" #include "InfoObject.h" #include "Generator.h" +#include "Resource.h" Krita* Krita::s_instance = 0; struct Krita::Private { Private() {} QList viewExtensions; bool batchMode {false}; Notifier *notifier{new Notifier()}; }; Krita::Krita(QObject *parent) : QObject(parent) , d(new Private) { qRegisterMetaType(); } Krita::~Krita() { qDeleteAll(d->viewExtensions); delete d->notifier; delete d; } QList Krita::actions() const { QList actionList; KisMainWindow *mainWindow = KisPart::instance()->currentMainwindow(); if (!mainWindow) { return actionList; } KActionCollection *actionCollection = mainWindow->actionCollection(); Q_FOREACH(QAction *action, actionCollection->actions()) { actionList << new Action(action->objectName(), action); } return actionList; } Action *Krita::action(const QString &name) const { KisMainWindow *mainWindow = KisPart::instance()->currentMainwindow(); if (!mainWindow) { return 0; } KActionCollection *actionCollection = mainWindow->actionCollection(); QAction *action = actionCollection->action(name); if (action) { return new Action(name, action); } return 0; } Document* Krita::activeDocument() const { KisMainWindow *mainWindow = KisPart::instance()->currentMainwindow(); if (!mainWindow) { return 0; } KisView *view = mainWindow->activeView(); if (!view) { return 0; } KisDocument *document = view->document(); return new Document(document); } void Krita::setActiveDocument(Document* value) { Q_FOREACH(KisView *view, KisPart::instance()->views()) { if (view->document() == value->document().data()) { view->activateWindow(); break; } } } bool Krita::batchmode() const { return d->batchMode; } void Krita::setBatchmode(bool value) { d->batchMode = value; } QList Krita::documents() const { QList ret; foreach(QPointer doc, KisPart::instance()->documents()) { ret << new Document(doc); } return ret; } QStringList Krita::filters() const { QStringList ls = KisFilterRegistry::instance()->keys(); qSort(ls); return ls; } Filter *Krita::filter(const QString &name) const { if (!filters().contains(name)) return 0; Filter *filter = new Filter(); filter->setName(name); KisFilterSP f = KisFilterRegistry::instance()->value(name); KisFilterConfigurationSP fc = f->defaultConfiguration(); InfoObject *info = new InfoObject(fc); filter->setConfiguration(info); return filter; } QStringList Krita::generators() const { QStringList ls = KisGeneratorRegistry::instance()->keys(); qSort(ls); return ls; } Generator *Krita::generator(const QString &name) const { // UNIMPLEMENTED if (!generators().contains(name)) return 0; Generator *generator = new Generator(); // generator->setName(name); // KisGeneratorSP f = KisGeneratorRegistry::instance()->value(name); // KisGeneratorConfigurationSP fc = f->defaultConfiguration(0); // InfoObject *info = new InfoObject(fc); // generator->setConfiguration(info); return generator; } QStringList Krita::profiles(const QString &colorModel, const QString &colorDepth) const { QSet profileNames; QString id = KoColorSpaceRegistry::instance()->colorSpaceId(colorModel, colorDepth); QList profiles = KoColorSpaceRegistry::instance()->profilesFor(id); Q_FOREACH(const KoColorProfile *profile, profiles) { profileNames << profile->name(); } return profileNames.toList(); } bool Krita::addProfile(const QString &profilePath) { KoColorSpaceEngine *iccEngine = KoColorSpaceEngineRegistry::instance()->get("icc"); return iccEngine->addProfile(profilePath); } Notifier* Krita::notifier() const { return d->notifier; } QString Krita::version() const { return KritaVersionWrapper::versionString(true); } QList Krita::views() const { QList ret; foreach(QPointer view, KisPart::instance()->views()) { ret << new View(view); } return ret; } Window *Krita::activeWindow() const { KisMainWindow *mainWindow = KisPart::instance()->currentMainwindow(); if (!mainWindow) { return 0; } return new Window(mainWindow); } QList Krita::windows() const { QList ret; foreach(QPointer mainWin, KisPart::instance()->mainWindows()) { ret << new Window(mainWin); } return ret; } -QList Krita::resources() const +QList Krita::resources(const QString &type) const { - // UNIMPLEMENTED - return QList (); + QList resources = QList (); + + if (type == "pattern") { + KoResourceServer* server = KoResourceServerProvider::instance()->patternServer(); + Q_FOREACH (KoResource *res, server->resources()) { + resources << new Resource(res); + } + } + else if (type == "gradient") { + KoResourceServer* server = KoResourceServerProvider::instance()->gradientServer(); + Q_FOREACH (KoResource *res, server->resources()) { + resources << new Resource(res); + } + } + else if (type == "brush") { + KisBrushResourceServer* server = KisBrushServer::instance()->brushServer(); + Q_FOREACH (KisBrushSP res, server->resources()) { + resources << new Resource(res.data()); + } + } + else if (type == "preset") { + KisPaintOpPresetResourceServer* server = KisResourceServerProvider::instance()->paintOpPresetServer(); + Q_FOREACH (KisPaintOpPresetSP res, server->resources()) { + resources << new Resource(res.data()); + } + } + else if (type == "palette") { + KoResourceServer* server = KoResourceServerProvider::instance()->paletteServer(); + Q_FOREACH (KoResource *res, server->resources()) { + resources << new Resource(res); + } + } + else if (type == "workspace") { + KoResourceServer< KisWorkspaceResource >* server = KisResourceServerProvider::instance()->workspaceServer(); + Q_FOREACH (KoResource *res, server->resources()) { + resources << new Resource(res); + } + } + return resources; } bool Krita::closeApplication() { qDebug() << "closeApplication called"; return false; } Document* Krita::createDocument(int width, int height, const QString &name, const QString &colorModel, const QString &colorDepth, const QString &profile) { KisDocument *document = KisPart::instance()->createDocument(); KisPart::instance()->addDocument(document); const KoColorSpace *cs = KoColorSpaceRegistry::instance()->colorSpace(colorModel, colorDepth, profile); Q_ASSERT(cs); QColor qc(Qt::white); qc.setAlpha(0); KoColor bgColor(qc, cs); if (!document->newImage(name, width, height, cs, bgColor, true, 1, "", 100.0)) { qDebug() << "Could not create a new image"; return 0; } Q_ASSERT(document->image()); qDebug() << document->image()->objectName(); return new Document(document); } Document* Krita::openDocument(const QString &filename) { KisDocument *document = KisPart::instance()->createDocument(); KisPart::instance()->addDocument(document); document->openUrl(QUrl::fromLocalFile(filename), KisDocument::OPEN_URL_FLAG_DO_NOT_ADD_TO_RECENT_FILES); return new Document(document); } Window* Krita::openWindow() { KisMainWindow *mw = KisPart::instance()->createMainWindow(); return new Window(mw); } Action *Krita::createAction(const QString &text) { KisAction *action = new KisAction(text, this); KisPart::instance()->addScriptAction(action); return new Action(action->objectName(), action); } void Krita::addViewExtension(ViewExtension* viewExtension) { d->viewExtensions.append(viewExtension); } QList< ViewExtension* > Krita::viewExtensions() { return d->viewExtensions; } +void Krita::writeSetting(const QString &group, const QString &name, const QString &value) +{ + KConfigGroup grp = KSharedConfig::openConfig()->group(group); + grp.writeEntry(name, value); +} + +QString Krita::readSetting(const QString &group, const QString &name, const QString &defaultValue) +{ + KConfigGroup grp = KSharedConfig::openConfig()->group(group); + return grp.readEntry(name, defaultValue); +} + void Krita::addDockWidgetFactory(DockWidgetFactoryBase* factory) { KoDockRegistry::instance()->add(factory); } Krita* Krita::instance() { if (!s_instance) { s_instance = new Krita; } return s_instance; } /** * Scripter.fromVariant(variant) * variant is a QVariant * returns instance of QObject-subclass * * This is a helper method for PyQt because PyQt cannot cast a variant to a QObject or QWidget */ QObject *Krita::fromVariant(const QVariant& v) { if (v.canConvert< QWidget* >()) { QObject* obj = qvariant_cast< QWidget* >(v); return obj; } else if (v.canConvert< QObject* >()) { QObject* obj = qvariant_cast< QObject* >(v); return obj; } else return 0; } diff --git a/libs/libkis/Krita.h b/libs/libkis/Krita.h index c5a7b0c2a3..afe2ea1f66 100644 --- a/libs/libkis/Krita.h +++ b/libs/libkis/Krita.h @@ -1,256 +1,306 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKIS_KRITA_H #define LIBKIS_KRITA_H #include #include "kritalibkis_export.h" #include "libkis.h" #include "ViewExtension.h" #include "Document.h" #include "Window.h" #include "View.h" #include "Action.h" #include "Notifier.h" class QAction; /** * Krita is a singleton class that offers the root access to the Krita object hierarchy. * * The Krita.instance() is aliased as two builtins: Scripter and Application. */ class KRITALIBKIS_EXPORT Krita : public QObject { Q_OBJECT public: explicit Krita(QObject *parent = 0); virtual ~Krita(); public Q_SLOTS: /** * @return the currently active document, if there is one. */ Document* activeDocument() const; /** * @brief setActiveDocument activates the first view that shows the given document * @param value the document we want to activate */ void setActiveDocument(Document* value); /** * @brief batchmode determines whether the script is run in batch mode. If batchmode * is true, scripts should now show messageboxes or dialog boxes. * * Note that this separate from Document.setBatchmode(), which determines whether * export/save option dialogs are shown. * * @return true if the script is run in batchmode */ bool batchmode() const; /** * @brief setBatchmode sets the the batchmode to @param value; if true, scripts should * not show dialogs or messageboxes. */ void setBatchmode(bool value); /** * @return return a list of all actions for the currently active mainWindow. */ QList actions() const; Action *action(const QString &name) const; /** * @return a list of all open Documents */ QList documents() const; /** * @brief Filters are identified by an internal name. This function returns a list * of all existing registered filters. * @return a list of all registered filters */ QStringList filters() const; /** * @brief filter construct a Filter object with a default configuration. * @param name the name of the filter. Use Krita.instance().filters() to get * a list of all possible filters. * @return the filter or None if there is no such filter. */ Filter *filter(const QString &name) const; /** * @brief Create a list of all available generator plugins. Generators are identified * by an internal name; this name can be used to construct a Generator object. The * Generator object can then be used to create a Node object representing a Fill Layer. * @return the list of available generators. */ QStringList generators() const; /** * @brief generator construct a Generator object with a default configuration. * @param name the name of the generator. Use Krita.instance().generators() to get * a list of all possible filters. * @return the generator or None if there is no such generator. */ Generator *generator(const QString &name) const; /** * @brief profiles creates a list with the names of all color profiles compatible * with the given color model and color depth. * @param colorModel A string describing the color model of the image: *
    *
  • A: Alpha mask
  • *
  • RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
  • *
  • XYZA: XYZ with alpha channel
  • *
  • LABA: LAB with alpha channel
  • *
  • CMYKA: CMYK with alpha channel
  • *
  • GRAYA: Gray with alpha channel
  • *
  • YCbCrA: YCbCr with alpha channel
  • *
* @param colorDepth A string describing the color depth of the image: *
    *
  • U8: unsigned 8 bits integer, the most common type
  • *
  • U16: unsigned 16 bits integer
  • *
  • F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
  • *
  • F32: 32 bits floating point
  • *
* @return a list with valid names */ QStringList profiles(const QString &colorModel, const QString &colorDepth) const; /** * @brief addProfile load the given profile into the profile registry. * @param profilePath the path to the profile. * @return true if adding the profile succeeded. */ bool addProfile(const QString &profilePath); /** * @brief notifier the Notifier singleton emits signals when documents are opened and * closed, the configuration changes, views are opened and closed or windows are opened. * @return the notifier object */ Notifier* notifier() const; /** * @brief version Determine the version of Krita * * Usage: print(Application.version ()) * * @return the version string including git sha1 if Krita was built from git */ QString version() const; /** * @return a list of all views. A Document can be shown in more than one view. */ QList views() const; /** * @return the currently active window or None if there is no window */ Window * activeWindow() const; /** * @return a list of all windows */ QList windows() const; - QList resources() const; + /** + * @brief resources returns a list of Resource objects of the given type + * @param type Valid types are: + * + *
    + *
  • pattern
  • + *
  • gradient
  • + *
  • brush
  • + *
  • preset
  • + *
  • palette
  • + *
  • workspace
  • + *
  • :
  • + *
+ + */ + QList resources(const QString &type) const; bool closeApplication(); /** * @brief createDocument creates a new document and image and registers the document with the Krita application. * * The document will have one transparent layer. * * @param width the width in pixels * @param height the height in pixels * @param name the name of the image (not the filename of the document) * @param colorModel A string describing the color model of the image: *
    *
  • A: Alpha mask
  • *
  • RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
  • *
  • XYZA: XYZ with alpha channel
  • *
  • LABA: LAB with alpha channel
  • *
  • CMYKA: CMYK with alpha channel
  • *
  • GRAYA: Gray with alpha channel
  • *
  • YCbCrA: YCbCr with alpha channel
  • *
* @param colorDepth A string describing the color depth of the image: *
    *
  • U8: unsigned 8 bits integer, the most common type
  • *
  • U16: unsigned 16 bits integer
  • *
  • F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
  • *
  • F32: 32 bits floating point
  • *
* @param profile The name of an icc profile that is known to Krita. If an empty string is passed, the default is * taken. * @return the created document. */ Document *createDocument(int width, int height, const QString &name, const QString &colorModel, const QString &colorDepth, const QString &profile); /** * @brief openDocument creates a new Document, registers it with the Krita application and loads the given file. * @param filename the file to open in the document * @return the document */ Document *openDocument(const QString &filename); /** * @brief openWindow create a new main window. The window is not shown by default. */ Window *openWindow(); /** * @brief createAction creates an action with the given text and passes it to Krita. Every newly created * mainwindow will create an instance of this action. * @param text the user-visible text * @return the QAction you can connect a slot to. */ Action *createAction(const QString &text); + /** + * @brief addViewExtension add the given plugin to Krita. For every window, a new instance of this + * extension will be made. + * @param viewExtension + */ void addViewExtension(ViewExtension* viewExtension); QList viewExtensions(); + /** + * @brief addDockWidgetFactory Add the given docker factory to the application. For scripts + * loaded on startup, this means that every window will have one of the dockers created by the + * factory. + * @param factory The factory object. + */ void addDockWidgetFactory(DockWidgetFactoryBase* factory ); + /** + * @brief writeSetting write the given setting under the given name to the kritarc file in + * the given settings group. + * @param group The group the setting belongs to. If empty, then the setting is written in the + * general section + * @param name The name of the setting + * @param value The value of the setting. Script settings are always written as strings. + */ + void writeSetting(const QString &group, const QString &name, const QString &value); + + /** + * @brief readSetting read the given setting value from the kritarc file. + * @param group The group the setting is part of. If empty, then the setting is read from + * the general group. + * @param name The name of the setting + * @param defaultValue The default value of the setting + * @return a string representing the setting. + */ + QString readSetting(const QString &group, const QString &name, const QString &defaultValue); + + /** + * @brief instance retrieve the singleton instance of the Application object. + */ static Krita* instance(); + /// For mikro.py static QObject *fromVariant(const QVariant& v); private: struct Private; Private *const d; static Krita* s_instance; }; Q_DECLARE_METATYPE(Notifier*); #endif // LIBKIS_KRITA_H diff --git a/libs/libkis/Resource.cpp b/libs/libkis/Resource.cpp index 266b9da0df..d967356da0 100644 --- a/libs/libkis/Resource.cpp +++ b/libs/libkis/Resource.cpp @@ -1,74 +1,115 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "Resource.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include struct Resource::Private { - Private() {} + Private(KoResource *_resource) + : resource(_resource) + {} + + KoResource *resource; }; -Resource::Resource(QObject *parent) +Resource::Resource(KoResource *resource, QObject *parent) : QObject(parent) - , d(new Private) + , d(new Private(resource)) { } Resource::~Resource() { delete d; } QString Resource::type() const { - // UNIMPLEMENTED - return QString(); + if (!d->resource) return QString(); + if (dynamic_cast(d->resource)) return "pattern"; + else if (dynamic_cast(d->resource)) return "gradient"; + else if (dynamic_cast(d->resource)) return "brush"; + else if (dynamic_cast(d->resource)) return "preset"; + else if (dynamic_cast(d->resource)) return "palette"; + else if (dynamic_cast(d->resource)) return "workspace"; + else return ""; +} + +QString Resource::name() const +{ + if (!d->resource) return QString(); + return d->resource->name(); } -void Resource::setType(QString value) +void Resource::setName(QString value) { - // UNIMPLEMENTED + if (!d->resource) return; + d->resource->setName(value); } -QString Resource::name() const +QString Resource::filename() const { - // UNIMPLEMENTED - return QString(); + if (!d->resource) return QString(); + return d->resource->filename(); } -void Resource::setName(QString value) + +QImage Resource::image() const { - // UNIMPLEMENTED + if (!d->resource) return QImage(); + return d->resource->image(); } +void Resource::setImage(QImage image) +{ + if (!d->resource) return; + d->resource->setImage(image); +} -QString Resource::filename() const +QByteArray Resource::data() const { - // UNIMPLEMENTED - return QString(); + QByteArray ba; + + if (!d->resource) return ba; + + QBuffer buf(&ba); + d->resource->saveToDevice(&buf); + return ba; } -void Resource::setFilename(QString value) +bool Resource::setData(QByteArray data) { - // UNIMPLEMENTED + if (!d->resource) return false; + QBuffer buf(&data); + return d->resource->loadFromDevice(&buf); } diff --git a/libs/libkis/Resource.h b/libs/libkis/Resource.h index 4db9843e4f..f3ccd3b76a 100644 --- a/libs/libkis/Resource.h +++ b/libs/libkis/Resource.h @@ -1,67 +1,61 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKIS_RESOURCE_H #define LIBKIS_RESOURCE_H #include - +#include #include "kritalibkis_export.h" #include "libkis.h" + +class KoResource; + /** * Resource */ class KRITALIBKIS_EXPORT Resource : public QObject { Q_OBJECT - Q_DISABLE_COPY(Resource) - - Q_PROPERTY(QString Type READ type WRITE setType) - Q_PROPERTY(QString Name READ name WRITE setName) - Q_PROPERTY(QString Filename READ filename WRITE setFilename) public: - explicit Resource(QObject *parent = 0); + explicit Resource(KoResource *resource, QObject *parent = 0); virtual ~Resource(); +public Q_SLOTS: + QString type() const; - void setType(QString value); QString name() const; void setName(QString value); QString filename() const; - void setFilename(QString value); - - - -public Q_SLOTS: - - - -Q_SIGNALS: + QImage image() const; + void setImage(QImage image); + QByteArray data() const; + bool setData(QByteArray data); private: struct Private; const Private *const d; }; #endif // LIBKIS_RESOURCE_H diff --git a/libs/pigment/resources/KoResource.h b/libs/pigment/resources/KoResource.h index be20bed321..f6e5720a5b 100644 --- a/libs/pigment/resources/KoResource.h +++ b/libs/pigment/resources/KoResource.h @@ -1,131 +1,131 @@ /* This file is part of the KDE project Copyright (c) 2003 Patrick Julien Copyright (c) 2005 Boudewijn Rempt This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef KORESOURCE_H #define KORESOURCE_H #include #include #include #include class QDomDocument; class QDomElement; /** * The KoResource class provides a representation of resources. This * includes, but not limited to, brushes and patterns. */ class KRITAPIGMENT_EXPORT KoResource { public: /** * Creates a new KoResource object using @p filename. No file is opened * in the constructor, you have to call load. * * @param filename the file name to save and load from. */ explicit KoResource(const QString &filename); virtual ~KoResource(); bool operator ==(const KoResource &other) const { return other.md5() == md5(); } public: /** * Load this resource. * @return true if loading the resource succeeded. */ virtual bool load() = 0; virtual bool loadFromDevice(QIODevice *dev) = 0; /** * Save this resource. - *@return true if saving the resource succeeded. + Layer *@return true if saving the resource succeeded. */ virtual bool save() = 0; virtual bool saveToDevice(QIODevice* dev) const; /** * @returns a QImage thumbnail image representing this resource. * * This image could be null. The image can be in any valid format. */ QImage image() const; void setImage(const QImage &image); /// @return the md5sum calculated over the contents of the resource. QByteArray md5() const; /// @returns true if resource can be removed by the user bool removable() const; /// @return the full path to this resource QString filename() const; void setFilename(const QString& filename); /// @return the name of the file without the path QString shortFilename() const; /// @return the user-visible name of the resource QString name() const; void setName(const QString& name); /// @return true if the resource is ready for use bool valid() const; void setValid(bool valid); /// @return the default file extension which should be used when saving the resource virtual QString defaultFileExtension() const; /// @return true if the resource is permanent and can't be removed by the user bool permanent() const; void setPermanent(bool permanent); protected: /// override generateMD5 and in your resource subclass virtual QByteArray generateMD5() const; /// call this when the contents of the resource change so the md5 needs to be recalculated void setMD5(const QByteArray &md5); protected: KoResource(const KoResource &rhs); private: struct Private; Private* const d; }; static inline bool operator==(const KoResource &resource1, const KoResource &resource2) { return (resource1.md5() == resource2.md5()); } static inline uint qHash(const KoResource &resource) { return qHash(resource.md5()); } #endif // KORESOURCE_H_ diff --git a/libs/widgets/KoResourceItemChooser.h b/libs/widgets/KoResourceItemChooser.h index 943a220ba3..c9f3151edd 100644 --- a/libs/widgets/KoResourceItemChooser.h +++ b/libs/widgets/KoResourceItemChooser.h @@ -1,153 +1,153 @@ /* This file is part of the KDE project Copyright (c) 2002 Patrick Julien Copyright (c) 2007 Jan Hambrecht Copyright (c) 2007 Sven Langkamp Copyright (c) 2010 Boudewijn Rempt Copyright (C) 2011 Srikanth Tiyyagura Copyright (c) 2011 José Luis Vergara Copyright (c) 2013 Sascha Suelzer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KO_RESOURCE_ITEM_CHOOSER #define KO_RESOURCE_ITEM_CHOOSER #include #include "kritawidgets_export.h" class QModelIndex; class QAbstractProxyModel; class QAbstractItemDelegate; class QAbstractButton; class QToolButton; class KoAbstractResourceServerAdapter; class KoResourceItemView; class KoResource; /** * A widget that contains a KoResourceChooser as well * as an import/export button */ class KRITAWIDGETS_EXPORT KoResourceItemChooser : public QWidget { Q_OBJECT public: enum Buttons { Button_Import, Button_Remove }; /// \p usePreview shows the aside preview with the resource's image explicit KoResourceItemChooser(QSharedPointer resourceAdapter, QWidget *parent = 0, bool usePreview = false); ~KoResourceItemChooser(); /// Sets number of columns in the view and causes the number of rows to be calculated accordingly void setColumnCount(int columnCount); /// Sets number of rows in the view and causes the number of columns to be calculated accordingly void setRowCount(int rowCount); /// Sets the height of the view rows void setRowHeight(int rowHeight); /// Sets the width of the view columns void setColumnWidth(int columnWidth); /// Sets a custom delegate for the view void setItemDelegate(QAbstractItemDelegate *delegate); /// Gets the currently selected resource /// @returns the selected resource, 0 is no resource is selected KoResource *currentResource() const; /// Sets the item representing the resource as selected void setCurrentResource(KoResource *resource); /** - * Sets the sected resource, does nothing if there is no valid item + * Sets the selected resource, does nothing if there is no valid item * @param row row of the item * @param column column of the item */ void setCurrentItem(int row, int column); void showButtons(bool show); void addCustomButton(QAbstractButton *button, int cell); /// determines whether the preview right or below the splitter void setPreviewOrientation(Qt::Orientation orientation); /// determines whether the preview should tile the resource's image or not void setPreviewTiled(bool tiled); /// shows the preview converted to grayscale void setGrayscalePreview(bool grayscale); /// sets the visibilty of tagging KlineEdits. void showTaggingBar(bool show); ///Set a proxy model with will be used to filter the resources void setProxyModel(QAbstractProxyModel *proxyModel); QSize viewSize() const; KoResourceItemView *itemView() const; void setViewModeButtonVisible(bool visible); QToolButton *viewModeButton() const; void setSynced(bool sync); virtual bool eventFilter(QObject *object, QEvent *event); Q_SIGNALS: /// Emitted when a resource was selected void resourceSelected(KoResource *resource); /// Emitted when an *already selected* resource is clicked /// again void resourceClicked(KoResource *resource); void splitterMoved(); public Q_SLOTS: void slotButtonClicked(int button); private Q_SLOTS: void activated(const QModelIndex &index); void clicked(const QModelIndex &index); void contextMenuRequested(const QPoint &pos); void baseLengthChanged(int length); void slotBeforeResourcesLayoutReset(KoResource *activateAfterReset); void slotAfterResourcesLayoutReset(); void updateView(); protected: virtual void showEvent(QShowEvent *event); private: void updateButtonState(); void updatePreview(KoResource *resource); virtual void resizeEvent(QResizeEvent *event); /// Resource for a given model index /// @returns the resource pointer, 0 is index not valid KoResource *resourceFromModelIndex(const QModelIndex &index) const; class Private; Private *const d; }; #endif // KO_RESOURCE_ITEM_CHOOSER diff --git a/plugins/extensions/pykrita/plugin/plugins/CMakeLists.txt b/plugins/extensions/pykrita/plugin/plugins/CMakeLists.txt index 62da3c35dc..ae8ad2d680 100644 --- a/plugins/extensions/pykrita/plugin/plugins/CMakeLists.txt +++ b/plugins/extensions/pykrita/plugin/plugins/CMakeLists.txt @@ -1,92 +1,93 @@ # Copyright (C) 2012, 2013 Shaheed Haque # Copyright (C) 2013 Alex Turbov # Copyright (C) 2014-2016 Boudewijn Rempt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(CMakeParseArguments) # # Simple helper function to install plugin and related files # having only a name of the plugin... # (just to reduce syntactic noise when a lot of plugins get installed) # function(install_pykrita_plugin name) set(_options) set(_one_value_args) set(_multi_value_args PATTERNS FILE) cmake_parse_arguments(install_pykrita_plugin "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN}) if(NOT name) message(FATAL_ERROR "Plugin filename is not given") endif() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py) install(FILES kritapykrita_${name}.desktop DESTINATION ${DATA_INSTALL_DIR}/krita/pykrita) foreach(_f ${name}.py ${name}.ui ${install_pykrita_plugin_FILE}) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_f}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${_f} DESTINATION ${DATA_INSTALL_DIR}/krita/pykrita) endif() endforeach() elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${name}) install(FILES ${name}/kritapykrita_${name}.desktop DESTINATION ${DATA_INSTALL_DIR}/krita/pykrita) install( DIRECTORY ${name} DESTINATION ${DATA_INSTALL_DIR}/krita/pykrita FILES_MATCHING PATTERN "*.py" PATTERN "*.ui" PATTERN "__pycache__*" EXCLUDE ) # TODO Is there any way to form a long PATTERN options string # and use it in a single install() call? # NOTE Install specified patterns one-by-one... foreach(_pattern ${install_pykrita_plugin_PATTERNS}) install( DIRECTORY ${name} DESTINATION ${DATA_INSTALL_DIR}/krita/pykrita FILES_MATCHING PATTERN "${_pattern}" PATTERN "__pycache__*" EXCLUDE ) endforeach() else() message(FATAL_ERROR "Do not know what to do with ${name}") endif() endfunction() install_pykrita_plugin(hello) install_pykrita_plugin(assignprofiledialog) install_pykrita_plugin(scripter) install_pykrita_plugin(highpass) +install_pykrita_plugin(tenbrushes) # if(PYTHON_VERSION_MAJOR VERSION_EQUAL 3) # install_pykrita_plugin(cmake_utils) # install_pykrita_plugin(js_utils PATTERNS "*.json") # install_pykrita_plugin(expand PATTERNS "*.expand" "templates/*.tpl") # endif() install( DIRECTORY libkritapykrita DESTINATION ${DATA_INSTALL_DIR}/krita/pykrita FILES_MATCHING PATTERN "*.py" PATTERN "__pycache__*" EXCLUDE ) diff --git a/plugins/extensions/pykrita/plugin/plugins/highpass/highpass.py b/plugins/extensions/pykrita/plugin/plugins/highpass/highpass.py index 5cbe641ea5..5b210bf814 100644 --- a/plugins/extensions/pykrita/plugin/plugins/highpass/highpass.py +++ b/plugins/extensions/pykrita/plugin/plugins/highpass/highpass.py @@ -1,117 +1,117 @@ import sys from PyQt5.QtGui import * from PyQt5.QtWidgets import * from krita import * class HighpassViewExtension(ViewExtension): def __init__(self, parent): super().__init__(parent) def setup(self): action = Application.createAction("High Pass") action.triggered.connect(self.showDialog) def showDialog(self): doc = Application.activeDocument() if doc == None: QMessageBox.information(Application.activeWindow().qwindow(), "Highpass Filter", "There is no active image.") return self.dialog = QDialog(Application.activeWindow().qwindow()) self.intRadius = QSpinBox() self.intRadius.setValue(10) self.intRadius.setRange(2, 200) self.cmbMode = QComboBox() self.cmbMode.addItems(["Color", "Preserve DC", "Greyscale", "Greyscale, Apply Chroma", "Redrobes"]) self.keepOriginal = QCheckBox("Keep Original Layer"); self.keepOriginal.setChecked(True) form = QFormLayout() form.addRow("Filter Radius", self.intRadius) form.addRow("Mode", self.cmbMode) form.addRow("", self.keepOriginal) self.buttonBox = QDialogButtonBox(self.dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self.dialog.accept) self.buttonBox.accepted.connect(self.highpass) self.buttonBox.rejected.connect(self.dialog.reject) vbox = QVBoxLayout(self.dialog) vbox.addLayout(form) vbox.addWidget(self.buttonBox) self.dialog.show() self.dialog.activateWindow() self.dialog.exec_() def highpass(self): # XXX: Start undo macro image = Application.activeDocument() original = image.activeNode() working_layer = original # We can only highpass on paint layers if self.keepOriginal.isChecked() or original.type() != "paintlayer": working_layer = image.createNode("working", "paintlayer") working_layer.setColorSpace(original.colorModel(), original.colorSpace(), original.profile()) working_layer.writeBytes(original.readBytes(0, 0, image.width(), image.height()), 0, 0, image.width(), image.height()) original.parentNode().addChildNode(working_layer, original) # XXX: Unimplemented image.setActiveNode(working_layer) colors_layer = None; # if keeping colors - if self.cmbMode.currentIndex() == 1 || self.cmbMode.currentIndex() == 3: + if self.cmbMode.currentIndex() == 1 or self.cmbMode.currentIndex() == 3: colors_layer = working_layer.duplicate() # XXX: Unimplemented colors_layer.setName("colors") original.parentNode().addChildNode(working_layer, colors_layer) # XXX: Unimplemented # if greyscale, desature - if (self.cmbMode.currentIndex() == 2 || self.cmbMode.currentIndex() == 3): + if (self.cmbMode.currentIndex() == 2 or self.cmbMode.currentIndex() == 3): filter = Application.filter("desaturate") filter.apply(working_layer, 0, 0, image.width(), image.height()) # Duplicate on top and blur blur_layer = working_layer.duplicate() blur_layer.setName("blur") original.parentNode().addChildNode(blur_layer, working_layer) # XXX: Unimplemented # blur filter = Application.filter("gaussian blur") filter_configuration = filter.configuration() filter_configuration.setProperty("horizRadius", self.intRadius.value()) filter_configuration.setProperty("vertRadius", self.intRadius.value()) filter_configuration.setProperty("lockAspect", true) filter.setConfiguration(filter_configuration) filter.apply(blur_layer, 0, 0, image.width(), image.height()) if self.cmbMode.currentIndex() <= 3: blur_layer.setBlendingMode("grain_extract") working_layer = image.mergeDown(blur_layer) # if preserve chroma, change set the mode to value and merge down with the layer we kept earlier. if self.cmbMode.currentIndex() == 3: working_layer.setBlendingMode("value") working_layer = image.mergeDown(working_layer) # if preserve DC, change set the mode to overlay and merge down with the average colour of the layer we kept earlier. if self.cmbMode.currentIndex() == 1: # get the average color of the entire image # clear the colors layer to the given color working_layer = image.mergeDown(working_layer) else: # Mode == 4, RedRobes image.setActiveNode(blur_layer) # Get the average color of the input layer # copy the solid colour layer # copy the blurred layer # XXX: End undo macro Scripter.addViewExtension(HighpassViewExtension(Krita.instance())) diff --git a/plugins/extensions/pykrita/plugin/plugins/tenbrushes/__init__.py b/plugins/extensions/pykrita/plugin/plugins/tenbrushes/__init__.py new file mode 100644 index 0000000000..ea8c588a34 --- /dev/null +++ b/plugins/extensions/pykrita/plugin/plugins/tenbrushes/__init__.py @@ -0,0 +1,2 @@ +# let's make a module +from .tenbrushes import * diff --git a/plugins/extensions/pykrita/plugin/plugins/tenbrushes/kritapykrita_tenbrushes.desktop b/plugins/extensions/pykrita/plugin/plugins/tenbrushes/kritapykrita_tenbrushes.desktop new file mode 100644 index 0000000000..724cf95bca --- /dev/null +++ b/plugins/extensions/pykrita/plugin/plugins/tenbrushes/kritapykrita_tenbrushes.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Service +ServiceTypes=Krita/PythonPlugin +X-KDE-Library=tenbrushes +X-Python-2-Compatible=false +Name=Hello World +Comment=Basic plugin to test PyKrita diff --git a/plugins/extensions/pykrita/plugin/plugins/tenbrushes/tenbrushes.py b/plugins/extensions/pykrita/plugin/plugins/tenbrushes/tenbrushes.py new file mode 100644 index 0000000000..c941bc9fa2 --- /dev/null +++ b/plugins/extensions/pykrita/plugin/plugins/tenbrushes/tenbrushes.py @@ -0,0 +1,83 @@ +import sys +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +from krita import * + +class DropButton(QPushButton): + + def __init__(self, parent): + super().__init__(parent) + self.setFixedSize(64, 64) + + +class TenBrushesViewExtension(ViewExtension): + + def __init__(self, parent): + super().__init__(parent) + + def setup(self): + action = Application.createAction("Ten Brushes") + action.setToolTip("Assign ten brush presets to ten shortcuts.") + action.triggered.connect(self.showDialog) + + # Read the ten selected brush presets from the settings + selectedBrushes = Application.readSetting("", "tenbrushes", "") + print(selectedBrushes.split(",")) + # Setup up to ten actions and give them default shortcuts + + def showDialog(self): + self.dialog = QDialog(Application.activeWindow().qwindow()) + + self.buttonBox = QDialogButtonBox(self.dialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) + self.buttonBox.accepted.connect(self.accept) + self.buttonBox.rejected.connect(self.dialog.reject) + + vbox = QVBoxLayout(self.dialog) + hbox = QHBoxLayout(self.dialog) + for i in ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']: + self.buttons = [] + button = DropButton(self.dialog) + button.setText("Ctrl+" + i) + hbox.addWidget(button) + self.buttons.append(button) + + + self.presetChooser = QTableWidget(self.dialog) + self.presetChooser.setColumnCount(20) + self.presetChooser.setRowCount(2000) + self.presetChooser.setShowGrid(True); + self.presetChooser.horizontalHeader().setVisible(False); + self.presetChooser.verticalHeader().setVisible(False); + self.presetChooser.setSortingEnabled(False) + col = 0 + row = 0 + for preset in Application.resources("preset"): + print(preset.name(), row, col) + pm = QPixmap.fromImage(preset.image()) + icon = QIcon(pm) + item = QTableWidgetItem(icon, preset.name()) + self.presetChooser.setItem(row, col, item) + col = col + 1 + if col > self.presetChooser.columnCount(): + col = 0 + row = row + 1 + self.presetChooser.setRowCount(row) + self.presetChooser.setSortingEnabled(True) + + + vbox.addLayout(hbox) + vbox.addWidget(self.presetChooser) + vbox.addWidget(self.buttonBox) + + self.dialog.show() + self.dialog.activateWindow() + self.dialog.exec_() + + + def accept(self): + print("Saving ten presets") + self.dialog.accept() + +Scripter.addViewExtension(TenBrushesViewExtension(Application)) diff --git a/plugins/extensions/pykrita/sip/krita/Action.sip b/plugins/extensions/pykrita/sip/krita/Action.sip index 6d95602239..92aa3b1da0 100644 --- a/plugins/extensions/pykrita/sip/krita/Action.sip +++ b/plugins/extensions/pykrita/sip/krita/Action.sip @@ -1,32 +1,33 @@ class Action : QObject { %TypeHeaderCode #include "Action.h" %End public: Action(QObject* parent /TransferThis/ = 0); Action(const QString & name, QAction* action, QObject* parent /TransferThis/ = 0); virtual ~Action(); +public Q_SLOTS: QString name() const; void setName(QString value); QString menu() const; void setMenu(QString value); bool isCheckable() const; void setCheckable(bool value); bool isChecked() const; void setChecked(bool value); QString shortcut() const; void setShortcut(QString value); bool isVisible() const; void setVisible(bool value); bool isEnabled() const; void setEnabled(bool value); -public Q_SLOTS: + void setToolTip(QString tooltip); void trigger(); Q_SIGNALS: void triggered(bool); private: private: Action(const Action &); // Generated }; diff --git a/plugins/extensions/pykrita/sip/krita/Krita.sip b/plugins/extensions/pykrita/sip/krita/Krita.sip index e6f9d43adb..52eeb4df74 100644 --- a/plugins/extensions/pykrita/sip/krita/Krita.sip +++ b/plugins/extensions/pykrita/sip/krita/Krita.sip @@ -1,56 +1,59 @@ class Krita : QObject { %TypeHeaderCode #include "Krita.h" %End public: public Q_SLOTS: Krita(QObject* parent /TransferThis/ = 0); virtual ~Krita(); Document * activeDocument() const /Factory/; void setActiveDocument(Document* value); bool batchmode() const; void setBatchmode(bool value); QList actions() const /Factory/; Action * action(const QString & name) const; QList documents() const /Factory/; QStringList filters() const; Filter * filter(const QString &name) const /Factory/; QStringList generators() const /Factory/; Generator * generator(const QString &name) const /Factory/; QStringList profiles(const QString &colorModel, const QString &ColorDepth) const; bool addProfile(const QString &profilePath); Notifier * notifier() const; QString version() const; QList views() const /Factory/; Window * activeWindow() const /Factory/; QList windows() const /Factory/; - QList resources() const /Factory/; + QList resources(const QString &type) const /Factory/; bool closeApplication(); Document * createDocument(int width, int height, const QString &name, const QString &colorModel, const QString &colorDepth, const QString &profile) /Factory/; Document * openDocument(const QString &filename) /Factory/; Window * openWindow(); Action * createAction(const QString & text); void addViewExtension(ViewExtension* _viewExtension /GetWrapper/); %MethodCode Py_BEGIN_ALLOW_THREADS sipCpp->addViewExtension(a0); Py_END_ALLOW_THREADS sipTransferTo(a0Wrapper, Py_None); %End void addDockWidgetFactory(DockWidgetFactoryBase* _factory /GetWrapper/); %MethodCode Py_BEGIN_ALLOW_THREADS sipCpp->addDockWidgetFactory(a0); Py_END_ALLOW_THREADS sipTransferTo(a0Wrapper, Py_None); %End + void writeSetting(const QString &group, const QString &name, const QString &value); + QString readSetting(const QString &group, const QString &name, const QString &defaultValue); + static Krita * instance(); static QObject * fromVariant(const QVariant & v); private: Krita(const Krita &); // Generated }; diff --git a/plugins/extensions/pykrita/sip/krita/Resource.sip b/plugins/extensions/pykrita/sip/krita/Resource.sip index 4dbf227124..c537ebba46 100644 --- a/plugins/extensions/pykrita/sip/krita/Resource.sip +++ b/plugins/extensions/pykrita/sip/krita/Resource.sip @@ -1,19 +1,21 @@ class Resource : QObject { %TypeHeaderCode #include "Resource.h" %End Resource(const Resource & __0); public: - Resource(QObject* parent /TransferThis/ = 0); virtual ~Resource(); +public Q_SLOTS: QString type() const; - void setType(QString value); QString name() const; void setName(QString value); QString filename() const; - void setFilename(QString value); + QImage image() const; + void setImage(QImage image); + QByteArray data() const; + bool setData(QByteArray data); public Q_SLOTS: Q_SIGNALS: private: };