first commit

This commit is contained in:
2026-02-21 17:11:31 +09:00
commit 18b4338361
4001 changed files with 365464 additions and 0 deletions

View File

@@ -0,0 +1,207 @@
#include "fm_base64.h"
#if (ENCODE_CFG_BASE64)
#include <QFile>
static const unsigned char base64_table[65] = "0123456789+/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // Changed Code...
#define BASE64_MARK_SIZE 4
static const unsigned char base64_start_mark[BASE64_MARK_SIZE] = { 0x1B, 0x9B, 0x1B, 0x9C };
static const unsigned char base64_end_mark[BASE64_MARK_SIZE] = { 0x1B, 0x9C, 0x1B, 0x9D };
/* base64_encode - Base64 encode */
uint8_t* FMBase64::mg_base64_encode(const uint8_t *src, uint32_t len, uint32_t *out_len)
{
uint8_t *out, *pos;
const uint8_t *end, *in;
uint32_t olen;
int line_len;
olen = len * 4 / 3 + 4; /* 3-byte blocks to 4-byte */
olen += olen / 72; /* line feeds */
olen++; /* nul termination */
if (olen < len) return NULL; /* integer overflow */
out = (uint8_t*)malloc(olen+(BASE64_MARK_SIZE*2));
memset(out,0,olen+(BASE64_MARK_SIZE*2));
if (out == NULL) return NULL;
end = src + len;
in = src;
pos = out;
line_len = 0;
memcpy((void*)pos, base64_start_mark, BASE64_MARK_SIZE);
pos += BASE64_MARK_SIZE;
while (end - in >= 3) {
*pos++ = base64_table[in[0] >> 2];
*pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
*pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
*pos++ = base64_table[in[2] & 0x3f];
in += 3;
line_len += 4;
if (line_len >= 72) {
*pos++ = '\n';
line_len = 0;
}
}
if (end - in) {
*pos++ = base64_table[in[0] >> 2];
if (end - in == 1) {
*pos++ = base64_table[(in[0] & 0x03) << 4];
*pos++ = '=';
} else {
*pos++ = base64_table[((in[0] & 0x03) << 4) |
(in[1] >> 4)];
*pos++ = base64_table[(in[1] & 0x0f) << 2];
}
*pos++ = '=';
line_len += 4;
}
if (line_len) *pos++ = '\n';
memcpy((void*)pos, base64_end_mark, BASE64_MARK_SIZE);
pos += BASE64_MARK_SIZE;
*pos = '\0';
if (out_len) *out_len = pos - out;
return out;
}
/* base64_decode - Base64 decode */
uint8_t* FMBase64::mg_base64_decode(uint8_t *src, uint32_t len, uint32_t *out_len)
{
uint8_t dtable[256], *out, *pos, block[4], tmp;
uint32_t i, count, olen;
int pad = 0;
if(src == NULL || len <= BASE64_MARK_SIZE*2) return NULL;
if(memcmp((void*)&src[0], base64_start_mark, BASE64_MARK_SIZE) ||
memcmp((void*)&src[len-BASE64_MARK_SIZE], base64_end_mark, BASE64_MARK_SIZE)) {
return NULL;
}
src += BASE64_MARK_SIZE;
len -= BASE64_MARK_SIZE*2;
memset((void*)dtable, 0x80, 256);
for (i = 0; i < sizeof(base64_table) - 1; i++)
dtable[base64_table[i]] = (uint8_t) i;
dtable['='] = 0;
count = 0;
for (i = 0; i < len; i++) {
if (dtable[src[i]] != 0x80) count++;
}
if (count == 0 || count % 4) return NULL;
olen = count / 4 * 3;
//qInfo() << olen << olen + (olen % 2048) << __FUNCTION__;
pos = out = (uint8_t*)malloc(qMax(olen,(uint32_t)4096));
memset(out,0,olen);
if (out == NULL) return NULL;
count = 0;
for (i = 0; i < len; i++) {
tmp = dtable[src[i]];
if (tmp == 0x80) continue;
if (src[i] == '=') pad++;
block[count] = tmp;
count++;
if (count == 4) {
*pos++ = (block[0] << 2) | (block[1] >> 4);
*pos++ = (block[1] << 4) | (block[2] >> 2);
*pos++ = (block[2] << 6) | block[3];
count = 0;
if (pad) {
if (pad == 1) pos--;
else if (pad == 2) pos -= 2;
else {
/* Invalid padding */
free((void*)out);
return NULL;
}
break;
}
}
}
*out_len = pos - out;
return out;
}
// 파일 확인하여 텍스트 스트림으로 처리
QStringList FMBase64::load(QString path, bool* isEncoded)
{
QFile file(path);
if(file.exists() && file.open(QIODevice::ReadOnly))
{
uint32_t len = (uint32_t)(file.size() + (file.size() % 8));
uint8_t* buffer = (uint8_t*)malloc(len);
memset(buffer,0,len);
file.read((char*)buffer,file.size());
uint8_t* text = buffer;
// MARK 확인 , 0x9C, 0x1B, 0x9D
if(buffer[0] == base64_start_mark[0] &&
buffer[1] == base64_start_mark[1] &&
buffer[2] == base64_start_mark[2] &&
buffer[3] == base64_start_mark[3] &&
buffer[file.size()-4] == base64_end_mark[0] &&
buffer[file.size()-3] == base64_end_mark[1] &&
buffer[file.size()-2] == base64_end_mark[2] &&
buffer[file.size()-1] == base64_end_mark[3]) {
*isEncoded = true;
uint32_t outlen = 0;
text = mg_base64_decode(buffer, file.size(),&outlen);
text[outlen] = 0;
} else {
*isEncoded = false;
}
QString lines = QString::fromLatin1((char*)text);
file.close();
if(buffer != text) {
free(text);
}
free(buffer);
return lines.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
}
return QStringList();
}
void FMBase64::save(QString path, QStringList lines, bool isEncoded)
{
// \r\n
QString str = QString();
for(int i=0;i<lines.size();i++) {
str += lines.at(i);
str += "\r\n";
}
QByteArray ba = str.toLatin1();
const uint8_t * src = (uint8_t*)ba.data();
uint8_t* dest = NULL;
uint32_t out_len = ba.size();
if(true) { // isEncoded) {
dest = mg_base64_encode(src, ba.size(),&out_len);
} else {
size_t ss = ba.size() + (ba.size() % 8);
dest = (uint8_t*)malloc(ss);
memset(dest,0,ss);
memcpy(dest,ba.data(),ba.size());
}
QFile file(path);
if (file.open(QIODevice::WriteOnly)) {
file.write((char*)dest,out_len);
file.close();
}
free(dest);
}
#endif // #if (ENCODE_CFG_BASE64)

View File

@@ -0,0 +1,20 @@
#ifndef FM_BASE64_H
#define FM_BASE64_H
#include "../rm_include.h"
#if (ENCODE_CFG_BASE64)
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#include <inttypes.h>
class FMBase64
{
public:
static QStringList load(QString path, bool* isEncoded);
static void save(QString path, QStringList lines, bool isEncoded);
private:
static uint8_t* mg_base64_encode(const uint8_t *src, uint32_t len, uint32_t *out_len);
static uint8_t* mg_base64_decode(uint8_t *src, uint32_t len, uint32_t *out_len);
};
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#endif // ENCODE_CFG_BASE64
#endif // FM_BASE64_H

View File

@@ -0,0 +1,19 @@
echo off
REM set /p id="IN Model: "
REM set /p id="OUT Model: "
REM set IN_MODEL=%1
REM set OUT_MODEL=%2
REM CALL :make_model 51fr,tr41fw
REM CALL :make_model 51fr,tzd201
REM CALL :make_model 61fh,tr61fw
REM CALL :make_model 91fh,tzd202fw
REM CALL :make_model 91fh,tzd203fw
:make_model
copy /y rm_settings_cfg_%~1.h rm_settings_cfg_%~2.h
copy /y rm_settings_cfg_%~1.cpp rm_settings_cfg_%~2.cpp
copy /y window_settings_%~1.h window_settings_%~2.h
copy /y window_settings_%~1.cpp window_settings_%~2.cpp
EXIT /B 0

View File

@@ -0,0 +1,227 @@
#include "rm_admin_passwd.h"
#if (USE_ADMIN_PW_SETTINGS)
#include "rm_include.h"
#include <QStyleOption>
#include <QPainter>
#include <QLabel>
#include <QDebug>
#include <QCheckBox>
#include <QDateTime>
#include <QDir>
#include <QFile>
#include <QLineEdit>
#include "../ui/rm_button.h"
#include "rm_radio_buttons.h"
#include "rm_settings_window_base.h"
#include "../ui/rm_widget_checkbox.h"
RMSettingAdminPW::RMSettingAdminPW(unsigned char* data, QList<int> values, QWidget *parent) : QGroupBox(parent)
{
dataP = data;
setFixedHeight(120);
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
setObjectName("settings");
// 管理者PW
//setTitle(MKU8("\xe7\xae\xa1\xe7\x90\x86\xe8\x80\x85\x50\x57"));
setTitle(FM_WSTR(L"暗証番号"));
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(4,2,4,2);
layout->setSpacing(2);
//QSpacerItem* space = new QSpacerItem(0,10);
//layout->addSpacerItem(space);
// 管理者PW保存
#if !(REMOVE_ADMIN_PW_CHECKBOX)
saveCheckbox = new RMWidgetCheckBox(this);
//#if (LIVE_LANGUAGE_CHANGE)
// if(RMLanguage::isJP() == false)
// {
// check->setText("PC Time Sync.");
// }
// else {
//#else
//#endif // LIVE_LANGUAGE_CHANGE
//#if (LIVE_LANGUAGE_CHANGE)
// }
//#endif
saveCheckbox->setText(MKU8("\xe7\xae\xa1\xe7\x90\x86\xe8\x80\x85\x50\x57\xe4\xbf\x9d\xe5\xad\x98"));
#else
// ナイトビジョン
const int lbWidth = 150;
const int rWidth = 360;
//RMRadioButtons* rb;
//QLabel* tl = new QLabel(this);
//static unsigned char dummy = 0;
// saveRadioButton = new QWidget(this);
// saveRadioButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
// //setObjectName("test_widget");
// saveRadioButton->setFixedHeight(25);
// QHBoxLayout* qlayout = new QHBoxLayout(saveRadioButton);
// qlayout->setContentsMargins(8,2,8,2);
// qlayout->setSpacing(2);
// qlayout->setAlignment(Qt::AlignJustify);
// QLabel* qtitleLabel = new QLabel(this);
// qtitleLabel->setObjectName("text_normal_label");
// qtitleLabel->setText(FM_WSTR(L"暗証番号設定"));
// qlayout->addWidget(qtitleLabel);
// foreach (QString eachTitle, (QStringList() << "OFF" << "ON")) {
// QRadioButton* btn = new QRadioButton(saveRadioButton);
// btn->setObjectName("settings");
// btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
// btn->setText(eachTitle);
// connect(btn,SIGNAL(clicked()),SLOT(onSelected()));
// qlayout->addWidget(btn);
// buttons.append(btn);
// }
// buttons.at(0)->setChecked(true);
saveRadioButton = new RMRadioButtons(this,FM_WSTR(L"暗証番号設定"),(QStringList() << "OFF" << "ON"),dataP,values);
connect(saveRadioButton,SIGNAL(selected(int)),SLOT(onSelected(int)));
layout->addWidget(saveRadioButton);
saveRadioButton->setFixedWidth(rWidth);
saveRadioButton->titleLabel->setFixedWidth(lbWidth);
//qtitleLabel->setFixedWidth(lbWidth);
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
//QSpacerItem* space = new QSpacerItem(10,0);
//layout->addSpacerItem(space);
//QLabel* saveCheckbox = new QLabel(this);
//saveCheckbox->setText(MKU8(" \xe7\xae\xa1\xe7\x90\x86\xe8\x80\x85\x50\x57\xe4\xbf\x9d\xe5\xad\x98"));
#endif
//layout->addWidget(saveCheckbox);
// connect(check,SIGNAL(clicked()),SLOT(onCheckBoxTimeSync()));
//saveCheckbox->setStyleSheet("font-size: 13px;color : white;");
QWidget* lw = new QWidget(this);
layout->addWidget(lw);
QHBoxLayout* ll = new QHBoxLayout(lw);
ll->setAlignment(Qt::AlignLeading);
// 管理者PW入力
QLabel* titleLB = new QLabel(lw);
titleLB->setObjectName("text_normal_label");
ll->addWidget(titleLB);
titleLB->setText(FM_WSTR(L"暗証番号変更"));
//titleLB->setText(MKU8("\xe7\xae\xa1\xe7\x90\x86\xe8\x80\x85\x50\x57\xe5\x85\xa5\xe5\x8a\x9b\x3a"));
titleLB->setFixedWidth(lbWidth-10);//100
//titleLB->setStyleSheet("font-size: 13px;color : white;");
editPW = new QLineEdit(lw);
editPW->setEchoMode(QLineEdit::Password);
editPW->setStyleSheet("font-family: Fixedsys;color : #111111;background-color: #DDDDDD;border:1px;border-style:solid;border-color:#313131;");
editPW->setMaxLength(4);
editPW->setFixedWidth(80);
editPW->setValidator( new QIntValidator(0, 9999, this) );
ll->addWidget(editPW);
editPW->setEnabled(*data == 0);
// 端末の管理者パスワードが変更された番号にリセットされます。最大4桁のみ入力可能。
lw = new QWidget(this);
layout->addWidget(lw);
QVBoxLayout* lv = new QVBoxLayout(lw);
ZERO_LAYOUT(lv);
lv->setContentsMargins(11,0,0,0);
lv->setSpacing(3);
lv->setAlignment(Qt::AlignLeading);
// 暗証番号設定をONにしているとき、暗証番号変更4桁の入力が可能。
//QString descString = MKU8("\xe7\xab\xaf\xe6\x9c\xab\xe3\x81\xae\xe7\xae\xa1\xe7\x90\x86\xe8\x80\x85\xe3\x83\x91\xe3\x82\xb9\xe3\x83\xaf\xe3\x83\xbc\xe3\x83\x89\xe3\x81\x8c\xe5\xa4\x89\xe6\x9b\xb4\xe3\x81\x95\xe3\x82\x8c\xe3\x81\x9f\xe7\x95\xaa\xe5\x8f\xb7\xe3\x81\xab\xe3\x83\xaa\xe3\x82\xbb\xe3\x83\x83\xe3\x83\x88\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82");
QString descString = FM_WSTR(L"暗証番号設定をONにしているとき、");
QLabel* desc = new QLabel(lw);
desc->setText(descString);
lv->addWidget(desc);
desc->setStyleSheet("font-size: 14px; font-weight:bold; color:#eab428;");
QString descString2 = FM_WSTR(L"暗証番号変更4桁の入力が可能。");
//QString descString2 = MKU8("\xe6\x9c\x80\xe5\xa4\xa7\x34\xe6\xa1\x81\xe3\x81\xae\xe3\x81\xbf\xe5\x85\xa5\xe5\x8a\x9b\xe5\x8f\xaf\xe8\x83\xbd\xe3\x80\x82");
QLabel* desc2 = new QLabel(this);
desc2->setText(descString2);
lv->addWidget(desc2);
desc2->setStyleSheet("font-size: 14px; font-weight:bold; color:#eab428;"); // ffc000
//color : white;
//font-size: 14px;
//font-weight: bold;
}
void RMSettingAdminPW::onUpdateByValue() {
// OFF
editPW->setEnabled(*dataP == 0); // ON
if(*dataP == 1) {
editPW->setText("");
}
}
void RMSettingAdminPW::onSelected(int index)
{
editPW->setEnabled(index == 1);
if(index == 0) {
editPW->setText("");
}
}
/*
void RMSettingAdminPW::onSelected()
{
QRadioButton* btn = qobject_cast<QRadioButton*>(sender());
int index = buttons.indexOf(btn);
qInfo() << index << __FUNCTION__;
//*_value = realValue(index);
//emit selected(index);
if(index == 0) {
editPW->setText("");
}
editPW->setEnabled(index == 1);
if (index == 1) {
editPW->setFocus();
}
}
*/
void RMSettingAdminPW::onSave() {
QString pws = editPW->text();
if(pws.length() == 4)
{
QString pwPath = QDir::cleanPath(RMSettingsWindowBase::lastSettingDisk + "//admin.cfg");
if(QFile::exists(pwPath))
{
QFile::remove(pwPath);
}
unsigned char pwb[4] = {0,};
pwb[0] = QString(pws.at(0)).toInt();
pwb[1] = QString(pws[1]).toInt();
pwb[2] = QString(pws[2]).toInt();
pwb[3] = QString(pws[3]).toInt();
pwb[0] ^= 0x80;
pwb[1] ^= 0x80;
pwb[2] ^= 0x80;
pwb[3] ^= 0x80;
QFile f(pwPath);
if(f.open(QIODevice::WriteOnly))
{
f.write((const char*)&pwb[0],4);
f.close();
}
}
}
#endif // #if (USE_ADMIN_PW_SETTINGS)

View File

@@ -0,0 +1,42 @@
#ifndef RM_ADMIN_PASSWD_H
#define RM_ADMIN_PASSWD_H
#if (USE_ADMIN_PW_SETTINGS)
#include <QWidget>
#include <QGroupBox>
#include <QComboBox>
#include <QList>
#include <QVBoxLayout>
#include <QDateEdit>
#include <QTimeEdit>
#include <QTimer>
#define REMOVE_ADMIN_PW_CHECKBOX 1
class RMWidgetCheckBox;
class RMRadioButtons;
class QLabel;
class QRadioButton;
class RMSettingAdminPW : public QGroupBox
{
Q_OBJECT
public:
explicit RMSettingAdminPW(unsigned char* data, QList<int> values, QWidget *parent = nullptr);
QBoxLayout* layout;
QLineEdit* editPW;
#if !(REMOVE_ADMIN_PW_CHECKBOX)
RMWidgetCheckBox* saveCheckbox; // 210924 -> 제거
#endif
RMRadioButtons* saveRadioButton;
//QList<QRadioButton*> buttons;
private:
unsigned char* dataP;
public slots:
void onSave();
void onSelected(int index);
void onUpdateByValue();
};
#endif // USE_ADMIN_PW_SETTINGS
#endif // RM_ADMIN_PASSWD_H

View File

