代码拉取完成,页面将自动刷新
同步操作将从 觉皇/QtSerialPortPlotter 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "settings.h"
#include <QColorDialog>
#include <QDebug>
#include <QInputDialog>
#include <QMessageBox>
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsDialog)
{
ui->setupUi(this);
// 设置多选模式
ui->lineColorslistWidget->setSelectionMode(QListWidget::ExtendedSelection);
connect(ui->lineColorslistWidget, &QListWidget::itemDoubleClicked, this, [=](QListWidgetItem* item){
bool ok = false;
QString channelName = QInputDialog::getText(this, tr("设置通道名称"), tr("名称:"), QLineEdit::Normal, item->text(), &ok, Qt::FramelessWindowHint);
if(ok)
{
if(channelName.isEmpty())
{
QMessageBox::critical(this, tr("错误"), tr("通道名称不能为空!"));
return ;
}
QColor c = QColorDialog::getColor(item->foreground().color());
if(c.isValid())
{
item->setText(channelName);
item->setForeground(QBrush(c));
}
}
});
connect(ui->addButton, &QPushButton::clicked, this, [=](){
bool ok = false;
QString channelName = QInputDialog::getText(this, tr("设置通道名称"), tr("名称:"), QLineEdit::Normal, "", &ok, Qt::FramelessWindowHint);
if(ok)
{
if(channelName.isEmpty())
{
QMessageBox::critical(this, tr("错误"), tr("通道名称不能为空!"));
return ;
}
QColor c = QColorDialog::getColor();
if(c.isValid())
{
ui->lineColorslistWidget->addItem(channelName);
ui->lineColorslistWidget->item(ui->lineColorslistWidget->count() - 1)->setForeground(QBrush(c));
}
}
});
connect(ui->removeButton, &QPushButton::clicked, this, [=](){
while (true)
{
QModelIndexList indexs = ui->lineColorslistWidget->selectionModel()->selectedIndexes();
if(indexs.isEmpty())
break;
QListWidgetItem* item = ui->lineColorslistWidget->takeItem(indexs[0].row());
delete item;
}
});
ui->themeComboBox->addItems({tr("默认"), tr("酷黑")});
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
void SettingsDialog::showEvent(QShowEvent *e)
{
QDialog::showEvent(e);
ui->themeComboBox->setCurrentIndex(Settings::getTheme());
QStringList colors = Settings::getLineColors();
QStringList names = Settings::getLineNames();
for(int i = 0; i != colors.size(); i++)
{
ui->lineColorslistWidget->addItem(names[i]);
ui->lineColorslistWidget->item(i)->setForeground(QBrush(QColor(colors[i])));
}
}
void SettingsDialog::accept()
{
QStringList colors;
QStringList names;
for(int i = 0; i != ui->lineColorslistWidget->count(); i++)
{
QListWidgetItem* item = ui->lineColorslistWidget->item(i);
QRgb rgb = item->foreground().color().rgb() & 0XFFFFFFU;
colors.append(QString::asprintf("#%06X", rgb));
names.append(item->text());
}
Settings::setLineColors(colors);
Settings::setLineNames(names);
Settings::setTheme(ui->themeComboBox->currentIndex());
done(Accepted);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。