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

156 lines
4.2 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 "qqtcloudprotocol.h"
#include "qqtuserserialprotocol.h"
#include "qqtpluginwatcher.h"
/*
* Lan协议当中去
*/
void QQTLanServer(QObject* parent = 0)
{
static QQtSocketTcpServer* s = new QQtSocketTcpServer(parent);
2017-09-05 18:07:05 +08:00
s->listen(QHostAddress::Any, 8000);
s->installedProtocol();
}
QQTApp::QQTApp(int &argc, char **argv) : QApplication(argc, argv)
{
#ifndef __QT5__
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QApplication::setOrganizationName(VER_COMPANYNAME_STR);
QApplication::setOrganizationDomain(VER_COMPANYDOMAIN_STR); // 专为Mac OS X 准备的
QApplication::setApplicationName(VER_PRODUCTNAME_STR);
QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, CONFIG_PATH);
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, CONFIG_PATH);
system("rm -f /tmp/LCK..ttyS*");
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
/*
*
*/
QApplication::setGraphicsSystem("raster");
#endif
#ifdef __EMBEDDED_LINUX__
2017-09-05 18:07:05 +08:00
//QApplication::setOverrideCursor(Qt::ArrowCursor);
QWSServer::setCursorVisible(false);
#endif
#ifdef __EMBEDDED_LINUX__
2017-09-05 18:07:05 +08:00
QFontDatabase db;
#if 0
int heitiFontID = db.addApplicationFont("/usr/lib/fonts/heiti.ttf");
QString heiti = db.applicationFontFamilies ( heitiFontID ).at(0);
pline() << heiti;
#else
int wenquanyiFontID = db.addApplicationFont("/usr/lib/fonts/wenquanyi.ttf");
QString wenquanyi = db.applicationFontFamilies ( wenquanyiFontID ).at(0);
pline() << wenquanyi;
#endif
QFont font(wenquanyi, 11);
QApplication::setFont(font);
#endif
pline() << qApp->applicationDirPath();
language = new QTranslator(this);
setLanguage();
#if 0
/*
*
*/
managerDB = newDatabaseConn();
setDatabaseName(managerDB, DB_MANAGER);
#endif
#if 1
/*
* Could not parse application stylesheet
* UI颜色和效果
*
* QQT效果
*/
QFile styleFile("./skin/default.qss");
styleFile.open(QIODevice::ReadOnly);
QString styleString(styleFile.readAll());;
styleFile.close();
setStyleSheet(styleString);
/*
*
*/
//setPalette(QPalette(QColor("#F0F0F0")));
#endif
#ifdef __EMBEDDED_LINUX__
QQtInput::Instance()->Init("min", "control", "QQT", 14, 14);
2017-09-05 18:07:05 +08:00
#endif
qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
QObject::connect(QQtPluginWatcher::Instance(), SIGNAL(storageChanged(int)),
2017-09-05 18:07:05 +08:00
this, SLOT(slotUPanAutoRun(int)));
//QQtSocketTcpClient
2017-09-05 18:07:05 +08:00
//QQTCloudClientInstance(this);
#ifdef __EMBEDDED_LINUX__
2017-09-05 18:07:05 +08:00
//QQTEthManager
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;
qm = setting.value("Language").toInt() ? "./lang/en_US.qm" : "./lang/zh_CN.qm";
language->load(qm);
pline() << "currentLanguage" << qm;
installTranslator(language);
}
void QQTApp::slotUPanAutoRun(int status)
{
if(QQtPluginWatcher::E_ADD == status)
2017-09-05 18:07:05 +08:00
{
QString mP = QQtPluginWatcher::Instance()->upanMountPath();
2017-09-05 18:07:05 +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;
QProcess* p = new QProcess(this);
p->setWorkingDirectory(mP);
p->start(app);
}
}