@@ -0,0 +1,116 @@
#include "rm_combo_box.h"
#include <QLabel>
#include <QStyleOption>
#include <QPainter>
#if (USE_JSON_SETTINGS)
#include <QJsonObject>
#include <QJsonArray>
#include "rm_settings_cfg.h"
RMComboBox::RMComboBox(QWidget *parent,QString title,int index) : QWidget(parent), RMValueSelector(index)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
//setObjectName("test_widget");
layout = new QHBoxLayout(this);
layout->setAlignment(Qt::AlignLeading | Qt::AlignVCenter);
layout->setContentsMargins(0,2,8,2);
layout->setSpacing(3);
if(!title.isEmpty())
{
titleLabel = new QLabel(this);
titleLabel->setObjectName("text_normal_label");
titleLabel->setText(title);
layout->addWidget(titleLabel);
}
else
{
titleLabel = NULL;
}
QJsonObject obj = CFG::items.at(index).toObject();
QStringList spacedItems;
QJsonArray array = obj.value("value_strings").toArray();
for(int i=0;i<array.size();i++)
{
spacedItems.append(" " + array.at(i).toString());
}
comboBox = new QComboBox(this);
comboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
comboBox->setObjectName("settings");
comboBox->addItems(spacedItems);
comboBox->setMaxVisibleItems(100);
int idx = obj.value("current").toInt();
comboBox->setCurrentIndex(realIndex(idx));
connect(comboBox,SIGNAL(currentIndexChanged(int)),SLOT(onSelected(int)));
layout->addWidget(comboBox);
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
}
void RMComboBox::onSelected(int index)
{
QJsonObject obj = CFG::items.at(_object).toObject();
obj.insert("current",QJsonValue(realValue(index)));
CFG::items.replace(_object,obj);
emit selected(index);
}
void RMComboBox::onUpdateByValue()
{
QJsonObject obj = CFG::items.at(_object).toObject();
comboBox->setCurrentIndex(realIndex(obj.value("current").toInt()));
}
#else // USE_JSON_SETTINGS
RMComboBox::RMComboBox(QWidget *parent,QString title, QStringList items,unsigned char* value,QList<int> indexMap) : QWidget(parent), RMValueSelector(value,indexMap)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
//setObjectName("test_widget");
layout = new QHBoxLayout(this);
layout->setAlignment(Qt::AlignLeading | Qt::AlignVCenter);
layout->setContentsMargins(0,2,8,2);
layout->setSpacing(3);
if(title.length() > 0)
{
titleLabel = new QLabel(this);
titleLabel->setObjectName("text_normal_label");
titleLabel->setText(title);
layout->addWidget(titleLabel);
}
else
{
titleLabel = NULL;
}
QStringList spacedItems;
foreach (QString eachItem, items) {
spacedItems.append(" " + eachItem);
}
comboBox = new QComboBox(this);
comboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
comboBox->setObjectName("settings");
comboBox->addItems(spacedItems);
comboBox->setMaxVisibleItems(100);
comboBox->setCurrentIndex(realIndex(*value));
connect(comboBox,SIGNAL(currentIndexChanged(int)),SLOT(onSelected(int)));
layout->addWidget(comboBox);
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
}
void RMComboBox::onSelected(int index)
{
*_value = realValue(index);
emit selected(index);
}
void RMComboBox::onUpdateByValue()
{
comboBox->setCurrentIndex(realIndex(*_value));
}
#endif // USE_JSON_SETTINGS
void RMComboBox::paintEvent(QPaintEvent *pe)
{
Q_UNUSED(pe);
QStyleOption o;
o.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}

View File

@@ -0,0 +1,32 @@
#ifndef RM_COMBO_BOX_H
#define RM_COMBO_BOX_H
#include <QWidget>
#include <QComboBox>
#include <QList>
#include <QHBoxLayout>
#include <QLabel>
#include "rm_value_selector.h"
class RMComboBox : public QWidget, public RMValueSelector
{
Q_OBJECT
public:
#if (USE_JSON_SETTINGS)
explicit RMComboBox(QWidget *parent,QString title, int index);
#else // USE_JSON_SETTINGS
explicit RMComboBox(QWidget *parent,QString title, QStringList items,unsigned char* value,QList<int> indexMap = QList<int>());
#endif // USE_JSON_SETTINGS
QHBoxLayout* layout;
QComboBox* comboBox;
QLabel* titleLabel;
private:
void paintEvent(QPaintEvent *pe);
signals:
void selected(int index);
private slots:
void onSelected(int index);
void onUpdateByValue();
};
#endif // RM_COMBO_BOX_H

View File

@@ -0,0 +1,43 @@
#include "rm_group_combo_box.h"
#include <QStyleOption>
#include <QPainter>
#include <QLabel>
#include <QDebug>
#include "rm_combo_box.h"
#if (USE_JSON_SETTINGS)
#include <QJsonObject>
#include "rm_settings_cfg.h"
RMGroupComboBox::RMGroupComboBox(QWidget *parent,int index) : QGroupBox(parent)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
setObjectName("settings");
QJsonObject obj = CFG::items.at(index).toObject();
if(obj.contains("title")) {
setTitle(obj.value("title").toString());
}
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(3);
comboBox = new RMComboBox(this,"",index);
layout->addWidget(comboBox);
}
#else
RMGroupComboBox::RMGroupComboBox(QWidget *parent,QString title, QStringList titles,unsigned char* value,QList<int> indexMap) : QGroupBox(parent)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
setObjectName("settings");
setTitle(title);
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(3);
comboBox = new RMComboBox(this,"",titles,value,indexMap);
layout->addWidget(comboBox);
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef RM_GROUP_COMBO_BOX_H
#define RM_GROUP_COMBO_BOX_H
#include <QWidget>
#include <QGroupBox>
#include <QComboBox>
#include <QList>
#include <QVBoxLayout>
class RMComboBox;
class QJsonObject;
class RMGroupComboBox : public QGroupBox
{
Q_OBJECT
public:
#if (USE_JSON_SETTINGS)
explicit RMGroupComboBox(QWidget *parent,int index);
#else // USE_JSON_SETTINGS
explicit RMGroupComboBox(QWidget *parent,QString title, QStringList items,unsigned char* value,QList<int> indexMap = QList<int>());
#endif // USE_JSON_SETTINGS
QVBoxLayout* layout;
RMComboBox* comboBox;
};
#endif // RM_GROUP_COMBO_BOX_H

View File

@@ -0,0 +1,70 @@
#include "rm_group_radio_buttons.h"
#include "rm_radio_buttons.h"
#include <QDebug>
#if (USE_JSON_SETTINGS)
#include <QJsonObject>
#include "rm_settings_cfg.h"
RMGroupRadioButtons::RMGroupRadioButtons(QWidget *parent,int object) : QGroupBox(parent)
{
setObjectName("settings");
QJsonObject obj = CFG::items.at(object).toObject();
if(obj.contains("title")) {
setTitle(obj.value("title").toString());
}
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(3);
radioButtons = new RMRadioButtons(this, "",object);
layout->addWidget(radioButtons);
}
RMGroupRadioButtons::RMGroupRadioButtons(QWidget *parent,int object, bool rowType) : QGroupBox(parent)
{
setObjectName("settings");
QJsonObject obj = CFG::items.at(object).toObject();
if(obj.contains("title")) {
setTitle(obj.value("title").toString());
}
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(3);
radioButtons = new RMRadioButtons(this, "",object,rowType);
layout->addWidget(radioButtons);
}
#else // USE_JSON_SETTINGS
RMGroupRadioButtons::RMGroupRadioButtons(QWidget *parent,QString title, QStringList titles,unsigned char* value,QList<int> indexMap) : QGroupBox(parent)
{
setObjectName("settings");
setTitle(title);
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(3);
radioButtons = new RMRadioButtons(this, "",titles,value,indexMap);
layout->addWidget(radioButtons);
}
RMGroupRadioButtons::RMGroupRadioButtons(QWidget *parent,QString title, QStringList titles,unsigned char* value,bool rowType, QList<int> indexMap) : QGroupBox(parent)
{
setObjectName("settings");
setTitle(title);
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(3);
radioButtons = new RMRadioButtons(this, "",titles,value,rowType,indexMap);
layout->addWidget(radioButtons);
}
#endif // #if (USE_JSON_SETTINGS)

View File

@@ -0,0 +1,28 @@
#ifndef RM_GROUP_RADIO_BUTTONS_H
#define RM_GROUP_RADIO_BUTTONS_H
#include <QWidget>
#include <QGroupBox>
#include <QList>
#include <QVBoxLayout>
class RMRadioButtons;
class RMGroupRadioButtons : public QGroupBox
{
Q_OBJECT
public:
#if (USE_JSON_SETTINGS)
explicit RMGroupRadioButtons(QWidget *parent,int object);
explicit RMGroupRadioButtons(QWidget *parent,int object,bool rowType);
#else // #if (USE_JSON_SETTINGS)
explicit RMGroupRadioButtons(QWidget *parent,QString title, QStringList items,unsigned char* value,QList<int> indexMap = QList<int>());
explicit RMGroupRadioButtons(QWidget *parent,QString title, QStringList items,unsigned char* value,bool rowType = false,QList<int> indexMap = QList<int>());
#endif // #if (USE_JSON_SETTINGS)
QVBoxLayout* layout;
RMRadioButtons* radioButtons;
};
#endif // RM_GROUP_RADIO_BUTTONS_H

View File

@@ -0,0 +1,243 @@
#include "rm_radio_buttons.h"
#include <QHBoxLayout>
#include <QDebug>
#include <QStyleOption>
#include <QPainter>
#include <QLabel>
#if (USE_JSON_SETTINGS)
#include <QJsonArray>
#include <QJsonObject>
#include "rm_settings_cfg.h"
RMRadioButtons::RMRadioButtons(QWidget *parent,
QString title, int object, bool rowType) : QWidget(parent), RMValueSelector(object)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
//setObjectName("test_widget");
if(rowType == true)
{
layout = new QVBoxLayout(this);
}
else
{
setFixedHeight(25);
layout = new QHBoxLayout(this);
}
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(2);
layout->setAlignment(Qt::AlignJustify);
if(title.isEmpty() == false) {
titleLabel = new QLabel(this);
titleLabel->setObjectName("text_normal_label");
titleLabel->setText(title);
layout->addWidget(titleLabel);
}
QJsonObject obj = CFG::items.at(object).toObject();
//foreach (QString eachTitle, titles) {
QJsonArray value_strings = obj.value("value_strings").toArray();
for(int i=0;i<value_strings.size();i++) {
QRadioButton* btn = new QRadioButton(this);
btn->setObjectName("settings");
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
btn->setText(value_strings.at(i).toString());
if(rowType == true)
{
btn->setFixedHeight(25);
}
connect(btn,SIGNAL(clicked()),SLOT(onSelected()));
layout->addWidget(btn);
buttons.append(btn);
}
if(buttons.count() <= realIndex(obj.value("current").toInt()))
{
obj.insert("current",QJsonValue(0));
}
buttons[realIndex(obj.value("current").toInt())]->setChecked(true);
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
}
RMRadioButtons::RMRadioButtons(QWidget *parent,
QString title,
int object) : QWidget(parent),
RMValueSelector(object)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
//setObjectName("test_widget");
setFixedHeight(25);
layout = new QHBoxLayout(this);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(2);
layout->setAlignment(Qt::AlignJustify);
if(title.isEmpty() == false) {
titleLabel = new QLabel(this);
titleLabel->setObjectName("text_normal_label");
titleLabel->setText(title);
layout->addWidget(titleLabel);
}
QJsonObject obj = CFG::items.at(object).toObject();
//foreach (QString eachTitle, titles) {
QJsonArray value_strings = obj.value("value_strings").toArray();
for(int i=0;i<value_strings.size();i++) {
QRadioButton* btn = new QRadioButton(this);
btn->setObjectName("settings");
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
btn->setText(value_strings.at(i).toString());
connect(btn,SIGNAL(clicked()),SLOT(onSelected()));
layout->addWidget(btn);
buttons.append(btn);
}
if(buttons.count() > realIndex(obj.value("current").toInt()))
{
buttons[realIndex(obj.value("current").toInt())]->setChecked(true);
}
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
}
void RMRadioButtons::onSelected()
{
QJsonObject obj = CFG::items.at(_object).toObject();
QRadioButton* btn = qobject_cast<QRadioButton*>(sender());
int index = buttons.indexOf(btn);
obj.insert("current",QJsonValue(realValue(index)));
CFG::items.replace(_object,obj);
emit selected(index);
}
void RMRadioButtons::onUpdateByValue()
{
QJsonObject obj = CFG::items.at(_object).toObject();
buttons[realIndex(obj.value("current").toInt())]->setChecked(true);
}
#else // #if (USE_JSON_SETTINGS)
RMRadioButtons::RMRadioButtons(QWidget *parent,
QString title,
QStringList titles,
unsigned char* value,
bool rowType,
QList<int> indexMap
) : QWidget(parent), RMValueSelector(value,indexMap)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
//setObjectName("test_widget");
if(rowType == true)
{
layout = new QVBoxLayout(this);
}
else
{
setFixedHeight(25);
layout = new QHBoxLayout(this);
}
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(2);
layout->setAlignment(Qt::AlignJustify);
if(title.isEmpty() == false) {
titleLabel = new QLabel(this);
titleLabel->setObjectName("text_normal_label");
titleLabel->setText(title);
layout->addWidget(titleLabel);
}
foreach (QString eachTitle, titles) {
QRadioButton* btn = new QRadioButton(this);
btn->setObjectName("settings");
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
btn->setText(eachTitle);
if(rowType == true)
{
btn->setFixedHeight(25);
}
connect(btn,SIGNAL(clicked()),SLOT(onSelected()));
layout->addWidget(btn);
buttons.append(btn);
}
if(buttons.count() <= realIndex(*_value))
{
*_value = 0;
}
buttons[realIndex(*_value)]->setChecked(true);
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
}
RMRadioButtons::RMRadioButtons(QWidget *parent,
QString title,
QStringList titles,
unsigned char* value,
QList<int> indexMap) : QWidget(parent),
RMValueSelector(value,indexMap)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
//setObjectName("test_widget");
setFixedHeight(25);
layout = new QHBoxLayout(this);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(2);
layout->setAlignment(Qt::AlignJustify);
if(title.isEmpty() == false) {
titleLabel = new QLabel(this);
titleLabel->setObjectName("text_normal_label");
titleLabel->setText(title);
layout->addWidget(titleLabel);
}
foreach (QString eachTitle, titles) {
QRadioButton* btn = new QRadioButton(this);
btn->setObjectName("settings");
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
btn->setText(eachTitle);
connect(btn,SIGNAL(clicked()),SLOT(onSelected()));
layout->addWidget(btn);
buttons.append(btn);
}
if(buttons.count() > realIndex(*_value))
{
buttons[realIndex(*_value)]->setChecked(true);
}
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
}
int RMRadioButtons::currentIndex()
{
for(int i=0;i<buttons.size();i++) {
if(buttons[i]->isChecked()) {
return i;
}
}
return -1;
}
void RMRadioButtons::setCurrentIndex(int index)
{
for(int i=0;i<buttons.size();i++) {
buttons[i]->setChecked(i == index);
}
}
void RMRadioButtons::onSelected()
{
QRadioButton* btn = qobject_cast<QRadioButton*>(sender());
int index = buttons.indexOf(btn);
*_value = realValue(index);
emit selected(index);
}
void RMRadioButtons::onUpdateByValue()
{
//qInfo() << buttons[0]->text() << "value:" << *_value << "_indexMap:" << _indexMap.size() << realIndex(*_value) << __FUNCTION__;
buttons[realIndex(*_value)]->setChecked(true);
}
#endif // #else // #if (USE_JSON_SETTINGS)
void RMRadioButtons::paintEvent(QPaintEvent *pe)
{
Q_UNUSED(pe);
QStyleOption o;
o.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}

View File

@@ -0,0 +1,39 @@
#ifndef RM_RADIO_BUTTONS_H
#define RM_RADIO_BUTTONS_H
#include <QWidget>
#include <QRadioButton>
#include <QHBoxLayout>
#include <QPaintEvent>
#include <QLabel>
#include "rm_value_selector.h"
class RMRadioButtons : public QWidget, public RMValueSelector
{
Q_OBJECT
public:
#if (USE_JSON_SETTINGS)
explicit RMRadioButtons(QWidget *parent,QString title, int object);
explicit RMRadioButtons(QWidget *parent,QString title, int object, bool rowType);
#else // USE_JSON_SETTINGS
explicit RMRadioButtons(QWidget *parent,QString title, QStringList titles,unsigned char* value, QList<int> indexMap = QList<int>());
explicit RMRadioButtons(QWidget *parent,QString title, QStringList titles,unsigned char* value, bool rowType = false,QList<int> indexMap = QList<int>());
#endif // USE_JSON_SETTINGS
QBoxLayout* layout;
//QHBoxLayout* layout;
QLabel* titleLabel;
void setCurrentIndex(int index);
int currentIndex();
private:
QList<QRadioButton*> buttons;
void paintEvent(QPaintEvent *pe);
signals:
void selected(int index);
private slots:
void onSelected();
void onUpdateByValue();
};
#endif // RM_RADIO_BUTTONS_H

View File

