|
@@ -3,13 +3,60 @@
|
|
|
#include <QQmlContext>
|
|
|
#include <QApplication>
|
|
|
#include<QMessageBox>
|
|
|
+#include <QSettings>
|
|
|
|
|
|
#include "TestService.h"
|
|
|
#include "Standard.h"
|
|
|
#include "Calibrationpara.h"
|
|
|
+#include "backendlogic.h"
|
|
|
|
|
|
#include "DLog.h"
|
|
|
|
|
|
+#if 0
|
|
|
+#define AUTO_RUN_KEY "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
|
|
+//设置/取消自启动
|
|
|
+//isStart: true(开机启动) false(开机不启动)
|
|
|
+void ServiceMediaPlayer::setMyAppAutoRun(bool isStart)
|
|
|
+{
|
|
|
+ QString application_name = QApplication::applicationName();//获取应用名称
|
|
|
+ QSettings *settings = new QSettings(AUTO_RUN_KEY, QSettings::NativeFormat);//创建QSetting, 需要添加QSetting头文件
|
|
|
+ if(isStart)
|
|
|
+ {
|
|
|
+ QString application_path = QApplication::applicationFilePath();//找到应用的目录
|
|
|
+ settings->setValue(application_name, application_path.replace("/", "\\"));//写入注册表
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ settings->remove(application_name); //从注册表中删除
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+void SetProcessAutoRunSelf(const QString &appPath)
|
|
|
+{
|
|
|
+ //注册表路径需要使用双反斜杠,如果是32位系统,要使用QSettings::Registry32Format
|
|
|
+ QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
|
|
|
+ QSettings::Registry64Format);
|
|
|
+
|
|
|
+ //以程序名称作为注册表中的键
|
|
|
+ //根据键获取对应的值(程序路径)
|
|
|
+ QFileInfo fInfo(appPath);
|
|
|
+ QString name = fInfo.baseName();
|
|
|
+ QString path = settings.value(name).toString();
|
|
|
+
|
|
|
+ //如果注册表中的路径和当前程序路径不一样,
|
|
|
+ //则表示没有设置自启动或自启动程序已经更换了路径
|
|
|
+ //toNativeSeparators的意思是将"/"替换为"\"
|
|
|
+ QString newPath = QDir::toNativeSeparators(appPath);
|
|
|
+ if (path != newPath)
|
|
|
+ {
|
|
|
+
|
|
|
+ settings.setValue(name, newPath);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
QObject *standardmananger_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
|
|
{
|
|
|
Q_UNUSED(engine)
|
|
@@ -34,7 +81,10 @@ int main(int argc, char *argv[])
|
|
|
#endif
|
|
|
QApplication app(argc, argv);
|
|
|
|
|
|
+#ifdef QT_NO_DEBUG
|
|
|
+ SetProcessAutoRunSelf(qApp->applicationFilePath());//创建程序自启注册表
|
|
|
qInstallMessageHandler(myMsgOutput);
|
|
|
+#endif
|
|
|
DLog_Init();
|
|
|
|
|
|
//QMessageBox::critical(NULL, "critical", "Content", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
@@ -44,6 +94,7 @@ int main(int argc, char *argv[])
|
|
|
qmlRegisterSingletonType<StandardManager>("TService", 1, 0, "CalibrationPara",calibrationpara_provider);
|
|
|
|
|
|
qmlRegisterType<TestService>("TService",1,0,"TestService");
|
|
|
+ qmlRegisterType<BackendLogic>("BackendLogic", 1, 0, "BackendLogic");
|
|
|
|
|
|
StandardManager::instance();
|
|
|
|