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-08-07 19:09:13 -04:00
|
|
|
#include <QObject>
|
2013-08-10 11:29:55 -04:00
|
|
|
#include <QSettings>
|
2013-10-04 15:00:29 -04:00
|
|
|
#include <QSysInfo>
|
2013-08-05 09:57:55 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
|
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);
|
|
|
|
|
2013-08-10 11:29:55 -04:00
|
|
|
qRegisterMetaType<AudioDevice::Channel> ("AudioDevice::Channel");
|
|
|
|
|
|
|
|
QSettings settings(a.applicationDirPath() + "/wsjtx.ini", QSettings::IniFormat);
|
|
|
|
|
2013-04-10 10:41:16 -04:00
|
|
|
QFile f("fonts.txt");
|
2013-07-24 15:07:57 -04:00
|
|
|
qint32 fontSize,fontWeight,fontSize2,fontWeight2; // Defaults 8 50 10 50
|
|
|
|
fontSize2=10;
|
|
|
|
fontWeight2=50;
|
2013-04-10 10:41:16 -04:00
|
|
|
if(f.open(QIODevice::ReadOnly)) {
|
2013-07-24 15:07:57 -04:00
|
|
|
QTextStream in(&f);
|
|
|
|
in >> fontSize >> fontWeight >> fontSize2 >> fontWeight2;
|
2013-04-10 10:41:16 -04:00
|
|
|
f.close();
|
2013-07-24 15:07:57 -04:00
|
|
|
QFont font=a.font();
|
|
|
|
if(fontSize!=8) font.setPointSize(fontSize);
|
|
|
|
font.setWeight(fontWeight); //Set the GUI fonts
|
2013-04-10 10:41:16 -04:00
|
|
|
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-10-04 15:00:29 -04:00
|
|
|
settings.beginGroup ("Tune");
|
|
|
|
|
|
|
|
// deal with Windows Vista input audio rate converter problems
|
|
|
|
unsigned downSampleFactor = settings.value ("Audio/DisableInputResampling",
|
|
|
|
#if defined (Q_OS_WIN)
|
|
|
|
QSysInfo::WV_VISTA == QSysInfo::WindowsVersion ? true : false
|
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
).toBool () ? 1u : 4u;
|
|
|
|
settings.endGroup ();
|
|
|
|
|
2013-07-18 20:23:40 -04:00
|
|
|
// Multiple instances: Call MainWindow() with the UUID key
|
2013-10-04 15:00:29 -04:00
|
|
|
MainWindow w(&settings, &mem_jt9, &my_key, fontSize2, fontWeight2, downSampleFactor);
|
2013-04-10 10:41:16 -04:00
|
|
|
w.show();
|
2013-08-07 19:09:13 -04:00
|
|
|
|
|
|
|
QObject::connect (&a, SIGNAL (lastWindowClosed()), &a, SLOT (quit()));
|
2013-04-10 10:41:16 -04:00
|
|
|
return a.exec();
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|