@@ -0,0 +1,246 @@
#include "rm_setting_time.h"
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON)
#include "rm_include.h"
#include <QStyleOption>
#include <QPainter>
#include <QLabel>
#include <QDebug>
#include <QCheckBox>
#include <QDateTime>
#include <QDir>
#include <QFile>
#include "../ui/rm_button.h"
#include "rm_settings_window_base.h"
#include "../ui/rm_widget_checkbox.h"
RMSettingTime::RMSettingTime(QWidget *parent) : QGroupBox(parent)
{
setFixedHeight(100);
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
setObjectName("settings");
// 日時
//#if (LIVE_LANGUAGE_CHANGE)
// if(RMLanguage::isJP() == false)
// {
// setTitle("Time");
// }
// else {
//#else
setTitle(MKU8("\xe6\x97\xa5\xe6\x99\x82"));
//#endif
//#if (LIVE_LANGUAGE_CHANGE)
// }
//#endif
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(4,2,4,2);
layout->setSpacing(3);
QSpacerItem* space = new QSpacerItem(0,10);
layout->addSpacerItem(space);
// パソコンの時刻と同期
check = new RMWidgetCheckBox(this);
//#if (LIVE_LANGUAGE_CHANGE)
// if(RMLanguage::isJP() == false)
// {
// check->setText("PC Time Sync.");
// }
// else {
//#else
check->setText(MKU8("\xe3\x83\x91\xe3\x82\xbd\xe3\x82\xb3\xe3\x83\xb3\xe3\x81\xae\xe6\x99\x82\xe5\x88\xbb\xe3\x81\xa8\xe5\x90\x8c\xe6\x9c\x9f"));
//#endif // LIVE_LANGUAGE_CHANGE
//#if (LIVE_LANGUAGE_CHANGE)
// }
//#endif
layout->addWidget(check);
// 시계 기능 없음
#if !(SETTINGS_TIME_TYPE2)
connect(check,SIGNAL(clicked()),SLOT(onCheckBoxTimeSync()));
#endif
check->setStyleSheet("font-size: 13px;color : white;");
QWidget* timeWidget = new QWidget(this);
layout->addWidget(timeWidget);
QHBoxLayout* timeLayout = new QHBoxLayout(timeWidget);
date = new QDateEdit(timeWidget);
date->setCalendarPopup(true);
date->setStyleSheet("font-family: Arial;font-size: 14px;");
timeLayout->addWidget(date);
time = new QTimeEdit(timeWidget);
timeLayout->addWidget(time);
time->setStyleSheet("font-family: Arial;font-size: 14px;");
time->setDisplayFormat("AP hh:mm:ss");
QString applyString = MKU8("\xe9\x81\xa9\xe7\x94\xa8");
//#if (LIVE_LANGUAGE_CHANGE)
// if(RMLanguage::isJP() == false)
// {
// applyString = "Apply";
// }
//#endif
#if !(SETTINGS_TIME_TYPE2)
#if (LIVE_LANGUAGE2)
RMButton* applyButton = RMButton::create2(timeWidget,timeLayout,"button","apply",QSize(60,30));
#else // LIVE_LANGUAGE2
RMButton* applyButton = RMButton::create(timeWidget,timeLayout,"button",applyString,QSize(60,30));
#endif // LIVE_LANGUAGE2
applyButton->setText(applyString);
connect(applyButton,SIGNAL(clicked()),this,SLOT(onSave()));
#endif // SETTINGS_TIME_TYPE2
_syncTimer = NULL;
// 읽어 오기는 한다 (나머지 공간에 저장값 그대로 유지하기 위해)
memset(_buffer,0,TIME_SET_FILE_SIZE);
QString timePath = QDir::cleanPath(RMSettingsWindowBase::lastSettingDisk + "//timeset.txt");
if(QFile::exists(timePath))
{
FILE* f = fopen(timePath.toLocal8Bit(),"r+b");
if(f != NULL)
{
fread(_buffer,1,TIME_SET_FILE_SIZE,f);
fclose(f);
//_readFromBuffer();
}
}
onSyncTime();
}
//void RMSettingTime::_readFromBuffer()
//{
//// 0x10 2BYTE 2019 // 년
//// 0x12 2BYTE 01 // 월
//// 0x14 2BYTE 01 // 일
//// 0x16 2BYTE 01 // 시
//// 0x18 2BYTE 00 // 분
//// 0x1A 2BYTE 00 // 초
// int y = _buffer[0x11] << 8 | _buffer[0x10];
// int m = _buffer[0x13] << 8 | _buffer[0x12];
// int d = _buffer[0x15] << 8 | _buffer[0x14];
// int h = _buffer[0x17] << 8 | _buffer[0x16];
// int mm = _buffer[0x19] << 8 | _buffer[0x18];
// int s = _buffer[0x1B] << 8 | _buffer[0x1A];
// //qInfo() << year << month << day << h << m << s;
// QDateTime dt;
// dt.setDate(QDate(y,m,d));
// dt.setTime(QTime(h,mm,s));
// date->setDate(dt.date());
// time->setTime(dt.time());
// qInfo() << dt;
//}
void RMSettingTime::onSave()
{
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
QString timePath = QDir::cleanPath(RMSettingsWindowBase::lastSettingDisk + "//data_time.cfg");
if(QFile::exists(timePath))
{
QFile::remove(timePath);
}
QDateTime dt = date->dateTime();
dt.setTime(time->time());
// 2020 10 21 17 18 28
QString ts = dt.toString("yyyy MM dd HH mm ss");
QFile f(timePath);
if(f.open(QIODevice::WriteOnly))
{
f.write(ts.toUtf8());
f.close();
}
#else
int y = date->date().year();
int m = date->date().month();
int d = date->date().day();
int h = time->time().hour();
int mm = time->time().minute();
int s = time->time().second();
_buffer[0x10] = (y) & 0xFF;
_buffer[0x11] = (y >> 8) & 0xFF;
_buffer[0x12] = (m) & 0xFF;
_buffer[0x13] = (m >> 8) & 0xFF;
_buffer[0x14] = (d) & 0xFF;
_buffer[0x15] = (d >> 8) & 0xFF;
_buffer[0x16] = (h) & 0xFF;
_buffer[0x17] = (h >> 8) & 0xFF;
_buffer[0x18] = (mm) & 0xFF;
_buffer[0x19] = (mm >> 8) & 0xFF;
_buffer[0x1A] = (s) & 0xFF;
_buffer[0x1B] = (s >> 8) & 0xFF;
QString timePath = QDir::cleanPath(RMSettingsWindowBase::lastSettingDisk + "//timeset.txt");
if(QFile::exists(timePath))
{
QFile::remove(timePath);
}
FILE* f = fopen(timePath.toLocal8Bit(),"w+b");
if(f != NULL)
{
fwrite(_buffer,1,TIME_SET_FILE_SIZE,f);
fclose(f);
}
#endif
}
void RMSettingTime::onCheckBoxTimeSync()
{
QCheckBox* checkbox = qobject_cast<QCheckBox *>(QObject::sender());
if(checkbox != NULL)
{
bool turnOn = (checkbox->checkState() != Qt::Unchecked );
_startStopTimer(turnOn);
}
}
void RMSettingTime::_startStopTimer(bool bStart)
{
if(_syncTimer != NULL) {
_syncTimer->stop();
delete _syncTimer;
_syncTimer = NULL;
}
if(bStart) {
_syncTimer = new QTimer(this);
_syncTimer->setSingleShot(false);
_syncTimer->setInterval(1000);
connect(_syncTimer,SIGNAL(timeout()),SLOT(onSyncTime()));
_syncTimer->start();
}
}
void RMSettingTime::onSyncTime()
{
QDateTime d = QDateTime::currentDateTime();
date->setDate(d.date());
time->setTime(d.time());
}
#endif // #if (USE_DEVICE_SETTINGS)

View File

@@ -0,0 +1,41 @@
#ifndef RM_SETTING_TIME_H
#define RM_SETTING_TIME_H
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON)
#include <QWidget>
#include <QGroupBox>
#include <QComboBox>
#include <QList>
#include <QVBoxLayout>
#include <QDateEdit>
#include <QTimeEdit>
#include <QTimer>
#define TIME_SET_FILE_SIZE 28
class RMWidgetCheckBox;
class RMSettingTime : public QGroupBox
{
Q_OBJECT
public:
explicit RMSettingTime(QWidget *parent = nullptr);
QBoxLayout* layout;
RMWidgetCheckBox* check;
private:
QTimer* _syncTimer;
void _startStopTimer(bool bStart);
QDateEdit* date;
QTimeEdit* time;
unsigned char _buffer[TIME_SET_FILE_SIZE];
//void _readFromBuffer();
public slots:
void onSave();
void onCheckBoxTimeSync();
void onSyncTime();
};
#endif // #if (USE_DEVICE_SETTINGS)
#endif // RM_SETTING_TIME_H

View File

@@ -0,0 +1,15 @@
#ifndef RM_SETTINGS_CFG_H
#define RM_SETTINGS_CFG_H
#if (USE_DEVICE_SETTINGS)
#include "../rm_include.h"
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#include "rm_settings_cfg_xdr6688.h"
#elif (RM_MODEL_EMT_KR)
#include "rm_settings_cfg_emt_kr.h"
#else
#include "rm_settings_cfg_standard.h"
#endif
#endif // #if (USE_DEVICE_SETTINGS)
#endif // RM_SETTINGS_CFG_H

View File

@@ -0,0 +1,268 @@
#include "rm_settings_cfg_emt_kr.h"
#include <QFile>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <Windows.h>
#if (USE_DEVICE_SETTINGS && RM_MODEL_EMT_KR)
unsigned char CFG::data[SETTINGS_CFG_SIZE] = {0,};
unsigned char CFG::stored[SETTINGS_CFG_SIZE] = {0,};
EMTINFO CFG::info = {0,};
QJsonArray CFG::items;
QString CFG::cfgPath = "";
QStringList CFG::model_names = QStringList() << "NM5000" << "NP5000" << "MIRROR5" << "PRO5" << "360X";
uint32_t CFG::model_codes[5] = { NM5000, NP5000, MIRROR5, PRO5, A360X};
bool CFG::_loadJSon()
{
// CLEAR
while(CFG::items.count()) {
CFG::items.pop_back();
}
//QString jsonPath = ":/raw/cfg_5102.json";
QString jsonPath = "";
switch(info.model) {
case NM5000:
jsonPath = ":/raw/cfg_nm5000.json";
break;
case NP5000:
jsonPath = ":/raw/cfg_np5000.json";
break;
case MIRROR5:
jsonPath = ":/raw/cfg_mirror5.json";
break;
case PRO5:
jsonPath = ":/raw/cfg_pro5.json";
break;
case A360X:
jsonPath = ":/raw/cfg_360x.json";
break;
default:
return false;
}
QFile file(jsonPath);
if(file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QByteArray data = file.readAll();
file.close();
CFG::items = QJsonDocument::fromJson(data).array();
}
return true;
}
void CFG::_getItems(QJsonArray& in, QJsonArray& ret)
{
for(int i=0;i<in.size();i++) {
QJsonObject obj = in.at(i).toObject();
if(obj.contains("group") && obj.contains("items")) {
_getItems(obj.value("items").toArray(),ret);
}
else {
ret.append(obj);
}
}
}
void CFG::serializeItems(QJsonArray& citems) {
_getItems(CFG::items,citems);
return;
}
void CFG::setDefault()
{
QJsonArray citems;
serializeItems(citems);
for(int i=0;i<citems.size();i++) {
QJsonObject obj = citems.at(i).toObject();
//qInfo() << obj << __FUNCTION__;
if(obj.contains("default") && obj.contains("offset")) {
QString type = obj.value("type").toString();
if(type == "int") {
int offset = obj.value("offset").toInt();
CFG::data[offset] = obj.value("default").toInt();
//qInfo() << obj << __FUNCTION__;
}
}
}
//qInfo() << items << __FUNCTION__;
}
void CFG::backup()
{
memcpy(CFG::stored,CFG::data,SETTINGS_CFG_SIZE);
}
void CFG::restore()
{
memcpy(CFG::data,CFG::stored,SETTINGS_CFG_SIZE);
}
bool CFG::isEdited()
{
return (0 != memcmp(CFG::stored,CFG::data,SETTINGS_CFG_SIZE-sizeof(_EMTINFO)));
}
CFG_ERROR_CODE CFG::load(QString path)
{
CFG_ERROR_CODE r = CFG_UNKNOWN_ERROR;
if(!QFile::exists(path)) {
return CFG_IO_ERROR;
}
FILE* f = fopen(path.toLocal8Bit(),"r+b");
if(f == NULL) {
return CFG_IO_ERROR;
}
unsigned char d[SETTINGS_CFG_SIZE] = {0,};
size_t read = fread(d,1,SETTINGS_CFG_SIZE,f);
fclose(f);
if(read > 0)
{
cfgPath = path;
memcpy(CFG::data,d,read);
// 나머지 영역 초기화???
if(read == SETTINGS_CFG_SIZE) {
memcpy(&CFG::info,&d[SETTINGS_CFG_SIZE-sizeof(_EMTINFO)],sizeof(_EMTINFO));
//setDefault();
r = verifyInfo();
if(r != CFG_SUCCESS) {
return r;
}
_loadJSon();
}
}
else
{
setDefault();
}
CFG::backup(); // 현재 데이터 보존
// CHECKSUM 확인
if(!appUserSettingCheck()) {
return CFG_CHECKSUM_ERROR;
}
return r;
}
CFG_ERROR_CODE CFG::verifyInfo()
{
if(info.magic != 0xA5A5CC33) {
return CFG_WRONG_FILE;
}
// Magnus : 5101
// Trinity : 5102
// Mirror5 : 5103
// Pro5 : 5104
// 360X : 5105
// qInfo() << info.file1 << info.file2 << __FUNCTION__; // ?? 값이 정확하지 않음
// qInfo() << "MODEL CODE:" << info.model << "FILE SIZE:" << info.file1 << info.file2 << __FUNCTION__;
if(info.model < 5101 || info.model > 5105)
{
return CFG_WRONG_FILE;
}
return CFG_SUCCESS;
}
QString CFG::modelName()
{
for(int i=0;i<model_names.size();i++) {
if(model_codes[i] == info.model) {
return model_names.at(i);
}
}
return "UNKNOWN";
}
uint32_t CFG::version()
{
return info.version;
}
void CFG::clear()
{
memset(CFG::stored,0,SETTINGS_CFG_SIZE);
memset(CFG::data,0,SETTINGS_CFG_SIZE);
}
bool CFG::save(QString path)
{
bool bSuccess = false;
DWORD dwAttrib = ::GetFileAttributes((LPCTSTR)path.utf16());
if((dwAttrib & FILE_ATTRIBUTE_HIDDEN)) {
::SetFileAttributes((LPCTSTR)path.utf16(),FILE_ATTRIBUTE_NORMAL);
}
FILE* f = fopen(path.toLocal8Bit(),"w+b");
if(f != NULL)
{
if(isEdited())
{
CFG::data[SD_VIEWSETTING_OFFSET] = 1;
_updateCheckSum(); // 다시 계산
}
size_t write = 0;
write = fwrite(CFG::data,1,SETTINGS_CFG_SIZE,f);
bSuccess = write > 0;
fclose(f);
::SetFileAttributes((LPCTSTR)path.utf16(),FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN);
}
CFG::backup();
return bSuccess;
}
#define COMBINE_16(h, l) (uint16_t)((((uint16_t)h)<<8) | (uint16_t)l)
uint16_t CFG::checkSum() // appGetSum16_Emt(uint16_t *Buf, uint32_t Size)
{
// 마지막 1은?
uint32_t Size = ((SETTINGS_CFG_SIZE - sizeof(_EMTINFO)) / 2) - 1;
//uint8_t bSettingFileOK = TRUE;
uint16_t* pbuf = (uint16_t*)&data[0];
uint16_t Sum = 0;
uint32_t SumTemp = 0;
while( Size )
{
SumTemp += (uint32_t)pbuf[--Size];
}
Sum = (uint16_t)((uint16_t)((SumTemp >> 16) & 0x0000ffff) | (uint16_t)(SumTemp & 0x0000ffff));
return Sum;
}
void CFG::_updateCheckSum()
{
uint16_t c = checkSum();
data[SETTINGS_CFG_SIZE-sizeof(_EMTINFO)-2] = ((c >> 8) & 0xFF);
data[SETTINGS_CFG_SIZE-sizeof(_EMTINFO)-1] = (c & 0xFF);
}
bool CFG::appUserSettingCheck()
{
/*
uint16_t* pbuf = (uint16_t*)&data[0];
uint16_t checkSum, CalCheckSum;
// 설정 영역의 마지막 2BYTE
uint8_t checkData1 = data[SETTINGS_CFG_SIZE-sizeof(_EMTINFO)-2];
uint8_t checkData2 = data[SETTINGS_CFG_SIZE-sizeof(_EMTINFO)-1];
const uint32_t dataSize = SETTINGS_CFG_SIZE - sizeof(_EMTINFO);
checkSum = COMBINE_16(checkData1, checkData2);
CalCheckSum = appGetSum16_Emt(pbuf, (dataSize / 2)); // sizeof(uiParamSetting_t)
return (checkSum != CalCheckSum);
*/
// 설정 영역의 마지막 2BYTE
uint8_t checkData1 = data[SETTINGS_CFG_SIZE-sizeof(_EMTINFO)-2];
uint8_t checkData2 = data[SETTINGS_CFG_SIZE-sizeof(_EMTINFO)-1];
//qInfo() << "CHECKED:" << COMBINE_16(checkData1,checkData2) << "CALCED:" << checkSum() <<__FUNCTION__;
return (COMBINE_16(checkData1,checkData2) == checkSum());
}
//uint16_t CFG::checkSum()
//{
// uint16_t* pbuf = (uint16_t*)&data[0];
// const uint32_t dataSize = SETTINGS_CFG_SIZE - sizeof(_EMTINFO);
// return appGetSum16_Emt(pbuf, (dataSize / 2) - 1);
//}
#endif // #if (USE_DEVICE_SETTINGS && RM_MODEL_EMT_KR)

View File

@@ -0,0 +1,101 @@
#ifndef RM_SETTINGS_CFG_EMT_KR_H
#define RM_SETTINGS_CFG_EMT_KR_H
#if (USE_DEVICE_SETTINGS && RM_MODEL_EMT_KR)
#include <QObject>
#include <QJsonArray>
#include <stdint.h>
#define SETTINGS_CFG_SIZE 248 // 248 BYTE
typedef enum
{
CFG_SUCCESS = 0, // 성공
CFG_IO_ERROR = 1, // 파일 열기, 읽기 실패
CFG_WRONG_FILE = 2, // 잘못된 파일 에러
CFG_CHECKSUM_ERROR = 3, // 체크섬 확인실패
// CFG_MODEL_CODE_ERROR = 3, // 모델코드 에러 UI 에서 확인
CFG_UNKNOWN_ERROR = 99, // ??
} CFG_ERROR_CODE;
typedef struct _EMTINFO
{
uint32_t magic;
uint32_t model; //micom ver : 31 ~ 16, model : 15 ~ 0
uint32_t version;//F/W version
uint32_t file1; //1 bit + 31 bit ( 1 : file exist, 31 : file size )
uint32_t file2; //1 bit + 31 bit ( 1 : file exist, 31 : file size )
} EMTINFO;
// 제품 코드에 따라 설정항목이 달라짐
// NM5000(5101),MIRROR5(5103) = MAGNUS
// NP5000(5102),PRO5(5104) = TRINITY
typedef enum
{
NM5000 = 5101, // NM5000 OFFLINE
NP5000 = 5102, // TRINITY OFFLINE
MIRROR5 = 5103, // Mirror5(MAGNUS ONLINE)
PRO5 = 5104, // Pro5(TRINITY ONLINE)
A360X = 5105, // Cyclops = 360X
} MODEL_CODE;
// 설정 편집시 1로 지정해야 하는 OFFSET
#define SD_VIEWSETTING_OFFSET 143
class CFG : public QObject
{
Q_OBJECT
public:
static QString cfgPath;
static QStringList model_names;// = QStringList() << "NM5000" << "NP5000";
static uint32_t model_codes[];// = { 5101, 5102};
static QJsonArray items;
static QJsonObject _findType(QString key,int* index);
static unsigned char data[SETTINGS_CFG_SIZE];
static unsigned char stored[SETTINGS_CFG_SIZE];
static EMTINFO info;
//! \brief 모델에 따른 JSON 파일 확인
//! \return
static bool _loadJSon();
static CFG_ERROR_CODE load(QString path);
static bool save(QString path);
static void backup();
static void restore();
static void setDefault();
//! \brief 데이터 수정여부 확인
//! \return
static bool isEdited();
static void clear();
static QString modelName();
static uint32_t version();
private:
//! \brief 모델정보등 검증
//! \return
static CFG_ERROR_CODE verifyInfo();
//static uint16_t appGetSum16_Emt(); // uint16_t *Buf, uint32_t Size
static bool appUserSettingCheck();
// 현재 데이터 CHECKSUM 계산하여 반영
static void _updateCheckSum();
// 설정항목을 그룹 제외하고 직렬화
static void _getItems(QJsonArray& in, QJsonArray& ret);
static void serializeItems(QJsonArray& citems);
// checkData1 << 8 | checkData2
//! \brief EMTINFO 를 제외한 데이터를 확인하여
//! \return checkData1 << 8 | checkData2
static uint16_t checkSum();
signals:
public slots:
};
#endif // #if (USE_DEVICE_SETTINGS && RM_MODEL_EMT_KR)
#endif // RM_SETTINGS_CFG_EMT_KR_H

