-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (61 loc) · 1.76 KB
/
Copy pathmain.cpp
File metadata and controls
74 lines (61 loc) · 1.76 KB
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
/**
* @file main.cpp
* @brief Application entry: branded icon and animated splash, then main window.
*/
#include "animatedsplash.h"
#include "mainwindow.h"
#include <QApplication>
#include <QElapsedTimer>
#include <QIcon>
#include <QPixmap>
#include <QThread>
namespace {
/**
* @brief Builds a multi-resolution app icon (Linux window managers need small sizes).
*
* @return QIcon with 16..256 pixmaps derived from the bundled master PNG.
*/
QIcon makeAppIcon()
{
const QPixmap master(QStringLiteral(":/resources/icons/app_icon.png"));
QIcon icon;
if (master.isNull()) {
return icon;
}
const int sizes[] = {16, 24, 32, 48, 64, 128, 256};
for (int size : sizes) {
icon.addPixmap(master.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
icon.addPixmap(master);
return icon;
}
} // namespace
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setAttribute(Qt::AA_DontUseNativeDialogs, true);
a.setApplicationName(QStringLiteral("Spectrum Analyzer"));
a.setApplicationDisplayName(QStringLiteral("Spectrum Analyzer"));
a.setOrganizationName(QStringLiteral("SpectrumAnalyzer"));
a.setDesktopFileName(QStringLiteral("spectrum-analyzer"));
const QIcon appIcon = makeAppIcon();
a.setWindowIcon(appIcon);
AnimatedSplash splash;
splash.setWindowIcon(appIcon);
splash.showCoveringScreen();
a.processEvents();
MainWindow w;
w.setWindowIcon(appIcon);
// Hold long enough for the circular sweep and name to read.
QElapsedTimer hold;
hold.start();
while (hold.elapsed() < 2800) {
a.processEvents();
QThread::msleep(16);
}
splash.close();
w.show();
w.raise();
w.activateWindow();
return a.exec();
}