SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
main.cpp
Go to the documentation of this file.
1 // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
3 // written by Christian Daniel //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #include <QApplication>
20 #include <QTextCodec>
21 #include <QProxyStyle>
22 #include <QStyleFactory>
23 #include <QFontDatabase>
24 #include <QSysInfo>
25 
26 #include "loggerwithfile.h"
27 #include "mainwindow.h"
28 #include "dsp/dsptypes.h"
29 
30 static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *logger)
31 {
32  QApplication a(argc, argv);
33 /*
34  QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
35  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
36 */
37  QCoreApplication::setOrganizationName(COMPANY);
38  QCoreApplication::setApplicationName(APPLICATION_NAME);
39  QCoreApplication::setApplicationVersion(SDRANGEL_VERSION);
40 
41 #if QT_VERSION >= 0x050600
42  QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
43  QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
44 #endif
45 
46 #if 1
47  qApp->setStyle(QStyleFactory::create("fusion"));
48 
49  QPalette palette;
50  palette.setColor(QPalette::Window, QColor(53,53,53));
51  palette.setColor(QPalette::WindowText, Qt::white);
52  palette.setColor(QPalette::Base, QColor(25,25,25));
53  palette.setColor(QPalette::AlternateBase, QColor(53,53,53));
54  palette.setColor(QPalette::ToolTipBase, Qt::white);
55  palette.setColor(QPalette::ToolTipText, Qt::black);
56  palette.setColor(QPalette::Text, Qt::white);
57  palette.setColor(QPalette::Button, QColor(0x40, 0x40, 0x40));
58  palette.setColor(QPalette::ButtonText, Qt::white);
59  palette.setColor(QPalette::BrightText, Qt::red);
60 
61  palette.setColor(QPalette::Light, QColor(53,53,53).lighter(125).lighter());
62  palette.setColor(QPalette::Mid, QColor(53,53,53).lighter(125));
63  palette.setColor(QPalette::Dark, QColor(53,53,53).lighter(125).darker());
64 
65  palette.setColor(QPalette::Link, QColor(0,0xa0,0xa0));
66  palette.setColor(QPalette::LinkVisited, QColor(0,0xa0,0xa0).lighter());
67  palette.setColor(QPalette::Highlight, QColor(0xff, 0x8c, 0x00));
68  palette.setColor(QPalette::HighlightedText, Qt::black);
69  qApp->setPalette(palette);
70 
71 #if 0
72  if(QFontDatabase::addApplicationFont("/tmp/Cuprum.otf") >= 0) {
73  QFont font("CuprumFFU");
74  font.setPointSize(10);
75  qApp->setFont(font);
76  }
77 #endif
78 #if 0
79  if(QFontDatabase::addApplicationFont("/tmp/PTN57F.ttf") >= 0) {
80  QFont font("PT Sans Narrow");
81  font.setPointSize(10);
82  qApp->setFont(font);
83  }
84 #endif
85 #if 0
86  if(QFontDatabase::addApplicationFont("/tmp/PTS55F.ttf") >= 0) {
87  QFont font("PT Sans");
88  font.setPointSize(10);
89  qApp->setFont(font);
90  }
91 #endif
92 #if 0
93  {
94  QFont font("Ubuntu Condensed");
95  font.setPointSize(10);
96  qApp->setFont(font);
97  }
98 #endif
99 
100 #endif
101  MainParser parser;
102  parser.parse(*qApp);
103 
104 #if QT_VERSION >= 0x050400
105  qInfo("%s %s Qt %s %db %s %s DSP Rx:%db Tx:%db PID %lld",
106  qPrintable(qApp->applicationName()),
107  qPrintable(qApp->applicationVersion()),
108  qPrintable(QString(QT_VERSION_STR)),
109  QT_POINTER_SIZE*8,
110  qPrintable(QSysInfo::currentCpuArchitecture()),
111  qPrintable(QSysInfo::prettyProductName()),
114  qApp->applicationPid());
115 #else
116  qInfo("%s %s Qt %s %db DSP Rx:%db Tx:%db PID: %lld",
117  qPrintable(qApp->applicationName()),
118  qPrintable((qApp->applicationVersion()),
119  qPrintable(QString(QT_VERSION_STR)),
120  QT_POINTER_SIZE*8,
123  applicationPid);
124 #endif
125 
126  MainWindow w(logger, parser);
127  w.show();
128 
129  return a.exec();
130 }
131 
132 int main(int argc, char* argv[])
133 {
135  logger->installMsgHandler();
136  int res = runQtApplication(argc, argv, logger);
137  qWarning("SDRangel quit.");
138  return res;
139 }
void installMsgHandler()
Definition: logger.cpp:111
#define SDR_RX_SAMP_SZ
Definition: dsptypes.h:32
void * create(QString type)
#define SDR_TX_SAMP_SZ
Definition: dsptypes.h:38
void parse(const QCoreApplication &app)
Definition: mainparser.cpp:53
int main(int argc, char *argv[])
Definition: main.cpp:132