View File

@@ -0,0 +1,301 @@
#include "rm_settings_cfg_standard.h"
#if (USE_DEVICE_SETTINGS && !(RM_MODEL_EMT_KR))
#include <QDebug>
#include <stdio.h>
#include <QFile>
#if !(RM_MODEL == RM_MODEL_TYPE_AN6000)
unsigned char CFG::data[SETTINGS_CFG_SIZE] = {0,};
unsigned char CFG::stored[SETTINGS_CFG_SIZE] = {0,};
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#if (ENCODE_CFG_BASE64)
#include "fm_base64.h"
#endif // ENCODE_CFG_BASE64
QJsonArray CFG::items;
QJsonObject CFG::_findType(QString key, int* index)
{
for(int i=0;i<items.size();i++) {
QJsonObject obj = items.at(i).toObject();
if(obj.value("key").toString() == key) {
*index = i;
return obj;
}
}
*index = -1;
return QJsonObject();
}
#endif // AN6000
#if (ENCODE_CFG_BASE64)
bool CFG::isEncoded = false;
#endif // #if (ENCODE_CFG_BASE64)
void CFG::setDefault()
{
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
// CLEAR
while(CFG::items.count()) {
CFG::items.pop_back();
}
#if (AN6000_YEC)
const char* fname = ":/html/an6000_cfg_yec.json";
#else
const char* fname = ":/html/an6000_cfg.json";
#endif
QFile file(fname); // ":/html/an6000_cfg.json"
if(file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QByteArray data = file.readAll();
file.close();
CFG::items = QJsonDocument::fromJson(data).array();
}
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
for(int i=0;i<items.size();i++) {
QJsonObject obj = items.at(i).toObject();
if(obj.contains("default")) {
QString type = obj.value("type").toString();
if(type == "int") {
obj.insert("current",QJsonValue(obj.value("default").toInt()));
}
else if(type == "text") {
obj.insert("current",QJsonValue(obj.value("default").toString()));
}
items.replace(i,obj); // 반영
}
}
//qInfo() << items << __FUNCTION__;
#else // !RM_MODEL_TYPE_AN6000
// CS-32FH
unsigned char def[SETTINGS_CFG_SIZE] = {0x00,// 0
0x00,// 1
0x00,// 2
0x00,// 3
0x00,// 4
0x00,// 5
0x00,// 6
0x00,// 7
0x00,// 8
0x00,// 9
0x00,// 10
0x00,// 11
0x00,// 12
0x00,// 13
0x00,// 14
0x00,// 15
0x00,// 16
0x00,// 17
0x00,// 18
0x00,// 19
0x00,// 20
0x02,// 21 // SD_SENSOR = SENSOR_MIDDLE
0x00,// 22 // SD_SIZE = SIZE_800x600
0x00,// 23 // SD_FRAME = FRAME_20
0x04,// 24 // SD_VOLUME = VOLUME_4
0x01,// 25 // SD_VOICE = VOICE_ENABLE
0x00 // RESERVED
};
memcpy(CFG::data,def,SETTINGS_CFG_SIZE);
#endif // RM_MODEL_TYPE_AN6000
}
void CFG::backup()
{
#if !(RM_MODEL == RM_MODEL_TYPE_AN6000)
memcpy(CFG::stored,CFG::data,SETTINGS_CFG_SIZE);
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
}
void CFG::restore()
{
#if !(RM_MODEL == RM_MODEL_TYPE_AN6000)
memcpy(CFG::data,CFG::stored,SETTINGS_CFG_SIZE);
#endif // #if !(RM_MODEL == RM_MODEL_TYPE_AN6000)
}
bool CFG::load(QString path)
{
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
// CLEAR
while(CFG::items.count()) {
CFG::items.pop_back();
}
#if (AN6000_YEC)
const char* fname = ":/html/an6000_cfg_yec.json";
#else
const char* fname = ":/html/an6000_cfg.json";
#endif
QFile file(fname); // ":/html/an6000_cfg.json"
if(file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QByteArray data = file.readAll();
file.close();
CFG::items = QJsonDocument::fromJson(data).array();
setDefault();
}
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
bool bSuccess = false;
if(QFile::exists(path)) {
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#if (ENCODE_CFG_BASE64)
QStringList lines = FMBase64::load(path,&isEncoded);
qInfo() << lines << __FUNCTION__;
for(int i=0;i<lines.size();i++) {
QString line = lines.at(i);
QStringList items = line.split('=');
if(items.size() != 2) {
qInfo() << "ERROR:" << line << __FUNCTION__;
continue;
}
QString key = items.at(0);
key = key.trimmed();
QString value = items.at(1);
value = value.trimmed();
int kidx = -1;
QJsonObject obj = _findType(key,&kidx);
if(obj.isEmpty() || kidx < 0) {
qInfo() << "KEY ERROR:" << line << __FUNCTION__;
continue;
}
QString otype = obj.value("type").toString();
if(otype == "text") {
obj.insert("current",QJsonValue(value));
CFG::items.replace(kidx,obj);
} else if (otype == "int") {
obj.insert("current",QJsonValue(value.toInt()));
CFG::items.replace(kidx,obj);
}
}
#else // #if (ENCODE_CFG_BASE64)
QFile file(path);
if(file.exists() && file.open(QIODevice::ReadOnly))
{
QTextStream in(&file);
while(!in.atEnd()) {
QString line = in.readLine();
QStringList items = line.split('=');
if(items.size() != 2) {
qInfo() << "ERROR:" << line << __FUNCTION__;
continue;
}
QString key = items.at(0);
key = key.trimmed();
QString value = items.at(1);
value = value.trimmed();
int kidx = -1;
QJsonObject obj = _findType(key,&kidx);
if(obj.isEmpty() || kidx < 0) {
qInfo() << "KEY ERROR:" << line << __FUNCTION__;
continue;
}
QString otype = obj.value("type").toString();
if(otype == "text") {
obj.insert("current",QJsonValue(value));
CFG::items.replace(kidx,obj);
} else if (otype == "int") {
obj.insert("current",QJsonValue(value.toInt()));
CFG::items.replace(kidx,obj);
}
}
file.close();
}
#endif // #else // #if (ENCODE_CFG_BASE64)
#else // !AN6000
FILE* f = fopen(path.toLocal8Bit(),"r+b");
if(f != NULL)
{
unsigned char d[SETTINGS_CFG_SIZE] = {0,};
size_t read = fread(d,1,SETTINGS_CFG_SIZE,f);
fclose(f);
#if (CFG_SEARCH_DISK)
bSuccess = read > 0 && strncmp(SETTINGS_TAG,(const char*)d,strlen(SETTINGS_TAG)) == 0;
#else
bSuccess = read > 0;
#endif
if(bSuccess == true)
{
memcpy(CFG::data,d,SETTINGS_CFG_SIZE);
}
else
{
setDefault();
}
}
#endif // #else // !AN6000
}
CFG::backup(); // 현재 데이터 보존
return bSuccess;
}
bool CFG::save(QString path)
{
bool bSuccess = false;
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#if (ENCODE_CFG_BASE64)
QStringList lines = QStringList();
for(int i=0;i<items.size();i++) {
QJsonObject obj = items.at(i).toObject();
QString type = obj.value("type").toString();
QString line;
line += obj.value("key").toString();
line += "=";
if(type == "int") {
line += QString::number(obj.value("current").toInt());
} else if (type == "text") {
line += obj.value("current").toString();
}
lines.append(line);
}
FMBase64::save(path,lines,true); // isEncoded // 항상 인코딩된 상태로 저장
#else // ENCODE_CFG_BASE64
QFile file(path);
if (file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
//stream << "something" << endl;
for(int i=0;i<items.size();i++) {
QJsonObject obj = items.at(i).toObject();
QString type = obj.value("type").toString();
QString line;
line += obj.value("key").toString();
line += "=";
if(type == "int") {
line += QString::number(obj.value("current").toInt());
} else if (type == "text") {
line += obj.value("current").toString();
}
stream << line << endl;
qInfo() << line << __FUNCTION__;
}
file.close();
}
#endif // ENCODE_CFG_BASE64
#else // !AN6000
FILE* f = fopen(path.toLocal8Bit(),"w+b");
if(f != NULL)
{
size_t write = fwrite(CFG::data,1,SETTINGS_CFG_SIZE,f);
bSuccess = write > 0;
fclose(f);
}
#endif // #if (RM_MODEL = RM_MODEL_TYPE_AN6000)
CFG::backup();
return bSuccess;
}
#endif // #if (USE_DEVICE_SETTINGS && !(RM_MODEL_EMT_KR))

View File

@@ -0,0 +1,54 @@
#ifndef RM_SETTINGS_CFG_STANDARD_H
#define RM_SETTINGS_CFG_STANDARD_H
#if (USE_DEVICE_SETTINGS && !(RM_MODEL_EMT_KR))
#include "../rm_include.h"
#include <QObject>
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#include <QJsonArray>
#endif
#if !(RM_MODEL == RM_MODEL_TYPE_AN6000)
#define SETTINGS_CFG_SIZE 0x2D // 45 BYTE
typedef enum
{
SD_SENSOR = 21, // SENSOR_LOW = 0, SENSOR_LOW_MID, SENSOR_MIDDLE, SENSOR_MID_HI,SENSOR_HIGH
SD_SIZE = 22, // SIZE_800x600, SIZE_640x320
SD_FRAME = 23, // FRAME_20, FRAME_25, FRAME_30
SD_VOLUME = 24, // VOLUME_0~5
SD_VOICE = 25, // VOICE_DISABLE, VOICE_ENABLE
} SD_TYPE;
#endif // !RM_MODEL_TYPE_AN6000
class CFG : public QObject
{
Q_OBJECT
public:
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#if (ENCODE_CFG_BASE64)
static bool isEncoded; // 암호화 되지 않은 CFG 파일의 경우 저장시에도 암호화 하지 않음
#endif // ENCODE_CFG_BASE64
static QJsonArray items;
static QJsonObject _findType(QString key,int* index);
#else
static unsigned char data[SETTINGS_CFG_SIZE];
static unsigned char stored[SETTINGS_CFG_SIZE];
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
static bool load(QString path);
static bool save(QString path);
static void backup();
static void restore();
static void setDefault();
signals:
public slots:
};
//#endif // #if (RM_MODEL == RM_SETTINGS_CFG_STANDARD_H)
#endif // (USE_DEVICE_SETTINGS && !(RM_MODEL_EMT_KR))
#endif // RM_SETTINGS_CFG_STANDARD_H

View File

@@ -0,0 +1,199 @@
#include "rm_settings_cfg_xdr6688.h"
#if (USE_DEVICE_SETTINGS)
#include <QDebug>
#include <stdio.h>
#include <QFile>
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
unsigned char CFG::data[SETTINGS_CFG_SIZE] = {0,};
unsigned char CFG::stored[SETTINGS_CFG_SIZE] = {0,};
MODEL_XDR CFG::model = MODEL_XDR_NOT_DEFINED;
void CFG::setDefault()
{
switch (CFG::model) {
case MODEL_XDR_66:
CFG66::setDefault();
break;
case MODEL_XDR_88:
CFG88::setDefault();
break;
default:
break;
}
}
void CFG::backup()
{
memcpy(CFG::stored,CFG::data,SETTINGS_CFG_SIZE);
}
void CFG::restore()
{
memcpy(CFG::data,CFG::stored,SETTINGS_CFG_SIZE);
}
QString CFG::modelName()
{
switch (CFG::model)
{
case MODEL_XDR_66:
return "XDR-66";
case MODEL_XDR_88:
return "XLDR-88";
default:
qInfo() << "MODEL NOT DEFINED";
}
return "";
}
bool CFG::setModel(QString modelString)
{
bool bSuccess = true;
if(modelString == "XDR-66") {
CFG::model = MODEL_XDR_66;
}
else if(modelString == "XLDR-88") {
CFG::model = MODEL_XDR_88;
}
else
{
bSuccess = false;
}
return bSuccess;
}
bool CFG::load(QString path)
{
bool bSuccess = false;
if(QFile::exists(path)) {
FILE* f = fopen(path.toLocal8Bit(),"r+b");
if(f != NULL)
{
size_t readSize = (model == MODEL_XDR_66) ? SETTINGS_CFG_SIZE : SETTINGS_CFG_SIZE_88;
unsigned char d[SETTINGS_CFG_SIZE] = {0,};
size_t read = fread(d,1,SETTINGS_CFG_SIZE,f);
fclose(f);
#if (CFG_SEARCH_DISK)
bSuccess = read > 0 && strncmp(SETTINGS_TAG,(const char*)d,strlen(SETTINGS_TAG)) == 0;
#else
bSuccess = read > 0;
#endif
if(bSuccess == true)
{
memcpy(CFG::data,d,read);
// EMS 데이터로 나머지는 초기화 해야함
if(read != readSize) {
setDefault();
}
}
else
{
setDefault();
}
}
}
CFG::backup(); // 현재 데이터 보존
return bSuccess;
}
bool CFG::save(QString path)
{
bool bSuccess = false;
FILE* f = fopen(path.toLocal8Bit(),"w+b");
if(f != NULL)
{
size_t write = 0;
if(model == MODEL_XDR_88) {
write = fwrite(CFG::data,1,SETTINGS_CFG_SIZE_88,f);
}
else {
write = fwrite(CFG::data,1,SETTINGS_CFG_SIZE,f);
}
bSuccess = write > 0;
fclose(f);
}
CFG::backup();
return bSuccess;
}
void CFG66::setDefault() {
// XDR-66
// SD_SENSOR = 21, // SENSOR_LOW = 0, SENSOR_LOW_MID, SENSOR_MIDDLE, SENSOR_MID_HI,SENSOR_HIGH
// SD_SIZE = 22, // SIZE_800x600, SIZE_640x320
// SD_FRAME = 23, // FRAME_20, FRAME_25, FRAME_30
// SD_VOLUME = 24, // VOLUME_0~5
// SD_VOICE = 25, // VOICE_DISABLE, VOICE_ENABLE
unsigned char def[SETTINGS_CFG_SIZE] = { 0x00,// 0
0x00,// 1
0x00,// 2
0x00,// 3
0x00,// 4
0x00,// 5
0x00,// 6
0x00,// 7
0x00,// 8
0x00,// 9
0x00,// 10
0x00,// 11
0x00,// 12
0x00,// 13
0x00,// 14
0x00,// 15
0x00,// 16
0x00,// 17
0x00,// 18
0x00,// 19
0x00,// 20
0x02,// 21 // SD_SENSOR = SENSOR_MIDDLE
0x00,// 22 // SD_SIZE = SIZE_800x600
0x00,// 23 // SD_FRAME = FRAME_20
0x04,// 24 // SD_VOLUME = VOLUME_4
0x01,// 25 // SD_VOICE = VOICE_ENABLE
0x00 // RESERVED
};
// 부분만 초기화함
memcpy(&CFG::data[21],&def[21],5);
}
void CFG88::setDefault() {
// XLDR-88
unsigned char def[SETTINGS_CFG_SIZE_88] = { 0x00,// 0
0x00,// 1
0x00,// 2
0x00,// 3
0x00,// 4
0x00,// 5
0x00,// 6
0x00,// 7
0x00,// 8
0x00,// 9
0x00,// 10
0x00,// 11
0x00,// 12
0x00,// 13
0x00,// 14
0x00,// 15
0x00,// 16
0x01,// 17 // SD88_SCREEN_SAVEER
0x02,// 18 // SD88_SCREEN_PIP
0x03,// 19 // SD88_SPEAKER
0x01,// 20 // SD88_MIC
0x00,// 21 // SD88_VOLUME
0x02,// 22 // SD88_GSENSOR_NORMAL
0x02,// 23 // SD88_GSENSOR_PARKING
0x00,// 24 // SD88_PARKING_ON (2021/04/01 OFF)
0x00,// 25 // SD88_PARKING_VOLTAGE
0x00,// 26 // SD88_VIDEO_RESOLUTION
0x01,// 27 // SD88_ADMIN_PW (SD88_VIDEO_QUALITY) -> 비밀번호 ON:/OFF1
0x02,// 28 // SD88_VIDEO_FRAME
0x01,// 29 // SD88_VIDEO_SUB_CAMERA
0x01,// 30 // SD88_VIDEO_HDR
0x01,// 31 // SD88_VIDEO_NIGHT_VISION (2021/04/01 OFF)
};
// 부분만 초기화 함
//memcpy(&CFG::data[11],&def[11],21);
memcpy(&CFG::data[17],&def[17],15);
//memcpy(CFG::data,def,SETTINGS_CFG_SIZE_88);
}
#endif // #if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#endif // #if (USE_DEVICE_SETTINGS)

View File

@@ -0,0 +1,106 @@
#ifndef RM_SETTINGS_CFG_XDR6688_H
#define RM_SETTINGS_CFG_XDR6688_H
#if (USE_DEVICE_SETTINGS)
#include "../rm_include.h"
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#include <QObject>
#define SETTINGS_CFG_SIZE 45 // 45 BYTE
#define SETTINGS_CFG_SIZE_88 0x20 // 32 BYTE
typedef enum
{
MODEL_XDR_NOT_DEFINED = 0,
MODEL_XDR_66 = 1,
MODEL_XDR_88 = 2,
} MODEL_XDR;
typedef enum
{
SD_SENSOR = 21, // SENSOR_LOW = 0, SENSOR_LOW_MID, SENSOR_MIDDLE, SENSOR_MID_HI,SENSOR_HIGH
SD_SIZE = 22, // SIZE_800x600, SIZE_640x320
SD_FRAME = 23, // FRAME_20, FRAME_25, FRAME_30
SD_VOLUME = 24, // VOLUME_0~5
SD_VOICE = 25, // VOICE_DISABLE, VOICE_ENABLE
} SD_TYPE_66;
typedef enum
{
SD88_ADMIN_PW = 27, // 관리자 암호 지정 0:ON 1:OFF
// SYSTEM システム
SD88_SCREEN_SAVEER = 17, // 画面表示, 1分後画面OFF, 常時ON, 1分後時計画面
SD88_SCREEN_PIP = 18, // 録画画面, フロント, リア, フロント/リア,リア/フロント
SD88_SPEAKER = 19, // Off,1 Level,2 Level,3 Level,4 Level,5 Level
SD88_MIC = 20, // Off, On
// STORAGE, メモリ割当
SD88_VOLUME = 21, // メモリ割当: 常時録画重視, 駐車録画重視, イベント録画重視
// G-SENSOR, センサー感度
SD88_GSENSOR_NORMAL = 22, // 常時センサー感度: Off, Low, Middle-Low, Middle, Middle-High, High
SD88_GSENSOR_PARKING = 23, // 駐車センサー感度: Off, Low, Middle-Low, Middle, Middle-High, High
// PARKING MODE, 駐車録画
SD88_PARKING_ON = 24, // 駐車録画機能: Off, On
SD88_PARKING_VOLTAGE = 25, // 放電遮断電圧: 표시만
// VIDEO, 録画設定
SD88_VIDEO_RESOLUTION = 26, // 解像度: "1920*1080", "1280*720"
//SD88_VIDEO_QUALITY = 27, // 画質: 低,中, 高
SD88_VIDEO_FRAME = 28, // 録画フレーム数: 4.9,19.1,29.1
SD88_VIDEO_SUB_CAMERA = 29, // サブカメラ録画: Off, On
SD88_VIDEO_HDR = 30, // HDR: Off, On
SD88_VIDEO_NIGHT_VISION = 31, // ナイトビジョン: Off, On
} SD_TYPE_88;
class CFG : public QObject
{
Q_OBJECT
public:
static MODEL_XDR model;
static QString modelName();
static bool setModel(QString modelString);
static unsigned char data[SETTINGS_CFG_SIZE];
static unsigned char stored[SETTINGS_CFG_SIZE];
static bool load(QString path);
static bool save(QString path);
static void backup();
static void restore();
static void setDefault();
signals:
public slots:
};
// XDR-66
class CFG66 : public CFG
{
Q_OBJECT
public:
static void setDefault();
signals:
public slots:
};
// XDR-88
class CFG88 : public CFG
{
Q_OBJECT
public:
static void setDefault();
signals:
public slots:
};
#endif // #if (RM_MODEL)
#endif
#endif // RM_SETTINGS_CFG_XDR6688_H

