2024-09-10 14:38:23 +08:00
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
#include <vld.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
|
|
#include "qtsingleapplication.h"
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QTranslator>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QScreen>
|
2024-10-11 14:20:12 +08:00
|
|
|
|
#include <QStyleFactory>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QDebug>
|
2024-09-10 14:38:23 +08:00
|
|
|
|
|
|
|
|
|
#include <hv/hv.h>
|
|
|
|
|
#include <hv/hmain.h>
|
|
|
|
|
#include <hv/iniparser.h>
|
|
|
|
|
#include <hv/hloop.h>
|
|
|
|
|
#include <hv/hsocket.h>
|
|
|
|
|
#include <hv/hssl.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
QString app_unique_name("emsConfigurer_application_name");
|
|
|
|
|
QtSingleApplication app(app_unique_name,argc, argv);
|
|
|
|
|
if(app.isRunning())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(nullptr, "EMS Configurer", "Another instance is already running.");
|
|
|
|
|
app.sendMessage("raise_window_noop", 1000); //1s后激活前个实例
|
|
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main_ctx_init(argc, argv);
|
|
|
|
|
QString appDir = QCoreApplication::applicationDirPath();
|
|
|
|
|
std::string logFilePath = (appDir + QString::fromStdString("/emsConfigurer.log")).toStdString();
|
|
|
|
|
|
|
|
|
|
hlog_set_file(logFilePath.c_str());
|
2024-09-10 16:12:38 +08:00
|
|
|
|
hlogi("=========--- Welcome to the Earth ---=========");
|
|
|
|
|
hlogi("%s version: %s", argv[0], "1.1.0");
|
2024-09-10 14:38:23 +08:00
|
|
|
|
hlog_fsync();
|
|
|
|
|
|
2024-10-11 14:20:12 +08:00
|
|
|
|
//若是系统自带的QStyle风格,则需要先创建为QStyleFactory::create(""),然后设置qApp->setStyle()
|
2024-10-12 14:00:37 +08:00
|
|
|
|
//QStringList listStyle = QStyleFactory::keys();
|
|
|
|
|
//foreach(QString val, listStyle) //打印当前系统支持的系统风格,,且打印出来
|
|
|
|
|
//{
|
|
|
|
|
// qDebug()<<val<<" ";
|
|
|
|
|
//}
|
2024-10-11 14:20:12 +08:00
|
|
|
|
|
|
|
|
|
//当前系统支持的系统风格
|
|
|
|
|
//"windowsvista"
|
|
|
|
|
//"Windows"
|
|
|
|
|
//"Fusion"
|
|
|
|
|
//qApp->setStyle(QStyleFactory::create("Fusion"));
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//QFile f(":qdarkstyle/light/lightstyle.qss");
|
|
|
|
|
QFile f(":bingle/bingle/Ubuntu.qss");
|
|
|
|
|
|
|
|
|
|
if (!f.exists())
|
|
|
|
|
{
|
|
|
|
|
hloge("Unable to set stylesheet, file not found");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
f.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
|
QTextStream ts(&f);
|
|
|
|
|
qApp->setStyleSheet(ts.readAll());
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-09-10 14:38:23 +08:00
|
|
|
|
QTranslator translator;
|
|
|
|
|
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
|
|
|
|
for (const QString &locale : uiLanguages)
|
|
|
|
|
{
|
|
|
|
|
const QString baseName = "emsConfigurer_" + QLocale(locale).name();
|
|
|
|
|
if (translator.load(":/i18n/" + baseName))
|
|
|
|
|
{
|
|
|
|
|
app.installTranslator(&translator);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow w;
|
2024-09-10 16:12:38 +08:00
|
|
|
|
//隐藏(不显示)最大化最小化按钮
|
|
|
|
|
w.setWindowFlags(w.windowFlags()&~Qt::WindowMinMaxButtonsHint);
|
|
|
|
|
//w.setWindowFlags(w.windowFlags() | Qt::WindowStaysOnTopHint);
|
|
|
|
|
|
2024-10-11 14:20:12 +08:00
|
|
|
|
//w.setStyleSheet("border-radius: 4px;"); // 定制圆角
|
2024-09-10 16:12:38 +08:00
|
|
|
|
// ".QLabel{background: gray;}.QTextEdit{background: white;}");
|
|
|
|
|
|
2024-09-10 14:38:23 +08:00
|
|
|
|
//获取窗口尺寸并居中
|
|
|
|
|
QScreen *scr = app.primaryScreen();
|
|
|
|
|
int scr_w = scr->size().width();
|
|
|
|
|
int scr_h = scr->size().height();
|
|
|
|
|
w.move((scr_w - w.width()) / 2, (scr_h - w.height()) / 2);
|
|
|
|
|
|
|
|
|
|
w.show();
|
2024-09-12 16:23:44 +08:00
|
|
|
|
|
2024-09-10 16:12:38 +08:00
|
|
|
|
int ret = app.exec();
|
|
|
|
|
hlogi("=========--- I'll be back! ---=========");
|
|
|
|
|
return ret;
|
2024-09-10 14:38:23 +08:00
|
|
|
|
}
|