first commit
This commit is contained in:
227
project/fm_viewer/cfg/rm_admin_passwd.cpp
Normal file
227
project/fm_viewer/cfg/rm_admin_passwd.cpp
Normal 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)
|
||||
Reference in New Issue
Block a user