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("\