-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
188 lines (169 loc) · 6.88 KB
/
main.cpp
File metadata and controls
188 lines (169 loc) · 6.88 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/****************************************************************************
// elforkane Copyright (C) 2012 yahia nouah <yahiaui@gmail.com>
//
// This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
// This is free software, and you are welcome to redistribute it
// under certain conditions; type `show c' for details.
//
// The hypothetical commands `show w' and `show c' should show the appropriate
// parts of the General Public License. Of course, your program's commands
// might be different; for a GUI interface, you would use an "about box".
//
// You should also get your employer (if you work as a programmer) or school,
// if any, to sign a "copyright disclaimer" for the program, if necessary.
// For more information on this, and how to apply and follow the GNU GPL, see
// <http://www.gnu.org/licenses/>.
//
// The GNU General Public License does not permit incorporating your program
// into proprietary programs. If your program is a subroutine library, you
// may consider it more useful to permit linking proprietary applications with
// the library. If this is what you want to do, use the GNU Lesser General
// Public License instead of this License. But first, please read
// <http://www.gnu.org/philosophy/why-not-lgpl.html>.
// ----------------------------------------------------------
** If you have questions regarding the use of this file, please contact
** yahia nouah (yahiaui@gmail.com)
** $elforkane_END_LICENSE$
**
****************************************************************************/
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "database.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("elforkane");
a.setOrganizationName("Abouzakaria");
a.setWindowIcon(QIcon(":/img/mashaf48")) ;
a.setApplicationVersion("1.2.1");
QDir appDir(a.applicationDirPath());
QString appPath;
#if defined(Q_OS_WIN)
appDir.cdUp();
appPath= appDir.absolutePath()+"/share/elforkane";
#elif defined(Q_OS_MAC)
if (appDir.dirName() == "MacOS") {
appDir.cdUp();
appDir.cdUp();
appDir.cdUp();
appPath= appDir.absolutePath()+"/elforkane";
}
#else
appDir.cdUp();
appPath= appDir.absolutePath()+"/share/elforkane";
#endif
//-----------------------
QDir dir;
// QString h=dir.homePath();
if (!dir.exists(QDir::homePath()+"/.elforkane")) //
{
dir.mkdir( QDir::homePath()+"/.elforkane");
}
QFile file;
if (!file.exists(QDir::homePath()+"/.elforkane/reciterInfo")){
file.copy(appPath+"/reciterInfo",QDir::homePath()+"/.elforkane/reciterInfo");
}
QSettings settings(QDir::homePath()+"/.elforkane/setting.ini",QSettings::IniFormat);
settings.beginGroup("Main");
QString lng=settings.value("lng","sys").toString();
int m_locale= settings.value("locale",0).toInt();
settings.endGroup();
switch (m_locale) {
case 0:
QLocale::setDefault(QLocale(QLocale::system()));
break;
case 1:
QLocale::setDefault(QLocale(QLocale::Latin));
break;
case 2:
QLocale::setDefault(QLocale(QLocale::Arabic));
break;
default:
break;
}
QString translatorFileName = QLatin1String("qt_");
translatorFileName += QLocale::system().name();
QTranslator *translatorsys = new QTranslator(&a);
if (translatorsys->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
a.installTranslator(translatorsys);
QString locale = QLocale::system().name();
QTranslator translator;
if(lng=="sys"){
translator.load(QString(appPath+"/language/elforkane_"+locale.section("_",0,0)) );
}else {
translator.load(QString(appPath+"/language/elforkane_"+lng) );
}
a.installTranslator(&translator);
//-------------------------------
const QStringList args = QCoreApplication::arguments();
if (args.count() ==2){
QString goPos1 = args.at(1);
if (goPos1.toLower()==("-help")){
QString txt=QString(QObject::trUtf8("elforkane The electronic Holly Quran browser Version : %1 \n"
"Usage: elforkane [options]\n"
"Options:\n"
"-help Show help about options.\n"
"-full Run in full screen .\n"
"-j <int> Run in the specified jozaa .\n"
"-h <int> Run in the specified hizb.\n"
"-s <int> <int> Run in the specified sura and aya.\n"
"-s <int> Run in the specified sura .\n"
"-f <string> Find .\n"
"-play <int> Play in the specified sura\n"
"-play <int> <int> Play in the specified sura and aya\n")).arg(a.applicationVersion());
qDebug()<<txt;
return 0;
}else if (goPos1.toLower()==("-full")){
MainWindow w;
w.fullScreen();
// w.showFullScreen();
w. m_plaOne=false;
w.mediaPlay();
return a.exec();
}
}
if (args.count() >= 3){
QString goPos1 = args.at(1);
QString goPos2 = args.at(2);
if (args.count() == 3){
if (goPos1.toLower()==("-j")){
MainWindow w;
w.setJozaa(goPos2.toInt());
}else if (goPos1.toLower()==("-h")){
MainWindow w;
w.setHizb(goPos2.toInt());
}else if (goPos1.toLower()==("-s")){
MainWindow w;
w.setSora(goPos2.toInt());
}else if (goPos1.toLower()==("-f")){
Database data;
data.searchInCuran(goPos2);
return 0;
}else if (goPos1.toLower()==("-play")){
MainWindow w;
w.setSora(goPos2.toInt());
w. m_plaOne=false;
w.mediaPlay();
w.hide();
return a.exec();
}
}
if (args.count() == 4){
MainWindow w;
QString goPos3 = args.at(3);
if (goPos1.toLower()==("-s")){
w.setAya(goPos2.toInt(),goPos3.toInt());
}
if (goPos1.toLower()==("-play")){
w.setAya(goPos2.toInt(),goPos3.toInt());
w. m_plaOne=false;
w.mediaPlay();
w.hide();
return a.exec();
}
}
}
MainWindow w;
w.show();
return a.exec();
}