2017-09-05 18:07:05 +08:00
|
|
|
|
#include "qqtapp.h"
|
2017-10-22 12:21:19 +08:00
|
|
|
|
#include "qqt-qt.h"
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#include "qqtgui.h"
|
|
|
|
|
#include "qqtcore.h"
|
|
|
|
|
#include "qqtinput.h"
|
|
|
|
|
#include "qqtmsgbox.h"
|
|
|
|
|
#include "qqtframe.h"
|
2017-11-22 17:56:37 +08:00
|
|
|
|
#include "qqtsockettcpclient.h"
|
|
|
|
|
#include "qqtsockettcpserver.h"
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#include "qqtserialport.h"
|
|
|
|
|
#include "qqtpluginwatcher.h"
|
2017-10-22 12:21:19 +08:00
|
|
|
|
#include "qqtversion.h"
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 转移到Lan协议当中去。
|
|
|
|
|
*/
|
2017-11-22 11:52:11 +08:00
|
|
|
|
void QQTLanServer ( QObject* parent = 0 )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
2017-11-22 17:56:37 +08:00
|
|
|
|
static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent );
|
2017-11-22 11:52:11 +08:00
|
|
|
|
s->listen ( QHostAddress::Any, 8000 );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
|
|
|
|
s->installedProtocol();
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QQTApp::QQTApp ( int& argc, char** argv ) : QApplication ( argc, argv )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
|
|
|
|
#ifndef __QT5__
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QTextCodec::setCodecForTr ( QTextCodec::codecForName ( "UTF-8" ) );
|
|
|
|
|
QTextCodec::setCodecForCStrings ( QTextCodec::codecForName ( "UTF-8" ) );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QTextCodec::setCodecForLocale ( QTextCodec::codecForName ( "UTF-8" ) );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QApplication::setOrganizationName ( "animationframe" );
|
|
|
|
|
QApplication::setOrganizationDomain ( "www.animationframe.com" ); // 专为Mac OS X 准备的
|
|
|
|
|
QApplication::setApplicationName ( "AnimationFrame" );
|
|
|
|
|
QSettings::setPath ( QSettings::NativeFormat, QSettings::UserScope, CONFIG_PATH );
|
|
|
|
|
QSettings::setPath ( QSettings::NativeFormat, QSettings::SystemScope, CONFIG_PATH );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
system ( "rm -f /tmp/LCK..ttyS*" );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
|
/*
|
|
|
|
|
* 打印失真与否与此处无关
|
|
|
|
|
*/
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QApplication::setGraphicsSystem ( "raster" );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2017-10-20 19:28:52 +08:00
|
|
|
|
#ifdef __EMBEDDED_LINUX__
|
2017-09-05 18:07:05 +08:00
|
|
|
|
//QApplication::setOverrideCursor(Qt::ArrowCursor);
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QWSServer::setCursorVisible ( false );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2017-10-20 19:28:52 +08:00
|
|
|
|
#ifdef __EMBEDDED_LINUX__
|
2017-09-05 18:07:05 +08:00
|
|
|
|
QFontDatabase db;
|
|
|
|
|
|
|
|
|
|
#if 0
|
2017-11-22 11:52:11 +08:00
|
|
|
|
int heitiFontID = db.addApplicationFont ( "/usr/lib/fonts/heiti.ttf" );
|
|
|
|
|
QString heiti = db.applicationFontFamilies ( heitiFontID ).at ( 0 );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
pline() << heiti;
|
|
|
|
|
#else
|
2017-11-22 11:52:11 +08:00
|
|
|
|
int wenquanyiFontID = db.addApplicationFont ( "/usr/lib/fonts/wenquanyi.ttf" );
|
|
|
|
|
QString wenquanyi = db.applicationFontFamilies ( wenquanyiFontID ).at ( 0 );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
pline() << wenquanyi;
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QFont font ( wenquanyi, 11 );
|
|
|
|
|
QApplication::setFont ( font );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
pline() << qApp->applicationDirPath();
|
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
language = new QTranslator ( this );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
setLanguage();
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/*
|
|
|
|
|
* 打开方法数据库
|
|
|
|
|
*/
|
|
|
|
|
managerDB = newDatabaseConn();
|
2017-11-22 11:52:11 +08:00
|
|
|
|
setDatabaseName ( managerDB, DB_MANAGER );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
/*
|
|
|
|
|
* Could not parse application stylesheet 告警 可以忽略
|
|
|
|
|
* 关于选中项的颜色,暂且按照默认,后来更改整体UI颜色和效果
|
|
|
|
|
* 可以实现橙色一行选中
|
|
|
|
|
* 肯定也能实现表头透明和QQT效果。
|
|
|
|
|
*/
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QFile styleFile ( "./skin/default.qss" );
|
|
|
|
|
styleFile.open ( QIODevice::ReadOnly );
|
|
|
|
|
QString styleString ( styleFile.readAll() );;
|
2017-09-05 18:07:05 +08:00
|
|
|
|
styleFile.close();
|
2017-11-22 11:52:11 +08:00
|
|
|
|
setStyleSheet ( styleString );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
/*
|
|
|
|
|
* 设置所有默认颜色
|
|
|
|
|
*/
|
|
|
|
|
//setPalette(QPalette(QColor("#F0F0F0")));
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-10-20 19:28:52 +08:00
|
|
|
|
#ifdef __EMBEDDED_LINUX__
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QQtInput::Instance()->Init ( "min", "control", "QQT", 14, 14 );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
qsrand ( QTime ( 0, 0, 0 ).secsTo ( QTime::currentTime() ) );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
#ifdef __PLUGINWATCHER__
|
|
|
|
|
QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ),
|
|
|
|
|
this, SLOT ( slotUPanAutoRun ( int ) ) );
|
|
|
|
|
#endif
|
2017-11-22 17:56:37 +08:00
|
|
|
|
//QQtSocketTcpClient
|
2017-09-05 18:07:05 +08:00
|
|
|
|
//QQTCloudClientInstance(this);
|
2017-10-20 19:28:52 +08:00
|
|
|
|
#ifdef __EMBEDDED_LINUX__
|
2017-09-05 18:07:05 +08:00
|
|
|
|
//QQTEthManager
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QQtEthenetManager::Instance ( this );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
#endif
|
2017-11-22 17:56:37 +08:00
|
|
|
|
//QQtSocketTcpServer
|
2017-09-05 18:07:05 +08:00
|
|
|
|
//QQTPeerPort
|
|
|
|
|
|
|
|
|
|
//QQTPeerPortInstance(this);
|
2017-11-22 11:52:11 +08:00
|
|
|
|
//QQtSerialPort
|
2017-09-05 18:07:05 +08:00
|
|
|
|
//QQTUserSerialPortInstance(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QQTApp::~QQTApp() {}
|
|
|
|
|
|
|
|
|
|
void QQTApp::setLanguage()
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* 公司或组织名
|
|
|
|
|
* 应用程序名
|
|
|
|
|
*/
|
|
|
|
|
QSettings setting;
|
|
|
|
|
QString qm;
|
2017-11-22 11:52:11 +08:00
|
|
|
|
qm = setting.value ( "Language" ).toInt() ? "./lang/en_US.qm" : "./lang/zh_CN.qm";
|
2017-09-05 18:07:05 +08:00
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
language->load ( qm );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
pline() << "currentLanguage" << qm;
|
2017-11-22 11:52:11 +08:00
|
|
|
|
installTranslator ( language );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-22 11:52:11 +08:00
|
|
|
|
void QQTApp::slotUPanAutoRun ( int status )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
2017-11-22 11:52:11 +08:00
|
|
|
|
#ifdef __PLUGINWATCHER__
|
|
|
|
|
|
|
|
|
|
if ( QQtPluginWatcher::E_ADD == status )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
{
|
2017-11-21 23:12:29 +08:00
|
|
|
|
QString mP = QQtPluginWatcher::Instance()->upanMountPath();
|
2017-11-22 11:52:11 +08:00
|
|
|
|
QString app = QString ( "%1/autorun.sh" ).arg ( mP );
|
|
|
|
|
QFile file ( app );
|
|
|
|
|
|
|
|
|
|
if ( file.exists() )
|
|
|
|
|
if ( QDialog::Rejected == QQtMsgBox::question ( 0, tr ( "Some app want to run in u disk!accepted?" ) ) )
|
2017-09-05 18:07:05 +08:00
|
|
|
|
return;
|
2017-11-22 11:52:11 +08:00
|
|
|
|
|
|
|
|
|
QProcess* p = new QProcess ( this );
|
|
|
|
|
p->setWorkingDirectory ( mP );
|
|
|
|
|
p->start ( app );
|
2017-09-05 18:07:05 +08:00
|
|
|
|
}
|
2017-11-22 11:52:11 +08:00
|
|
|
|
|
|
|
|
|
#endif
|
2017-09-05 18:07:05 +08:00
|
|
|
|
}
|