修訂 | da1a7433001ec9902ff09e7892e46d75b591fd03 (tree) |
---|---|
時間 | 2013-02-06 15:40:23 |
作者 | alucky4416 <alucky4416@user...> |
Commiter | alucky4416 |
change: change to UTF-8, MainWinodow Display Text, IniFormat.
@@ -1,6 +1,7 @@ | ||
1 | 1 | #include "mainwindow.h" |
2 | 2 | #include "ui_mainwindow.h" |
3 | 3 | |
4 | +#include <QTextCodec> | |
4 | 5 | #include <QDir> |
5 | 6 | #include <QSettings> |
6 | 7 |
@@ -16,6 +17,9 @@ MainWindow::MainWindow(QWidget *parent) : | ||
16 | 17 | { |
17 | 18 | ui->setupUi(this); |
18 | 19 | |
20 | + // set Codec | |
21 | + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); // source codec is UTF-8 | |
22 | + | |
19 | 23 | QCoreApplication::setApplicationName("QtUSBRH-Logger-win32"); |
20 | 24 | QCoreApplication::setApplicationVersion("0.1"); |
21 | 25 |
@@ -73,6 +77,7 @@ MainWindow::~MainWindow() | ||
73 | 77 | void MainWindow::LoadSaveSetting(QString filepath, bool store) |
74 | 78 | { |
75 | 79 | QSettings settings(filepath, QSettings::IniFormat); |
80 | + settings.setIniCodec("UTF-8"); | |
76 | 81 | if (store) { // Store(Save) |
77 | 82 | settings.setValue("SETTING/SAVEPATH", logpath); |
78 | 83 | } else { // Load |
@@ -95,25 +100,25 @@ void MainWindow::slotGetData(QDateTime timestamp, double tmpr, double humid) | ||
95 | 100 | tmpr_min = tmpr; |
96 | 101 | time_min = timestamp; |
97 | 102 | } |
98 | - ui->label_Max->setText(QString("Max: %1 'C at ").arg(tmpr_max) + time_max.toString("yyyy/MM/dd hh:mm:ss")); | |
99 | - ui->label_Min->setText(QString("Min: %1 'C at ").arg(tmpr_min) + time_min.toString("yyyy/MM/dd hh:mm:ss")); | |
103 | + ui->label_Max->setText(QString(tr("Max: %1 'C at ")).arg(tmpr_max) + time_max.toString("yyyy/MM/dd hh:mm:ss")); | |
104 | + ui->label_Min->setText(QString(tr("Min: %1 'C at ")).arg(tmpr_min) + time_min.toString("yyyy/MM/dd hh:mm:ss")); | |
100 | 105 | |
101 | 106 | if (logging) { |
102 | 107 | int lapsed_time = (QDateTime::currentMSecsSinceEpoch() - logstart_time.toMSecsSinceEpoch()) / 1000; |
103 | 108 | if (lapsed_time < 60) { // 1 minute |
104 | - ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 sec").arg(lapsed_time)); | |
109 | + ui->label_LogLapsedTime->setText(QString(tr("Lapsed Time: %1 sec")).arg(lapsed_time)); | |
105 | 110 | } else if (lapsed_time < 3600) { // 1 hour |
106 | - ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 min").arg(lapsed_time/60)); | |
111 | + ui->label_LogLapsedTime->setText(QString(tr("Lapsed Time: %1 min")).arg(lapsed_time/60)); | |
107 | 112 | } else if (lapsed_time < 86400) { // 1 day |
108 | - ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 hour").arg(lapsed_time/3600)); | |
113 | + ui->label_LogLapsedTime->setText(QString(tr("Lapsed Time: %1 hour")).arg(lapsed_time/3600)); | |
109 | 114 | } else { // over 1 day |
110 | - ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 day").arg(lapsed_time/86400)); | |
115 | + ui->label_LogLapsedTime->setText(QString(tr("Lapsed Time: %1 day")).arg(lapsed_time/86400)); | |
111 | 116 | } |
112 | 117 | } |
113 | 118 | } |
114 | 119 | void MainWindow::slotChangeLogFilename(QString filename) |
115 | 120 | { |
116 | - ui->statusBar->showMessage(QString("logfile: %1").arg(filename)); | |
121 | + ui->statusBar->showMessage(QString(tr("logfile: %1")).arg(filename)); | |
117 | 122 | } |
118 | 123 | |
119 | 124 | void MainWindow::slotLogStarted() |
@@ -124,9 +129,9 @@ void MainWindow::slotLogStarted() | ||
124 | 129 | void MainWindow::slotLogEnded(int status) |
125 | 130 | { |
126 | 131 | logging = false; |
127 | - ui->pushButton_LogStart->setText("Log Start"); | |
132 | + ui->pushButton_LogStart->setText(tr("Log Start")); | |
128 | 133 | |
129 | - ui->label_LogState->setText("LogEnded: " + QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss")); | |
134 | + ui->label_LogState->setText(tr("LogEnded: ") + QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss")); | |
130 | 135 | } |
131 | 136 | |
132 | 137 |
@@ -143,8 +148,8 @@ void MainWindow::on_pushButton_LogStart_clicked() | ||
143 | 148 | emit LogStop(); |
144 | 149 | |
145 | 150 | logging = false; |
146 | - ui->pushButton_LogStart->setText("Log Start"); | |
147 | - ui->label_LogState->setText("LogEnded: " + QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss")); | |
151 | + ui->pushButton_LogStart->setText(tr("Log Start")); | |
152 | + ui->label_LogState->setText(tr("LogEnded: ") + QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss")); | |
148 | 153 | ui->label_LogLapsedTime->setText(""); |
149 | 154 | } else { |
150 | 155 | // now idle.. |
@@ -156,9 +161,9 @@ void MainWindow::on_pushButton_LogStart_clicked() | ||
156 | 161 | qDebug() << "logpath is " << logpath; |
157 | 162 | |
158 | 163 | logging = true; |
159 | - ui->pushButton_LogStart->setText("Log Stop"); | |
164 | + ui->pushButton_LogStart->setText(tr("Log Stop")); | |
160 | 165 | logstart_time = QDateTime::currentDateTime(); |
161 | - ui->label_LogState->setText("LogStarted: " + logstart_time.toString("yyyy/MM/dd hh:mm:ss")); | |
166 | + ui->label_LogState->setText(tr("LogStarted: ") + logstart_time.toString("yyyy/MM/dd hh:mm:ss")); | |
162 | 167 | |
163 | 168 | // reset Max/Min |
164 | 169 | tmpr_max = -1000.0; |