1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#if defined(_MSC_VER)
// disable warning "'QtConcurrent::BlockSizeManager' : assignment operator could not be generated"
#pragma warning( disable : 4512 )
#endif
#include "Debug.h"
#include <QScriptEngine>
#include <QMessageBox>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QThread>
#include "SyntopiaCore/Logging/Logging.h"
#include "../../SyntopiaCore/Exceptions/Exception.h"
#include "../../SyntopiaCore/GLEngine/Sphere.h"
using namespace SyntopiaCore::Logging;
using namespace SyntopiaCore::Exceptions;
namespace StructureSynth {
namespace JavaScriptSupport {
namespace {
// Dont know why Qt has chosen to make 'sleep' protected.
class MyThread : public QThread {
public:
static void sleep(unsigned long msecs) { msleep(msecs); }
};
};
Debug::Debug(QStatusBar* statusBar) : statusBar(statusBar) {
progress = 0;
}
Debug::~Debug() {
}
void Debug::Info(QString input) {
INFO(input);
}
void Debug::Message(QString input) {
QMessageBox::information(0, "JavaScript Message", input);
}
void Debug::ShowProgress(QString caption) {
delete(progress);
progress = new QProgressDialog(caption, "Cancel", 0, 1000, 0);
progress->setWindowModality(Qt::WindowModal);
progress->show();
}
void Debug::SetProgress(double percentage) {
if (progress) progress->setValue(percentage*1000.0);
qApp->processEvents();
}
void Debug::HideProgress() {
delete(progress);
progress = 0;
}
void Debug::Sleep(int ms) {
MyThread::sleep(ms);
}
void Debug::waitForMouseButton() {
while (true) {
statusBar->showMessage("Left Mousebutton to continue, right to quit.", 4000);
if (QApplication::mouseButtons() == Qt::LeftButton) {
//statusBar->showMessage("");
break;
} else if (QApplication::mouseButtons() == Qt::RightButton) {
//statusBar->showMessage("");
throw Exception("");
break;
}
qApp->processEvents();
//QThread::msleep(100);
}
}
}
}
|