-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
136 lines (123 loc) · 6.02 KB
/
main.cpp
File metadata and controls
136 lines (123 loc) · 6.02 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include <QtGui/QApplication>
#include "widget.h"
#include "penguin.h"
#include<QDebug>
#include "objectdesktop.h"
#include <QLocale>
#include <QTranslator>
#include <QLibraryInfo>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("objdesktop");
a.setOrganizationName("Abou zakaria");
a.setApplicationVersion("0.1");
QIcon icon;
icon.addPixmap(QPixmap(QString::fromUtf8(":/img/snowicon48.png")), QIcon::Normal, QIcon::Off);
a.setWindowIcon(icon);
QString locale = QLocale::system().name();
//qDebug() << "language:"<< locale;
//! [2]
QTranslator translator;
//! [2] //! [3]
translator.load(QString(":/objdesktop_") + locale);
a.installTranslator(&translator);
QString translatorFileName = QLatin1String("qt_");
translatorFileName += QLocale::system().name();
QTranslator *translatorsys = new QTranslator(&a);
if (translatorsys->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
a.installTranslator(translatorsys);
const QStringList args = QCoreApplication::arguments();
if (args.count() >1){
QString goPos1 = args.at(1);
if (goPos1.toLower()==("-help")){
QString txt=QString(QObject::trUtf8(
"objdesktop Version : %1 \n"
"Usage: objdesktop [type] [Options]\n"
"type:\n"
"-help Show help about options.\n"
"-s Run snow Animation .\n"
"-a Run Autumn Animation .\n"
"-b Run Butterfly Animation.\n"
"-r Run Rain Animation.\n"
"-e Run Stars Animation .\n"
"-t Run tux Animation .\n"
"-o setting dialog .\n"
"-d restore deault settings .\n"
"Options:\n"
"objdesktop -s -max <int> -min <int> -time <int> -num <int> -top \n"
"objdesktop -a -max <int> -min <int> -time <int> -num <int> -top \n"
"objdesktop -b -num <int> -time <int> -top \n"
"objdesktop -r -num <int> -time <int> -obj -top \n"
"objdesktop -e -max <int> -min <int> -num <int> -obj -top \n"
"objdesktop -t -num <int> -top \n"
"\n"
"-max <int> Maximum size .\n"
"-min <int> Minimum size .\n"
"-time <int> Timer intervale Animation in milliseconds.\n"
"-num <int> Objects numbers.\n"
"-top Top most .\n"
"-obj Show object in rain or stars .\n"
"\n"
"Timer intervale descripton:\n"
"in snow and Autumn maximum is:1000 minimum is :50 default is: 100\n"
"in rain maximum is:200 minimum is :50 default is: 100\n"
"\n"
"Maximum Maximum numbers descripton:\n"
"in snow and Autumn Maximum 100 Minimum 1 numbers<=100 \n "
"in rain numbers<=100 \n "
"in stars Maximum 30 Minimum 1 numbers<= 100 \n "
"in Butterfly and tux numbers <=10 \n "
)).arg(a.applicationVersion());
qDebug()<<txt;
return 0;
}else if (goPos1.toLower()==("-o")){
Widget w;
w.show();
return a.exec();
}else if (goPos1.toLower()==("-d")){
Widget w;
w.restoreDefault();
return (0);
}else{
int type=0; QString max="25";QString min="3";QString interval="100";QString number="25";
bool ontop=false; bool obj=false;
for (int i=0;i<args.count();i++){
//type
QString goPos = args.at(i);
if(goPos=="-s")type=0;//snow
if(goPos=="-a")type=1;//autumn
if(goPos=="-b")type=2;//butterfly
if(goPos=="-r")type=3;//rain
if(goPos=="-e")type=4;//stars
if(goPos=="-t")type=5;//tux
//options
if(goPos=="-max")max=(args.at(i+1));
if(goPos=="-min")min=(args.at(i+1));
if(goPos=="-time")interval=(args.at(i+1));
if(goPos=="-num")number=(args.at(i+1));
if(goPos=="-top")ontop=true;
if(goPos=="-obj")obj=true;
}
ObjectDesktop Ob;
if(type==0) {//snow
Ob.showSnow(max.toInt(),min.toInt(),interval.toInt(),number.toInt(),ontop);
} else if(type==1) {//autumn
Ob. showAutumn( max.toInt(), min.toInt(), interval.toInt(), number.toInt(), ontop);
} else if(type==2) {//butterfly
Ob.showButterfly( number.toInt(), ontop);
}else if(type==3) {//rain
Ob. showRin(interval.toInt(),number.toInt(),obj, ontop);
}else if(type==4) {//stars
Ob.showStars(number.toInt(),ontop,obj);
}else if(type==5) {//tux
Ob.showTux(number.toInt(),ontop);
}
return a.exec();
}
}
Widget w;
w.hide();
// w.show();
return a.exec();
}