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

155 lines
4.1 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 "qqtclient.h"
#include "qqtserver.h"
#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协议当中去
*/
void QQTLanServer(QObject* parent = 0)
{
static QQtServer* s = new QQtServer(parent);
2017-09-05 18:07:05 +08:00
s->listen(QHostAddress::Any, 8000);
s->installedProtocol();
}
2017-10-22 12:21:19 +08:00
QQTApp::QQTApp(int& argc, char** argv) : QApplication(argc, argv)
2017-09-05 18:07:05 +08:00
{
#ifndef __QT5__
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
2017-10-24 13:52:25 +08:00
QApplication::setOrganizationName("animationframe");
QApplication::setOrganizationDomain("www.animationframe.com"); // 专为Mac OS X 准备的
QApplication::setApplicationName("AnimationFrame");
2017-09-05 18:07:05 +08:00
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");
2017-10-22 12:21:19 +08:00
QString heiti = db.applicationFontFamilies(heitiFontID).at(0);
2017-09-05 18:07:05 +08:00
pline() << heiti;
#else
int wenquanyiFontID = db.addApplicationFont("/usr/lib/fonts/wenquanyi.ttf");
2017-10-22 12:21:19 +08:00
QString wenquanyi = db.applicationFontFamilies(wenquanyiFontID).at(0);
2017-09-05 18:07:05 +08:00
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)));
//QQtClient
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
//QQtServer
2017-09-05 18:07:05 +08:00
//QQTPeerPort
//QQTPeerPortInstance(this);
//QQTSerialPort
//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);
2017-10-22 12:21:19 +08:00
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);
}
}