allpy
changeset 460:563a5b6eb954
blocks3d/wt: move all messages and other texts to xml file
this xml file can be usefull for localization
Other changes:
* render corformity file widgets, but then hide them
(to avoid possible memory leak)
* fix mistake in confirmity file label buddy
author | boris <bnagaev@gmail.com> |
---|---|
date | Thu, 17 Feb 2011 00:09:01 +0300 |
parents | 46d8caca3f47 |
children | 018ad778cf91 |
files | blocks3d/wt/blocks3d-wt-widget.C blocks3d/wt/blocks3d-wt.C blocks3d/wt/compile.sh blocks3d/wt/locales/blocks3d.xml |
diffstat | 4 files changed, 85 insertions(+), 39 deletions(-) [+] |
line diff
1.1 --- a/blocks3d/wt/blocks3d-wt-widget.C Wed Feb 16 23:11:02 2011 +0300 1.2 +++ b/blocks3d/wt/blocks3d-wt-widget.C Thu Feb 17 00:09:01 2011 +0300 1.3 @@ -1,3 +1,10 @@ 1.4 + 1.5 +#include <fstream> 1.6 +#include <iostream> 1.7 +#include <boost/format.hpp> 1.8 +#include <cstdlib> 1.9 +#include <list> 1.10 +#include <string> 1.11 1.12 #include "config.h" 1.13 #include "blocks3d-wt-widget.h" 1.14 @@ -12,19 +19,12 @@ 1.15 #include <Wt/WAnchor> 1.16 #include <Wt/WFileResource> 1.17 1.18 -#include <fstream> 1.19 -#include <iostream> 1.20 -#include <boost/format.hpp> 1.21 -#include <cstdlib> 1.22 -#include <list> 1.23 -#include <string> 1.24 - 1.25 std::list<std::string> current_taks; 1.26 1.27 Blocks3DWidget::Blocks3DWidget(Wt::WContainerWidget* parent) : 1.28 Wt::WContainerWidget(parent) 1.29 { 1.30 - Wt::WText* head = new Wt::WText("Blocks3D", this); 1.31 + Wt::WText* head = new Wt::WText(tr("main_header"), this); 1.32 head->setStyleClass("header"); 1.33 1.34 alignment_upload = new Wt::WFileUpload(); 1.35 @@ -36,11 +36,11 @@ 1.36 conformity_textarea->setColumns(40); 1.37 conformity_textarea->setRows(20); 1.38 1.39 - Wt::WLabel* alignment_label = new Wt::WLabel("Alignment:"); 1.40 + Wt::WLabel* alignment_label = new Wt::WLabel(tr("alignment")); 1.41 alignment_label->setBuddy(alignment_textarea); 1.42 1.43 - Wt::WLabel* conformity_label = new Wt::WLabel("Confiomity file:"); 1.44 - conformity_label->setBuddy(alignment_textarea); 1.45 + Wt::WLabel* conformity_label = new Wt::WLabel(tr("conformity_file")); 1.46 + conformity_label->setBuddy(conformity_textarea); 1.47 1.48 new Wt::WBreak(this); 1.49 Wt::WTable* table = new Wt::WTable(this); 1.50 @@ -49,20 +49,29 @@ 1.51 table->elementAt(1, 0)->addWidget(alignment_textarea); 1.52 table->elementAt(2, 0)->addWidget(alignment_upload); 1.53 1.54 + table->elementAt(0, 1)->addWidget(conformity_label); 1.55 + table->elementAt(1, 1)->addWidget(conformity_textarea); 1.56 + table->elementAt(2, 1)->addWidget(conformity_upload); 1.57 + conformity_upload->hide(); 1.58 + conformity_textarea->hide(); 1.59 + conformity_label->hide(); 1.60 + 1.61 new Wt::WBreak(this); 1.62 delta_input = new Wt::WLineEdit(Malakite::defaults::delta, this); 1.63 - delta_validator = new Wt::WDoubleValidator(0.0, 10.0); // FIXME: not to allow empty 1.64 + delta_validator = new Wt::WDoubleValidator(0.0, 10.0); 1.65 delta_validator->setMandatory(true); 1.66 delta_input->setValidator(delta_validator); 1.67 - Wt::WLabel* delta_label = new Wt::WLabel("Distance spreading", this); 1.68 + Wt::WLabel* delta_label = new Wt::WLabel(tr("delta"), this); 1.69 delta_label->setBuddy(delta_input); 1.70 1.71 new Wt::WBreak(this); 1.72 - min_block_width_input = new Wt::WLineEdit(Malakite::defaults::min_block_width, this); 1.73 + min_block_width_input = 1.74 + new Wt::WLineEdit(Malakite::defaults::min_block_width, this); 1.75 min_block_width_validator = new Wt::WIntValidator(3, 9999); 1.76 min_block_width_validator->setMandatory(true); 1.77 min_block_width_input->setValidator(min_block_width_validator); 1.78 - Wt::WLabel* min_block_width_label = new Wt::WLabel("Min block width", this); 1.79 + Wt::WLabel* min_block_width_label = 1.80 + new Wt::WLabel(tr("min_block_width"), this); 1.81 min_block_width_label->setBuddy(min_block_width_input); 1.82 1.83 new Wt::WBreak(this); 1.84 @@ -70,8 +79,7 @@ 1.85 timeout_validator = new Wt::WIntValidator(-1, 30*24*3600); 1.86 timeout_validator->setMandatory(true); 1.87 timeout_input->setValidator(timeout_validator); 1.88 - Wt::WLabel* timeout_label = new Wt::WLabel( 1.89 - "Bron-Kerbosh (couple cores) timeout", this); 1.90 + Wt::WLabel* timeout_label = new Wt::WLabel(tr("timeout"), this); 1.91 timeout_label->setBuddy(timeout_input); 1.92 1.93 new Wt::WBreak(this); 1.94 @@ -79,25 +87,30 @@ 1.95 timeout2_validator = new Wt::WIntValidator(-1, 30*24*3600); 1.96 timeout2_validator->setMandatory(true); 1.97 timeout2_input->setValidator(timeout2_validator); 1.98 - Wt::WLabel* timeout2_label = new Wt::WLabel( 1.99 - "Bron-Kerbosh (blocks) timeout", this); 1.100 + Wt::WLabel* timeout2_label = new Wt::WLabel(tr("timeout2"), this); 1.101 timeout2_label->setBuddy(timeout2_input); 1.102 1.103 1.104 new Wt::WBreak(this); 1.105 - go_button = new Wt::WPushButton("Run", this); 1.106 + go_button = new Wt::WPushButton(tr("Run"), this); 1.107 1.108 new Wt::WBreak(this); 1.109 results_panel = new Wt::WContainerWidget(this); 1.110 1.111 go_button->clicked().connect(this, &Blocks3DWidget::go_button_click); 1.112 - alignment_upload->uploaded().connect(this, &Blocks3DWidget::alignment_uploaded); 1.113 - conformity_upload->uploaded().connect(this, &Blocks3DWidget::conformity_uploaded); 1.114 - alignment_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge); 1.115 - conformity_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge); 1.116 + alignment_upload->uploaded() 1.117 + .connect(this, &Blocks3DWidget::alignment_uploaded); 1.118 + conformity_upload->uploaded() 1.119 + .connect(this, &Blocks3DWidget::conformity_uploaded); 1.120 + alignment_upload->fileTooLarge() 1.121 + .connect(this, &Blocks3DWidget::fileTooLarge); 1.122 + conformity_upload->fileTooLarge() 1.123 + .connect(this, &Blocks3DWidget::fileTooLarge); 1.124 1.125 - alignment_upload->changed().connect(alignment_upload, &Wt::WFileUpload::upload); 1.126 - conformity_upload->changed().connect(conformity_upload, &Wt::WFileUpload::upload); 1.127 + alignment_upload->changed() 1.128 + .connect(alignment_upload, &Wt::WFileUpload::upload); 1.129 + conformity_upload->changed() 1.130 + .connect(conformity_upload, &Wt::WFileUpload::upload); 1.131 1.132 timer = new Wt::WTimer(this); 1.133 timer->timeout().connect(this, &Blocks3DWidget::timeout); 1.134 @@ -177,31 +190,31 @@ 1.135 if (alignment.empty()) 1.136 { 1.137 new Wt::WBreak(results_panel); 1.138 - new Wt::WText("No alignment provided", results_panel); 1.139 + new Wt::WText(tr("no_alignment"), results_panel); 1.140 return; 1.141 } 1.142 if (delta_input->validate() != Wt::WValidator::Valid) 1.143 { 1.144 new Wt::WBreak(results_panel); 1.145 - new Wt::WText("Enter delta parameter", results_panel); 1.146 + new Wt::WText(tr("enter_delta"), results_panel); 1.147 return; 1.148 } 1.149 if (min_block_width_input->validate() != Wt::WValidator::Valid) 1.150 { 1.151 new Wt::WBreak(results_panel); 1.152 - new Wt::WText("Enter min block width parameter", results_panel); 1.153 + new Wt::WText(tr("enter_min_block_width"), results_panel); 1.154 return; 1.155 } 1.156 if (timeout_input->validate() != Wt::WValidator::Valid) 1.157 { 1.158 new Wt::WBreak(results_panel); 1.159 - new Wt::WText("Enter timeout parameter", results_panel); 1.160 + new Wt::WText(tr("enter_timeout"), results_panel); 1.161 return; 1.162 } 1.163 if (timeout2_input->validate() != Wt::WValidator::Valid) 1.164 { 1.165 new Wt::WBreak(results_panel); 1.166 - new Wt::WText("Enter timeout2 parameter", results_panel); 1.167 + new Wt::WText(tr("enter_timeout2"), results_panel); 1.168 return; 1.169 } 1.170 1.171 @@ -256,10 +269,11 @@ 1.172 // security??? 1.173 system(str(boost::format("sh %s &") % tempfile_sh.c_str()).c_str()); 1.174 new Wt::WBreak(results_panel); 1.175 - new Wt::WText("Task start", results_panel); 1.176 + new Wt::WText(tr("task_start"), results_panel); 1.177 1.178 new Wt::WBreak(results_panel); 1.179 - new Wt::WText("Time elapsed: ", results_panel); 1.180 + new Wt::WText(tr("time_elapsed"), results_panel); 1.181 + new Wt::WText(": ", results_panel); 1.182 worktime = new Worktime(results_panel); 1.183 1.184 timer->start(); 1.185 @@ -272,7 +286,6 @@ 1.186 void Blocks3DWidget::timeout() 1.187 { 1.188 worktime->render(); 1.189 - // FIXME: check status of task 1.190 if (!is_completed(tempfile_check)) 1.191 { 1.192 return; 1.193 @@ -287,24 +300,25 @@ 1.194 if (!tempfile_html_file) 1.195 { 1.196 new Wt::WBreak(results_panel); 1.197 - new Wt::WText("Task failed. Please contact developer", results_panel); 1.198 + new Wt::WText(tr("task_failed"), results_panel); 1.199 return; 1.200 } 1.201 tempfile_html_file.close(); 1.202 1.203 new Wt::WBreak(results_panel); 1.204 - new Wt::WText("Task finished", results_panel); 1.205 + new Wt::WText(tr("task_finished"), results_panel); 1.206 1.207 new Wt::WText(" | ", results_panel); 1.208 Wt::WFileResource* html_view = 1.209 new Wt::WFileResource("text/html", tempfile_html, this); 1.210 - Wt::WAnchor* a_view = new Wt::WAnchor(html_view, "View", results_panel); 1.211 + Wt::WAnchor* a_view = 1.212 + new Wt::WAnchor(html_view, tr("View"), results_panel); 1.213 a_view->setTarget(Wt::TargetNewWindow); 1.214 1.215 new Wt::WText(" | ", results_panel); 1.216 Wt::WFileResource* html_download = 1.217 new Wt::WFileResource("application/html", tempfile_html, this); 1.218 - new Wt::WAnchor(html_download, "Download", results_panel); 1.219 + new Wt::WAnchor(html_download, tr("Download"), results_panel); 1.220 } 1.221 1.222
2.1 --- a/blocks3d/wt/blocks3d-wt.C Wed Feb 16 23:11:02 2011 +0300 2.2 +++ b/blocks3d/wt/blocks3d-wt.C Thu Feb 17 00:09:01 2011 +0300 2.3 @@ -17,6 +17,8 @@ 2.4 Blocks3DApplication::Blocks3DApplication(const Wt::WEnvironment& env) : 2.5 Wt::WApplication(env) 2.6 { 2.7 + messageResourceBundle().use(Wt::WApplication::appRoot() + 2.8 + "locales/blocks3d"); 2.9 useStyleSheet("/css/1.css"); 2.10 blocks3d_widget = new Blocks3DWidget(root()); 2.11 }
3.1 --- a/blocks3d/wt/compile.sh Wed Feb 16 23:11:02 2011 +0300 3.2 +++ b/blocks3d/wt/compile.sh Thu Feb 17 00:09:01 2011 +0300 3.3 @@ -1,6 +1,6 @@ 3.4 mkdir -p build 3.5 cd build 3.6 +if [ ! -d ./locales ]; then ln -s ../locales ./locales; fi 3.7 qmake ../blocks3d-wt.pro && make VERBOSE=0 3.8 -#~ cmake .. && make VERBOSE=1 3.9 3.10
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/blocks3d/wt/locales/blocks3d.xml Thu Feb 17 00:09:01 2011 +0300 4.3 @@ -0,0 +1,30 @@ 4.4 +<?xml version="1.0" encoding="UTF-8"?> 4.5 +<messages> 4.6 + <message id='main_header'>Blocks3D</message> 4.7 + <message id='alignment'>Alignment</message> 4.8 + <message id='conformity_file'>Conformity file</message> 4.9 + <message id='delta'>Distance spreading</message> 4.10 + <message id='min_block_width'>Min block width</message> 4.11 + <message id='timeout'>Bron-Kerbosh (couple cores) timeout</message> 4.12 + <message id='timeout2'>Bron-Kerbosh (blocks) timeout</message> 4.13 + <message id='Run'>Run</message> 4.14 + <message id='enter_delta'>Enter delta parameter</message> 4.15 + <message id='no_alignment'>No alignment provided</message> 4.16 + <message id='enter_timeout'>Enter timeout parameter</message> 4.17 + <message id='enter_timeout2'>Enter timeout2 parameter</message> 4.18 + <message id='enter_min_block_width'> 4.19 + Enter min block width paramete 4.20 + </message> 4.21 + 4.22 + <message id='task_start'>Task start</message> 4.23 + <message id='task_finished'>Task finished</message> 4.24 + <message id='time_elapsed'>Time elapsed</message> 4.25 + <message id='task_failed'> 4.26 + Task failed. Please contact developer 4.27 + </message> 4.28 + <message id='View'>View</message> 4.29 + <message id='Download'>Download</message> 4.30 + 4.31 + 4.32 +</messages> 4.33 +