115 lines
2.9 KiB
C++
115 lines
2.9 KiB
C++
#include "mainwindow.h"
|
|
//#include "splashscreen.h"
|
|
//#include "unit.h"
|
|
#include "skin.h"
|
|
//#include "appconfig.h"
|
|
|
|
#include <QApplication>
|
|
#include <QTextCodec>
|
|
#include <QDesktopWidget>
|
|
#include <QScreen>
|
|
#include <QDir>
|
|
#include <QTranslator>
|
|
#include <QDebug>
|
|
#include <QTextCodec>
|
|
|
|
//#include <windows.h>
|
|
//#include <winver.h>
|
|
//#pragma comment(lib, "Version")
|
|
|
|
|
|
QSize GetDesktopSize() {
|
|
#ifdef __arm__
|
|
int fb_fd = open("/dev/fb0", O_RDWR);
|
|
int lcd_width, lcd_height;
|
|
static struct fb_var_screeninfo var;
|
|
|
|
if(-1 == fb_fd)
|
|
{
|
|
printf("cat't open /dev/fb0 \n");
|
|
return QSize(0, 0);
|
|
}
|
|
//获取屏幕参数
|
|
if(-1 == ioctl(fb_fd, FBIOGET_VSCREENINFO, &var))
|
|
{
|
|
close(fb_fd);
|
|
printf("cat't ioctl /dev/fb0 \n");
|
|
return QSize(0, 0);
|
|
}
|
|
|
|
// 计算参数
|
|
lcd_width = var.xres;
|
|
lcd_height = var.yres;
|
|
|
|
printf("fb width:%d height:%d \n", lcd_width, lcd_height);
|
|
close(fb_fd);
|
|
|
|
return QSize(lcd_width, lcd_height);
|
|
#endif
|
|
//return QSize(800, 480);
|
|
return QSize(800, 480);
|
|
}
|
|
|
|
void CheckDir(const QString &path) {
|
|
QDir dir(path);
|
|
if (!dir.exists()) {
|
|
dir.mkpath(path);
|
|
}
|
|
}
|
|
|
|
void CheckDirs(const QString &path, const QStringList &dirs) {
|
|
for (int i = 0; i < dirs.size(); i++) {
|
|
CheckDir(path + dirs.at(i));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#define SoftWareVersion "V1.0.0"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QApplication a(argc, argv);
|
|
MainWindow w;
|
|
|
|
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF8"));
|
|
|
|
QTranslator * qtTranslator = new QTranslator{};
|
|
QString lang = "qt_" + QLocale::system().name();
|
|
if (qtTranslator->load(lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath))
|
|
&& a.installTranslator(qtTranslator))
|
|
{
|
|
qDebug() << "Success to load translator " <<lang << " from " << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
|
}
|
|
else
|
|
{
|
|
qWarning() << "Fail to load translator " <<lang << " from " << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
|
}
|
|
|
|
QTranslator * myappTranslator = new QTranslator{};
|
|
lang = "SimpleGroundStation_" + QLocale::system().name();
|
|
if (myappTranslator->load(lang, QCoreApplication::applicationDirPath())
|
|
&& a.installTranslator(myappTranslator))
|
|
{
|
|
qDebug() << "Success to load translator " <<lang << " from " << QCoreApplication::applicationDirPath();
|
|
}
|
|
else
|
|
{
|
|
qWarning() << "Fail to load translator " <<lang << " from " << QCoreApplication::applicationDirPath();
|
|
}
|
|
|
|
|
|
|
|
w.setWindowTitle(QStringLiteral("GCS New Frame @ %1"));//with version
|
|
// 主要是控制HDMI输出,如果是LCD显示,此行无关紧要
|
|
w.resize(GetDesktopSize());
|
|
|
|
|
|
w.show();
|
|
|
|
return a.exec();
|
|
}
|
|
|
|
|
|
|