This repository has been archived by the owner on Jun 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qtfractal.cpp
85 lines (71 loc) · 2.14 KB
/
qtfractal.cpp
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
/*
** Copyright (c) 2011 Andrea Cisternino
**
** This file is part of QtFractal.
**
** QtFractal is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published
** by the Free Software Foundation, version 2.
**
** QtFractal is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with QtFractal. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file qtfractal.cpp
* \brief Main source file for the QtFractal application
* \author Andrea Cisternino
*/
#include <QApplication>
#include <QIcon>
#include <QDebug>
#ifdef Q_OS_WIN32
# define WIN32_LEAN_AND_MEAN 1
# include <windows.h>
#endif
#include "fractalwidget.h"
#include "mainwindow.h"
// ---- Global variables --------------------------------------------------
int cpuNum = 1; // number of cpus in the system
// ---- Support methods ---------------------------------------------------
int
detectCpuNumber()
{
int np = 1;
#ifdef Q_OS_LINUX
np = sysconf(_SC_NPROCESSORS_ONLN);
if (np == -1) {
exit(EXIT_FAILURE); // value unavailable, scary!
} else if (np == 0) {
np = 1;
}
#elif defined Q_OS_WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
np = sysinfo.dwNumberOfProcessors;
#endif
return np;
}
// ---- Main --------------------------------------------------------------
int
main(int argc, char *argv[])
{
// find number of CPU's in the system
cpuNum = detectCpuNumber();
qDebug() << "CPU's detected:" << cpuNum;
// prepare the Application object and load resources
QApplication app(argc, argv);
app.setApplicationName("QtFractal");
app.setOrganizationName("Craftware");
app.setQuitOnLastWindowClosed(true);
Q_INIT_RESOURCE(qtfractal);
// fire up GUI
MainWindow mw;
mw.setWindowIcon(QIcon(":/images/winicon.png"));
mw.show();
return app.exec();
}