-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutility.cpp
More file actions
545 lines (458 loc) · 20.3 KB
/
utility.cpp
File metadata and controls
545 lines (458 loc) · 20.3 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
/*
Copyright (C) 2009–2014 jakago
Copyright (C) 2018–2025 CSReviser Team
This file is part of CaptureStream2, a recorder that supports HLS for
NHK radio language courses.
CaptureStream2 is a modified version of CaptureStream, originally
developed by jakago.
This program 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, either version 2 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <https://www.gnu.org/licenses/gpl-2.0.html>.
*/
#include "utility.h"
#include "urldownloader.h"
#include "mainwindow.h"
#include "downloadthread.h"
#include "qt4qt5.h"
#include <QRegularExpression>
#include <QUrl>
#include <QCoreApplication>
#include <QDir>
#include <QTemporaryFile>
#include <QProcess>
#include <QFileInfo>
#include <QFile>
#include <QByteArray>
#include <QDebug>
#include <QDateTime>
#include <QDate>
#include <QStandardPaths>
#include <QtNetwork>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QMap>
#include <QLockFile>
#include <QTimer>
#include <QElapsedTimer>
#include <QSettings>
#define SETTING_GROUP "MainWindow"
#define SETTING_MULTI_GUI "multi_gui"
#define MULTI_GUI_FLAG false
namespace {
const QString UPUPUP( "/../../.." );
const QString FLARE( "flare" );
const QString GNASH( "gnash" );
const QString GNASH_arguments { "-r0 -v http://www.nhk.or.jp/gogaku/common/swf/streaming.swf" };
const QUrl STREAMINGSWF( "http://www.nhk.or.jp/gogaku/common/swf/streaming.swf" );
const QString TEMPLATE( "streamingXXXXXX.swf" );
const QRegularExpression REGEXP( "function startInit\\(\\) \\{[^}]*\\}\\s*function (\\w*).*startInit\\(\\);" );
const QRegularExpression PREFIX( "load\\('([A-Z0-9]*)' \\+ CONNECT_DIRECTORY" );
const QRegularExpression SUFFIX( "CONNECT_DIRECTORY \\+ '(.*)/' \\+ INIT_URI" );
const QString LISTDATAFLV( "http://www.nhk.or.jp/gogaku/common/swf/(\\w+)/listdataflv.xml" );
const QString WIKIXML1( "doc('" );
const QString WIKIXML2( "')/flv/scramble[@date=\"" );
const QString WIKIXML3( "\"]/@code/string()" );
const QString APPNAME( "CaptureStream2" );
const QString lockFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/CaptureStream2.lock";
static QLockFile lockFile(lockFilePath);
QTimer* removeTimer = nullptr;
QElapsedTimer elapsed;
const int maxWaitMs = 3000;
const int retryIntervalMs = 100;
QDate nendo_start_date = DownloadThread::nendo_start_date1;
QDate zenki_end_date = DownloadThread::zenki_end_date;
QDate kouki_start_date = DownloadThread::kouki_start_date;
QDate nendo_end_date = DownloadThread::nendo_end_date;
QMap<QString, QString> koza_unkown = {
{ "XQ487ZM61K_x1", "まいにちフランス語【入門/初級編】" }, // まいにちフランス語 入門編
{ "XQ487ZM61K_y1", "まいにちフランス語【応用編】" }, // まいにちフランス語 応用編
{ "N8PZRZ9WQY_x1", "まいにちドイツ語【入門/初級編】" }, // まいにちドイツ語 入門編
{ "N8PZRZ9WQY_y1", "まいにちドイツ語【応用編】" }, // まいにちドイツ語 応用編
{ "NRZWXVGQ19_x1", "まいにちスペイン語【入門/初級編】" }, // まいにちスペイン語 入門編
{ "NRZWXVGQ19_y1", "まいにちスペイン語【中級/応用編】" }, // まいにちスペイン語 応用編
{ "LJWZP7XVMX_x1", "まいにちイタリア語【入門/初級編】" }, // まいにちイタリア語 入門編
{ "LJWZP7XVMX_y1", "まいにちイタリア語【応用編】" }, // まいにちイタリア語 応用編
{ "YRLK72JZ7Q_x1", "まいにちロシア語【入門/初級編】" }, // まいにちロシア語 入門編
{ "YRLK72JZ7Q_y1", "まいにちロシア語【応用編】" }, // まいにちロシア語 応用編
};
}
// Macの場合はアプリケーションバンドル、それ以外はアプリケーションが含まれるディレクトリを返す
QString Utility::applicationBundlePath() {
#ifdef Q_OS_LINUX
QString basePath;
// AppImage 環境変数が存在すれば AppImage 実行中
QString appImagePath = qgetenv("APPIMAGE");
if (!appImagePath.isEmpty()) {
// AppImage 実行:本体のある場所を保存先とする
QFileInfo fi(appImagePath);
basePath = fi.absolutePath();
basePath += QDir::separator();
return basePath;
}
#endif
QString result = QCoreApplication::applicationDirPath();
//#ifdef Q_OS_MACOS //Macのffmpegパス不正対策 2022/04/13
// result = QDir::cleanPath( result + UPUPUP );
//#endif
result += QDir::separator();
return result;
}
QString Utility::getSettingsPath() {
QString basePath;
// AppImage 環境変数が存在すれば AppImage 実行中
QString appImagePath = qgetenv("APPIMAGE");
if (!appImagePath.isEmpty()) {
// AppImage 実行:本体のある場所を保存先とする
QFileInfo fi(appImagePath);
basePath = fi.absolutePath();
qDebug() << "Running from AppImage, using path:" << basePath;
} else {
// 通常実行:バイナリの場所を保存先とする
QFileInfo fi(QCoreApplication::applicationFilePath());
basePath = fi.absolutePath();
qDebug() << "Running from normal binary, using path:" << basePath;
}
// 保存先ファイル名
return basePath + "/capturestream2.ini";
}
QString Utility::appLocaldataLocationPath() {
QString result = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/";
result += QDir::separator();
return result;
}
QString Utility::appConfigLocationPath() {
QString result = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/";
result += QDir::separator();
return result;
}
QString Utility::ConfigLocationPath() {
QString result = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/";
result += QDir::separator();
return result;
}
QString Utility::DownloadLocationPath() {
QString result = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/";
result += QDir::separator();
return result;
}
QString Utility::HomeLocationPath() {
QString result = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/" + APPNAME + "/";
result += QDir::separator();
return result;
}
std::tuple<QStringList, QStringList> Utility::getProgram_List( ) {
QStringList idList; idList.clear() ;
QStringList titleList; titleList.clear() ;
const QString jsonUrl1 = "https://www.nhk.or.jp/radio-api/app/v1/web/ondemand/corners/new_arrivals";
QString strReply;
int flag = 0;
int TimerMin = 100;
int TimerMax = 5000;
int Timer = TimerMin;
int retry = 20;
for ( int i = 0 ; i < retry ; i++ ) {
strReply = Utility::getJsonFile( jsonUrl1, Timer );
if ( strReply != "error" ) {
flag = 1; break;
}
if ( Timer < 500 ) Timer += 50;
if ( Timer > 500 && Timer < TimerMax ) Timer += 100;
}
switch ( flag ) {
case 0: idList += "error"; titleList += "error"; break;
case 1: std::tie( idList, titleList ) = Utility::getProgram_List1( strReply ); break;
// case 2: std::tie( idList, titleList ) = Utility::getProgram_List2( strReply ); break;
default: idList += "error"; titleList += "error"; break;
}
return { idList, titleList };
}
std::tuple<QStringList, QStringList> Utility::getProgram_List1( QString strReply ) {
QStringList attribute1; attribute1.clear() ;
QStringList attribute2; attribute2.clear() ;
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
QJsonObject jsonObject = jsonResponse.object();
QJsonArray jsonArray = jsonObject[ "corners" ].toArray();
for (const auto&& value : jsonArray) {
QJsonObject objxx = value.toObject();
QString title = objxx[ "title" ].toString();
QString corner_name = objxx[ "corner_name" ].toString();
QString series_site_id = objxx[ "series_site_id" ].toString();
QString corner_site = objxx[ "corner_site_id" ].toString();
QString program_name = Utility::getProgram_name3( title, corner_name );
QString url_id = series_site_id + "_" + corner_site;
attribute1 += url_id;
attribute2 += program_name;
}
return { attribute1, attribute2 };
}
QString Utility::getJsonFile(QString jsonUrl, int Timer) {
QEventLoop eventLoop;
QString attribute;
QTimer timer;
timer.setSingleShot(true);
QNetworkAccessManager mgr;
// Qt5 / Qt6 両対応のシグナル接続
QObject::connect(&timer, &QTimer::timeout, &eventLoop, &QEventLoop::quit);
QObject::connect(&mgr, &QNetworkAccessManager::finished, &eventLoop, &QEventLoop::quit);
QUrl url_json(jsonUrl);
QNetworkRequest req(url_json);
QNetworkReply *reply = mgr.get(req);
timer.start(Timer); // ミリ秒指定
eventLoop.exec(); // シグナルを待つ
if (timer.isActive()) {
timer.stop();
if (reply->error() == QNetworkReply::NoError) {
attribute = reply->readAll();
} else {
attribute = "error";
}
} else {
// タイムアウト処理
reply->abort();
attribute = "error";
}
reply->deleteLater(); // メモリ管理を適切に
return attribute;
}
QString Utility::getProgram_name( QString url ) {
QString attribute; QString title; QString corner_name;
attribute.clear() ;
QString url_tmp = url;
QString pattern( "[A-Z0-9][0-9]{3}|[A-Z0-9]{10}" );
pattern = QRegularExpression::anchoredPattern(pattern);
QString pattern2( "[A-Z0-9][0-9]{3}_[sxy0-9][0-9]|[A-Z0-9]{10}_[sxy0-9][0-9]" );
if ( QRegularExpression(pattern).match( url ).hasMatch() ) url += "_01";
// QString pattern( "[A-Z0-9]{4}_[0-9]{2}" );
// pattern = QRegularExpression::anchoredPattern(pattern);
// QString pattern2( "[A-Z0-9]{10}_[0-9]{2}" );
// if ( url.right(3) != "_01" ) url += "_01";
if ( MainWindow::id_map.contains( url ) ) return MainWindow::id_map.value( url );
int l = 10 ; int l_length = url.length();
if ( l_length != 13 ) l = l_length -3 ;
// if ( !(QRegularExpression(pattern).match( url ).hasMatch()) && !(QRegularExpression(pattern2).match( url ).hasMatch()) ) return attribute;
const QString jsonUrl1 = "https://www.nhk.or.jp/radio-api/app/v1/web/ondemand/series?site_id=" + url.left( l ) + "&corner_site_id=" + url.right(2);
QString strReply;
int flag = 0;
int TimerMin = 100;
int TimerMax = 5000;
int Timer = TimerMin;
int retry = 20;
for ( int i = 0 ; i < retry ; i++ ) {
strReply = Utility::getJsonFile( jsonUrl1, Timer );
if ( strReply != "error" ) {
flag = 1; break;
}
// strReply = Utility::getJsonFile( jsonUrl2, Timer );
// if ( strReply != "error" ) {
// flag = 2; break;
// }
if ( Timer < 500 ) Timer += 50;
if ( Timer > 500 && Timer < TimerMax ) Timer += 100;
}
switch ( flag ) {
case 0: return attribute;
case 1: std::tie( title, corner_name ) = Utility::getProgram_name1( strReply ); break;
default: return attribute;
}
attribute = Utility::getProgram_name3( title, corner_name );
return attribute;
}
std::tuple<QString, QString> Utility::getProgram_name1( QString strReply ) {
QString attribute;
attribute.clear() ;
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
QJsonObject jsonObject = jsonResponse.object();
attribute = jsonObject[ "title" ].toString().replace( " ", " " );
QString corner_name = jsonObject[ "corner_name" ].toString().remove( "を聴く" ).replace( " ", " " );
return { attribute, corner_name };
}
QString Utility::getProgram_name3( QString title, QString corner_name ) {
QString attribute = title.replace( " ", " " );
if ( !(corner_name.isNull() || corner_name.isEmpty()) ) {
if( corner_name.contains( "曜日放送", Qt::CaseInsensitive ) || corner_name.contains( "曜放送", Qt::CaseInsensitive ) || corner_name.contains( "特集", Qt::CaseInsensitive )){
attribute = title + "-" + corner_name;
} else {
attribute = corner_name;
}
}
for (ushort i = 0xFF1A; i < 0xFF5F; ++i) {
attribute = attribute.replace(QChar(i), QChar(i - 0xFEE0));
}
for (ushort i = 0xFF10; i < 0xFF1A; ++i) {
attribute = attribute.replace( QChar(i - 0xFEE0), QChar(i) );
}
attribute = attribute.remove( "【らじる文庫】" ).remove( "より" ).remove( "カルチャーラジオ " ).remove( "【恋する朗読】" ).remove( "【ラジオことはじめ】" ).remove( "【生朗読!】" );
attribute.replace( QString::fromUtf8( "初級編" ), QString::fromUtf8( "【初級編】" ) ); attribute.replace( QString::fromUtf8( "入門編" ), QString::fromUtf8( "【入門編】" ) );
attribute.replace( QString::fromUtf8( "中級編" ), QString::fromUtf8( "【中級編】" ) ); attribute.replace( QString::fromUtf8( "応用編" ), QString::fromUtf8( "【応用編】" ) );
return attribute;
}
std::tuple<QStringList, QStringList, QStringList, QStringList, QStringList>
Utility::getJsonData1(const QString& strReply, int json_ohyo) {
QStringList fileList, kouzaList, file_titleList, hdateList, yearList;
if (strReply == "error") return { fileList, kouzaList, file_titleList, hdateList, yearList };
QJsonParseError parseError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(strReply.toUtf8(), &parseError);
if (parseError.error != QJsonParseError::NoError || !jsonDoc.isObject())
return { fileList, kouzaList, file_titleList, hdateList, yearList };
QJsonObject jsonObj = jsonDoc.object();
QString programName = jsonObj.value("title").toString().replace(" ", " ");
QString cornerName = jsonObj.value("corner_name").toString().replace(" ", " ");
if (!cornerName.isEmpty()) {
cornerName.remove("を聴く");
if (cornerName.contains("曜日放送") || cornerName.contains("曜放送") || cornerName.contains("特集")) {
programName += " - " + cornerName;
} else {
programName = cornerName;
}
}
// 半角化:記号
for (ushort i = 0xFF1A; i < 0xFF5F; ++i)
programName.replace(QChar(i), QChar(i - 0xFEE0));
// 半角化:数字
for (ushort i = 0xFF10; i < 0xFF1A; ++i)
programName.replace(QChar(i - 0xFEE0), QChar(i));
QJsonArray episodes = jsonObj.value("episodes").toArray();
if (episodes.isEmpty()) {
QStringList emptyList = { "\0" };
kouzaList.append(programName);
return { emptyList, kouzaList, emptyList, emptyList, emptyList };
}
static const QRegularExpression dateRx(R"(\d{4}-\d{2}-\d{2})");
for (const auto& val : episodes) {
QJsonObject obj = val.toObject();
QString fileTitle = obj.value("program_title").toString();
QString fileName = obj.value("stream_url").toString();
QString contentsId = obj.value("aa_contents_id").toString();
QString onairDate = obj.value("onair_date").toString();
QString year = dateRx.match(contentsId).captured(0).left(4);
if ((json_ohyo == 1 && (fileTitle.contains("中級編") || fileTitle.contains("応用編"))) ||
(json_ohyo == 2 && (fileTitle.contains("入門編") || fileTitle.contains("初級編")))) {
continue;
}
QString nameTmp = programName;
if (MainWindow::name_space_flag) {
if (json_ohyo == 1 && fileTitle.contains("入門編")) nameTmp += "【入門編】";
if (json_ohyo == 1 && fileTitle.contains("初級編")) nameTmp += "【初級編】";
if (json_ohyo == 2 && fileTitle.contains("中級編")) nameTmp += "【中級編】";
if (json_ohyo == 2 && fileTitle.contains("応用編")) nameTmp += "【応用編】";
} else {
if (json_ohyo == 1 && fileTitle.contains("入門編")) nameTmp += " 入門編";
if (json_ohyo == 1 && fileTitle.contains("初級編")) nameTmp += " 初級編";
if (json_ohyo == 2 && fileTitle.contains("中級編")) nameTmp += " 中級編";
if (json_ohyo == 2 && fileTitle.contains("応用編")) nameTmp += " 応用編";
}
kouzaList.append(nameTmp);
file_titleList.append(fileTitle);
fileList.append(fileName);
hdateList.append(onairDate);
yearList.append(year);
}
return { fileList, kouzaList, file_titleList, hdateList, yearList };
}
QString Utility::getLatest_version() {
QString attribute;
attribute.clear();
const QString jsonUrl = "https://api.github.com/repos/CSReviser/CaptureStream2/releases/latest";
QString strReply;
int TimerMin = 100;
int TimerMax = 5000;
int Timer = TimerMin;
int retry = 20;
for ( int i = 0 ; i < retry ; i++ ) {
strReply = Utility::getJsonFile( jsonUrl, Timer );
if ( strReply != "error" ) break;
if ( Timer < 500 ) Timer += 50;
if ( Timer > 500 && Timer < TimerMax ) Timer += 100;
}
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
QJsonObject jsonObject = jsonResponse.object();
attribute = jsonObject[ "tag_name" ].toString();
return attribute;
}
bool Utility::nogui() {
bool nogui_flag = QCoreApplication::arguments().contains( "-nogui" );
return nogui_flag;
}
bool Utility::gui() {
bool nogui_flag = QCoreApplication::arguments().contains( "-nogui" );
bool gui_flag = QCoreApplication::arguments().contains( "-gui" ) && !nogui_flag;
return gui_flag;
}
bool Utility::option_check( QString option ) {
bool option_flag = ( QCoreApplication::arguments().contains( option ) && QCoreApplication::arguments().contains( "-nogui" ) );
return option_flag;
}
QStringList Utility::optionList() {
QStringList attribute;
QStringList ProgList = QCoreApplication::arguments();
int ccc = 3;
if ( Utility::option_check( "-z" ) || Utility::option_check( "-b" ) ) ccc = 4;
if ( ProgList.count() < ccc ) { attribute += "erorr" ; return attribute; }
ProgList.removeAt(0);
QStringList idList = MainWindow::id_map.keys();;
// QStringList titleList;
// std::tie( idList, titleList ) = Utility::getProgram_List();
if( Utility::nogui() ) {
for( int i = 0; i < ProgList.count() ; i++ ){
if ( koza_unkown.contains( ProgList[i] ) ) { attribute += ProgList[i]; continue; }
if ( idList.contains( ProgList[i] ) ) attribute += ProgList[i];
}
if ( attribute.count() < 1 ) attribute += "return" ;
}
return attribute;
}
std::tuple<QString, QString, QString, QString> Utility::nogui_option( QString titleFormat, QString fileNameFormat, QString outputDir, QString extension ) {
QString titleFormat_out = titleFormat;
QString fileNameFormat_out = fileNameFormat;
QString outputDir_out = outputDir;
QString extension_out = extension;
QStringList optionList = QCoreApplication::arguments();
optionList.removeAt(0);
if ( optionList.contains( "-t" ) ) { titleFormat_out = optionList[ optionList.indexOf( "-t" ) + 1 ].remove( "'" ).remove( "\"" );}
if ( optionList.contains( "-f" ) ) { fileNameFormat_out = optionList[ optionList.indexOf( "-f" ) + 1 ].remove( "'" ).remove( "\"" );}
if ( optionList.contains( "-o" ) ) { outputDir_out = optionList[ optionList.indexOf( "-o" ) + 1 ].remove( "'" ).remove( "\"" ) + QDir::separator();}
if ( optionList.contains( "-e" ) ) { extension_out = optionList[ optionList.indexOf( "-e" ) + 1 ].remove( "'" ).remove( "\"" ); if (extension_out == "mp3") extension_out += "-64k-S"; }
return { titleFormat_out, fileNameFormat_out, outputDir_out, extension_out };
}
bool Utility::tryLockFile() {
lockFile.setStaleLockTime(100);
if(multi_gui_flag_check()) return true;
return lockFile.tryLock();
}
void Utility::unLockFile() {
lockFile.unlock();
return;
}
void Utility::remove_LockFile() {
QString lockFilePath2 = QFileInfo(lockFilePath).absoluteFilePath();
lockFile.removeStaleLockFile();
lockFile.unlock();
QFile::remove(lockFilePath2);
return;
}
bool Utility::multi_gui_flag_check() {
if( Utility::nogui() || Utility::gui() ) return 1;
#ifdef Q_OS_MACOS
QString ini_file_path = Utility::ConfigLocationPath();
#endif
#if !defined( Q_OS_MACOS )
QString ini_file_path = Utility::applicationBundlePath();
#endif
QSettings settings( ini_file_path + INI_FILE, QSettings::IniFormat );
settings.beginGroup( SETTING_GROUP );
QVariant saved = settings.value( SETTING_MULTI_GUI );
bool multi_gui_flag = !saved.isValid() ? MULTI_GUI_FLAG : saved.toBool();
if(multi_gui_flag)
return true;
else
return false;
}