760 lines
21 KiB
C++
760 lines
21 KiB
C++
#include "GlobalSetting.h"
|
|
#include "ui_GlobalSetting.h"
|
|
|
|
GlobalSetting::GlobalSetting(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::GlobalSetting)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
ui->comboBox_ID->addItem(tr("250"),250);
|
|
ui->comboBox_ID->addItem(tr("251"),251);
|
|
ui->comboBox_ID->addItem(tr("252"),252);
|
|
ui->comboBox_ID->addItem(tr("253"),253);
|
|
ui->comboBox_ID->addItem(tr("254"),254);
|
|
ui->comboBox_ID->addItem(tr("255"),255);
|
|
|
|
ui->comboBox_Beep->addItem(tr("开"),true);
|
|
ui->comboBox_Beep->addItem(tr("关"),false);
|
|
|
|
ui->comboBox_TTS->addItem(tr("开"),true);
|
|
ui->comboBox_TTS->addItem(tr("关"),false);
|
|
|
|
ui->comboBox_InfoExport->addItem(tr("输出开启"),true);
|
|
ui->comboBox_InfoExport->addItem(tr("输出关闭"),false);
|
|
|
|
ui->comboBox_InfoID->addItem(tr("1"),1);
|
|
ui->comboBox_InfoID->addItem(tr("2"),2);
|
|
ui->comboBox_InfoID->addItem(tr("3"),3);
|
|
ui->comboBox_InfoID->addItem(tr("4"),4);
|
|
ui->comboBox_InfoID->addItem(tr("5"),5);
|
|
ui->comboBox_InfoID->addItem(tr("6"),6);
|
|
|
|
|
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
QVariant id;
|
|
cfg->get_GCS_ID(&id);
|
|
ui->comboBox_ID->setCurrentIndex(ui->comboBox_ID->findData(id.toInt()));
|
|
|
|
QVariant exportinfo;
|
|
QVariant exportinfoid;
|
|
cfg->get_ExportInfo(&exportinfo,&exportinfoid);
|
|
ui->comboBox_InfoExport->setCurrentIndex(ui->comboBox_InfoExport->findData(exportinfo.toBool()));
|
|
ui->comboBox_InfoID->setCurrentIndex(ui->comboBox_InfoID->findData(exportinfoid.toInt()));
|
|
|
|
|
|
QVariant beep;
|
|
cfg->getBeep(&beep);
|
|
ui->comboBox_Beep->setCurrentIndex(ui->comboBox_Beep->findData(beep.toBool()));
|
|
|
|
|
|
QVariant tts;
|
|
cfg->getTTS(&tts);
|
|
ui->comboBox_TTS->setCurrentIndex(ui->comboBox_TTS->findData(tts.toBool()));
|
|
|
|
emit setTTS(tts.toBool());
|
|
|
|
|
|
|
|
emit setGCSID(id.toInt());//设置全局ID
|
|
|
|
|
|
on_pushButton_getServoOffset_clicked();
|
|
|
|
|
|
QVariant frq;
|
|
QVariant state;
|
|
cfg->getHeartBeat(&state,&frq);
|
|
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("1.0Hz"),1.0);
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("2.0Hz"),2.0);
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("5.0Hz"),5.0);
|
|
ui->comboBox_HeartBeat_Frq->addItem(tr("10Hz"),10);
|
|
ui->comboBox_HeartBeat_Frq->setCurrentIndex(ui->comboBox_HeartBeat_Frq->findData(frq));
|
|
|
|
|
|
ui->comboBox_HeartBeat_State->addItem(tr("发送心跳包"),true);
|
|
ui->comboBox_HeartBeat_State->addItem(tr("关闭心跳包"),false);
|
|
ui->comboBox_HeartBeat_State->setCurrentIndex(ui->comboBox_HeartBeat_Frq->findData(state));
|
|
|
|
on_pushButton_getHeartBeat_clicked();
|
|
getVirtualMargin();
|
|
}
|
|
|
|
GlobalSetting::~GlobalSetting()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_setGCSID_clicked()
|
|
{
|
|
int id = 0;
|
|
|
|
id = ui->comboBox_ID->currentData(Qt::DisplayRole).toInt();
|
|
|
|
qDebug() << id;
|
|
|
|
emit setGCSID(id);
|
|
|
|
Config *cfg = new Config();
|
|
|
|
cfg->set_GCS_ID(id);
|
|
|
|
cfg->deleteLater();
|
|
delete cfg;
|
|
|
|
emit showMessage(tr("设置本机ID成功,ID:%1").arg(QString::number(id)));
|
|
|
|
}
|
|
|
|
void GlobalSetting::getGCSID(void)
|
|
{
|
|
Config *cfg = new Config();
|
|
|
|
QVariant id;
|
|
cfg->get_GCS_ID(&id);
|
|
emit setGCSID(id.toInt());//设置全局ID
|
|
|
|
delete cfg;
|
|
|
|
emit showMessage(tr("设置本机ID成功,ID:%1").arg(QString::number(id.toInt())));
|
|
}
|
|
|
|
|
|
void GlobalSetting::getServo(void)
|
|
{
|
|
on_pushButton_getServoOffset_clicked();
|
|
}
|
|
|
|
|
|
void GlobalSetting::on_pushButton_getServoOffset_clicked()
|
|
{
|
|
Config *cfg = new Config();
|
|
|
|
_servo ch1;
|
|
_servo ch2;
|
|
_servo ch3;
|
|
_servo ch4;
|
|
_servo ch5;
|
|
_servo ch6;
|
|
_servo ch7;
|
|
_servo ch8;
|
|
|
|
|
|
cfg->getServoOffset(&ch1.d0,&ch1.kd,&ch1.len,
|
|
&ch2.d0,&ch2.kd,&ch2.len,
|
|
&ch3.d0,&ch3.kd,&ch3.len,
|
|
&ch4.d0,&ch4.kd,&ch4.len,
|
|
&ch5.d0,&ch5.kd,&ch5.len,
|
|
&ch6.d0,&ch6.kd,&ch6.len,
|
|
&ch7.d0,&ch7.kd,&ch7.len,
|
|
&ch8.d0,&ch8.kd,&ch8.len);
|
|
|
|
ui->doubleSpinBox_Servo_d0_1->setValue(ch1.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_1->setValue(ch1.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_1->setValue(ch1.len.toDouble());
|
|
|
|
ui->doubleSpinBox_Servo_d0_2->setValue(ch2.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_2->setValue(ch2.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_2->setValue(ch2.len.toDouble());
|
|
|
|
ui->doubleSpinBox_Servo_d0_3->setValue(ch3.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_3->setValue(ch3.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_3->setValue(ch3.len.toDouble());
|
|
|
|
ui->doubleSpinBox_Servo_d0_4->setValue(ch4.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_4->setValue(ch4.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_4->setValue(ch4.len.toDouble());
|
|
|
|
ui->doubleSpinBox_Servo_d0_5->setValue(ch5.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_5->setValue(ch5.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_5->setValue(ch5.len.toDouble());
|
|
|
|
ui->doubleSpinBox_Servo_d0_6->setValue(ch6.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_6->setValue(ch6.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_6->setValue(ch6.len.toDouble());
|
|
|
|
ui->doubleSpinBox_Servo_d0_7->setValue(ch7.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_7->setValue(ch7.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_7->setValue(ch7.len.toDouble());
|
|
|
|
ui->doubleSpinBox_Servo_d0_8->setValue(ch8.d0.toDouble());
|
|
ui->doubleSpinBox_Servo_kd_8->setValue(ch8.kd.toDouble());
|
|
ui->doubleSpinBox_Servo_len_8->setValue(ch8.len.toDouble());
|
|
|
|
|
|
|
|
emit setServo(ch1.d0,ch1.kd,ch1.len,
|
|
ch2.d0,ch2.kd,ch2.len,
|
|
ch3.d0,ch3.kd,ch3.len,
|
|
ch4.d0,ch4.kd,ch4.len,
|
|
ch5.d0,ch5.kd,ch5.len,
|
|
ch6.d0,ch6.kd,ch6.len,
|
|
ch7.d0,ch7.kd,ch7.len,
|
|
ch8.d0,ch8.kd,ch8.len);
|
|
|
|
delete cfg;
|
|
|
|
emit showMessage(tr("舵面偏差读取成功"));
|
|
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_setServoOffset_clicked()
|
|
{
|
|
_servo ch1;
|
|
_servo ch2;
|
|
_servo ch3;
|
|
_servo ch4;
|
|
_servo ch5;
|
|
_servo ch6;
|
|
_servo ch7;
|
|
_servo ch8;
|
|
|
|
|
|
ch1.d0 = ui->doubleSpinBox_Servo_d0_1->value();
|
|
ch2.d0 = ui->doubleSpinBox_Servo_d0_2->value();
|
|
ch3.d0 = ui->doubleSpinBox_Servo_d0_3->value();
|
|
ch4.d0 = ui->doubleSpinBox_Servo_d0_4->value();
|
|
ch5.d0 = ui->doubleSpinBox_Servo_d0_5->value();
|
|
ch6.d0 = ui->doubleSpinBox_Servo_d0_6->value();
|
|
ch7.d0 = ui->doubleSpinBox_Servo_d0_7->value();
|
|
ch8.d0 = ui->doubleSpinBox_Servo_d0_8->value();
|
|
|
|
ch1.kd = ui->doubleSpinBox_Servo_kd_1->value();
|
|
ch2.kd = ui->doubleSpinBox_Servo_kd_2->value();
|
|
ch3.kd = ui->doubleSpinBox_Servo_kd_3->value();
|
|
ch4.kd = ui->doubleSpinBox_Servo_kd_4->value();
|
|
ch5.kd = ui->doubleSpinBox_Servo_kd_5->value();
|
|
ch6.kd = ui->doubleSpinBox_Servo_kd_6->value();
|
|
ch7.kd = ui->doubleSpinBox_Servo_kd_7->value();
|
|
ch8.kd = ui->doubleSpinBox_Servo_kd_8->value();
|
|
|
|
ch1.len = ui->doubleSpinBox_Servo_len_1->value();
|
|
ch2.len = ui->doubleSpinBox_Servo_len_2->value();
|
|
ch3.len = ui->doubleSpinBox_Servo_len_3->value();
|
|
ch4.len = ui->doubleSpinBox_Servo_len_4->value();
|
|
ch5.len = ui->doubleSpinBox_Servo_len_5->value();
|
|
ch6.len = ui->doubleSpinBox_Servo_len_6->value();
|
|
ch7.len = ui->doubleSpinBox_Servo_len_7->value();
|
|
ch8.len = ui->doubleSpinBox_Servo_len_8->value();
|
|
|
|
|
|
|
|
emit setServo(ch1.d0,ch1.kd,ch1.len,
|
|
ch2.d0,ch2.kd,ch2.len,
|
|
ch3.d0,ch3.kd,ch3.len,
|
|
ch4.d0,ch4.kd,ch4.len,
|
|
ch5.d0,ch5.kd,ch5.len,
|
|
ch6.d0,ch6.kd,ch6.len,
|
|
ch7.d0,ch7.kd,ch7.len,
|
|
ch8.d0,ch8.kd,ch8.len);
|
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
cfg->setServoOffset(ch1.d0,ch1.kd,ch1.len,
|
|
ch2.d0,ch2.kd,ch2.len,
|
|
ch3.d0,ch3.kd,ch3.len,
|
|
ch4.d0,ch4.kd,ch4.len,
|
|
ch5.d0,ch5.kd,ch5.len,
|
|
ch6.d0,ch6.kd,ch6.len,
|
|
ch7.d0,ch7.kd,ch7.len,
|
|
ch8.d0,ch8.kd,ch8.len);
|
|
|
|
cfg->deleteLater();
|
|
delete cfg;
|
|
|
|
|
|
emit showMessage(tr("舵面偏差设置成功"));
|
|
|
|
}
|
|
|
|
|
|
void GlobalSetting::getHeartBeat(void)
|
|
{
|
|
on_pushButton_getHeartBeat_clicked();
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_getHeartBeat_clicked()
|
|
{
|
|
Config *cfg = new Config();
|
|
|
|
QVariant state;
|
|
QVariant frq;
|
|
|
|
cfg->getHeartBeat(&state,&frq);
|
|
|
|
ui->comboBox_HeartBeat_Frq->setCurrentIndex(ui->comboBox_HeartBeat_Frq->findData(frq));
|
|
ui->comboBox_HeartBeat_State->setCurrentIndex(ui->comboBox_HeartBeat_State->findData(state));
|
|
|
|
delete cfg;
|
|
|
|
emit setHeartBeat(state,frq);
|
|
|
|
emit showMessage(tr("心跳读取成功"));
|
|
}
|
|
|
|
|
|
void GlobalSetting::on_pushButton_setHeartBeat_clicked()
|
|
{
|
|
QVariant state;
|
|
QVariant frq;
|
|
|
|
state = ui->comboBox_HeartBeat_State->currentData();
|
|
frq = ui->comboBox_HeartBeat_Frq->currentData();
|
|
|
|
emit setHeartBeat(state,frq);
|
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
cfg->setHeartBeat(state,frq);
|
|
|
|
cfg->deleteLater();
|
|
delete cfg;
|
|
|
|
|
|
emit showMessage(tr("心跳设置成功"));
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_Beep_clicked()
|
|
{
|
|
QVariant state;
|
|
|
|
state = ui->comboBox_Beep->currentData();
|
|
|
|
emit setBeep(state.toBool());
|
|
|
|
Config *cfg = new Config();
|
|
|
|
cfg->setBeep(state);
|
|
|
|
cfg->deleteLater();
|
|
delete cfg;
|
|
|
|
|
|
emit showMessage((state.toBool())?(tr("心跳声音开启")):(tr("心跳声音关闭")));
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_TTS_clicked()
|
|
{
|
|
QVariant state;
|
|
|
|
state = ui->comboBox_TTS->currentData();
|
|
|
|
emit setTTS(state.toBool());
|
|
|
|
Config *cfg = new Config();
|
|
|
|
cfg->setTTS(state);
|
|
|
|
cfg->deleteLater();
|
|
delete cfg;
|
|
|
|
|
|
emit showMessage((state.toBool())?(tr("语音提示开启")):(tr("语音提示关闭")));
|
|
}
|
|
|
|
void GlobalSetting::getTTS(void)
|
|
{
|
|
on_pushButton_TTS_clicked();
|
|
}
|
|
|
|
|
|
void GlobalSetting::getVirtualMargin(void)
|
|
{
|
|
Config *cfg = new Config();
|
|
|
|
red = cfg->getVirtualMargin(0);
|
|
orange = cfg->getVirtualMargin(1);
|
|
drop1 = cfg->getVirtualMargin(2);
|
|
drop2 = cfg->getVirtualMargin(3);
|
|
|
|
ui->textEdit_Warning->clear();
|
|
foreach (Config::_latlng var, red) {
|
|
ui->textEdit_Warning->insertPlainText(QString::number(var.index) + " " + QString::number(var.latitude,'f',8) + " " +QString::number(var.longitude,'f',8) + "\n");
|
|
}
|
|
|
|
ui->textEdit_Notice->clear();
|
|
foreach (Config::_latlng var, orange) {
|
|
ui->textEdit_Notice->insertPlainText(QString::number(var.index) + " " + QString::number(var.latitude,'f',8) + " " +QString::number(var.longitude,'f',8) + "\n");
|
|
}
|
|
|
|
ui->textEdit_Drop1->clear();
|
|
foreach (Config::_latlng var, drop1) {
|
|
ui->textEdit_Drop1->insertPlainText(QString::number(var.index) + " " + QString::number(var.latitude,'f',8) + " " +QString::number(var.longitude,'f',8) + "\n");
|
|
}
|
|
|
|
ui->textEdit_Drop2->clear();
|
|
foreach (Config::_latlng var, drop2) {
|
|
ui->textEdit_Drop2->insertPlainText(QString::number(var.index) + " " + QString::number(var.latitude,'f',8) + " " +QString::number(var.longitude,'f',8) + "\n");
|
|
}
|
|
|
|
//读取后告诉map,并生成
|
|
emit setMargin(0,red,QColor("#F64034"));
|
|
emit setMargin(1,orange,QColor("#F1B243"));
|
|
emit setMargin(2,drop1,QColor("#01DFD7"));
|
|
emit setMargin(3,drop2,QColor("#01DFD7"));
|
|
}
|
|
|
|
void GlobalSetting::setVirtualMargin(void)
|
|
{
|
|
red.clear();
|
|
orange.clear();
|
|
drop1.clear();
|
|
drop2.clear();
|
|
|
|
Config *cfg = new Config();
|
|
|
|
QString red_str = ui->textEdit_Warning->toPlainText();
|
|
|
|
QStringList red_list = red_str.split('\n');
|
|
|
|
foreach (QString var, red_list) {
|
|
QStringList items = var.split(' ');
|
|
|
|
if(items.size() >=3)
|
|
{
|
|
QString index = items.at(0);
|
|
QString latitude = items.at(1);
|
|
QString longitude = items.at(2);
|
|
|
|
Config::_latlng latlng;
|
|
|
|
latlng.index = index.toInt();
|
|
latlng.latitude = latitude.toDouble();
|
|
latlng.longitude = longitude.toDouble();
|
|
|
|
red.insert(latlng.index,latlng);
|
|
}
|
|
}
|
|
|
|
QString orange_str = ui->textEdit_Notice->toPlainText();
|
|
|
|
QStringList orange_list = orange_str.split('\n');
|
|
|
|
foreach (QString var, orange_list) {
|
|
QStringList items = var.split(' ');
|
|
|
|
if(items.size() >=3)
|
|
{
|
|
QString index = items.at(0);
|
|
QString latitude = items.at(1);
|
|
QString longitude = items.at(2);
|
|
|
|
Config::_latlng latlng;
|
|
|
|
latlng.index = index.toInt();
|
|
latlng.latitude = latitude.toDouble();
|
|
latlng.longitude = longitude.toDouble();
|
|
|
|
orange.insert(latlng.index,latlng);
|
|
}
|
|
}
|
|
|
|
QString drop1_str = ui->textEdit_Drop1->toPlainText();
|
|
QStringList drop1_list = drop1_str.split('\n');
|
|
foreach (QString var, drop1_list) {
|
|
QStringList items = var.split(' ');
|
|
|
|
if(items.size() >=3)
|
|
{
|
|
QString index = items.at(0);
|
|
QString latitude = items.at(1);
|
|
QString longitude = items.at(2);
|
|
|
|
Config::_latlng latlng;
|
|
|
|
latlng.index = index.toInt();
|
|
latlng.latitude = latitude.toDouble();
|
|
latlng.longitude = longitude.toDouble();
|
|
|
|
drop1.insert(latlng.index,latlng);
|
|
}
|
|
}
|
|
|
|
QString drop2_str = ui->textEdit_Drop2->toPlainText();
|
|
QStringList drop2_list = drop2_str.split('\n');
|
|
foreach (QString var, drop2_list) {
|
|
QStringList items = var.split(' ');
|
|
|
|
if(items.size() >=3)
|
|
{
|
|
QString index = items.at(0);
|
|
QString latitude = items.at(1);
|
|
QString longitude = items.at(2);
|
|
|
|
Config::_latlng latlng;
|
|
|
|
latlng.index = index.toInt();
|
|
latlng.latitude = latitude.toDouble();
|
|
latlng.longitude = longitude.toDouble();
|
|
|
|
drop2.insert(latlng.index,latlng);
|
|
}
|
|
}
|
|
|
|
|
|
cfg->setVirtualMargin(red,0);
|
|
cfg->setVirtualMargin(orange,1);
|
|
cfg->setVirtualMargin(drop1,2);
|
|
cfg->setVirtualMargin(drop2,3);
|
|
|
|
//读取后告诉map,并生成
|
|
emit setMargin(0,red,QColor("#F64034"));
|
|
emit setMargin(1,orange,QColor("#F1B243"));
|
|
emit setMargin(2,drop1,QColor("#01DFD7"));
|
|
emit setMargin(3,drop2,QColor("#01DFD7"));
|
|
|
|
}
|
|
|
|
void GlobalSetting::setMapSource(QStringList const &sources)
|
|
{
|
|
while(ui->comboMapSource->count() )
|
|
{
|
|
ui->comboMapSource->removeItem(0);
|
|
}
|
|
|
|
ui->comboMapSource->addItems(sources);
|
|
}
|
|
|
|
void GlobalSetting::setDefaultMapSource(const QString &mapName)
|
|
{
|
|
int index = ui->comboMapSource->findText(mapName);
|
|
if(index != -1)
|
|
{
|
|
ui->comboMapSource->setCurrentIndex(index);
|
|
}
|
|
}
|
|
|
|
void GlobalSetting::cleanDownloadInfo()
|
|
{
|
|
isSaveMap = false;
|
|
ui->pushButton->setText(u8"开始缓存");
|
|
cancelCheckedMapGrade(); //地图缓存完成后,所有选择的地图缓存级别设置未选中
|
|
|
|
|
|
// ui->lab_image_num->setText(QString(u8"下载图片数:") );
|
|
// ui->progressBar->setValue(0);
|
|
// ui->labMapGrade->setText(QString(u8"地图级别:") );
|
|
}
|
|
|
|
void GlobalSetting::showDownloadImageNum(int total, int actual, quint8 id)
|
|
{
|
|
QProgressBar *bar;
|
|
switch(id)
|
|
{
|
|
case 0: bar = ui->progress_0; break;
|
|
case 1: bar = ui->progress_1; break;
|
|
case 2: bar = ui->progress_2; break;
|
|
case 3: bar = ui->progress_3; break;
|
|
}
|
|
|
|
QString format = QString("%v/%1").arg(total);
|
|
bar->setFormat(format);
|
|
bar->setMaximum(total);
|
|
bar->setValue(actual);
|
|
// QString format = QString("%v/%1").arg(total);
|
|
// ui->progressBar->setFormat(format);
|
|
// ui->progressBar->setMaximum(total);
|
|
// ui->progressBar->setValue(actual);
|
|
//// ui->lab_image_num->setText(QString(u8"下载图片数:%1/%2").arg(actual).arg(total) );
|
|
}
|
|
|
|
void GlobalSetting::setLngLatRectRange(double lng1, double lat1, double lng2, double lat2)
|
|
{
|
|
ui->dSpinStartLng->setValue(lng1);
|
|
ui->dSpinStartLat->setValue(lat1);
|
|
ui->dSpinEndLng->setValue(lng2);
|
|
ui->dSpinEndLat->setValue(lat2);
|
|
}
|
|
|
|
void GlobalSetting::setProgressBarValue(int value)
|
|
{
|
|
// ui->progressBar->setValue(value);
|
|
}
|
|
|
|
void GlobalSetting::setMapSaveGrade(int zoom, quint8 id)
|
|
{
|
|
QLabel *lab;
|
|
QProgressBar *bar;
|
|
switch(id)
|
|
{
|
|
case 0:
|
|
{
|
|
lab = ui->labMapGrade_0;
|
|
bar = ui->progress_0;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
lab = ui->labMapGrade_1;
|
|
bar = ui->progress_1;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
lab = ui->labMapGrade_2;
|
|
bar = ui->progress_2;
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
lab = ui->labMapGrade_3;
|
|
bar = ui->progress_3;
|
|
break;
|
|
}
|
|
}
|
|
|
|
lab->setText(QString("地图级别:%1").arg(zoom) );
|
|
bar->setValue(0);
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_readVirtualMargin_clicked()
|
|
{
|
|
getVirtualMargin();
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_saveVirtualMargin_clicked()
|
|
{
|
|
setVirtualMargin();
|
|
}
|
|
|
|
void GlobalSetting::getExportInfo(void)
|
|
{
|
|
on_pushButton_InfoExport_clicked();
|
|
}
|
|
|
|
void GlobalSetting::on_pushButton_InfoExport_clicked()
|
|
{
|
|
QVariant state,id;
|
|
|
|
state = ui->comboBox_InfoExport->currentData();
|
|
id = ui->comboBox_InfoID->currentData();
|
|
|
|
emit setExportInfo(state,id);
|
|
|
|
Config *cfg = new Config();
|
|
|
|
cfg->set_ExportInfo(state,id);
|
|
|
|
cfg->deleteLater();
|
|
delete cfg;
|
|
|
|
|
|
emit showMessage((state.toBool())?(tr("信息输出开启")):(tr("信息输出关闭")));
|
|
}
|
|
|
|
void GlobalSetting::on_comboMapSource_currentIndexChanged(int index)
|
|
{
|
|
QVariant value(ui->comboMapSource->currentText() );
|
|
Config *config = new Config();
|
|
config->setMapType(value);
|
|
delete config;
|
|
|
|
emit setMapTypes(value);
|
|
}
|
|
|
|
|
|
void GlobalSetting::on_btnRectRange_clicked()
|
|
{
|
|
emit goToBase();
|
|
}
|
|
|
|
|
|
void GlobalSetting::on_pushButton_clicked()
|
|
{
|
|
isSaveMap = !isSaveMap;
|
|
|
|
if(isSaveMap)
|
|
{
|
|
ui->pushButton->setText(u8"取消缓存");
|
|
|
|
//获取需要保存地图级别
|
|
internals::RectLatLng range = internals::RectLatLng::FromLTRB(ui->dSpinStartLng->value(), ui->dSpinStartLat->value(),
|
|
ui->dSpinEndLng->value(), ui->dSpinEndLat->value() );
|
|
QList<QCheckBox*> temp = ui->groupMapGrade->findChildren<QCheckBox*>(); //获取QCheckBox
|
|
|
|
QList<int> grades;
|
|
|
|
foreach(QCheckBox *chk, temp)
|
|
{
|
|
if(chk->isChecked() )
|
|
{
|
|
grades << chk->text().toInt();
|
|
}
|
|
}
|
|
|
|
std::sort(grades.begin(), grades.end() ); //排序
|
|
|
|
emit mapSave(range, grades);
|
|
}
|
|
else
|
|
{
|
|
ui->pushButton->setText(u8"开始缓存");
|
|
|
|
emit cancelSaveMap();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void GlobalSetting::on_btnLogin_clicked()
|
|
{
|
|
int proxyIndex = ui->chkProxyType->currentIndex(); //获取coboBox的当前索引值
|
|
QNetworkProxy::ProxyType proxyType;
|
|
|
|
switch(proxyIndex) //根据当前索引值获取代理类型
|
|
{
|
|
case 0:
|
|
proxyType = QNetworkProxy::NoProxy; break;
|
|
case 1:
|
|
proxyType = QNetworkProxy::HttpProxy; break;
|
|
case 2:
|
|
proxyType = QNetworkProxy::Socks5Proxy; break;
|
|
}
|
|
|
|
QString addr(ui->editAddr->text() ); //获取地址
|
|
int port = ui->editPort->text().toInt(); //获取端口号
|
|
QString name(ui->edit_name->text() );
|
|
QString password(ui->edit_password->text() );
|
|
|
|
QNetworkProxy proxy(proxyType, addr, port, name, password);
|
|
|
|
QNetworkProxy::setApplicationProxy(proxy);
|
|
}
|
|
|
|
|
|
void GlobalSetting::on_chkProxyType_currentIndexChanged(int index)
|
|
{
|
|
if(index == 1)
|
|
{
|
|
ui->editAddr->setText("127.0.0.1");
|
|
ui->editPort->setText("33210");
|
|
}
|
|
else
|
|
{
|
|
ui->editAddr->setText("");
|
|
ui->editPort->setText("");
|
|
}
|
|
|
|
ui->edit_name->setText("");
|
|
ui->edit_password->setText("");
|
|
}
|
|
|
|
void GlobalSetting::cancelCheckedMapGrade()
|
|
{
|
|
QList<QCheckBox*> temp = ui->groupMapGrade->findChildren<QCheckBox*>(); //获取QCheckBox
|
|
foreach(QCheckBox *box, temp) //所有级别取消选中
|
|
{
|
|
if(box->isChecked() )
|
|
{
|
|
box->setChecked(false);
|
|
}
|
|
}
|
|
}
|
|
|