JarvisServer::JarvisServer() : settings("InfoAG", "Jarvis.Server")
{
    defaultSetting("Port", 4200);
    defaultSetting("ModulePath", QCoreApplication::applicationDirPath() + "/../modules/");
    settings.setValue("ModulePath", QCoreApplication::applicationDirPath() + "/../modules/");
    emit output(QCoreApplication::applicationDirPath() + "/modules");
    QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() + "/modules");
    //settings.setValue("Version", 1);
    listen(QHostAddress::Any, settings.value("Port").toUInt());
    parser = std::unique_ptr<ExpressionParser>(new ExpressionParser(QDir(settings.value("ModulePath").toString())));
    QObject::connect(parser.get(), SIGNAL(output(const QString &)), SIGNAL(output(const QString &)));
}
Beispiel #2
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),system_tray(NULL),preBtnPut(NULL),_flagCloseWin(false),TimerGlbDly(NULL),_flagAppStartFirst(false),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    defaultSetting();
    set_ui();

    connect(ui->btnSetting,&QToolButton::clicked,[=]{
        FormSetting *settingform = setupSettingForm();
        if(settingform)
            settingform->isHidden()?settingform->show():settingform->activateWindow();
    });

    //default timer to show current time
    QTimer *time = new QTimer(this);
    time->start(1000);
    connect(time,&QTimer::timeout,[=]{
        ui->states_group_timeSet->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
    });

    if(_flagAppStartFirst){//程序第一次启动时弹出设置对话框
        setupSettingForm();
    }else{
        //NOTE:检测是否有分组记录,否也应弹出
        QSettings setting;
        setting.beginGroup("GroupData");
        if(!setting.childGroups().count())
            setupSettingForm();
        setting.endGroup();
        //end
    }
}