View File

@@ -0,0 +1,442 @@
#include "rm_settings_window_base.h"
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON)
#include "../fm_dimensions.h"
#include "../ui/title_widget.h"
#include "rm_combo_box.h"
#include "rm_radio_buttons.h"
#include "rm_group_combo_box.h"
#include "rm_group_radio_buttons.h"
#include "../core/fm_strings.h"
#include "rm_settings_cfg.h"
#include <QComboBox>
#include <QGridLayout>
#include <QDir>
#if (SETTINGS_WINDOW_SCROLL)
#include <QScrollArea>
#include <QScrollBar>
#include "../ui/fm_colors.h"
#endif
#if (DETECT_SETTING_USB_EJECT && !DETECT_USB_CHANGE)
#include "../core/rm_usb.h"
#include "../rm_application.h"
#endif
// 문자열 처리 UTF
// https://www.branah.com/unicode-converter
//bool RMSettingsWindowBase::loaded = false;
QString RMSettingsWindowBase::lastSettingDisk = "";
//const int gComboBoxWidth = 200;
//const int gTitleWidth = 50;
#if (RM_MODEL_EMT_KR)
static const QStringList gOnOff = QStringList() << "ON" << "OFF";
#else // RM_MODEL_EMT_KR
static const QStringList gOnOff = QStringList() << MKU8("\xe3\x82\xaa\xe3\x83\xb3") << MKU8("\xe3\x82\xaa\xe3\x83\x95");
#endif // RM_MODEL_EMT_KR
static const QStringList gEOnOff = QStringList() << "ON" << "OFF";
#if (RM_MODEL_EMT_KR)
RMSettingsWindowBase::RMSettingsWindowBase(QWidget *parent) : RMPopup(parent,FMS::txt("settings"),"")
#else
RMSettingsWindowBase::RMSettingsWindowBase(QWidget *parent) : RMPopup(parent,"","title_settings.png")
#endif
{
// 이미 로딩됨
#if !(RM_MODEL_EMT_KR)
QString path = QDir::cleanPath(lastSettingDisk + SETTINGS_FILE_NAME);
// 모델 디스크가 아닐 경우
#if (MULTI_MODEL_VIEWER)
if(RMApp::isModelDisk(lastSettingDisk,NULL) == false)
#else // MULTI_MODEL_VIEWER
if(RMApp::isModelDisk(lastSettingDisk) == false)
#endif // MULTI_MODEL_VIEWER
{
CFG::setDefault();
#if !(DO_NOT_MAKE_CFG)
CFG::save(path);
#endif
}
else {
CFG::load(path);
}
#endif // #if !(RM_MODEL_EMT_KR)
#if (SETTINGS_WINDOW_SCROLL)
this->setFixedSize(SETTINGS_WINDOW_WIDTH,SETTINGS_WiNDOW_SCROLL_HEIGHT);
#else
this->setFixedSize(SETTINGS_WINDOW_WIDTH,SETTINGS_WiNDOW_HEIGHT);
#endif
//_contentWidget->setObjectName("bg_dark_widget");
layout = new QHBoxLayout(_contentWidget);
layout->setMargin(8);
layout->setSpacing(8);
QWidget* bwLeft = new QWidget(_buttonWidget);
_buttonLayout->addWidget(bwLeft);
QWidget* bwRight = new QWidget(_buttonWidget);
_buttonLayout->addWidget(bwRight);
QHBoxLayout* blLeft = new QHBoxLayout(bwLeft);
blLeft->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
QHBoxLayout* blRight = new QHBoxLayout(bwRight);
blRight->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
#if (LIVE_LANGUAGE2)
RMButton* defaultButton = RMButton::create2(bwRight,blRight,"button","default",QSize(120,30));
defaultButton->setText(FMS::txt("default"));
connect(defaultButton,SIGNAL(clicked()),SLOT(onDefault()));
RMButton* okButton = RMButton::create2(bwRight,blRight,"button","ok",QSize(120,30));
okButton->setText(FMS::txt("ok"));
connect(okButton,SIGNAL(clicked()),this,SLOT(onSaveAnAccept()));
RMButton* cancelButton = RMButton::create2(bwRight,blRight,"button","cancel",QSize(120,30));
cancelButton->setText(FMS::txt("cancel"));
connect(cancelButton,SIGNAL(clicked()),this,SLOT(onCancel()));
#else // LIVE_LANGUAGE2
// 初期値
QString title = MKU8("\xe5\x88\x9d\xe6\x9c\x9f\xe5\x80\xa4");
#if (LIVE_LANGUAGE_CHANGE)
if(RMLanguage::isJP() == false) { title = "Reset"; }
#endif
RMButton* defaultButton = RMButton::create(bwRight,blRight,"button",FMS::txt("default"),QSize(120,30));
//RMButton* defaultButton = RMButton::create(bwLeft,blLeft,"popup_button",title,QSize(120,30));
defaultButton->setText(FMS::txt("default"));
connect(defaultButton,SIGNAL(clicked()),SLOT(onDefault()));
// 適用
title = MKU8("\xe9\x81\xa9\xe7\x94\xa8");
#if (LIVE_LANGUAGE_CHANGE)
if(RMLanguage::isJP() == false) { title = "Save";}
#endif
//#if !(MODEL_WATEX)
// RMButton* applyButton = RMButton::create(bwRight,blRight,"popup_button",title,QSize(120,30));
// applyButton->setText(title);
// connect(applyButton,SIGNAL(clicked()),this,SLOT(onSave()));
//#endif
RMButton* okButton = RMButton::create(bwRight,blRight,"button",FMS::txt("ok"),QSize(120,30));
//RMButton* okButton = RMButton::create(bwRight,blRight,"popup_button",QString("OK"),QSize(120,30));
okButton->setText(FMS::txt("ok"));
connect(okButton,SIGNAL(clicked()),this,SLOT(onSaveAnAccept()));
#if (MODEL_WATEX)
title = MKU8("\xe3\x82\xad\xe3\x83\xa3\xe3\x83\xb3\xe3\x82\xbb\xe3\x83\xab"); // キャンセル
#else
title = MKU8("\xe9\x96\x89\xe3\x81\x98\xe3\x82\x8b"); // 閉じる
#endif
#if (LIVE_LANGUAGE_CHANGE)
if(RMLanguage::isJP() == false) { title = "Cancel";}
#endif
RMButton* cancelButton = RMButton::create(bwRight,blRight,"button",FMS::txt("cancel"),QSize(120,30));
cancelButton->setText(FMS::txt("cancel"));
// connect(okButton,SIGNAL(clicked()),this,SLOT(onOK()));
// RMButton* cancelButton = RMButton::create(bwRight,blRight,"popup_button",title,QSize(120,30));
// cancelButton->setText(title);
connect(cancelButton,SIGNAL(clicked()),this,SLOT(onCancel()));
/* 모델명 사용하지 않음
QLabel* modelName = new QLabel(_title->_toolBar);
modelName->setText(QString((const char*)CFG::data) + " ");
modelName->setObjectName("title_label");
_title->_toolBarLayout->insertWidget(0,modelName);
*/
#endif // #else // LIVE_LANGUAGE2
#if (DETECT_SETTING_USB_EJECT && !DETECT_USB_CHANGE)
_usb = new rm_usb(this);
_usb->registerEvent(this);
RMApplication::instance()->installNativeEventFilter(_usb);
connect(_usb,SIGNAL(usbChanged(bool,QString&)),SLOT(onUSBChange(bool,QString&)));
#endif // @DETECT_SETTING_USB_EJECT
#if (SETTINGS_WINDOW_SCROLL)
layout->setMargin(0);
layout->setSpacing(0);
// 스크롤 영역 생성
_contentScrollArea = new QScrollArea(_contentWidget);
_contentScrollArea->setStyleSheet("QScrollArea { background: transparent; }");
_contentScrollArea->setWidgetResizable( true );
layout->addWidget(_contentScrollArea);
_contentScrollWidget = new QWidget(); // _contentScrollArea
//_contentScrollWidget->setStyleSheet("QWidget { background: #FF0000;}");
_contentScrollLayout = new QHBoxLayout(_contentScrollWidget);
//ZERO_LAYOUT(_contentScrollLayout);
//_contentScrollLayout->setMargin(8);
_contentScrollLayout->setSpacing(8);
_contentScrollLayout->setContentsMargins(8,10,8,10); // 상하단 마진
_contentScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
_contentScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// 자동 설정
//_contentScrollWidget->setFixedHeight(SETTINGS_WiNDOW_HEIGHT);
_contentScrollWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
_contentScrollArea->setFrameShape(QFrame::NoFrame);
_contentScrollWidget->setObjectName("scroll2");
_contentScrollWidget->setStyleSheet("QWidget#scroll2 { background: transparent; }");
//_contentScrollWidget->setFixedHeight(SETTINGS_WiNDOW_HEIGHT);
_contentScrollArea->setWidget(_contentScrollWidget);
QString scrollStyle = "QScrollBar:vertical\
{\
border-width: 0px;\
border-style: solid;\
background: #3B3B3B;\
width: 10px;\
margin: 0px 0 0px 0;\
}\
QScrollBar::handle:vertical:disabled{background: #3B3B3B;}\
QScrollBar::handle:vertical\
{\
background: $HANDLE_COLOR$;\
min-height: 25px;\
margin: 2px 1px 2px 1px;\
}\
QScrollBar::add-line:vertical\
{\
border: none;\
background: none;\
height: 0px;\
width: 0px;\
subcontrol-position: bottom;\
subcontrol-origin: margin;\
}\
QScrollBar::sub-line:vertical\
{\
border: none;\
background: none;\
height: 0px;\
width: 0px;\
subcontrol-position: top;\
subcontrol-origin: margin;\
}\
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical\
{\
background: #3A3A3A;\
}\
QScrollBar::up-arrow:vertical\
{\
border: none;\
background: #3A3A3A;\
}\
QScrollBar::down-arrow:vertical\
{\
border: none;\
background: #5A5A5A;\
}";
_contentScrollArea->verticalScrollBar()->setStyleSheet(scrollStyle.replace("$HANDLE_COLOR$",QString().sprintf("#%06X",FM_SILDER_COLOR)));
#endif // SCROLL
}
#if (DETECT_SETTING_USB_EJECT && !DETECT_USB_CHANGE)
void RMSettingsWindowBase::onUSBChange(bool inserted, QString& drive)
{
// qInfo() << __FUNCTION__;
if(inserted == false && RMSettingsWindowBase::lastSettingDisk.contains(drive,Qt::CaseInsensitive)) {
reject();
}
}
#elif (DETECT_USB_CHANGE)
void RMSettingsWindowBase::onUsbRemoved()
{
reject();
}
#endif // @DETECT_SETTING_USB_EJECT
#if (USE_JSON_SETTINGS)
#else // #if (USE_JSON_SETTINGS)
RMGroupRadioButtons* RMSettingsWindowBase::_MGR_ONOFF(QWidget* parent,QString title,QLayout* layout,int type)
{
#if (LIVE_LANGUAGE_CHANGE && !RM_MODEL_EMT_KR)
if(RMLanguage::isJP() == false) { return _MGR(parent,title,layout,gEOnOff,type); }
#endif
return _MGR(parent,title,layout,gOnOff,type);
}
RMRadioButtons* RMSettingsWindowBase::_MR_ONOFF(QWidget* parent,QString title,QLayout* layout,int type,QLabel** titleLabel)
{
#if (LIVE_LANGUAGE_CHANGE && !RM_MODEL_EMT_KR)
if(RMLanguage::isJP() == false) { return _MR(parent,title,layout,gEOnOff,type,QList<int>(),titleLabel); }
#endif
return _MR(parent,title,layout,gOnOff,type,QList<int>(),titleLabel);
}
RMGroupRadioButtons* RMSettingsWindowBase::_MGR(QWidget *parent,QString title,QLayout* layout,QStringList items,int type,QList<int> indexMap)
{
RMGroupRadioButtons* gr = new RMGroupRadioButtons(parent,title,items,&CFG::data[type],indexMap);
layout->addWidget(gr);
return gr;
}
RMGroupRadioButtons* RMSettingsWindowBase::_MGRR(QWidget *parent,QString title,QLayout* layout,QStringList items,int type,QList<int> indexMap)
{
RMGroupRadioButtons* gr = new RMGroupRadioButtons(parent,title,items,&CFG::data[type],true,indexMap);
layout->addWidget(gr);
return gr;
}
RMRadioButtons* RMSettingsWindowBase::_MR(QWidget *parent,QString title,QLayout* layout,QStringList items,int type,QList<int> indexMap,QLabel** titleLabel)
{
RMRadioButtons* gr = NULL;
if(strcmp(layout->metaObject()->className(),"QGridLayout") == 0)
{
// (qobject_cast<QGridLayout*>)
QGridLayout* gl = (QGridLayout*)layout;
int row = ceil((double)layout->count() / 2.0);
QLabel* tl = new QLabel(this);
tl->setObjectName("text_normal_label");
tl->setText(title);
gl->addWidget(tl,row,0,Qt::AlignLeft);
// qInfo() << title << "MR row:" << row;
gr = new RMRadioButtons(parent,"",items,&CFG::data[type],indexMap);
gl->addWidget(gr,row,1,Qt::AlignLeft);
if(titleLabel != NULL) {
*titleLabel = tl;
}
}
else
{
gr = new RMRadioButtons(parent,title,items,&CFG::data[type],indexMap);
layout->addWidget(gr);
}
return gr;
}
void RMSettingsWindowBase::_MGT(QWidget *parent,QString title,QLayout* layout, QString text,QLabel** titleLabel)
{
if(strcmp(layout->metaObject()->className(),"QGridLayout") == 0)
{
QGridLayout* gl = (QGridLayout*)layout;
int row = ceil(((double)layout->count()) / 2.0);
int column = 0;
int columnSpan = 2;
if(title.length() > 0) {
QLabel* tl = new QLabel(this);
tl->setObjectName("text_normal_label");
tl->setText(title);
gl->addWidget(tl,row,0,Qt::AlignLeft);
column = 1;
columnSpan = 1;
if(titleLabel != NULL) {
*titleLabel = tl;
}
}
if(text.length() > 0)
{
QLabel* textLabel = new QLabel(parent);
textLabel->setObjectName("text_normal_label");
textLabel->setText(text);
gl->addWidget(textLabel,row,column,1,columnSpan,Qt::AlignLeft);
}
}
else
{
QLabel* textLabel = new QLabel(parent);
textLabel->setObjectName("text_normal_label");
textLabel->setText(text);
layout->addWidget(textLabel);
};
}
RMComboBox* RMSettingsWindowBase::_MC(QWidget *parent,QString title,QLayout* layout, QStringList items,int type,QList<int> indexMap,QLabel** titleLabel)
{
RMComboBox* c = NULL;
if(strcmp(layout->metaObject()->className(),"QGridLayout") == 0)
{
QGridLayout* gl = (QGridLayout*)layout;
int row = ceil(((double)layout->count()) / 2.0);
int column = 0;
int columnSpan = 2;
if(title.length() > 0) {
QLabel* tl = new QLabel(this);
tl->setObjectName("text_normal_label");
tl->setText(title);
gl->addWidget(tl,row,0,Qt::AlignLeft);
column = 1;
columnSpan = 1;
if(titleLabel != NULL) {
*titleLabel = tl;
}
}
//qInfo() << "row" << row << " column:" << column;
c = new RMComboBox(parent,"",items,&CFG::data[type],indexMap);
gl->addWidget(c,row,column,1,columnSpan,Qt::AlignLeft);
}
else
{
c = new RMComboBox(parent,title,items,&CFG::data[type],indexMap);
layout->addWidget(c);
}
return c;
}
RMGroupComboBox* RMSettingsWindowBase::_MGC(QWidget *parent,QString title,QLayout* layout,QStringList items,int type,QList<int> indexMap)
{
RMGroupComboBox* c = new RMGroupComboBox(parent,title,items,&CFG::data[type],indexMap);
layout->addWidget(c);
return c;
}
#endif // #else // #if (USE_JSON_SETTINGS)
void RMSettingsWindowBase::onSaveAnAccept()
{
#if (RM_MODEL_EMT_KR)
QString path = CFG::cfgPath;
#else // RM_MODEL_EMT_KR
QString path = QDir::cleanPath(lastSettingDisk + SETTINGS_FILE_NAME);
#endif // RM_MODEL_EMT_KR
if(validateData()) {
CFG::save(path);
afterSave();
accept();
}
}
RMSettingsWindowBase::~RMSettingsWindowBase()
{
}
void RMSettingsWindowBase::onSave()
{
QString path = QDir::cleanPath(lastSettingDisk + SETTINGS_FILE_NAME);
if(validateData()) {
CFG::save(path);
afterSave();
}
}
void RMSettingsWindowBase::onCancel()
{
CFG::restore();
reject();
}
void RMSettingsWindowBase::onDefault()
{
CFG::setDefault();
emit RMValueUpdater::instance()->updateByValues();
// 레코드 세팅 문제로 (Combo box event 발생하면 default 값이 save 됨)
CFG::setDefault();
}
#endif // #if (USE_DEVICE_SETTINGS)

View File

