Skip to content

Commit

Permalink
Added sendMessage signal
Browse files Browse the repository at this point in the history
Signed-off-by: Vaishnavi Bhandari <vaishnavibhandari.128@gmail.com>
  • Loading branch information
peach280 committed Jan 31, 2025
1 parent 3322ff7 commit dac7063
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions avogadro/qtplugins/surfaces/surfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ namespace {
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QProgressDialog>

#include<QJsonObject>
#include<QJsonDocument>
#include<QObject>
#include <QGuiApplication>
#include <QScreen>

Expand All @@ -76,6 +78,8 @@ class Surfaces::PIMPL
public:
GifWriter* gifWriter = nullptr;
gwavi_t* gwaviWriter = nullptr;
signals:
void sendMessage(const QJsonObject& message);
};

Surfaces::Surfaces(QObject* p) : ExtensionPlugin(p), d(new PIMPL())
Expand Down Expand Up @@ -368,7 +372,10 @@ float inline square(float x)
{
return x * x;
}

void sendMessage(QString& message)
{
qDebug() << "Message received:" << message;
}
void Surfaces::calculateEDT(Type type, float defaultResolution)
{
if (type == Unknown && m_dialog != nullptr)
Expand Down Expand Up @@ -447,7 +454,14 @@ void Surfaces::calculateEDT(Type type, float defaultResolution)
}
}
});

QJsonObject jsonMessage;
jsonMessage["status"] = "finished";
jsonMessage["message"] = "Surface calculation completed successfully.";
QJsonDocument doc(jsonMessage);
QString jsonString = doc.toJson(QJsonDocument::Compact);

// Emitting the signal to notify the plugin that the calculation is finished
emit sendMessage(jsonString);
innerFuture.waitForFinished();
});

Expand Down Expand Up @@ -514,8 +528,7 @@ void Surfaces::performEDTStep()
}
}
});

innerFuture.waitForFinished();

});

m_displayMeshWatcher.setFuture(future);
Expand Down

0 comments on commit dac7063

Please sign in to comment.