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,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);
}