From 10aa14fab45b02772fa7b1d1f5ff4d6d6845de48 Mon Sep 17 00:00:00 2001 From: Gangphon Date: Tue, 25 Jun 2024 09:37:41 +0800 Subject: [PATCH] ledok --- LedOK/device/ctrlverifyclockpanel.cpp | 87 +-------------------------- LedOK/deviceitem.cpp | 5 +- LedOK/program/eaclock.cpp | 14 ++--- LedOK/program/edclock.cpp | 10 +-- LedOK/program/ephoto.cpp | 10 ++- 5 files changed, 24 insertions(+), 102 deletions(-) diff --git a/LedOK/device/ctrlverifyclockpanel.cpp b/LedOK/device/ctrlverifyclockpanel.cpp index b79cef3..d1153af 100644 --- a/LedOK/device/ctrlverifyclockpanel.cpp +++ b/LedOK/device/ctrlverifyclockpanel.cpp @@ -5,6 +5,7 @@ #include "gutil/qgui.h" #include "tools.h" #include +#include #include #include #include "devicepanel.h" @@ -17,90 +18,8 @@ CtrlVerifyClockPanel::CtrlVerifyClockPanel() { hBox->addWidget(label); fdTimezone = new QComboBox; - fdTimezone->setMinimumWidth(200); - fdTimezone->addItem("Africa/Brazzaville");//西部非洲标准时间 (布拉扎维) - fdTimezone->addItem("Africa/Cairo");//东欧标准时间 (开罗) - fdTimezone->addItem("Africa/Casablanca");//卡萨布兰卡 - fdTimezone->addItem("Africa/Harare");//中部非洲标准时间 (哈拉雷) - fdTimezone->addItem("Africa/Nairobi");//东部非洲标准时间 (内罗毕) - fdTimezone->addItem("Africa/Windhoek");//温得和克 - fdTimezone->addItem("America/Anchorage");//>安克雷奇 - fdTimezone->addItem("America/Argentina/Buenos_Aires");//布宜诺斯艾利斯 - fdTimezone->addItem("America/Barbados");//>大西洋时间 (巴巴多斯) - fdTimezone->addItem("America/Bogota");//>哥伦比亚时间 (波哥大) - fdTimezone->addItem("America/Caracas");//>委内瑞拉时间 (加拉加斯) - fdTimezone->addItem("America/Chicago");//>美国中部时间 (芝加哥) - fdTimezone->addItem("America/Chihuahua");//>奇瓦瓦 - fdTimezone->addItem("America/Costa_Rica");//>美国中部时间 (哥斯达黎加) - fdTimezone->addItem("America/Denver");//>美国山区时间 (丹佛) - fdTimezone->addItem("America/Godthab");//戈特霍布 - fdTimezone->addItem("America/Los_Angeles");//>美国太平洋时间 (洛杉矶) - fdTimezone->addItem("America/Manaus");//亚马逊标准时间 (马瑙斯) - fdTimezone->addItem("America/Mexico_City");//>美国中部时间 (墨西哥城) - fdTimezone->addItem("America/Montevideo");//乌拉圭时间 (蒙得维的亚) - fdTimezone->addItem("America/New_York");//>美国东部时间 (纽约) - fdTimezone->addItem("America/Phoenix");//>美国山区时间 (凤凰城) - fdTimezone->addItem("America/Regina");//>美国中部时间 (里贾纳) - fdTimezone->addItem("America/Santiago");//圣地亚哥 - fdTimezone->addItem("America/Sao_Paulo");//圣保罗 - fdTimezone->addItem("America/St_Johns");//纽芬兰时间 (圣约翰) - fdTimezone->addItem("America/Tijuana");//>美国太平洋时间 (提华纳) - fdTimezone->addItem("Asia/Almaty");//阿拉木图 - fdTimezone->addItem("Asia/Amman");//东欧标准时间 (安曼) - fdTimezone->addItem("Asia/Baghdad");//巴格达 - fdTimezone->addItem("Asia/Baku");//巴库 - fdTimezone->addItem("Asia/Bangkok");//曼谷 - fdTimezone->addItem("Asia/Beirut");//东欧标准时间 (贝鲁特) - fdTimezone->addItem("Asia/Calcutta");//加尔各答 - fdTimezone->addItem("Asia/Colombo");//科伦坡 - fdTimezone->addItem("Asia/Dubai");//迪拜 - fdTimezone->addItem("Asia/Hong_Kong");//香港时间 (香港) - fdTimezone->addItem("Asia/Irkutsk");//伊尔库茨克时间 (伊尔库茨克) - fdTimezone->addItem("Asia/Jerusalem");//以色列时间 (耶路撒冷) - fdTimezone->addItem("Asia/Kabul");//阿富汗时间 (喀布尔) - fdTimezone->addItem("Asia/Karachi");//卡拉奇 - fdTimezone->addItem("Asia/Katmandu");//尼泊尔时间 (加德满都) - fdTimezone->addItem("Asia/Krasnoyarsk");//克拉斯诺亚尔斯克 - fdTimezone->addItem("Asia/Kuala_Lumpur");//吉隆坡 - fdTimezone->addItem("Asia/Kuwait");//科威特 - fdTimezone->addItem("Asia/Magadan");//马加丹时间 (马加丹) - fdTimezone->addItem("Asia/Oral");//乌拉尔 - fdTimezone->addItem("Asia/Rangoon");//缅甸时间 (仰光) - fdTimezone->addItem("Asia/Seoul");//首尔 - fdTimezone->addItem("Asia/Shanghai");//中国标准时间 (北京) - fdTimezone->addItem("Asia/Taipei");//台北时间 (台北) - fdTimezone->addItem("Asia/Tbilisi");//第比利斯 - fdTimezone->addItem("Asia/Tehran");//伊朗标准时间 (德黑兰) - fdTimezone->addItem("Asia/Tokyo");//日本时间 (东京) - fdTimezone->addItem("Asia/Vladivostok");//海参崴时间 (符拉迪沃斯托克) - fdTimezone->addItem("Asia/Yakutsk");//雅库茨克时间 (雅库茨克) - fdTimezone->addItem("Asia/Yekaterinburg");//叶卡捷林堡 - fdTimezone->addItem("Asia/Yerevan");//埃里温 - fdTimezone->addItem("Atlantic/Azores");//亚述尔群岛 - fdTimezone->addItem("Atlantic/Cape_Verde");//佛得角 - fdTimezone->addItem("Atlantic/South_Georgia");//南乔治亚 - fdTimezone->addItem("Australia/Adelaide");//阿德莱德 - fdTimezone->addItem("Australia/Brisbane");//布里斯班 - fdTimezone->addItem("Australia/Darwin");//达尔文 - fdTimezone->addItem("Australia/Hobart");//霍巴特 - fdTimezone->addItem("Australia/Perth");//佩思 - fdTimezone->addItem("Australia/Sydney");//悉尼 - fdTimezone->addItem("Europe/Amsterdam");//中欧标准时间 (阿姆斯特丹) - fdTimezone->addItem("Europe/Athens");//东欧标准时间 (雅典) - fdTimezone->addItem("Europe/Belgrade");//中欧标准时间 (贝尔格莱德) - fdTimezone->addItem("Europe/Brussels");//中欧标准时间 (布鲁塞尔) - fdTimezone->addItem("Europe/Helsinki");//东欧标准时间 (赫尔辛基) - fdTimezone->addItem("Europe/London");//格林尼治标准时间 (伦敦) - fdTimezone->addItem("Europe/Minsk");//明斯克 - fdTimezone->addItem("Europe/Moscow");//莫斯科 - fdTimezone->addItem("Europe/Sarajevo");//中欧标准时间 (萨拉热窝) - fdTimezone->addItem("Pacific/Auckland");//奥克兰 - fdTimezone->addItem("Pacific/Fiji");//斐济 - fdTimezone->addItem("Pacific/Guam");//关岛 - fdTimezone->addItem("Pacific/Honolulu"); - fdTimezone->addItem("Pacific/Majuro"); - fdTimezone->addItem("Pacific/Midway"); - fdTimezone->addItem("Pacific/Tongatapu");//东加塔布 + auto zoneIds = QTimeZone::availableTimeZoneIds(); + for(auto &zoneId : zoneIds) fdTimezone->addItem(zoneId); hBox->addWidget(fdTimezone); fdTimeZoneSet = new QPushButton; diff --git a/LedOK/deviceitem.cpp b/LedOK/deviceitem.cpp index efba5e4..9208017 100644 --- a/LedOK/deviceitem.cpp +++ b/LedOK/deviceitem.cpp @@ -7,7 +7,6 @@ #include #include #include -#include DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) { setFlags(flags() & ~Qt::ItemIsUserCheckable); @@ -21,7 +20,7 @@ DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) { btnGetCapture->setIcon(QIcon(":/res/deviceReadbackPic.png")); btnGetCapture->setIconSize({28, 28}); QObject::connect(btnGetCapture, &QPushButton::clicked, btnGetCapture, [=] { - QJsonObject json; + JObj json; json.insert("_id", "GetScreenshotFull"); json.insert("_type", "GetScreenshotFull"); auto waitingDlg = new WaitingDlg(btnGetCapture, DevicePanel::tr("Getting ")+DevicePanel::tr("Screenshot")+" ..."); @@ -58,7 +57,7 @@ DeviceItem::DeviceItem(LoQTreeWidget *parent) : TreeWidgetItem(parent) { bool ok; auto pwd = QInputDialog::getText(treeWidget(), DevicePanel::tr("Input password"), DevicePanel::tr("Input password"), QLineEdit::Password, QString(), &ok); if(! ok) return; - QJsonObject json; + JObj json; json.insert("_id", "VerifyPassword"); json.insert("_type", "VerifyPassword"); json.insert("pwd", pwd); diff --git a/LedOK/program/eaclock.cpp b/LedOK/program/eaclock.cpp index 6560005..b6581f5 100644 --- a/LedOK/program/eaclock.cpp +++ b/LedOK/program/eaclock.cpp @@ -205,7 +205,7 @@ QWidget* EAClock::attrWgt() { auto hBox = new HBox(vBox); hBox->addWidget(new QLabel(tr("Basic Properties"))); - auto line = new QFrame(); + auto line = new QFrame; line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); hBox->addWidget(line, 1); @@ -215,15 +215,15 @@ QWidget* EAClock::attrWgt() { hBox->addSpacing(6); hBox->addWidget(new QLabel(tr("Time Zone"))); - auto wTimeZone = new QComboBox(); - QList ids = QTimeZone::availableTimeZoneIds(); - foreach(QByteArray id, ids) wTimeZone->addItem(QString::fromUtf8(id)); - wTimeZone->setCurrentText(m_attr.timeZone.id()); - connect(wTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) { + auto edTimeZone = new QComboBox; + auto zoneIds = QTimeZone::availableTimeZoneIds(); + for(auto &zoneId : zoneIds) edTimeZone->addItem(zoneId); + edTimeZone->setCurrentText(m_attr.timeZone.id()); + connect(edTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) { m_attr.timeZone = QTimeZone(text.toUtf8()); update(); }); - hBox->addWidget(wTimeZone); + hBox->addWidget(edTimeZone); hBox->addStretch(); diff --git a/LedOK/program/edclock.cpp b/LedOK/program/edclock.cpp index 48d42b1..f5a55b6 100644 --- a/LedOK/program/edclock.cpp +++ b/LedOK/program/edclock.cpp @@ -153,15 +153,15 @@ QWidget* EDClock::attrWgt() { hBox->addSpacing(6); hBox->addWidget(new QLabel(tr("Time Zone"))); - auto wTimeZone = new QComboBox(); + auto edTimeZone = new QComboBox; auto zoneIds = QTimeZone::availableTimeZoneIds(); - foreach(QByteArray zoneId, zoneIds) wTimeZone->addItem(QString::fromUtf8(zoneId)); - wTimeZone->setCurrentText(QString::fromUtf8(m_attr.timeZoneId)); - connect(wTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) { + for(auto &zoneId : zoneIds) edTimeZone->addItem(zoneId); + edTimeZone->setCurrentText(m_attr.timeZoneId); + connect(edTimeZone, &QComboBox::currentTextChanged, this, [this](const QString &text) { m_attr.timeZoneId = text.toUtf8(); update(); }); - hBox->addWidget(wTimeZone); + hBox->addWidget(edTimeZone); hBox->addStretch(); vBox->addLayout(hBox); diff --git a/LedOK/program/ephoto.cpp b/LedOK/program/ephoto.cpp index 78258cc..4c29db5 100644 --- a/LedOK/program/ephoto.cpp +++ b/LedOK/program/ephoto.cpp @@ -12,7 +12,8 @@ EPhoto *EPhoto::create(const QString &file, PageListItem *pageItem, EBase *multiWin) { QImageReader reader(file); - QImage img = reader.read(); + reader.setAutoTransform(true); + auto img = reader.read(); if(img.isNull()) { QMessageBox::critical(pageItem->listWidget(), "Image Error", Tools::readErrStr(reader.error())+": "+reader.errorString()+"\n"+file); return 0; @@ -34,7 +35,9 @@ EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin else if(QFileInfo(file2 = dir + "/card_"+name).isFile()) QFile::rename(file2, file); else return nullptr; } - auto img = QImage(file); + QImageReader reader(file); + reader.setAutoTransform(true); + auto img = reader.read(); if(img.isNull()) return 0; auto ins = new EPhoto(img, dir, name, pageItem, multiWin); ins->setBaseAttr(json); @@ -114,7 +117,8 @@ QWidget* EPhoto::attrWgt() { QString file = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), home, EPhoto::filters()); if(file.isEmpty()) return; QImageReader reader(file); - QImage aimg = reader.read(); + reader.setAutoTransform(true); + auto aimg = reader.read(); if(aimg.isNull()) { QMessageBox::critical(wgtAttr, tr("Image Read Error"), Tools::readErrStr(reader.error())+": "+reader.errorString()+"\n"+file); return;