[krita/krita/3.3] plugins/extensions/qmic: Remove the configuration for gmic-qt

Boudewijn Rempt null at kde.org
Tue Sep 19 09:16:43 UTC 2017


Git commit d2736ff6c4d0fe8d33f94433e53952aca00575f1 by Boudewijn Rempt.
Committed on 19/09/2017 at 09:15.
Pushed by rempt into branch 'krita/3.3'.

Remove the configuration for gmic-qt

There are now two ways of finding gmic-qt: have the executable
built with the same Qt and other libraries as krita next to the
krita executable (should work for both our builds as well as for
distributions that package both krita and gmic-qt), or locate
a folder that starts with gmic next to the krita executable. The
folder can contain the version of gmic-qt that is build by gmic.eu.

For a next iteration, I am considering also looking into
QStandardPaths::AppDataLocation or QStandardPaths::AppLocalDataLocation
to find a gmic-qt plugin folder, but for the current release, this
should work.

CCMAIL:kimageshop at kde.org

M  +21   -12   plugins/extensions/qmic/PluginSettings.cpp
M  +6    -54   plugins/extensions/qmic/QMic.cpp
M  +0    -6    plugins/extensions/qmic/QMic.h

https://commits.kde.org/krita/d2736ff6c4d0fe8d33f94433e53952aca00575f1

diff --git a/plugins/extensions/qmic/PluginSettings.cpp b/plugins/extensions/qmic/PluginSettings.cpp
index 86d8390e94c..e9e96d30309 100644
--- a/plugins/extensions/qmic/PluginSettings.cpp
+++ b/plugins/extensions/qmic/PluginSettings.cpp
@@ -18,6 +18,7 @@
 
 #include <QVBoxLayout>
 #include <QStandardPaths>
+#include <QDir>
 
 #include <kconfiggroup.h>
 #include <klocalizedstring.h>
@@ -37,7 +38,7 @@ PluginSettings::PluginSettings(QWidget *parent)
 
 PluginSettings::~PluginSettings()
 {
-    KisConfig().writeEntry<QString>("gmic_qt_plugin_path", fileRequester->fileName());
+//    KisConfig().writeEntry<QString>("gmic_qt_plugin_path", fileRequester->fileName());
 }
 
 QString PluginSettings::id()
@@ -68,21 +69,29 @@ QString PluginSettings::gmicQtPath()
     gmicqt += ".exe";
 #endif
 
-    QString gmicqt_path = KisConfig().readEntry<QString>("gmic_qt_plugin_path",  qApp->applicationDirPath() + "/" + gmicqt);
-
-    QFileInfo fi(gmicqt_path);
-    if (!fi.exists() || !fi.isFile()) {
+    QFileInfo fi(qApp->applicationDirPath() + "/" + gmicqt);
 
-        QFileInfo fi2(qApp->applicationDirPath() + "/" + gmicqt);
+    // Check for gmic-qt next to krita
+    if (fi.exists() && fi.isFile()) {
+//        qDebug() << 1 << fi.canonicalFilePath();
+        return fi.canonicalFilePath();
+    }
 
-        if (fi2.exists() && fi2.isFile()) {
-            gmicqt_path = fi2.canonicalFilePath();
-        }
-        else {
-            gmicqt_path.clear();
-        }
+    // Check whether we've got a gmic subfolder
+    QDir d(qApp->applicationDirPath());
+    QStringList gmicdirs = d.entryList(QStringList() << "gmic*", QDir::Dirs);
+    qDebug() << gmicdirs;
+    if (gmicdirs.isEmpty()) {
+//        qDebug() << 2;
+        return "";
+    }
+    fi = QFileInfo(qApp->applicationDirPath() + "/" + gmicdirs.first() + "/" + gmicqt);
+    if (fi.exists() && fi.isFile()) {
+//        qDebug() << "3" << fi.canonicalFilePath();
+        return fi.canonicalFilePath();
     }
 
+//    qDebug() << 4 << gmicqt;
     return gmicqt;
 }
 
diff --git a/plugins/extensions/qmic/QMic.cpp b/plugins/extensions/qmic/QMic.cpp
index 5dac1c42876..a22e1fb3b17 100644
--- a/plugins/extensions/qmic/QMic.cpp
+++ b/plugins/extensions/qmic/QMic.cpp
@@ -63,7 +63,6 @@
 #include <PluginSettings.h>
 
 #include "kis_qmic_applicator.h"
-#include "kis_qmic_progress_manager.h"
 
 static const char ack[] = "ack";
 
