|
| 1 | +#include "AngyPlugin.h" |
| 2 | +#include "FilterAngy.h" |
| 3 | + |
| 4 | + |
| 5 | +#include "PluginHub.h" |
| 6 | +#include "PluginDependency.h" |
| 7 | + |
| 8 | +#include <QDebug> |
| 9 | +#include <iostream> |
| 10 | + |
| 11 | + |
| 12 | +#include <QWidget> |
| 13 | +#include <QPushButton> |
| 14 | +#include <QSettings> |
| 15 | + |
| 16 | + |
| 17 | +#define PLUGIN_NAME_HR "Angy" |
| 18 | + |
| 19 | + |
| 20 | +extern "C" BIBBLE_API B5Plugin *b5plugin() { return new AngyPlugin; } |
| 21 | + |
| 22 | + |
| 23 | +bool AngyPlugin::init(PluginHub *hub, int id, int groupId, const QString &bundlePath) |
| 24 | +{ |
| 25 | + Q_UNUSED(bundlePath); |
| 26 | + qDebug() << "Initialising "<<PLUGIN_NAME_HR<<" filter"; |
| 27 | + |
| 28 | + if(hub == NULL) return false; |
| 29 | + m_hub = hub; |
| 30 | + m_id = id; |
| 31 | + m_groupId = groupId; |
| 32 | + |
| 33 | + // Store our group ID and group name (andrewj) |
| 34 | +// QSettings oSettings("Bibble and AfterShot Plugins", "PluginGroups"); |
| 35 | +// oSettings.setValue(group(), groupId); |
| 36 | + return true; |
| 37 | +} |
| 38 | + |
| 39 | +bool AngyPlugin::registerFilters() |
| 40 | +{ |
| 41 | + AngyFilter *angy = new AngyFilter(m_hub, m_groupId); |
| 42 | + |
| 43 | + |
| 44 | + if (m_hub->addFilter(angy, PluginHub::Before, QString("Curves"))) { |
| 45 | + qDebug() << "Successfully registered "<<angy->name()<<" filter after Curves"; |
| 46 | + } else { |
| 47 | + qDebug() << "Failed to register "<<angy->name()<<" filter"; |
| 48 | + return false; |
| 49 | + } |
| 50 | + |
| 51 | + return true; |
| 52 | +} |
| 53 | + |
| 54 | +#define SNONE "None" |
| 55 | +bool AngyPlugin::registerOptions() |
| 56 | +{ |
| 57 | + m_hub->addBoolOption (AngyFilter::Enable , "AngyOn" , "Enabled" , tr("Enable Plugin"), "AngyFilter", false, false, 0); |
| 58 | + m_hub->addBoolOption (AngyFilter::Bleach , "AngyBleach" , "Bleach" , tr(""), "AngyFilter", false, false, 0); |
| 59 | + |
| 60 | + m_hub->addIntOption (AngyFilter::Screen , "AngyOpa" , "" , tr(""), "AngyFilter", 80, 0, 0); |
| 61 | + m_hub->addIntOption (AngyFilter::Total , "AngyStrength", "" , tr(""), "AngyFilter", 100, 0, 0); |
| 62 | + m_hub->addIntOption (AngyFilter::Flatten , "AngyEdge" , "" , tr(""), "AngyFilter", 0, 0, 0); |
| 63 | + m_hub->addIntOption (AngyFilter::Brightness, "AngyBrightness","" , tr(""), "AngyFilter", 0, 0, 0); |
| 64 | + m_hub->addIntOption (AngyFilter::Recovery , "AngyRecovery", "" , tr(""), "AngyFilter", 0, 0, 0); |
| 65 | + m_hub->addIntOption (AngyFilter::Degamma , "AngyDegamma", "" , tr(""), "AngyFilter", 100, 0, 0); |
| 66 | + |
| 67 | + return true; |
| 68 | +} |
| 69 | + |
| 70 | +bool AngyPlugin::finish() |
| 71 | +{ |
| 72 | + connect(m_hub, SIGNAL(settingsChanged(const PluginImageSettings &, const PluginImageSettings &, int)), this, SLOT(handleSettingsChange(const PluginImageSettings &, const PluginImageSettings &, int))); |
| 73 | + connect(m_hub, SIGNAL(controlChanged(const QString &, int, int , const PluginImageSettings &, const PluginOptionList &, PluginOptionList &)), this, SLOT(handleControlChange(const QString &, int, int , const PluginImageSettings &, const PluginOptionList &, PluginOptionList &))); |
| 74 | + connect(m_hub, SIGNAL(hotnessChanged(const PluginImageSettings &)), this, SLOT(handleHotnessChanged(const PluginImageSettings &))); |
| 75 | + return true; |
| 76 | +} |
| 77 | + |
| 78 | +PluginDependency *AngyPlugin::createDependency(const QString &name) |
| 79 | +{ |
| 80 | + Q_UNUSED(name); |
| 81 | + return NULL; |
| 82 | +} |
| 83 | + |
| 84 | +QList<QString> AngyPlugin::toolFiles() |
| 85 | +{ |
| 86 | + return QList<QString>(); |
| 87 | +} |
| 88 | + |
| 89 | +QList<QWidget*> AngyPlugin::toolWidgets() |
| 90 | +{ |
| 91 | + return QList<QWidget*>(); |
| 92 | +} |
| 93 | + |
| 94 | +void AngyPlugin::toolWidgetCreated(QWidget *uiWidget) |
| 95 | +{ |
| 96 | + //Q_UNUSED(uiWidget); |
| 97 | + if(uiWidget == NULL) return; //protection |
| 98 | + |
| 99 | + |
| 100 | + /*if (QPushButton *rbtn = uiWidget->findChild<QPushButton*>("FatToniReset_btn")) { |
| 101 | + connect(rbtn, SIGNAL(clicked()), this, SLOT(reset())); |
| 102 | + } |
| 103 | +*/ |
| 104 | +} |
| 105 | + |
| 106 | +//======================================================================================================== |
| 107 | +void AngyPlugin::handleSettingsChange(const PluginImageSettings &options, const PluginImageSettings &changed, int currentLayer) |
| 108 | +{ |
| 109 | + |
| 110 | + Q_UNUSED(options); |
| 111 | + Q_UNUSED(changed); |
| 112 | + Q_UNUSED(currentLayer); |
| 113 | +} |
| 114 | + |
| 115 | +void AngyPlugin::handleControlChange(const QString &optionName, int groupId, int layer, const PluginImageSettings &options, const PluginOptionList ¤t, PluginOptionList &changes) |
| 116 | +{ |
| 117 | + |
| 118 | + Q_UNUSED(optionName); |
| 119 | + Q_UNUSED(groupId); |
| 120 | + Q_UNUSED(current); |
| 121 | + // v-- You need to add this if you're going to use the options --v |
| 122 | + // some changes do not have options - check for NULL |
| 123 | + // qDebug()<<"handlecontrolchange_prenull"; |
| 124 | + if (options.options(layer) == NULL) return; |
| 125 | + //bool okay; |
| 126 | + |
| 127 | + //qDebug()<<"handlecontrolchange"; |
| 128 | + // USM settings changes |
| 129 | +/* if( |
| 130 | + changes.contains(AngyFilter::HH, m_groupId) |
| 131 | + ||changes.contains(AngyFilter::SH, m_groupId) |
| 132 | + ||changes.contains(AngyFilter::HS, m_groupId) |
| 133 | + ||changes.contains(AngyFilter::SS, m_groupId) |
| 134 | + ||changes.contains(AngyFilter::Cont, m_groupId) |
| 135 | + ||changes.contains(AngyFilter::Mid, m_groupId) |
| 136 | + ||changes.contains(AngyFilter::Mix, m_groupId) |
| 137 | + ||changes.contains(AngyFilter::BaseH, m_groupId) |
| 138 | + ||changes.contains(AngyFilter::BaseS, m_groupId) |
| 139 | + ||changes.contains(AngyFilter::BaseL, m_groupId) |
| 140 | + ){ |
| 141 | + changes.setBool(AngyFilter::Enable, m_groupId, true); |
| 142 | + } |
| 143 | + */ |
| 144 | + |
| 145 | +} |
| 146 | + |
| 147 | +//======================================================================================================== |
| 148 | +void AngyPlugin::handleHotnessChanged(const PluginImageSettings &options) |
| 149 | +{ |
| 150 | + |
| 151 | + Q_UNUSED(options); |
| 152 | +} |
| 153 | + |
| 154 | +void AngyPlugin::reset() { |
| 155 | + /* if (PluginOptionList *options = m_hub->beginSettingsChange("Reset Fat Toni")) { |
| 156 | + options->setInt(AngyFilter::HH, m_groupId, DEFAULT_HH); |
| 157 | + options->setInt(AngyFilter::SH, m_groupId, DEFAULT_SH); |
| 158 | + options->setInt(AngyFilter::HS, m_groupId, DEFAULT_HS); |
| 159 | + options->setInt(AngyFilter::SS, m_groupId, DEFAULT_SS); |
| 160 | + options->setInt(AngyFilter::Mid, m_groupId, DEFAULT_MID); |
| 161 | + options->setInt(AngyFilter::Mix, m_groupId, DEFAULT_MIX); |
| 162 | + options->setInt(AngyFilter::Cont, m_groupId, DEFAULT_CONT); |
| 163 | + options->setInt(AngyFilter::BaseH, m_groupId, DEFAULT_BASEH); |
| 164 | + options->setInt(AngyFilter::BaseS, m_groupId, DEFAULT_BASES); |
| 165 | + options->setInt(AngyFilter::BaseL, m_groupId, DEFAULT_BASEL); |
| 166 | + m_hub->endSettingChange(); |
| 167 | + }*/ |
| 168 | +} |
0 commit comments