qt/ledset/brightwin.cpp

197 lines
5.4 KiB
C++
Raw Permalink Normal View History

2022-08-25 18:43:03 +08:00
#include "brightwin.h"
#include <QBoxLayout>
#include <QFrame>
#include <QLabel>
#include <QSpinBox>
#include <QSlider>
#include <QPushButton>
#include <QTableWidget>
#include <QHeaderView>
#include <QDebug>
BrightWin::BrightWin(QWidget *parent) : BaseWin{parent} {
setWindowModality(Qt::WindowModal);
setAttribute(Qt::WA_DeleteOnClose);
2022-12-16 15:08:53 +08:00
setWindowTitle(tr("亮度控制"));
2022-08-25 18:43:03 +08:00
resize(620, 700);
auto vBox = new QVBoxLayout(center);
vBox->setContentsMargins(0,0,0,0);
vBox->addLayout(addBtns(new QHBoxLayout()));
auto hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("亮度设置")));
auto line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
auto lb = new QLabel(tr("亮度")+":");
lb->setMinimumWidth(70);
lb->setAlignment(Qt::AlignRight);
hBox->addWidget(lb);
auto fdBright = new QSpinBox();
fdBright->setRange(0,255);
fdBright->setValue(255);
hBox->addWidget(fdBright);
auto sliBright = new QSlider(Qt::Horizontal);
sliBright->setRange(0,255);
sliBright->setValue(255);
hBox->addWidget(sliBright);
connect(fdBright, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, sliBright, &QSlider::setValue);
connect(sliBright, &QSlider::valueChanged, fdBright, &QSpinBox::setValue);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
lb = new QLabel(tr("对比度")+":");
lb->setMinimumWidth(70);
lb->setAlignment(Qt::AlignRight);
hBox->addWidget(lb);
auto fdContrast = new QSpinBox();
fdContrast->setRange(1,255);
fdContrast->setValue(64);
hBox->addWidget(fdContrast);
auto sliContrast = new QSlider(Qt::Horizontal);
sliContrast->setRange(1,255);
sliContrast->setValue(64);
hBox->addWidget(sliContrast);
connect(fdContrast, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, sliContrast, &QSlider::setValue);
connect(sliContrast, &QSlider::valueChanged, fdContrast, &QSpinBox::setValue);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox->addStretch();
2022-12-16 15:08:53 +08:00
auto btnSave = new QPushButton(tr("固化"));
2022-08-25 18:43:03 +08:00
btnSave->setMinimumWidth(80);
hBox->addWidget(btnSave);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("色彩调整")));
line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
lb = new QLabel(tr("")+":");
lb->setMinimumWidth(70);
lb->setAlignment(Qt::AlignRight);
hBox->addWidget(lb);
auto fdRed = new QSpinBox();
fdRed->setRange(0, 32768);
fdRed->setValue(32768);
hBox->addWidget(fdRed);
auto sliRed = new QSlider(Qt::Horizontal);
sliRed->setRange(0, 32768);
sliRed->setValue(32768);
hBox->addWidget(sliRed);
connect(fdRed, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, sliRed, &QSlider::setValue);
connect(sliRed, &QSlider::valueChanged, fdRed, &QSpinBox::setValue);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
lb = new QLabel(tr("绿")+":");
lb->setMinimumWidth(70);
lb->setAlignment(Qt::AlignRight);
hBox->addWidget(lb);
auto fdGreen = new QSpinBox();
fdGreen->setRange(0, 32768);
fdGreen->setValue(32768);
hBox->addWidget(fdGreen);
auto sliGreen = new QSlider(Qt::Horizontal);
sliGreen->setRange(0, 32768);
sliGreen->setValue(32768);
hBox->addWidget(sliGreen);
connect(fdGreen, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, sliGreen, &QSlider::setValue);
connect(sliGreen, &QSlider::valueChanged, fdGreen, &QSpinBox::setValue);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
lb = new QLabel(tr("")+":");
lb->setMinimumWidth(70);
lb->setAlignment(Qt::AlignRight);
hBox->addWidget(lb);
auto fdBlue = new QSpinBox();
fdBlue->setRange(0, 32768);
fdBlue->setValue(32768);
hBox->addWidget(fdBlue);
auto sliBlue = new QSlider(Qt::Horizontal);
sliBlue->setRange(0, 32768);
sliBlue->setValue(32768);
hBox->addWidget(sliBlue);
connect(fdBlue, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, sliBlue, &QSlider::setValue);
connect(sliBlue, &QSlider::valueChanged, fdBlue, &QSpinBox::setValue);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox->addStretch();
2022-12-16 15:08:53 +08:00
btnSave = new QPushButton(tr("固化"));
2022-08-25 18:43:03 +08:00
btnSave->setMinimumWidth(80);
hBox->addWidget(btnSave);
vBox->addLayout(hBox);
hBox = new QHBoxLayout();
hBox->addWidget(new QLabel(tr("Gamma 调节")));
line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1);
vBox->addLayout(hBox);
auto table = new QTableWidget(256, 2);
table->setSelectionBehavior(QTableWidget::SelectRows);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setAlternatingRowColors(true);
table->setHorizontalHeaderLabels({"X","Y"});
table->horizontalHeader()->setBackgroundRole(QPalette::Window);
for(int i=0; i<256; i++) {
table->setItem(i, 0, new QTableWidgetItem(QString::number(i)));
}
vBox->addWidget(table);
connect(btnSave, &QPushButton::clicked, this, [] {
qDebug()<<"aaa";
});
vBox->addStretch();
}