@@ -72,12 +71,11 @@ K_PLUGIN_FACTORY_WITH_JSON(QMicFactory, "kritaqmic.json", registerPlugin<QMic>()
 QMic::QMic(QObject *parent, const QVariantList &)
     : KisViewPlugin(parent)
     , m_gmicApplicator(0)
-    , m_progressManager(0)
 {
 #ifndef Q_OS_MAC
-    KisPreferenceSetRegistry *preferenceSetRegistry = KisPreferenceSetRegistry::instance();
-    PluginSettingsFactory* settingsFactory = new PluginSettingsFactory();
-    preferenceSetRegistry->add("QMicPluginSettingsFactory", settingsFactory);
+//    KisPreferenceSetRegistry *preferenceSetRegistry = KisPreferenceSetRegistry::instance();
+//    PluginSettingsFactory* settingsFactory = new PluginSettingsFactory();
+//    preferenceSetRegistry->add("QMicPluginSettingsFactory", settingsFactory);
 
     m_qmicAction = createAction("QMic");
     m_qmicAction->setActivationFlags(KisAction::ACTIVE_DEVICE);
@@ -108,7 +106,6 @@ QMic::~QMic()
     }
 
     delete m_gmicApplicator;
-    delete m_progressManager;
     delete m_localServer;
 }
 
@@ -122,35 +119,11 @@ void QMic::slotQMic(bool again)
     m_qmicAction->setEnabled(false);
     m_againAction->setEnabled(false);
 
-    if (m_pluginProcess) {
-        qDebug() << "Plugin is already started" << m_pluginProcess->state();
-        return;
-    }
-
-    delete m_progressManager;
-    m_progressManager = new KisQmicProgressManager(m_view);
-    connect(m_progressManager, SIGNAL(sigProgress()), this, SLOT(slotUpdateProgress()));
-
     // find the krita-gmic-qt plugin
     QString pluginPath = PluginSettings::gmicQtPath();
-    if (pluginPath.isEmpty() || (!QFileInfo(pluginPath).exists() && !QFileInfo(pluginPath).isFile())) {
-        {
-            KoDialog dlg;
-            dlg.setWindowTitle(i18nc("@title:Window", "Krita"));
-            QWidget *w = new QWidget(&dlg);
-            dlg.setMainWidget(w);
-            QVBoxLayout *l = new QVBoxLayout(w);
-            l->addWidget(new PluginSettings(w));
-            dlg.setButtons(KoDialog::Ok);
-            dlg.exec();
-        }
-        pluginPath = PluginSettings::gmicQtPath();
-        if (pluginPath.isEmpty() || !QFileInfo(pluginPath).exists()) {
-            m_qmicAction->setEnabled(true);
-            m_againAction->setEnabled(true);
-            return;
-        }
-
+    if (pluginPath.isEmpty() || !QFileInfo(pluginPath).exists() || !QFileInfo(pluginPath).isFile()) {
+        QMessageBox::warning(0, i18nc("@title:window", "Krita"), i18n("Krita cannot find the gmic-qt plugin."));
+        return;
     }
 
     m_key = QUuid::createUuid().toString();
@@ -331,31 +304,10 @@ void QMic::pluginFinished(int exitCode, QProcess::ExitStatus exitStatus)
     m_pluginProcess = 0;
     delete m_localServer;
     m_localServer = 0;
-    delete m_progressManager;
-    m_progressManager = 0;
     m_qmicAction->setEnabled(true);
     m_againAction->setEnabled(true);
 }
 
-void QMic::slotUpdateProgress()
-{
-    if (!m_gmicApplicator) {
-        qWarning() << "G'Mic applicator already deleted!";
-        return;
-    }
-    qDebug() << "slotUpdateProgress" << m_gmicApplicator->getProgress();
-    m_progressManager->updateProgress(m_gmicApplicator->getProgress());
-}
-
-void QMic::slotStartProgressReporting()
-{
-    qDebug() << "slotStartProgressReporting();";
-    if (m_progressManager->inProgress()) {
-        m_progressManager->finishProgress();
-    }
-    m_progressManager->initProgress();
-}
-
 void QMic::slotGmicFinished(bool successfully, int milliseconds, const QString &msg)
 {
     qDebug() << "slotGmicFinished();" << successfully << milliseconds << msg;
diff --git a/plugins/extensions/qmic/QMic.h b/plugins/extensions/qmic/QMic.h
index 3194f526193..95f9564980e 100644
--- a/plugins/extensions/qmic/QMic.h
+++ b/plugins/extensions/qmic/QMic.h
@@ -32,7 +32,6 @@ class QLocalServer;
 class QSharedMemory;
 
 class KisQmicApplicator;
-class KisQmicProgressManager;
 
 class QMic : public KisViewPlugin
 {
@@ -48,8 +47,6 @@ private Q_SLOTS:
     void connected();
     void pluginStateChanged(QProcess::ProcessState);
     void pluginFinished(int exitCode, QProcess::ExitStatus exitStatus);
-    void slotUpdateProgress();
-    void slotStartProgressReporting();
     void slotGmicFinished(bool successfully, int milliseconds = -1, const QString& msg = QString());
     void slotStartApplicator(QStringList gmicImages);
 
@@ -63,10 +60,7 @@ private:
     KisAction *m_qmicAction {0};
     KisAction *m_againAction {0};
     QVector<QSharedMemory *> m_sharedMemorySegments;
-
     KisQmicApplicator *m_gmicApplicator {0};
-    KisQmicProgressManager *m_progressManager {0};
-
     InputLayerMode m_inputMode {ACTIVE_LAYER};
     OutputMode m_outputMode {IN_PLACE};
 


More information about the kimageshop mailing list