@@ -0,0 +1,131 @@
#ifndef RM_SETTINGS_WINDOW_BASE_H
#define RM_SETTINGS_WINDOW_BASE_H
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON)
#include "../ui/rm_popup.h"
#include <QGroupBox>
#include <QRadioButton>
class RMRadioButtons;
class RMGroupComboBox;
class RMGroupRadioButtons;
class RMComboBox;
class QJsonObject;
class QScrollArea;
#if (DETECT_SETTING_USB_EJECT)
class rm_usb;
#endif
extern const QStringList gOnOff;
class RMSettingsWindowBase : public RMPopup
{
Q_OBJECT
public:
//static bool loaded;
static QString lastSettingDisk;
explicit RMSettingsWindowBase(QWidget *parent = 0);
~RMSettingsWindowBase();
virtual void afterSave() = NULL;
virtual bool validateData() = NULL;
protected:
#if (DETECT_SETTING_USB_EJECT)
rm_usb* _usb;
#endif // @DETECT_SETTING_USB_EJECT
#if (SETTINGS_WINDOW_SCROLL)
QScrollArea* _contentScrollArea;
QWidget* _contentScrollWidget;
QHBoxLayout* _contentScrollLayout;
#endif // SCROLL
QHBoxLayout* layout;
// ON,OFF 기능만 하는 라디오 버튼 생성
#if (USE_JSON_SETTINGS)
RMGroupRadioButtons* _MGR_ONOFF(QWidget* parent,
QJsonObject* object,
QLayout* layout);
RMGroupRadioButtons* _MGR(QWidget *parent,
QLayout* layout,
QJsonObject* object);
RMGroupComboBox* _MGC(QWidget *parent,
QLayout* layout,
QJsonObject* object);
#else // USE_JSON_SETTINGS
RMGroupRadioButtons* _MGR_ONOFF(QWidget* parent,
QString title,
QLayout* layout,
int type
);
RMRadioButtons* _MR_ONOFF(QWidget* parent,
QString title,
QLayout* layout,
int type,
QLabel** titleLabel = NULL);
RMGroupRadioButtons* _MGR(QWidget *parent,
QString title,
QLayout* layout,
QStringList items,
int type,
QList<int> indexMap = QList<int>());
RMGroupRadioButtons* _MGRR(QWidget *parent,
QString title,
QLayout* layout,
QStringList items,
int type,
QList<int> indexMap = QList<int>());
RMRadioButtons* _MR(QWidget *parent,
QString title,
QLayout* layout,
QStringList items,
int type,
QList<int> indexMap = QList<int>(),
QLabel** titleLabel = NULL);
void _MGT(QWidget *parent,QString title,QLayout* layout, QString text,QLabel** titleLabel = NULL);
RMComboBox* _MC(QWidget *parent,
QString title,
QLayout* layout,
QStringList items,
int type,
QList<int> indexMap = QList<int>(),
QLabel** titleLabel = NULL);
RMGroupComboBox* _MGC(QWidget *parent,
QString title,
QLayout* layout,
QStringList items,
int type,
QList<int> indexMap = QList<int>());
#endif // USE_JSON_SETTINGS
protected slots:
void onDefault();
void onSave();
void onCancel();
void onSaveAnAccept();
// DETECT_USB_CHANGE 사용시에는 직접 처리하여 필요없음???
#if (DETECT_SETTING_USB_EJECT && !DETECT_USB_CHANGE)
void onUSBChange(bool inserted, QString& drive);
#elif (DETECT_USB_CHANGE)
void onUsbRemoved();
#endif
};
#endif // #if (USE_DEVICE_SETTINGS)
#endif // RM_SETTINGS_WINDOW_BASE_H

View File

@@ -0,0 +1,86 @@
#include "rm_text_edit.h"
#if (USE_JSON_SETTINGS)
#include <QJsonObject>
#include <QStyleOption>
#include <QPainter>
#include "rm_settings_cfg.h"
RMTextEdit::RMTextEdit(QWidget *parent,QString title, int index) : QWidget(parent), RMValueSelector(index)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
layout = new QHBoxLayout(this);
layout->setAlignment(Qt::AlignLeading | Qt::AlignVCenter);
layout->setContentsMargins(0,2,8,2);
layout->setSpacing(3);
if(!title.isEmpty())
{
titleLabel = new QLabel(this);
titleLabel->setObjectName("text_normal_label");
titleLabel->setText(title);
layout->addWidget(titleLabel);
}
else
{
titleLabel = NULL;
}
QJsonObject obj = CFG::items.at(index).toObject();
edit = new QLineEdit(this);
edit->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
edit->setObjectName("file");
edit->setText(obj.value("current").toString());
/*
if(obj.contains("regex")) {
QRegExp re(obj.value("regex").toString());
QRegExpValidator *validator = new QRegExpValidator(re, this);
edit->setValidator(validator);
}
if(obj.contains("input_mask")) {
edit->setInputMask(obj.value("input_mask").toString());
}
*/
connect(edit,SIGNAL(textChanged(const QString &)),SLOT(onTextChanged(const QString &)));
layout->addWidget(edit);
connect(RMValueUpdater::instance(),SIGNAL(updateByValues()),SLOT(onUpdateByValue()));
}
void RMTextEdit::onTextChanged(const QString &text) {
QJsonObject obj = CFG::items.at(_object).toObject();
obj.insert("current",QJsonValue(text));
CFG::items.replace(_object,obj);
//qInfo() << text << __FUNCTION__;
}
void RMTextEdit::paintEvent(QPaintEvent *pe)
{
Q_UNUSED(pe);
QStyleOption o;
o.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}
void RMTextEdit::onUpdateByValue()
{
QJsonObject obj = CFG::items.at(_object).toObject();
edit->setText(obj.value("current").toString());
}
RMGroupTextEdit::RMGroupTextEdit(QWidget *parent,int index) : QGroupBox(parent)
{
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
setObjectName("settings");
QJsonObject obj = CFG::items.at(index).toObject();
if(obj.contains("title")) {
setTitle(obj.value("title").toString());
}
layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignVCenter | Qt::AlignLeading);
layout->setContentsMargins(8,2,8,2);
layout->setSpacing(3);
text = new RMTextEdit(this,"",index);
layout->addWidget(text);
}
#endif // #if (USE_JSON_SETTINGS)

View File

@@ -0,0 +1,44 @@
#ifndef RM_TEXT_EDIT_H
#define RM_TEXT_EDIT_H
#include <QObject>
#include <QWidget>
#include <QLineEdit>
#include <QList>
#include <QHBoxLayout>
#include <QLabel>
#include <QGroupBox>
#include "rm_value_selector.h"
#if (USE_JSON_SETTINGS)
class RMTextEdit : public QWidget, public RMValueSelector
{
Q_OBJECT
public:
explicit RMTextEdit(QWidget *parent,QString title, int index);
QHBoxLayout* layout;
QLineEdit* edit;
QLabel* titleLabel;
private:
void paintEvent(QPaintEvent *pe);
signals:
void selected(int index);
private slots:
void onTextChanged(const QString &text);
void onUpdateByValue();
};
class RMGroupTextEdit : public QGroupBox
{
Q_OBJECT
public:
explicit RMGroupTextEdit(QWidget *parent,int index);
QVBoxLayout* layout;
RMTextEdit* text;
};
#endif // USE_JSON_SETTINGS
#endif // RM_TEXT_EDIT_H

View File

@@ -0,0 +1,39 @@
#include "rm_value_selector.h"
#if (USE_JSON_SETTINGS)
#include <QJsonArray>
#include <QJsonObject>
#include "rm_settings_cfg.h"
RMValueSelector::RMValueSelector(int object)
{
_object = object;
}
unsigned char RMValueSelector::realValue(int index)
{
QJsonObject obj = CFG::items.at(_object).toObject();
if(obj.contains("index_map")) {
QJsonArray a = obj.value("index_map").toArray();
return a.at(index).toInt();
}
return index;
}
int RMValueSelector::realIndex(unsigned char value)
{
QJsonObject obj = CFG::items.at(_object).toObject();
if(obj.contains("index_map")) {
QJsonArray a = obj.value("index_map").toArray();
for(int i=0;i<a.size();i++) {
if(a.at(i).toInt() == value) {
return i;
}
}
}
return value;
}
#else // USE_JSON_SETTINGS
RMValueSelector::RMValueSelector(unsigned char* value,QList<int> indexMap)
{
_value = value;
_indexMap = indexMap;
}
#endif // USE_JSON_SETTINGS

View File

@@ -0,0 +1,60 @@
#ifndef RM_VALUE_SELECTOR_H
#define RM_VALUE_SELECTOR_H
#include <QObject>
#include <QList>
class QJsonObject;
class RMValueSelector
{
public:
#if (USE_JSON_SETTINGS)
explicit RMValueSelector(int object);
protected:
int _object;
unsigned char realValue(int index);
int realIndex(unsigned char value);
#else // USE_JSON_SETTINGS
public:
RMValueSelector(unsigned char* value,QList<int> indexMap);
unsigned char realValue(int index)
{
return _indexMap.isEmpty() ? (unsigned char)index : (unsigned char)_indexMap[index];
}
int realIndex(unsigned char value)
{
return _indexMap.isEmpty() ? (int)value : _indexMap.indexOf(value);
}
protected:
QList<int> _indexMap;
unsigned char* _value;
#endif // USE_JSON_SETTINGS
};
class RMValueUpdater : public QObject
{
Q_OBJECT
public:
explicit RMValueUpdater(QObject* parent = nullptr) : QObject(parent){
}
// SIGNAL 연동을 위해 사용
static RMValueUpdater* instance()
{
static RMValueUpdater * _instance = 0;
if ( _instance == 0 ) {
_instance = new RMValueUpdater();
}
return _instance;
}
signals:
void updateByValues();
};
#endif // RM_VALUE_SELECTOR_H

View File

@@ -0,0 +1,19 @@
#ifndef WINDOW_SETTINGS_COMMON_H
#define WINDOW_SETTINGS_COMMON_H
#if (USE_DEVICE_SETTINGS)
#include "../rm_include.h"
#if (USE_DEVICE_SETTINGS_JSON)
#include "window_settings_json.h"
#else // USE_DEVICE_SETTINGS_JSON
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#include "window_settings_xdr6688.h"
#elif (RM_MODEL_EMT_KR)
#include "window_settings_emt_kr.h"
#else
#include "window_settings_standard.h"
#endif
#endif // USE_DEVICE_SETTINGS_JSON
#endif // USE_DEVICE_SETTINGS
#endif // WINDOW_SETTINGS_COMMON_H

View File

@@ -0,0 +1,420 @@
#include "window_settings_emt_kr.h"
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON && RM_MODEL_EMT_KR)
#include "../fm_dimensions.h"
#include "../ui/title_widget.h"
#include "rm_combo_box.h"
#include "rm_radio_buttons.h"
#include "rm_group_combo_box.h"
#include "rm_group_radio_buttons.h"
#include "rm_text_edit.h"
//#include "rm_setting_time.h"
#include <QComboBox>
#include <QGridLayout>
#include <QDir>
#include <QMessageBox>
#include <QJsonObject>
#include "rm_settings_cfg_emt_kr.h"
#if (DETECT_SETTING_USB_EJECT)
#include "../core/rm_usb.h"
#include "../rm_application.h"
#endif
// 문자열 처리 UTF
// https://www.branah.com/unicode-converter
const int gComboBoxWidth = 200;
const int gTitleWidth = 50;
const int defaultHeight = 55;
const int subHeight = 30;
WindowSettings::WindowSettings(QWidget *parent) : RMSettingsWindowBase(parent)
{
QWidget* row = NULL;
QVBoxLayout* rowLayout = _createRow(&row);
_createRowS(row,rowLayout,CFG::items,0,200);
_refresh(CFG::items,0);
}
void WindowSettings::afterSave()
{
}
bool WindowSettings::validateData()
{
return true;
}
QStringList WindowSettings::_valueStrings(QJsonObject& object,const char* key)
{
QStringList ret = QStringList();
if(object.contains(key)) {
QJsonArray array = object.value(key).toArray();
for(int i=0;i<array.size();i++) {
ret.append(array.at(i).toString());
}
}
return ret;
}
QList<int> WindowSettings::_valueIndices(QJsonObject& object,const char* key)
{
QList<int> ret = QList<int>();
if(object.contains(key)) {
QJsonArray array = object.value(key).toArray();
for(int i=0;i<array.size();i++) {
ret.append(array.at(i).toInt());
}
}
return ret;
}
int WindowSettings::_getObjectIndex(QString& id)
{
QObject* obj = _controlByNames.value(id);
RMComboBox* combo = qobject_cast<RMComboBox*>(obj);
if(combo != NULL) {
return combo->comboBox->currentIndex();
}
else {
RMRadioButtons* radios = qobject_cast<RMRadioButtons*>(obj);
if(radios != NULL) {
return radios->currentIndex();
}
}
return -1;
}
void WindowSettings::_refresh(QJsonArray items,int depth)
{
for(int i=0;i<items.size();i++) {
QJsonObject obj = items.at(i).toObject();
// sub group
if(obj.contains("group")) {
_refresh(obj.value("items").toArray(),depth+1);
}
if(obj.contains("events")) {
//qInfo() << obj << __FUNCTION__;
QStringList eventList = _valueStrings(obj,"events");
QString keyString = obj.value("key").toString();
int index = _getObjectIndex(keyString);
//qInfo() << index << __FUNCTION__;
_processEvent(keyString,eventList,index);
}
}
}
void WindowSettings::_createRowS(QWidget* parent, QLayout* playout, QJsonArray items, int depth, int value_column_width)
{
for(int i=0;i<items.size();i++) {
QJsonObject obj = items.at(i).toObject();
if(obj.contains("hidden")) {
continue;
}
// 열 변환
if(obj.contains("column_break")) {
QWidget* row = NULL;
QVBoxLayout* rowLayout = _createRow(&row);
parent = row;
playout = rowLayout;
}
if(!obj.contains("key")) {
qInfo() << "ERROR:" << obj << __FUNCTION__;
continue;
}
QString key = obj.value("key").toString();
QString title = "";
if(obj.contains("title")) {
title = obj.value("title").toString();
}
QObject* keyObject = NULL;
// 그룹 타입의 경우
if(obj.contains("group")) {
QGroupBox* g = new QGroupBox(parent);
keyObject = g;
//g->setFixedHeight(160);
g->setObjectName("settings");
playout->addWidget(g);
g->setTitle(title);
QLayout *gg = NULL;
if(!obj.contains("no_grid")) {
QGridLayout* gl = new QGridLayout(g);
gl->setMargin(8);
gl->setSpacing(4);
gg = gl;
} else {
QVBoxLayout* gl = new QVBoxLayout(g);
gl->setMargin(8);
gl->setSpacing(4);
gg = gl;
}
int vcw = value_column_width;
if(obj.contains("value_column_width")) {
vcw = obj.value("value_column_width").toInt(value_column_width);
}
_createRowS(g,gg,obj.value("items").toArray(),depth+1,vcw);
}
else if(obj.contains("control")) {
QString ctype = obj.value("control").toString();
if(ctype == "radio" || ctype == "combo") {
if (!obj.contains("value_strings") || !obj.contains("offset")) {
qInfo() << "ERROR ITEM:" << obj << __FUNCTION__;
continue;
}
QStringList items = _valueStrings(obj,"value_strings"); // .value("value_strings").toArray()
int offset = obj.value("offset").toInt();
QList<int> indexMap = QList<int>();
if(obj.contains("values")) {
indexMap = _valueIndices(obj,"values");
}
QLabel* titleLabel = NULL;
if(ctype == "radio") {
RMRadioButtons* rrb = NULL;
if(depth == 0 || obj.contains("group_box")) {
RMGroupRadioButtons* rb = _MGR(parent,title,playout,items,offset,indexMap);
rb->setFixedHeight(defaultHeight);
rrb = rb->radioButtons;
} else {
rrb = _MR(parent,title,playout,items,offset,indexMap,&titleLabel);
rrb->setFixedHeight(subHeight);
rrb->setFixedWidth(value_column_width);
//titleLabel->setFixedWidth(100);
}
keyObject = rrb;
if(obj.contains("events")) {
connect(rrb,SIGNAL(selected(int)),SLOT(onSelected(int)));
}
if(obj.contains("disabled")) {
rrb->setEnabled(false);
}
} else {
RMComboBox* ccb = NULL;
if(depth == 0 || obj.contains("group_box")) {
RMGroupComboBox* cb = _MGC(parent,title,playout,items,offset,indexMap);
cb->comboBox->setFixedWidth(gComboBoxWidth);
cb->setFixedHeight(defaultHeight);
ccb = cb->comboBox;
} else {
ccb = _MC(parent,title,playout,items,offset,indexMap,&titleLabel);
ccb->setFixedHeight(subHeight);
ccb->setFixedWidth(value_column_width);
//titleLabel->setFixedWidth(100);
}
keyObject = ccb;
if(obj.contains("events")) {
connect(ccb,SIGNAL(selected(int)),SLOT(onSelected(int)));
}
if(obj.contains("disabled")) {
//qInfo() << "disabled" << title << __FUNCTION__;
ccb->setEnabled(false);
}
}
}
}
if(keyObject != NULL) {
_controlByNames.insert(key,keyObject);
_controlByObjects.insert(keyObject,key);
// 이벤트 추가
if(obj.contains("events")) {
QStringList eventList = _valueStrings(obj,"events");
// QJsonArray events = obj.value("events").toArray();
// QStringList eventList = QStringList();
// for(int e=0;e<events.size();e++) {
// eventList.append(events.at(e).toString());
// }
_controlEvents.insert(keyObject,eventList);
}
}
}
}
void WindowSettings::_processEvent(QString& key, QStringList& eventStrings, int index)
{
for(int e=0;e<eventStrings.size();e++) {
QString event = eventStrings.at(e);
if(event.startsWith("UPDATEVALUES")) {
_processUpdateEvent(key,event,index);
}
else if(event.startsWith("ENABLED")) {
_processEnableEvent(key,event,index);
}
else if (event.startsWith("UPDATE_OTHER_BY_EVENTS")) {
_processUpdateOtherEvent(key,event,index);
}
}
}
void WindowSettings::_setObjectIndex(QObject* sender, int index)
{
RMComboBox* combo = qobject_cast<RMComboBox*>(sender);
if(combo != NULL) {
combo->comboBox->setCurrentIndex(index);
}
else {
RMRadioButtons* radios = qobject_cast<RMRadioButtons*>(sender);
if(radios != NULL) {
radios->setCurrentIndex(index);
}
}
}
void WindowSettings::_setObjectEnable(QObject* sender, bool enabled)
{
RMComboBox* combo = qobject_cast<RMComboBox*>(sender);
if(combo != NULL) {
combo->setEnabled(enabled);
}
else {
RMRadioButtons* radios = qobject_cast<RMRadioButtons*>(sender);
if(radios != NULL) {
radios->setEnabled(enabled);
}
}
}
void WindowSettings::_processUpdateOtherEvent(QString& key, QString& event, int index)
{
Q_UNUSED(index)
Q_UNUSED(key)
QStringList args = event.split(",");
if(args.size() < 2) {
return;
}
//qInfo() << "key:" << key << __FUNCTION__;
// SD_OMAKASE의 항목을 확인하여
QString target = args.at(1); // = SD_OMAKASE
QObject* tt = _controlByNames.value(target); // 프리셋 컨트롤
// "UPDATEVALUES,0,SD_DRIVERECMODE=0,SD_PARKINGRECMODE=4,SD_VIDEOQUALITY=1,SD_VIDEOFRAME=1",
// "UPDATEVALUES,1,SD_DRIVERECMODE=0,SD_PARKINGRECMODE=1,SD_VIDEOQUALITY=2,SD_VIDEOFRAME=1",
// "UPDATEVALUES,2,SD_DRIVERECMODE=0,SD_PARKINGRECMODE=3,SD_VIDEOQUALITY=0,SD_VIDEOFRAME=0"
QStringList targetEvents = _controlEvents.value(tt);
for(int e=0;e<targetEvents.size();e++) {
// "UPDATEVALUES,0,SD_DRIVERECMODE=0,SD_PARKINGRECMODE=4,SD_VIDEOQUALITY=1,SD_VIDEOFRAME=1",
QStringList eargs = targetEvents.at(e).split(",");
// UPDATEVALUES 항목이 아닌 경우 무시
if(eargs.at(0) != "UPDATEVALUES") {
//qInfo() << eargs.at(0) << __FUNCTION__;
continue;
}
// 각 KEY=VALUE 확인 모든 조합이 일치하면
bool bAllEqual = true;
for(int a=2;a<eargs.size();a++) {
QString etarget = eargs[a]; // SD_DRIVERECMODE=0
QStringList etargetList = etarget.split("=");
QString etargetKey = etargetList.at(0); // SD_DRIVERECMODE
int etargetValue = etargetList.at(1).toInt(); // 0
int eidx = _getObjectIndex(etargetKey); // 현재 컨트롤 값
//QObject* ct = _controlByNames.value(etargetKey); // 컨트롤 값 확인
// 조합이 틀린경우 다음 UPDATEVALUES 로 이동
if(eidx != etargetValue) {
bAllEqual = false;
break;
}
}
// 모든 항목이 일치하는 조합이 발생하면 해당 컨트롤 업데이트 후 종료
if(bAllEqual) {
int foundIndex = eargs.at(1).toInt(); // UPDATEVALUES,0 -> 0
_setObjectIndex(tt,foundIndex);
return;
}
}
// 발견된 조합이 없을 경우 NOT_FOUND 확인 (VERIFYVALUES_BY,SD_OMAKASE,NOT_FOUND=4)
if(args.size() >= 3) {
QString nf = args.at(2);
if(nf.startsWith("NOT_FOUND")) {
int idx = nf.split("=").at(1).toInt();
//QObject* tt = _controlByNames.value(target);
_setObjectIndex(tt,idx);
}
}
//qInfo() << args << __FUNCTION__;
}
void WindowSettings::_processUpdateEvent(QString& key, QString& event, int index)
{
Q_UNUSED(key)
QStringList args = event.split(",");
// 업데이트 명령일 경우
if(args[1].toInt() != index) {
return;
}
// 각 업데이트 확인
for(int a=2;a<args.size();a++) {
QString target = args[a];
QStringList taget = target.split("=");
QString targetKey = taget.at(0);
int targetValue = taget.at(1).toInt();
QObject* tt = _controlByNames.value(targetKey);
_setObjectIndex(tt,targetValue);
}
}
void WindowSettings::_processEnableEvent(QString& key, QString& event, int index)
{
Q_UNUSED(key)
// SHOWHIDE,1,SD_PARKING_CUTOFF_NORMAL=1,SD_PARKING_CUTOFF_HYBRID=0,SD_PARKING_CUTOFF_ELECTRIC=0
QStringList args = event.split(",");
// 선택된 인덱스의 항목이 아닐 경우
if(args[1].toInt() != index) {
return;
}
// 각 업데이트 확인
for(int a=2;a<args.size();a++) {
QString target = args[a];
QStringList taget = target.split("=");
QString targetKey = taget.at(0);
int targetValue = taget.at(1).toInt();
QObject* tt = _controlByNames.value(targetKey);
//qInfo() << tt << taget << targetValue << __FUNCTION__;
_setObjectEnable(tt,targetValue == 1);
}
}
void WindowSettings::onSelected(int index)
{
QObject* s = sender();
// 정보 존재
if(_controlEvents.contains(s)) {
QStringList eventStrings = _controlEvents.value(s);
QString key = _controlByObjects[s];
_processEvent(key,eventStrings,index);
}
}
QVBoxLayout* WindowSettings::_createRow(QWidget** rw)
{
const int width = SETTINGS_WINDOW_WIDTH - _contentScrollLayout->contentsMargins().left() - _contentScrollLayout->contentsMargins().right() - _contentScrollLayout->spacing() - 20;
*rw = new QWidget(_contentScrollWidget);
(*rw)->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
(*rw)->setFixedWidth(width / 2);
_contentScrollLayout->addWidget(*rw);
_contentScrollLayout->setAlignment(Qt::AlignTop);
QVBoxLayout* l = new QVBoxLayout(*rw);
l->setMargin(0);
l->setSpacing(10);
l->setAlignment(Qt::AlignTop);
return l;
}
WindowSettings::~WindowSettings()
{
}
#endif // #if (USE_DEVICE_SETTINGS)
//#endif // #if (RM_MODEL == RM_MODEL_TYPE_CS_32FH)

