2013-05-23 16:21:47 -04:00
|
|
|
#ifdef QT5
|
|
|
|
#include <QtWidgets>
|
|
|
|
#else
|
2012-05-22 13:09:48 -04:00
|
|
|
#include <QtGui>
|
2013-05-23 16:21:47 -04:00
|
|
|
#endif
|
2013-05-23 15:35:37 -04:00
|
|
|
#include <QApplication>
|
2013-04-13 11:22:12 -04:00
|
|
|
#include <portaudio.h>
|
2012-05-22 13:09:48 -04:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2013-07-18 20:23:40 -04:00
|
|
|
// Multiple instances:
|
|
|
|
QSharedMemory mem_jt9;
|
|
|
|
QUuid my_uuid;
|
|
|
|
QString my_key;
|
2013-04-13 08:28:03 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2013-04-10 10:41:16 -04:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
|
|
|
|
QFile f("fonts.txt");
|
|
|
|
if(f.open(QIODevice::ReadOnly)) {
|
|
|
|
QTextStream in(&f); //Example:
|
|
|
|
QString fontFamily; // helvetica
|
|
|
|
qint32 fontSize,fontWeight; // 8,50
|
|
|
|
in >> fontFamily >> fontSize >> fontWeight;
|
|
|
|
f.close();
|
|
|
|
QFont font;
|
|
|
|
font=QFont(fontFamily,fontSize,fontWeight);
|
|
|
|
a.setFont(font);
|
|
|
|
}
|
|
|
|
|
2013-04-13 08:28:03 -04:00
|
|
|
// Create and initialize shared memory segment
|
2013-07-18 20:23:40 -04:00
|
|
|
// Multiple instances: generate shared memory keys with UUID
|
|
|
|
my_uuid = QUuid::createUuid();
|
|
|
|
my_key = my_uuid.toString();
|
|
|
|
mem_jt9.setKey(my_key);
|
|
|
|
|
2013-04-13 08:28:03 -04:00
|
|
|
if(!mem_jt9.attach()) {
|
|
|
|
if (!mem_jt9.create(sizeof(jt9com_))) {
|
|
|
|
QMessageBox::critical( 0, "Error", "Unable to create shared memory segment.");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char *to = (char*)mem_jt9.data();
|
|
|
|
int size=sizeof(jt9com_);
|
|
|
|
if(jt9com_.newdat==0) {
|
|
|
|
}
|
|
|
|
memset(to,0,size); //Zero all decoding params in shared memory
|
|
|
|
|
2013-04-13 11:22:12 -04:00
|
|
|
//Initialize Portaudio
|
|
|
|
PaError paerr=Pa_Initialize();
|
|
|
|
if(paerr!=paNoError) {
|
|
|
|
QMessageBox::critical( 0, "Error", "Unable to initialize PortAudio.");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2013-07-18 20:23:40 -04:00
|
|
|
// Multiple instances: Call MainWindow() with the UUID key
|
|
|
|
MainWindow w(&mem_jt9, &my_key);
|
2013-04-10 10:41:16 -04:00
|
|
|
w.show();
|
|
|
|
return a.exec();
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|