forked from bnufree/Hq
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
62 lines (56 loc) · 1.65 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
#include "dialog.h"
#include <QApplication>
#include <QTextCodec>
#include <QDebug>
#include <QDate>
//#include "qglobalapplication.h"
#include <QFile>
#include <QDesktopWidget>
#include <QDir>
#include <iostream>
#include <new>
#include <zchxmainwindow.h>
#include "exchange/qexchangerecordworker.h"
#include "date/annualcloseddaydisclosure.h"
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QtAndroid>
bool requestPermission() {
#if QT_VERSION >= QT_VERSION_CHECK(5,12,0)
QStringList list;
list.append("android.permission.WRITE_EXTERNAL_STORAGE");
list.append("android.permission.READ_EXTERNAL_STORAGE");
QtAndroid::PermissionResultMap result = QtAndroid::requestPermissionsSync(list);
QtAndroid::PermissionResultMap::const_iterator it = result.begin();
for(; it != result.end(); it++)
{
if(it.value() == QtAndroid::PermissionResult::Denied) return false;
}
#endif
return true;
}
#endif
void no_memory () {
std::cout << "Failed to allocate memory!\n";
std::exit (1);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
std::set_new_handler(no_memory);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF8"));
int height = QApplication::desktop()->availableGeometry().height();
int width = QApplication::desktop()->availableGeometry().width();
qDebug()<<"device size:"<<height<<width;
zchxMainWindow w;
#ifdef Q_OS_WIN
w.setFixedSize(0.4*height, height*0.9);
w.show();
#else
qDebug()<<"device size:"<<height<<width;
if(requestPermission())
{
w.showMaximized();
}
#endif
return a.exec();
}