View File

@@ -0,0 +1,68 @@
#ifndef WINDOW_SETTINGS_H
#define WINDOW_SETTINGS_H
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON && RM_MODEL_EMT_KR)
#include "../rm_include.h"
#include "rm_settings_window_base.h"
#include "../ui/rm_popup.h"
#include <QGroupBox>
#include <QRadioButton>
#define SETTING_NUM_ROW 2
class RMTextEdit;
class WindowSettings : public RMSettingsWindowBase
{
Q_OBJECT
public:
explicit WindowSettings(QWidget *parent = 0);
~WindowSettings();
virtual void afterSave() override;
virtual bool validateData() override;
private:
QHash<QString,QObject*> _controlByNames; ///! 명칭으로 Contro(Combo,Button) 확인
QHash<QObject*,QString> _controlByObjects; ///! 컨트롤로 명칭 확인
QHash<QObject*,QStringList> _controlEvents; ///! 컨트롤로 이벤트 확인
// Utility
QVBoxLayout* _createRow(QWidget** rw);
void _createRowS(QWidget* parent, QLayout* playout, QJsonArray items, int depth, int value_column_width = -1);
// 이벤트가 존재하는 항목 확인하여 ENABLE/DISABLED 등 처리함
// 항목 사용에 따라 값을 변경
void _refresh(QJsonArray items,int depth);
// 설정 항목별 리스트를 확인
static QStringList _valueStrings(QJsonObject& object,const char* key);
// 설정 항목별 저장값을 확인
static QList<int> _valueIndices(QJsonObject& object,const char* key);
void _processEvent(QString& key, QStringList& events, int index);
//! \brief 항목이 변경되면 다른 항목을 업데이트함
//! \param event
//! \param index
void _processUpdateEvent(QString& key, QString& event, int index);
void _processEnableEvent(QString& key, QString& event, int index);
//! \brief 항목이 변경되면 다른 항목을 (UpdateEvent) 를 참조하여 업데이트함
//! eg. 화질설정이 변경되면 프리셋을 프리셋내의 UPDATES.. 를 확인하여 업데이트
//! \param event
//! \param index
void _processUpdateOtherEvent(QString& key, QString& event, int index);
int _getObjectIndex(QString& id);
void _setObjectIndex(QObject* sender, int index);
void _setObjectEnable(QObject* sender, bool enabled);
private slots:
void onSelected(int index);
};
#endif // #if (USE_DEVICE_SETTINGS)
#endif // WINDOW_SETTINGS_H

View File

@@ -0,0 +1,69 @@
#if (USE_DEVICE_SETTINGS_JSON)
#include "window_settings_json.h"
#include "../ui/title_widget.h"
#include "../core/fm_strings.h"
#include "rm_combo_box.h"
#include "rm_radio_buttons.h"
#include "rm_group_combo_box.h"
#include "rm_group_radio_buttons.h"
#include "rm_text_edit.h"
//#include "rm_settings_cfg_standard.h"
//#include "rm_setting_time.h"
#include <QComboBox>
#include <QGridLayout>
#include <QDir>
#include <QMessageBox>
#if (DETECT_SETTING_USB_EJECT)
#include "../core/rm_usb.h"
#include "../rm_application.h"
#endif
QString WindowSettings::lastSettingDisk = "";
WindowSettings::WindowSettings(QWidget *parent) : RMPopup(parent,"","title_settings.png")
{
if(RMApp::isModelDisk(lastSettingDisk) == false)
{
// CFG::setDefault();
// CFG::save(path);
}
else {
// CFG::load(path);
}
this->setFixedSize(640,480);
_contentWidget->setObjectName("bg_dark_widget");
layout = new QHBoxLayout(_contentWidget);
layout->setMargin(8);
layout->setSpacing(8);
QWidget* bwLeft = new QWidget(_buttonWidget);
_buttonLayout->addWidget(bwLeft);
QWidget* bwRight = new QWidget(_buttonWidget);
_buttonLayout->addWidget(bwRight);
QHBoxLayout* blLeft = new QHBoxLayout(bwLeft);
blLeft->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
QHBoxLayout* blRight = new QHBoxLayout(bwRight);
blRight->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
RMButton* defaultButton = RMButton::create2(bwRight,blRight,"button","default",QSize(120,30));
defaultButton->setText(FMS::txt("default"));
connect(defaultButton,SIGNAL(clicked()),SLOT(onDefault()));
RMButton* okButton = RMButton::create2(bwRight,blRight,"button","ok",QSize(120,30));
okButton->setText(FMS::txt("ok"));
connect(okButton,SIGNAL(clicked()),this,SLOT(onSaveAnAccept()));
RMButton* cancelButton = RMButton::create2(bwRight,blRight,"button","cancel",QSize(120,30));
cancelButton->setText(FMS::txt("cancel"));
connect(cancelButton,SIGNAL(clicked()),this,SLOT(onCancel()));
}
WindowSettings::~WindowSettings()
{
}
#endif // #if (USE_DEVICE_SETTINGS_JSON)

View File

@@ -0,0 +1,20 @@
#ifndef WINDOW_SETTINGS_JSON_H
#define WINDOW_SETTINGS_JSON_H
#if (USE_DEVICE_SETTINGS_JSON)
#include "../ui/rm_popup.h"
class WindowSettings : public RMPopup
{
Q_OBJECT
public:
explicit WindowSettings(QWidget *parent = 0);
~WindowSettings();
static QString lastSettingDisk;
private:
QHBoxLayout* layout;
QVBoxLayout* _createRow(QWidget** rw);
};
#endif // #if (USE_DEVICE_SETTINGS_JSON)
#endif // WINDOW_SETTINGS_JSON_H

View File

@@ -0,0 +1,184 @@
#include "window_settings_standard.h"
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON && !RM_MODEL_EMT_KR)
#include "../fm_dimensions.h"
//#if (RM_MODEL == RM_MODEL_TYPE_STANDARD || RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#include "../ui/title_widget.h"
#include "rm_combo_box.h"
#include "rm_radio_buttons.h"
#include "rm_group_combo_box.h"
#include "rm_group_radio_buttons.h"
#include "rm_text_edit.h"
#include "rm_settings_cfg_standard.h"
#include "rm_setting_time.h"
#include <QComboBox>
#include <QGridLayout>
#include <QDir>
#include <QMessageBox>
#if (DETECT_SETTING_USB_EJECT)
#include "../core/rm_usb.h"
#include "../rm_application.h"
#endif
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
#include <QJsonObject>
#endif // RM_MODEL_TYPE_AN6000
// 문자열 처리 UTF
// https://www.branah.com/unicode-converter
const int gComboBoxWidth = 200;
const int gTitleWidth = 50;
static const QString glevel = MKU8("\xe3\x83\xac\xe3\x83\x99\xe3\x83\xab");
WindowSettings::WindowSettings(QWidget *parent) : RMSettingsWindowBase(parent)
{
_createRowA();
}
void WindowSettings::afterSave()
{
}
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
bool WindowSettings::validateData()
{
const QList<QString> keys = validateList.keys();
for(int i=0;i<keys.size();i++){
QPair<QString,RMTextEdit*> item = validateList[keys.at(i)];
QString str = item.second->edit->text();
QString reg = item.first;
QRegExp regexp(reg);
if(!regexp.exactMatch(str)) {
QMessageBox msgBox(QMessageBox::Warning,
"AN6000",
FM_WSTR(L"「入力内容にエラーがあります。\n修正して再度ご登録をお願いいたします。」"),
QMessageBox::Ok,
this);
msgBox.exec();
QTimer::singleShot(0, item.second->edit, SLOT(setFocus()));
return false;
}
}
return true;
}
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
void WindowSettings::_createRowA()
{
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
QWidget* row = NULL;
QVBoxLayout* rowLayout = NULL;
rowLayout = _createRow(&row);
int fh = 55;
for(int i=0;i<CFG::items.size();i++) {
QJsonObject obj = CFG::items.at(i).toObject();
if(obj.contains("hidden")) {
continue;
}
if(obj.contains("control")) {
QString ctype = obj.value("control").toString();
if(ctype == "radio") {
RMGroupRadioButtons* rb = new RMGroupRadioButtons(row,i);
rowLayout->addWidget(rb);
rb->setFixedHeight(fh);
} else if(ctype == "combo") {
RMGroupComboBox* cb = new RMGroupComboBox(row,i);
rowLayout->addWidget(cb);
cb->comboBox->setFixedWidth(gComboBoxWidth);
cb->setFixedHeight(fh);
} else if(ctype == "text") {
RMGroupTextEdit* tb = new RMGroupTextEdit(row,i);
// REGEX 포함 데이터일 경우 추가
if(obj.contains("regex")) {
validateList.insert(obj.value("key").toString(),QPair<QString,RMTextEdit*>(obj.value("regex").toString(),tb->text));
}
rowLayout->addWidget(tb);
tb->text->setFixedWidth(gComboBoxWidth);
tb->setFixedHeight(fh);
}
}
}
#else // AN6000
QWidget* row = NULL;
QVBoxLayout* rowLayout = NULL;
rowLayout = _createRow(&row);
int fh = 65;
RMGroupComboBox* gs = new RMGroupComboBox(row,
MKU8("\x33\x47\xe3\x82\xbb\xe3\x83\xb3\xe3\x82\xb5\xe3\x83\xbc\xe6\x84\x9f\xe5\xba\xa6"),
QStringList() << glevel + "1" << glevel + "2" << glevel + "3" \
<< glevel + "4" << glevel + "5",
&CFG::data[SD_SENSOR]);
rowLayout->addWidget(gs);
gs->comboBox->setFixedWidth(gComboBoxWidth);
gs->setFixedHeight(fh);
// 画像 SIZE_800x600, SIZE_640x320
RMGroupRadioButtons* gr = _MGR(row,MKU8("\xe7\x94\xbb\xe5\x83\x8f"),rowLayout,QStringList() << "800x600" << "640x320",SD_SIZE);
gr->setFixedHeight(fh);
// 録画フレームレート
gr = _MGR(row,
MKU8("\xe9\x8c\xb2\xe7\x94\xbb\xe3\x83\x95\xe3\x83\xac\xe3\x83\xbc\xe3\x83\xa0\xe3\x83\xac\xe3\x83\xbc\xe3\x83\x88"),
rowLayout,
QStringList()
<< "20 fps"
<< "25 fps"
<< "30 fps",SD_FRAME);
gr->setFixedHeight(fh);
// 音量調整
gr = _MGR(row,
MKU8("\xe9\x9f\xb3\xe9\x87\x8f\xe8\xaa\xbf\xe6\x95\xb4") + " ",
rowLayout,
QStringList() << "0" << "1" << "2" << "3" << "4" << "5",
SD_VOLUME);
gr->setFixedHeight(fh);
// ボイス
gr = _MGR(row,
MKU8("\xe3\x83\x9c\xe3\x82\xa4\xe3\x82\xb9") + " ",
rowLayout,
QStringList() << MKU8("\xe3\x82\xaa\xe3\x83\x95") << MKU8("\xe3\x82\xaa\xe3\x83\xb3"),
SD_VOICE);
gr->setFixedHeight(fh);
RMSettingTime* time = new RMSettingTime(row);
rowLayout->addWidget(time);
#endif // #else // AN6000
}
QVBoxLayout* WindowSettings::_createRow(QWidget** rw)
{
*rw = new QWidget(_contentWidget);
(*rw)->setFixedWidth(SETTINGS_WINDOW_WIDTH-(8*2));
layout->addWidget(*rw);
QVBoxLayout* l = new QVBoxLayout(*rw);
l->setMargin(0);
l->setSpacing(4);
l->setAlignment(Qt::AlignTop);
return l;
}
WindowSettings::~WindowSettings()
{
}
#endif // #if (USE_DEVICE_SETTINGS)
//#endif // #if (RM_MODEL == RM_MODEL_TYPE_CS_32FH)

View File

@@ -0,0 +1,53 @@
#ifndef WINDOW_SETTINGS_H
#define WINDOW_SETTINGS_H
#if (USE_DEVICE_SETTINGS && !USE_DEVICE_SETTINGS_JSON && !RM_MODEL_EMT_KR)
#include "../rm_include.h"
#include "rm_settings_window_base.h"
//#if (RM_MODEL == RM_MODEL_TYPE_STANDARD || RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#include "../ui/rm_popup.h"
#include <QGroupBox>
#include <QRadioButton>
#define SETTING_NUM_ROW 3
class RMTextEdit;
class WindowSettings : public RMSettingsWindowBase
{
Q_OBJECT
public:
explicit WindowSettings(QWidget *parent = 0);
~WindowSettings();
virtual void afterSave() override;
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
virtual bool validateData() override;
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
private:
// Utility
QVBoxLayout* _createRow(QWidget** rw);
RMRadioButtons* videoResolution; // 1
RMRadioButtons* videoQuality; // 2
RMRadioButtons* videoBrightness; // 3
RMRadioButtons* videoContrast; // 4
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
// 검증용 데이터 KEY 명칭, (REGEX,CONTROL)
QMap<QString,QPair<QString,RMTextEdit*>> validateList;
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
void _createRowA();
private slots:
// void onRecordSetting(int index);
// void onGSensorSensitivity(int index);
};
//#endif // #if (RM_MODEL == RM_MODEL_TYPE_CS_91FH)
#endif // #if (USE_DEVICE_SETTINGS)
#endif // WINDOW_SETTINGS_H

View File

