00001 #!/usr/local/php512/bin/php
00002 <?
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 if(empty($argc))
00023 {
00024 exit;
00025 }
00026 include_once('QtBackend.php');
00027
00028 if(!extension_loaded('php_qt')) {
00029 dl('php_qt.so');
00030 }
00031
00032 class MainWindow extends QWidget
00033 {
00034
00035 public $layMain;
00036
00037
00038 public $txtOriginal;
00039 public $txtTranslation;
00040 public $lblOriginal;
00041 public $lblTranslation;
00042
00043
00044 public $btnQuit;
00045 public $btnPrev;
00046 public $btnNext;
00047 public $btnOKNext;
00048 public $wButtons;
00049 public $layButtons;
00050
00051
00052 public $sldPercent;
00053 public $lcdPercent;
00054 public $btnRefresh;
00055 public $wGuessControls;
00056 public $layGuessControls;
00057
00058
00059 public $txtGuessPercents;
00060 public $txtGuessOriginals;
00061 public $txtGuessTranslations;
00062 public $btnGuessTake;
00063 public $layGrid;
00064
00065 function __construct()
00066 {
00067 parent::__construct();
00068
00069 $this->resize(600,500);
00070 $maxGuesses = 9;
00071
00072 $this->layMain = new QVBoxLayout($this);
00073
00074
00075 $this->txtOriginal = new QLineEdit("This will be the place for the English text.", $this);
00076 $this->layMain->addWidget($this->txtOriginal);
00077
00078
00079
00080
00081
00082
00083
00084
00085 $this->txtTranslation = new QLineEdit("Translation comes here", $this);
00086 $this->layMain->addWidget($this->txtTranslation);
00087
00088
00089 $this->wButtons = new QWidget();
00090 $this->layButtons = new QHBoxLayout($this->wButtons);
00091 $this->wButtons->setLayout($this->layButtons);
00092
00093 $this->btnOKNext = new QPushButton("OK + Next", $this->wButtons);
00094 $this->layButtons->addWidget($this->btnOKNext);
00095
00096 $this->btnPrev = new QPushButton("Previous", $this->wButtons);
00097 $this->layButtons->addWidget($this->btnPrev);
00098
00099 $this->btnNext = new QPushButton("Next", $this->wButtons);
00100 $this->layButtons->addWidget($this->btnNext);
00101
00102 $this->layButtons->addStretch(1);
00103
00104 $this->btnQuit = new QPushButton("Quit", $this->wButtons);
00105 $this->layButtons->addWidget($this->btnQuit);
00106
00107
00108 $this->connect($this->btnQuit, SIGNAL("clicked()"), QApplication::instance(), SLOT("quit()"));
00109 $this->connect($this->btnNext, SIGNAL("clicked()"), $this, SLOT("btnNext_Clicked()"));
00110
00111
00112
00113 $this->wGuessControls = new QWidget();
00114 $this->sldPercent = new QSlider($this->wGuessControls);
00115 $this->sldPercent->setOrientation(QT_ORIENTATIONS_HORIZONTAL);
00116 $this->sldPercent->setRange(0, 99);
00117 $this->sldPercent->setValue(50);
00118 $this->lcdPercent = new QLCDNumber(2, $this->wGuessControls);
00119 $this->lcdPercent->value(50);
00120 $this->btnRefresh = new QPushButton("Refresh", $this->wGuessControls);
00121
00122
00123 $this->layGuessControls = new QHBoxLayout($this->wGuessControls);
00124 $this->layGuessControls->addWidget($this->sldPercent);
00125 $this->layGuessControls->addWidget($this->lcdPercent);
00126 $this->layGuessControls->addWidget($this->btnRefresh);
00127
00128 $this->layGrid = new QGridLayout();
00129
00130 for($i = 0; $i < $maxGuesses; $i++)
00131 {
00132
00133 $this->txtGuessPercents[$i] = new QLineEdit("", $this);
00134 $this->txtGuessOriginals[$i] = new QLineEdit("", $this);
00135 $this->txtGuessTranslations[$i] = new QLineEdit("", $this);
00136 $this->btnGuessTake[$i] = new QPushButton("^", $this);
00137
00138
00139 $this->layGrid->addWidget($this->txtGuessPercents[$i], $i, 0, 0);
00140 $this->layGrid->addWidget($this->txtGuessOriginals[$i], $i, 1, 0);
00141 $this->layGrid->addWidget($this->txtGuessTranslations[$i], $i, 2, 0);
00142 $this->layGrid->addWidget($this->btnGuessTake[$i], $i, 3, 0);
00143 }
00144
00145
00146 $this->connect($this->sldPercent, SIGNAL("valueChanged(int)"),$this->lcdPercent, SLOT("display(int)"));
00147
00148 $this->layMain->addWidget($this->wButtons);
00149 $this->layMain->addLayout($this->layGrid);
00150 $this->layMain->addWidget($this->wGuessControls);
00151
00152
00153 $this->setLayout($this->layMain);
00154
00155 $this->JustTest();
00156 }
00157
00158 function btnNext_Clicked()
00159 {
00160 echo "here we go";
00161 QApplication::instance()->aboutQt();
00162
00163 }
00164
00165 function JustTest()
00166 {
00167
00168 $findText = "Delete All";
00169 $filterPercent = 60;
00170
00171
00172
00173 $str = new TranslationString();
00174 $translations = $str->FindSimilar($findText, $filterPercent);
00175
00176 if(empty($translations))
00177 {
00178 echo("nothing similar, sorry.\n");
00179 return;
00180 }
00181
00182 $i = 0;
00183 foreach($translations as $id => $tr)
00184 {
00185 foreach($tr["strings"] as $key => $str)
00186 {
00187
00188
00189 if($i < 9)
00190 {
00191 $this->txtGuessPercents[$i]->setText($tr["percent"]."%");
00192
00193 $this->txtGuessOriginals[$i]->setText($str->GetOriginal());
00194
00195
00196
00197
00198
00199 $this->txtGuessTranslations[$i]->setText($str->GetTranslation());
00200 }
00201 $i++;
00202 }
00203 }
00204
00205 }
00206
00207 }
00208
00209
00210 $app = new QApplication();
00211 $widget = new MainWindow();
00212 $widget->show();
00213
00214 $app->exec();
00215
00216 ?>