-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
73 lines (63 loc) · 2.04 KB
/
main.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
#include <QDesktopWidget>
#include <QWidget>
#include <QIcon>
#include <QString>
#include <string>
#include "mainWindow.hpp"
#include "keyboard.hpp"
#include <iostream>
#include <unistd.h>
int main(int argc, char *argv[])
{
QString layoutFile = "assets/default.keys";
int opt;
int min = 2, max = 5;
std::string usage = keyBoard::Usage().toUtf8().constData();
while ( (opt = getopt(argc, argv, "hvk:b:t:")) != -1 ) {
switch ( opt ) {
case 'v':
std::cout << "CPPiano v1.05 - Licensed under GNU/LGPL v3.0" << std::endl;
return 0;
break;
case 'h':
std::cout << "Usage:" << std::endl;
std::cout << usage << std::endl;
return 0;
break;
case 'k':
layoutFile = QString::fromStdString(optarg);
break;
case 'b':
min = atoi(optarg);
min = qMin(1, min);
break;
case 't':
max = atoi(optarg);
max = qMax(7, max);
break;
case '?':
return 1;
break;
}
}
QApplication app(argc, argv);
mainWindow * window = new mainWindow;
QDesktopWidget * dt = QApplication::desktop();
keyBoard * kb = new keyBoard(window);
window->setMainWidget<keyBoard*>(kb);
kb->generate(min,max,layoutFile);
kb->draw();
// set Height and Width of the main window
int wHeight = 20 + (window->getToolbars() * 30) + ((keyBoard*)(window->getMainWidget()))->height();
int wWidth = ((keyBoard*)(window->getMainWidget()))->width();
//centering the window
int x,y;
x = ( dt->width() - wWidth ) / 2;
y = ( dt->height() - wHeight ) / 2;
window->resize(wWidth, wHeight);
window->move( x , y );
window->setWindowTitle("CPPiano");
window->setWindowIcon(QIcon("assets/icon.png"));
window->draw()->show();
return app.exec();
}