@@ -0,0 +1,402 @@
#include "window_settings_xdr6688.h"
#if (USE_DEVICE_SETTINGS)
#include "../fm_dimensions.h"
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#include "../ui/title_widget.h"
#include "rm_combo_box.h"
#include "rm_radio_buttons.h"
#include "rm_group_combo_box.h"
#include "rm_group_radio_buttons.h"
#include "rm_settings_cfg_xdr6688.h"
#include "rm_setting_time.h"
#include "rm_admin_passwd.h"
#include <QComboBox>
#include <QGridLayout>
#include <QDir>
#include "../ui/rm_widget_checkbox.h"
#if (DETECT_SETTING_USB_EJECT)
#include "../core/rm_usb.h"
#include "../rm_application.h"
#endif
// 문자열 처리 UTF
// https://www.branah.com/unicode-converter
const int gComboBoxWidth = 200;
const int gTitleWidth = 50;
static const QString glevel = MKU8("\xe3\x83\xac\xe3\x83\x99\xe3\x83\xab");
static const QStringList gEOffOn = QStringList() << "OFF" << "ON";
WindowSettings::WindowSettings(QWidget *parent) : RMSettingsWindowBase(parent)
{
//_createRowA();
}
WindowSettings::~WindowSettings()
{
}
//-------------------------------------------------------------
// XDR-66
WindowSettings66::WindowSettings66(QWidget *parent) : WindowSettings(parent)
{
_wwidth = SETTINGS_WINDOW_WIDTH;
_wheight = 600;
setFixedSize(_wwidth,_wheight);
_createRowA();
}
QVBoxLayout* WindowSettings66::_createRow(QWidget** rw)
{
*rw = new QWidget(_contentWidget);
(*rw)->setFixedWidth(_wwidth-(8*2));
layout->addWidget(*rw);
QVBoxLayout* l = new QVBoxLayout(*rw);
l->setMargin(0);
l->setSpacing(4);
l->setAlignment(Qt::AlignTop);
return l;
}
void WindowSettings66::_createRowA()
{
QWidget* row = NULL;
QVBoxLayout* rowLayout = NULL;
rowLayout = _createRow(&row);
int fh = 65;
RMGroupComboBox* gs = new RMGroupComboBox(row,
MKU8("\x33\x47\xe3\x82\xbb\xe3\x83\xb3\xe3\x82\xb5\xe3\x83\xbc\xe6\x84\x9f\xe5\xba\xa6"),
QStringList() << glevel + "1" << glevel + "2" << glevel + "3" \
<< glevel + "4" << glevel + "5",
&CFG::data[SD_SENSOR]);
rowLayout->addWidget(gs);
gs->comboBox->setFixedWidth(gComboBoxWidth);
gs->setFixedHeight(fh);
// 画像 SIZE_800x600, SIZE_640x320
RMGroupRadioButtons* gr = _MGR(row,MKU8("\xe7\x94\xbb\xe5\x83\x8f"),rowLayout,QStringList() << "800x600" << "640x320",SD_SIZE);
gr->setFixedHeight(fh);
// 録画フレームレート
gr = _MGR(row,
MKU8("\xe9\x8c\xb2\xe7\x94\xbb\xe3\x83\x95\xe3\x83\xac\xe3\x83\xbc\xe3\x83\xa0\xe3\x83\xac\xe3\x83\xbc\xe3\x83\x88"),
rowLayout,
QStringList()
<< "20 fps"
<< "25 fps"
<< "30 fps",SD_FRAME);
gr->setFixedHeight(fh);
// 音量調整
gr = _MGR(row,
MKU8("\xe9\x9f\xb3\xe9\x87\x8f\xe8\xaa\xbf\xe6\x95\xb4") + " ",
rowLayout,
QStringList() << "0" << "1" << "2" << "3" << "4" << "5",
SD_VOLUME);
gr->setFixedHeight(fh);
// ボイス
gr = _MGR(row,
MKU8("\xe3\x83\x9c\xe3\x82\xa4\xe3\x82\xb9") + " ",
rowLayout,
QStringList() << MKU8("\xe3\x82\xaa\xe3\x83\x95") << MKU8("\xe3\x82\xaa\xe3\x83\xb3"),
SD_VOICE);
gr->setFixedHeight(fh);
time = new RMSettingTime(row);
rowLayout->addWidget(time);
}
void WindowSettings66::afterSave()
{
if(time->check->isChecked()) {
time->onSave();
}
}
//-------------------------------------------------------------
// XDR-88
WindowSettings88::WindowSettings88(QWidget *parent) : WindowSettings(parent)
{
_wwidth = 800;
_wheight = 550;
setFixedSize(_wwidth,_wheight);
_createRowA();
_createRowB();
}
QVBoxLayout* WindowSettings88::_createRow(QWidget** rw)
{
*rw = new QWidget(_contentWidget);
(*rw)->setFixedWidth((_wwidth-(8*4))/2);
layout->addWidget(*rw);
QVBoxLayout* l = new QVBoxLayout(*rw);
l->setMargin(0);
l->setSpacing(4);
l->setAlignment(Qt::AlignTop);
return l;
}
void WindowSettings88::_createRowA()
{
QWidget* row = NULL;
QVBoxLayout* rowLayout = NULL;
QLabel* tl;
RMRadioButtons* rb;
rowLayout = _createRow(&row);
// システム
QGroupBox* g = new QGroupBox(row);
g->setObjectName("settings");
rowLayout->addWidget(g);
const int lbWidth = 130;
const int cWidth = 150;
const int rWidth = 220;
g->setTitle(MKU8("\xe3\x82\xb7\xe3\x82\xb9\xe3\x83\x86\xe3\x83\xa0"));
QGridLayout* gl = new QGridLayout(g);
gl->setMargin(8);
gl->setSpacing(4);
g->setFixedHeight(160);
// 画面表示
// 1分後画面OFF
// 常時ON
// 1分後時計画面
// RMComboBox* RMSettingsWindowBase::_MC(QWidget *parent,QString title,QLayout* layout, QStringList items,int type,QList<int> indexMap,QLabel** titleLabel)
RMComboBox* tc;
tc = _MC(g,
MKU8("\xe7\x94\xbb\xe9\x9d\xa2\xe8\xa1\xa8\xe7\xa4\xba"),
gl,
QStringList() << MKU8("\x31\xe5\x88\x86\xe5\xbe\x8c\xe7\x94\xbb\xe9\x9d\xa2\x4f\x46\x46") \
<< MKU8("\xe5\xb8\xb8\xe6\x99\x82\x4f\x4e") \
<< MKU8("\x31\xe5\x88\x86\xe5\xbe\x8c\xe6\x99\x82\xe8\xa8\x88\xe7\x94\xbb\xe9\x9d\xa2"),
SD88_SCREEN_SAVEER,
QList<int>(),&tl);
tl->setFixedWidth(lbWidth);
tc->comboBox->setFixedWidth(cWidth);
// 録画画面
// フロント
// リア
// フロント/リア
// リア/フロント
tc = _MC(g,
MKU8("\xe9\x8c\xb2\xe7\x94\xbb\xe7\x94\xbb\xe9\x9d\xa2"),
gl,
QStringList() << FM_WSTR(L"フロント") << FM_WSTR(L"サブ") << FM_WSTR(L"フロント/サブ") << FM_WSTR(L"サブ/フロント"),
SD88_SCREEN_PIP,
QList<int>(),&tl);
tl->setFixedWidth(lbWidth);
tc->comboBox->setFixedWidth(cWidth);
// スピーカー音量
tc = _MC(g,
MKU8("\xe3\x82\xb9\xe3\x83\x94\xe3\x83\xbc\xe3\x82\xab\xe3\x83\xbc\xe9\x9f\xb3\xe9\x87\x8f"),
gl,
QStringList() << "Off" << "1" << "2" << "3" << "4" << "5",
SD88_SPEAKER,
QList<int>(),&tl);
tl->setFixedWidth(lbWidth);
tc->comboBox->setFixedWidth(cWidth);
// MIC
rb = _MR(g,FM_WSTR(L"録音設定"),gl,gEOffOn,SD88_MIC,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
// GROUP 2 STORAGE, メモリ割当
g = new QGroupBox(row);
g->setObjectName("settings");
rowLayout->addWidget(g);
g->setTitle(MKU8("\xe3\x83\xa1\xe3\x83\xa2\xe3\x83\xaa\xe5\x89\xb2\xe5\xbd\x93"));
g->setFixedHeight(89);
gl = new QGridLayout(g);
gl->setMargin(8);
gl->setSpacing(4);
// メモリ割当情報
// 常時録画重視
// 駐車録画重視
// イベント録画重視
tc = _MC(g,
MKU8("\xe3\x83\xa1\xe3\x83\xa2\xe3\x83\xaa\xe5\x89\xb2\xe5\xbd\x93\xe6\x83\x85\xe5\xa0\xb1"),
gl,
QStringList() << MKU8("\xe5\xb8\xb8\xe6\x99\x82\xe9\x8c\xb2\xe7\x94\xbb\xe9\x87\x8d\xe8\xa6\x96") \
<< MKU8("\xe9\xa7\x90\xe8\xbb\x8a\xe9\x8c\xb2\xe7\x94\xbb\xe9\x87\x8d\xe8\xa6\x96") \
<< MKU8("\xe3\x82\xa4\xe3\x83\x99\xe3\x83\xb3\xe3\x83\x88\xe9\x8c\xb2\xe7\x94\xbb\xe9\x87\x8d\xe8\xa6\x96"),
SD88_VOLUME,
QList<int>(),&tl);
tl->setFixedWidth(lbWidth);
tc->comboBox->setFixedWidth(cWidth);
// GROUP 3 G-SENSOR, センサー感度
g = new QGroupBox(row);
g->setObjectName("settings");
rowLayout->addWidget(g);
g->setTitle(MKU8("\xe3\x82\xbb\xe3\x83\xb3\xe3\x82\xb5\xe3\x83\xbc\xe6\x84\x9f\xe5\xba\xa6"));
g->setFixedHeight(120);
gl = new QGridLayout(g);
gl->setMargin(8);
gl->setSpacing(4);
// 常時センサー感度
//QStringList sensors = QStringList() << "Low" << "Middle-Low" << "Middle" << "Middle-High" << "High";
QStringList sensors = QStringList() << "1" << "2" << "3" << "4" << "5";
tc = _MC(g,
MKU8("\xe5\xb8\xb8\xe6\x99\x82\xe3\x82\xbb\xe3\x83\xb3\xe3\x82\xb5\xe3\x83\xbc\xe6\x84\x9f\xe5\xba\xa6"),
gl,
sensors,
SD88_GSENSOR_NORMAL,
QList<int>(),&tl);
tl->setFixedWidth(lbWidth);
tc->comboBox->setFixedWidth(cWidth);
// 駐車センサー感度
tc = _MC(g,
MKU8("\xe9\xa7\x90\xe8\xbb\x8a\xe3\x82\xbb\xe3\x83\xb3\xe3\x82\xb5\xe3\x83\xbc\xe6\x84\x9f\xe5\xba\xa6"),
gl,
sensors,
SD88_GSENSOR_PARKING,
QList<int>(),&tl);
tl->setFixedWidth(lbWidth);
tc->comboBox->setFixedWidth(cWidth);
// GROUP 4 PARKING MODE, 駐車録画
g = new QGroupBox(row);
g->setObjectName("settings");
rowLayout->addWidget(g);
g->setTitle(MKU8("\xe9\xa7\x90\xe8\xbb\x8a\xe9\x8c\xb2\xe7\x94\xbb"));
gl = new QGridLayout(g);
gl->setMargin(8);
gl->setSpacing(4);
//駐車録画機能
rb = _MR(g,MKU8("\xe9\xa7\x90\xe8\xbb\x8a\xe9\x8c\xb2\xe7\x94\xbb\xe6\xa9\x9f\xe8\x83\xbd"),gl,gEOffOn,SD88_PARKING_ON,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
rb->setFixedHeight(45);
// 放電遮断電圧
/*
tl = new QLabel(this);
tl->setObjectName("text_normal_label");
tl->setText(MKU8("\xe6\x94\xbe\xe9\x9b\xbb\xe9\x81\xae\xe6\x96\xad\xe9\x9b\xbb\xe5\x9c\xa7"));
gl->addWidget(tl,1,0,Qt::AlignLeft);
*/
}
void WindowSettings88::_createRowB()
{
QWidget* row = NULL;
QVBoxLayout* rowLayout = NULL;
QLabel* tl;
RMRadioButtons* rb;
const int lbWidth = 130;
//const int cWidth = 150;
const int rWidth = 220;
rowLayout = _createRow(&row);
//int fh = 55;
QGroupBox* g;
QGridLayout* gl;
//暗証番号暗証番号設定OFF 0 ON暗証番号変更暗証番号設定をONにしているとき暗証番号変更4桁の入力が可能。
// GROUP 5 VIDEO, 録画設定
g = new QGroupBox(row);
g->setObjectName("settings");
rowLayout->addWidget(g);
g->setTitle(MKU8("\xe9\x8c\xb2\xe7\x94\xbb\xe8\xa8\xad\xe5\xae\x9a"));
g->setFixedHeight(220);
gl = new QGridLayout(g);
gl->setMargin(8);
gl->setSpacing(4);
// 解像度
rb = _MR(g,MKU8("\xe8\xa7\xa3\xe5\x83\x8f\xe5\xba\xa6"),gl,QStringList() << "FHD" << "HD",SD88_VIDEO_RESOLUTION,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
// 画質
// 低
// 中
// 高
/* 2021/11/22 수정제거
rb = _MR(g,MKU8("\xe7\x94\xbb\xe8\xb3\xaa"),gl,QStringList() << MKU8("\xe4\xbd\x8e") << MKU8("\xe4\xb8\xad") << MKU8("\xe9\xab\x98"),SD88_VIDEO_QUALITY,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
*/
// 録画フレーム数
rb = _MR(g,MKU8("\xe9\x8c\xb2\xe7\x94\xbb\xe3\x83\x95\xe3\x83\xac\xe3\x83\xbc\xe3\x83\xa0\xe6\x95\xb0"),gl,QStringList() << "4.9 fps" << "19.1 fps" << "29.1 fps",SD88_VIDEO_FRAME,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
// サブカメラ録画
rb = _MR(g,MKU8("\xe3\x82\xb5\xe3\x83\x96\xe3\x82\xab\xe3\x83\xa1\xe3\x83\xa9\xe9\x8c\xb2\xe7\x94\xbb"),gl,gEOffOn,SD88_VIDEO_SUB_CAMERA,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
// HDR
rb = _MR(g,"HDR",gl,gEOffOn,SD88_VIDEO_HDR,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
// ナイトビジョン
rb = _MR(g,MKU8("\xe3\x83\x8a\xe3\x82\xa4\xe3\x83\x88\xe3\x83\x93\xe3\x82\xb8\xe3\x83\xa7\xe3\x83\xb3"),gl,gEOffOn,SD88_VIDEO_NIGHT_VISION,QList<int>(),&tl);;
tl->setFixedWidth(lbWidth);
rb->setFixedWidth(rWidth);
// 관리자 암호 설정도 저장
pw = new RMSettingAdminPW(&CFG::data[SD88_ADMIN_PW],(QList<int>() << 1 << 0), row);
rowLayout->addWidget(pw);
//time = new RMSettingTime(row);
//time->setFixedHeight(100);
//rowLayout->addWidget(time);
}
void WindowSettings88::afterSave()
{
// if(time->check->isChecked()) {
// time->onSave();
// }
#if (REMOVE_ADMIN_PW_CHECKBOX)
// 저장
if(CFG::data[SD88_ADMIN_PW] == 0) { // pw->buttons.at(1)->isChecked()) {
#else
if(pw->saveCheckbox->isChecked()) {
#endif
pw->onSave();
}
//qInfo() << __FUNCTION__;
}
#endif // #if (USE_DEVICE_SETTINGS)
#endif // #if (RM_MODEL)

View File

@@ -0,0 +1,71 @@
#ifndef WINDOW_SETTINGS_H
#define WINDOW_SETTINGS_H
#if (USE_DEVICE_SETTINGS)
#include "../rm_include.h"
#include "rm_settings_window_base.h"
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
#include "../ui/rm_popup.h"
#include <QGroupBox>
#include <QRadioButton>
#define SETTING_NUM_ROW 3
class RMSettingTime;
class WindowSettings : public RMSettingsWindowBase
{
Q_OBJECT
public:
int _wwidth;
int _wheight;
explicit WindowSettings(QWidget *parent = 0);
~WindowSettings();
protected:
private slots:
};
// XDR-66
class WindowSettings66 : public WindowSettings
{
Q_OBJECT
public:
explicit WindowSettings66(QWidget *parent = 0);
QVBoxLayout* _createRow(QWidget** rw);
void afterSave() override;
bool validateData(){return true;}
private:
RMSettingTime* time;
void _createRowA();
private slots:
};
// XDR-88
class RMSettingAdminPW;
class RMSettingTime;
class WindowSettings88 : public WindowSettings
{
Q_OBJECT
public:
explicit WindowSettings88(QWidget *parent = 0);
QVBoxLayout* _createRow(QWidget** rw);
void afterSave() override;
bool validateData(){return true;}
private:
RMSettingAdminPW* pw;
//RMSettingTime* time;
void _createRowA();
void _createRowB();
private slots:
};
#endif // #if (RM_MODEL)
#endif // #if (USE_DEVICE_SETTINGS)
#endif // WINDOW_SETTINGS_H

View File

@@ -0,0 +1,61 @@
#ifndef WINDOW_SETTINGS_H
#define WINDOW_SETTINGS_H
#include "../rm_include.h"
#include "rm_settings_window_base.h"
#if (RM_MODEL == RM_MODEL_TYPE_XLDR_F_ADAS)
#include "../ui/rm_popup.h"
#include <QGroupBox>
#include <QRadioButton>
#define SETTING_NUM_ROW 3
class WindowSettings : public RMSettingsWindowBase
{
Q_OBJECT
public:
explicit WindowSettings(QWidget *parent = 0);
~WindowSettings();
private:
// custom value save
//int _lastRecordingSetting;
//void _saveCustomRecordingSetting();
//void _loadCustomRecordingSetting();
// Utility
QVBoxLayout* _createRow(QWidget** rw);
//void _createRecordSetting(QWidget* row,QVBoxLayout* rowLayout);
// RMRadioButtons* videoResolution; // 1
// RMRadioButtons* videoQuality; // 2
// RMRadioButtons* videoBrightness; // 3
// RMRadioButtons* videoContrast; // 4
// void _createGSensorSensitivity(QWidget* row,QVBoxLayout* rowLayout);
// RMGroupComboBox* gSensorSensitivity;
// RMComboBox* gSensorSensitivityFB;
// RMComboBox* gSensorSensitivityLR;
// RMComboBox* gSensorSensitivityUD;
//void _createOrbis(QWidget* row,QVBoxLayout* rowLayout);
//void _createDisasterAlarm(QWidget* row,QVBoxLayout* rowLayout);
void _createFCWS(QWidget* row,QVBoxLayout* rowLayout);
//void _createBCWS(QWidget* row,QVBoxLayout* rowLayout);
//void _createFLIP(QWidget* row,QVBoxLayout* rowLayout);
void _createRowA();
void _createRowB();
//void _createRowC();
private slots:
//void onRecordSetting(int index);
//void onGSensorSensitivity(int index);
};
#endif // #if (RM_MODEL == RM_MODEL_TYPE_CS_91FH)
#endif // WINDOW_SETTINGS_H