1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

163 lines
4.4 KiB
C++
Raw Normal View History

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"
#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
{
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
#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
#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
#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
//QQtSocketTcpClient
2017-09-05 18:07:05 +08:00
//QQTCloudClientInstance(this);
#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
//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
{
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
}