From 00fd78596e70d5c646f24afcc61229e6565ff408 Mon Sep 17 00:00:00 2001 From: byloveletter Date: Fri, 19 May 2017 14:39:22 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84(=EC=97=94=EC=A7=80=EB=8B=88=EC=96=B4?= =?UTF-8?q?=EB=A7=81=20=EB=AA=A8=EB=93=9C=20=EC=A0=81=EC=9A=A9)=20=20-=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=EC=99=80=20=EC=8B=9C=EA=B0=84=20=20-=20?= =?UTF-8?q?=EC=98=A8=EB=8F=84=20=EB=8B=A8=EC=9C=84=20=20-=20=EC=8B=A4?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=ED=8F=AC=EB=A7=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui/oven_control/config.cpp | 1 - app/gui/oven_control/configwindow.cpp | 2 +- app/gui/oven_control/historylistwindow.cpp | 13 +++++++------ app/gui/oven_control/realtimesensorwindow.cpp | 24 ++++++++++++++---------- app/gui/oven_control/stringer.cpp | 18 ++++++++++++++++++ app/gui/oven_control/stringer.h | 10 ++++++++++ 6 files changed, 50 insertions(+), 18 deletions(-) diff --git a/app/gui/oven_control/config.cpp b/app/gui/oven_control/config.cpp index 527c070..5600490 100644 --- a/app/gui/oven_control/config.cpp +++ b/app/gui/oven_control/config.cpp @@ -192,7 +192,6 @@ QString Config::getValueString(Define::ConfigType idx){ case config_datetime: qstrTemp = qdt.toString("yyyy.MM.dd hh:mm"); break; - case config_temptype: if(configlist.items.temptype.d32 >=2 ) configlist.items.temptype.d32 = 0; qstrTemp = tr(temptype_menu[configlist.items.temptype.d32]); diff --git a/app/gui/oven_control/configwindow.cpp b/app/gui/oven_control/configwindow.cpp index 31e9c12..88e12cf 100644 --- a/app/gui/oven_control/configwindow.cpp +++ b/app/gui/oven_control/configwindow.cpp @@ -105,7 +105,7 @@ void ConfigWindow::onConfigBtnClicked(uint16_t id){ switch(id){ case config_datetime: dlg = new ConfigDateTimeDlg(this); - dlg->show(); + dlg->exec(); if(m_nCurConfigPos != config_menu_favorite) reloadValue(); break; case config_enter_engineer_mode: diff --git a/app/gui/oven_control/historylistwindow.cpp b/app/gui/oven_control/historylistwindow.cpp index 616f0a3..08ce07a 100644 --- a/app/gui/oven_control/historylistwindow.cpp +++ b/app/gui/oven_control/historylistwindow.cpp @@ -1,10 +1,12 @@ #include #include #include +#include #include #include "historylistwindow.h" #include "ui_historylistwindow.h" #include "ovenstatics.h" +#include "stringer.h" @@ -100,12 +102,11 @@ void HistoryListWindow::reloadDataset(void){ item = err_items[m_nCurDpStartPos+i]; m_ctrlErrBtns[i]->setText(strTemp); m_ctrlCountLabels[i] ->setText(strTemp.sprintf("%d",item->fired_cnt)); - timeptr = localtime(&(item->first_fired)); - strftime(strTime,64,"%y-%m-%d %H:%M:%S",timeptr); - m_ctrlFirstTimeLabels[i]->setText(strTime); - timeptr = localtime(&(item->last_fried)); - strftime(strTime,64,"%y-%m-%d %H:%M:%S",timeptr); - m_ctrlLastTimeLabels[i]->setText(strTime); + QDateTime dt; + dt.setTime_t(item->first_fired); + m_ctrlFirstTimeLabels[i]->setText(Stringer::DateTimeString(dt, Stringer::datetime_string_type_oneline)); + dt.setTime_t(item->last_fried); + m_ctrlLastTimeLabels[i]->setText(Stringer::DateTimeString(dt, Stringer::datetime_string_type_oneline)); } } else{ diff --git a/app/gui/oven_control/realtimesensorwindow.cpp b/app/gui/oven_control/realtimesensorwindow.cpp index 6a7ef9c..ff65a0a 100644 --- a/app/gui/oven_control/realtimesensorwindow.cpp +++ b/app/gui/oven_control/realtimesensorwindow.cpp @@ -1,6 +1,8 @@ #include "realtimesensorwindow.h" #include "ui_realtimesensorwindow.h" #include "ovenstatics.h" +#include "stringer.h" +#include "QDateTime" RealtimeSensorWindow::RealtimeSensorWindow(QWidget *parent) : QMainWindow(parent), @@ -88,33 +90,35 @@ void RealtimeSensorWindow::reloadUi(void){ temp_temp = ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]); if(ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 2 ) - strTemp.sprintf("%d℃",ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).itemp/10); + strTemp = Stringer::temperature(ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).itemp/10);// strTemp.sprintf("%d℃",ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).itemp/10); else if(ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 1 ) - strTemp.sprintf("%d℃",ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).utemp); - else strTemp.sprintf("%d℃",ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).itemp); + strTemp = Stringer::temperature(ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).utemp); + else strTemp = Stringer::temperature(ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).itemp); m_arrLbState[0][i]->setText(strTemp); } for(i=0;igetSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 2 ) - strTemp.sprintf("%d℃",m_arrSensorItems[i]->high_temp.itemp/10); + strTemp = Stringer::temperature(m_arrSensorItems[i]->high_temp.itemp/10); else if(ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 1) - strTemp.sprintf("%d℃",m_arrSensorItems[i]->high_temp.utemp); - else strTemp.sprintf("%d℃",m_arrSensorItems[i]->high_temp.itemp); + strTemp = Stringer::temperature(m_arrSensorItems[i]->high_temp.utemp); + else strTemp= Stringer::temperature(m_arrSensorItems[i]->high_temp.itemp); m_arrLbState[1][i]->setText(strTemp); } for(i=0;isetText(strTemp); } for(i=0;ilast_high_time !=0){ - timeptr = localtime(&(m_arrSensorItems[i]->last_high_time)); - strftime(strTime,64,"%y-%m-%d\n%H:%M:%S",timeptr); - m_arrLbState[3][i]->setText(strTime); + QDateTime dt_tm; + dt_tm.setTime_t(m_arrSensorItems[i]->last_high_time); + //timeptr = localtime(&(m_arrSensorItems[i]->last_high_time)); + //strftime(strTime,64,"%y-%m-%d\n%H:%M:%S",timeptr); + m_arrLbState[3][i]->setText(Stringer::DateTimeString(dt_tm)); } else{ m_arrLbState[3][i]->setText("-"); diff --git a/app/gui/oven_control/stringer.cpp b/app/gui/oven_control/stringer.cpp index 5736431..1826b1d 100644 --- a/app/gui/oven_control/stringer.cpp +++ b/app/gui/oven_control/stringer.cpp @@ -189,3 +189,21 @@ QString Stringer::unusedTemperature(QString style) return style + lightSpan.arg("℃"); } } + + +QString Stringer::DateTimeString(const QDateTime &dt_tm, datetime_string_type type){ + QString strTemp; + Define::config_item item = Config::getInstance()->getConfigValue(Define::config_time_type); + switch(item.d32){ + case Define::time_type_12h: + if(type == datetime_string_type_oneline) strTemp = dt_tm.toString("yy-MM-dd a hh:mm" ); + else strTemp = dt_tm.toString("yy-MM-dd\na hh:mm" ); + break; + case Define::time_type_24h: + default: + if(type == datetime_string_type_oneline) strTemp = dt_tm.toString("yy-MM-dd HH:mm" ); + else strTemp = dt_tm.toString("yy-MM-dd\nHH:mm" ); + break; + } + return strTemp; +} diff --git a/app/gui/oven_control/stringer.h b/app/gui/oven_control/stringer.h index b5af772..1d874cc 100644 --- a/app/gui/oven_control/stringer.h +++ b/app/gui/oven_control/stringer.h @@ -3,8 +3,15 @@ #include +#include namespace Stringer { + +enum datetime_string_type{ + datetime_string_type_oneline=0, + datetime_string_type_twoline +}; + const QString fontSize14("\