#!/usr/bin/env ruby $KCODE="EUC" require 'qte' require 'qpe' require 'qtesound' require 'nkf' include Qte include Qpe include Qtesound if (!FileTest.exist?("/home/zaurus/Documents/Noukaihatu_Files")) Dir.mkdir("/home/zaurus/Documents/Noukaihatu_Files") end if (!FileTest.exist?("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk")) Dir.mkdir("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk") end if (!FileTest.exist?("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/s-test.txt")) fp1 = File.new("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/s-test.txt", "w") fp1.puts(NKF.nkf("-s","Q 我輩は猫であるを書いた人は?")) fp1.puts(NKF.nkf("-s","A 夏目漱石")) fp1.puts(NKF.nkf("-s","M 菊地筧")) fp1.puts(NKF.nkf("-s","M 芥川龍之介")) fp1.puts(NKF.nkf("-s","M 太宰治")) fp1.puts(NKF.nkf("-s","Q 志賀直哉の代表作は次のうちどれ?")) fp1.puts(NKF.nkf("-s","A 暗夜行路")) fp1.puts(NKF.nkf("-s","M 或る男")) fp1.puts(NKF.nkf("-s","M 富嶽百景")) fp1.puts(NKF.nkf("-s","Q 次のうち樋口一葉の作品でないものは?")) fp1.puts(NKF.nkf("-s","A 三四郎")) fp1.puts(NKF.nkf("-s","M たけくらべ")) fp1.puts(NKF.nkf("-s","M にごりえ")) fp1.puts(NKF.nkf("-s","M わかれ道")) fp1.puts(NKF.nkf("-s","M 月の夜")) fp1.puts(NKF.nkf("-s","Q END")) fp1.close() end if (!FileTest.exist?("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/m-test.txt")) fp2 = File.new("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/m-test.txt", "w") fp2.puts(NKF.nkf("-s","Y 富士山は日本一高い山だ。")) fp2.puts(NKF.nkf("-s","N 八幡製鉄所は阪神工業地帯にある。")) fp2.puts(NKF.nkf("-s","Y 太平洋へ流れる寒流は親潮と呼ばれる。")) fp2.puts(NKF.nkf("-s","Y 紀伊山地は近畿地方にある。")) fp2.puts(NKF.nkf("-s","N 竹島領有権問題で対立しているのはインドである。")) fp2.puts(NKF.nkf("-s","Y スケトウダラ漁は底引き網で漁をする。")) fp2.puts(NKF.nkf("-s","Y END")) fp2.close() end if (!FileTest.exist?("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/i-test.txt")) fp3 = File.new("/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/i-test.txt", "w") fp3.puts(NKF.nkf("-s","O consent to〜"));fp3.puts(NKF.nkf("-s","U 〜に同意する")) fp3.puts(NKF.nkf("-s","O remember doing"));fp3.puts(NKF.nkf("-s","U 〜したのを覚えている")) fp3.puts(NKF.nkf("-s","O decline to do"));fp3.puts(NKF.nkf("-s","U 〜することを断る")) fp3.puts(NKF.nkf("-s","O quit doing"));fp3.puts(NKF.nkf("-s","U 〜するのをやめる")) fp3.puts(NKF.nkf("-s","O intelligible"));fp3.puts(NKF.nkf("-s","U わかりやすい")) fp3.puts(NKF.nkf("-s","O not at all"));fp3.puts(NKF.nkf("-s","U 少しも〜でない")) fp3.puts(NKF.nkf("-s","O no longer〜"));fp3.puts(NKF.nkf("-s","U もはや〜ない")) fp3.puts(NKF.nkf("-s","O ---")) fp3.close() end $ddd="/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/s-test.txt" $mmm="/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/m-test.txt" $iii="/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/i-test.txt" class MainWindow < QMainWindow $KCODE="EUC" PENG_PNG = '/home/QtPalmtop/pics/tux-logo.png' def initialize super self.setCaption(tr("○×問題")) @mbx=QVBox.new(self) self.setCentralWidget(@mbx) dir="/home/zaurus/Documents/Noukaihatu_Files/mrbtsntk/" @dirLabel = QLabel.new(tr(dir), @mbx) @fileListBox = QListBox.new(@mbx) @fileListBox.setFocus() readDirectory() Qte::connect(@fileListBox, QSIGNAL("clicked(QListBoxItem *)"),self, "selectFileAction(QListBoxItem *)") Qte::connect(@fileListBox, QSIGNAL("returnPressed(QListBoxItem *)"),self, "selectFileAction(QListBoxItem *)") @ombx=QHBox.new(@mbx) @dirLabel2 = QLabel.new(tr("現在設定された問題:"), @ombx) @dirLabel3 = QLabel.new(tr($ddd), @ombx) @dirLabel2.setFont QFont.new('Lcfont',12, QFont::Bold) @dirLabel3.setFont QFont.new('Lcfont',12, QFont::Bold) @pmbx=QHBox.new(@mbx) @mbtn02qls=QPushButton.new(tr("選択問題"),@pmbx) @mbtn=QPushButton.new(tr("選択ランダム"),@pmbx) connect(@mbtn02qls,QSIGNAL("clicked()"),self,'mrtk') connect(@mbtn,QSIGNAL("clicked()"),self,'mrtkr') @wmbx=QHBox.new(@mbx) @dirLabel4 = QLabel.new(tr("現在設定された問題:"), @wmbx) @dirLabel5 = QLabel.new(tr($mmm), @wmbx) @dirLabel4.setFont QFont.new('Lcfont',12, QFont::Bold) @dirLabel5.setFont QFont.new('Lcfont',12, QFont::Bold) @rmbx=QHBox.new(@mbx) @mbtne1=QPushButton.new(tr("○×問題"),@rmbx) @mbtne2=QPushButton.new(tr("○×ランダム"),@rmbx) connect(@mbtne1,QSIGNAL("clicked()"),self,'kkmr') connect(@mbtne2,QSIGNAL("clicked()"),self,'mebtrndm') @pmbxi=QHBox.new(@mbx) $dirLabel6 = QLabel.new(tr(dir), @pmbxi) $dirLabel6.setFont QFont.new('Lcfon',12, QFont::Bold) @kmbx=QHBox.new(@mbx) @mbtn05=QPushButton.new(tr("○×、選択フォルダ内総ランダム"),@kmbx) connect(@mbtn05,QSIGNAL("clicked()"),self,'mrbtsntkrndm') @wimbx=QHBox.new(@mbx) @dirLabel7 = QLabel.new(tr("現在設定された問題:"), @wimbx) @dirLabel8 = QLabel.new(tr($iii), @wimbx) @dirLabel7.setFont QFont.new('Lcfont',12, QFont::Bold) @dirLabel8.setFont QFont.new('Lcfont',12, QFont::Bold) @rimbx=QHBox.new(@mbx) @mbtne7=QPushButton.new(tr("一問一答"),@rimbx) @mbtne8=QPushButton.new(tr("一問一答ランダム"),@rimbx) connect(@mbtne7,QSIGNAL("clicked()"),self,'iti') connect(@mbtne8,QSIGNAL("clicked()"),self,'itirdm') end def selectFileAction(item) dirPath = @dirLabel.text().utf8().to_str() $fileName = item.text().utf8().to_str() if ($fileName == "./") # NA elsif ($fileName == "../") ndir = File.expand_path("..", dirPath) @dirLabel.setText(tr(ndir)) $dirLabel6.setText(tr(ndir)) readDirectory() elsif ($fileName[-1, 1] == "/") if (dirPath[-1, 1] == "/") ndir = dirPath + $fileName.chop() else ndir = dirPath + "/" + $fileName.chop() end if (FileTest.directory?(ndir)) @dirLabel.setText(tr(ndir)) $dirLabel6.setText(tr(ndir)) readDirectory() end else $ddd=dirPath + "/" + $fileName $mmm=dirPath + "/" + $fileName $iii=dirPath + "/" + $fileName @dirLabel3.setText(tr($ddd)) @dirLabel5.setText(tr($mmm)) @dirLabel8.setText(tr($iii)) end end def accpt() $gg="" @result = true $tex= 0;@wk=0 dirPath= @dirLabel.text().utf8().to_str() f=File::open(dirPath+"/"+$fileName,"r") $tex= 0;@wk=0 $ff=Array.new(){|i| i} while (!f.eof?) buf=f.gets buf=buf[0,buf.length-1] $ff[$tex]=buf $gg+=buf+"\n" $e2.setText(tr($gg)) $tex=$tex+1 @wk=@wk+1 end f.close() close() end def rjct() close() end def readDirectory() @fileListBox.clear() dirs = Array.new() files = Array.new() dirPath = @dirLabel.text().utf8().to_str() Dir.foreach(dirPath) { |file| if (FileTest.directory?(File.join(dirPath, file))) dirs.push(file) else files.push(file) end } dirs.sort.each { |dir| @fileListBox.insertItem(tr(dir + "/")) } files.sort.each { |file| @fileListBox.insertItem(tr(file)) } end def filePath() dirPath = @dirLabel.text().utf8().to_str() fileName = @fileLine.text().utf8().to_str() return File.join(dirPath, fileName) end def iti dlg = ItiDialog.new(self,"一問一答") res = dlg.exec() end def itirdm dlg = ItirdmDialog.new(self,"一問一答ランダム") res = dlg.exec() end def mrtk dlg = MrtkDialog.new(self,"選択問題") res = dlg.exec() end def mrtkr dlg = MrtkaDialog.new(self,"選択ランダム") res = dlg.exec() end $www=0 def kkmr dlg = MrbtDialog.new(self,"○×問題") res = dlg.exec() end def mebtrndm dlg = MrbtrndmDialog.new(self,"○×ランダム") res = dlg.exec() end def mrbtsntkrndm dirs = Array.new() files = Array.new() dirPath = $dirLabel6.text().utf8().to_str() Dir.foreach(dirPath) { |file| if (FileTest.directory?(File.join(dirPath, file))) dirs.push(file) else files.push(file) end } qq=0 $hh = Array.new() files.sort.each { |file| if (file[0,1]=="m" || file[0,1]=="s") then $hh[qq]=file qq=qq+1 end } if ($hh.length==0) then QMessageBox.about(self, tr("error"), tr("利用可能な問題がありません。")) return else b=rand($hh.length) $tt=$dirLabel6.text().utf8().to_str() $tt=$tt+"/"+$hh[b] if $hh[b][0,1]=="m" then dlg = Mrbtrndm2Dialog.new(self,"○×選択ランダム") res = dlg.exec() elsif $hh[b][0,1]=="s" then dlg = Mrtka2Dialog.new(self,"○×選択ランダム") res = dlg.exec() else QMessageBox.about(self, tr("error"), tr("書式が違います!\n確認してください。")) return end end end end class ItirdmDialog < QDialog def initialize(parent, caption) super(parent, "ItirdmDialog", true) ymkm() setCaption(tr(caption)) if (@yorn[0]=="O") then @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @mrbtLbl1 = QLabel.new(tr(""), self) @mrbtLbl2 = QLabel.new(tr("一問一答"), self) @mrbtLbl3 = QLabel.new(tr("問題文"), self) @mrbtLbl3.setFont QFont.new('Lcfont',32, QFont::Bold) @mrbtLbl4 = QLabel.new(tr(""), self) @mrbtLbl4.setFont QFont.new('Lcfont',16, QFont::Bold) @mrbtbtn1=QPushButton.new(@saveIcon,tr("終了する"),self) @mrbtbtn3=QPushButton.new(tr("戻る (m)"),self) @mrbtbtn2=QPushButton.new(tr("次へ (n)"),self) connect(@mrbtbtn1,QSIGNAL("clicked()"),self,'mrbtowari') connect(@mrbtbtn2,QSIGNAL("clicked()"),self,'mrtrnm') connect(@mrbtbtn3,QSIGNAL("clicked()"),self,'modoru') @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_N), self, 'mrtrnm') @key.connectItem(@key.insertItem(Qt::Key_M), self, 'modoru') @mrbtLbl1.setGeometry(5, 2, 640, 480) @mrbtLbl2.setGeometry(5, 2, 300, 30) @mrbtLbl4.setGeometry(35, 52, 500, 100) @mrbtLbl3.setGeometry(15, 180, 550, 250) @mrbtbtn1.setGeometry(5, 32, 150, 40) @mrbtbtn2.setGeometry(305, 32, 100, 40) @mrbtbtn3.setGeometry(205, 32, 100, 40) @bbb=0 @nnn=1 mrtrnm() else @mrbtLbl1 = QLabel.new(tr("一問一答の書式が違います!"), self) @mrbtLbl2 = QLabel.new(tr("確認してください"), self) @mrbtLbl1.setGeometry(5, 2, 300, 40) @mrbtLbl2.setGeometry(5, 42, 300, 30) end end def mrbtowari close() end def modoru @mrbtbtn3.setEnabled(false) if @bbb==0 then @mrbtLbl3.setText(tr(NKF.nkf("-ef30",@ooo))) @mrbtLbl4.setText(tr("")) elsif @bbb==1 then if @qqq!=nil then @mrbtLbl3.setText(tr(NKF.nkf("-ef30",@qqq))) @mrbtLbl4.setText(tr("")) end end @nnn=0 end def mrtrnm if @nnn==1 then gg=@bnsu-2 jj=gg/2 ff=rand(jj) @vv=ff*2 QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") end @mrbtLbl3.setText(tr(NKF.nkf("-ef30",@hnbn[@vv].gsub(/@/," ")))) if @bbb==0 then @ooo=@hnbn[@vv].gsub(/@/," ") @bbb=1 elsif @bbb==1 then @qqq=@hnbn[@vv].gsub(/@/," ") @bbb=0 end @mrbtLbl2.setText(tr("問題"+ff.to_s)) if @nnn==1 then if @ggg==0 then @mrbtLbl4.setText(tr("---")) @hh=@vv+1 @ggg=1 elsif @ggg==1 then @mrbtLbl4.setText(tr(NKF.nkf("-ef40",@hnbn[@hh].gsub(/@/," ")))) @bb=@vv+1 @ggg=2 elsif @ggg==2 then @mrbtLbl4.setText(tr(NKF.nkf("-ef40",@hnbn[@bb].gsub(/@/," ")))) @hh=@vv+1 @ggg=1 end elsif @nnn==0 then @mrbtbtn3.setEnabled(true) @nnn=1 end end def ymkm @ggg=0 @bngu=0 mrbtfile=File::open($iii,"r") mrbtcunt= 0 @hnbn=Array.new(){|i| i} @yorn=Array.new(){|i| i} while (!mrbtfile.eof?) buf=mrbtfile.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @hnbn[mrbtcunt]=buf @yorn[mrbtcunt]=bufkte mrbtcunt=mrbtcunt+1 end mrbtfile.close() @bnsu=@hnbn.length-1 end end class ItiDialog < QDialog def initialize(parent, caption) super(parent, "ItiDialog", true) ymkm() setCaption(tr(caption)) if (@yorn[0]=="O") then @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @mrbtLbl1 = QLabel.new(tr(""), self) @mrbtLbl2 = QLabel.new(tr("一問一答"), self) @mrbtLbl3 = QLabel.new(tr("問題文"), self) @mrbtLbl3.setFont QFont.new('Lcfont',32, QFont::Bold) @mrbtLbl4 = QLabel.new(tr(""), self) @mrbtLbl4.setFont QFont.new('Lcfont',16, QFont::Bold) @mrbtbtn1=QPushButton.new(@saveIcon,tr("終了する"),self) @mrbtbtn3=QPushButton.new(tr("戻る (m)"),self) @mrbtbtn2=QPushButton.new(tr("次へ (n)"),self) @mrbtbtn3.setEnabled(false) connect(@mrbtbtn1,QSIGNAL("clicked()"),self,'mrbtowari') connect(@mrbtbtn2,QSIGNAL("clicked()"),self,'mrtrnm') connect(@mrbtbtn3,QSIGNAL("clicked()"),self,'modoru') @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_N), self, 'mrtrnm') @key.connectItem(@key.insertItem(Qt::Key_M), self, 'modoru') @mrbtLbl1.setGeometry(5, 2, 640, 480) @mrbtLbl2.setGeometry(5, 2, 300, 30) @mrbtLbl4.setGeometry(35, 52, 500, 100) @mrbtLbl3.setGeometry(15, 180, 550, 250) @mrbtbtn1.setGeometry(5, 32, 150, 40) @mrbtbtn2.setGeometry(305, 32, 100, 40) @mrbtbtn3.setGeometry(205, 32, 100, 40) @hjmt=0 @zzz=0 mrtrnm() else @mrbtLbl1 = QLabel.new(tr("一問一答の書式が違います!"), self) @mrbtLbl2 = QLabel.new(tr("確認してください"), self) @mrbtLbl1.setGeometry(5, 2, 300, 40) @mrbtLbl2.setGeometry(5, 42, 300, 30) end end def mrbtowari close() end def modoru if @bngu==2 then @mrbtLbl3.setText(tr(NKF.nkf("-ef30",@hnbn[@bngu-5].gsub(/@/," ")))) elsif @bngu==0 then @mrbtLbl3.setText(tr(NKF.nkf("-ef30",@hnbn[@bngu-5].gsub(/@/," ")))) else @mrbtLbl3.setText(tr(NKF.nkf("-ef30",@hnbn[@bngu-4].gsub(/@/," ")))) end @mrbtbtn3.setEnabled(false) @mrbtLbl4.setText(tr("")) @zzz=1 @bngu=@bngu-2 end def mrtrnm if @hjmt!=0 then @mrbtbtn3.setEnabled(true) end if @zzz==0 then @bng2=@bngu+1 QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") bb=@bngu/2 @mrbtLbl2.setText(tr("問題"+bb.to_s)) if @hnbn[@bng2-2]!=nil then @mrbtLbl4.setText(tr(NKF.nkf("-e",@hnbn[@bng2-2].gsub(/@/," ")))) end if (@bngu==0 && @ggg==1) then @mrbtLbl4.setText(tr(NKF.nkf("-e",@hnbn[@bng2-3].gsub(/@/," ")))) end end @mrbtLbl3.setText(tr(NKF.nkf("-ef30",@hnbn[@bngu].gsub(/@/," ")))) if @zzz==1 then @bngu=@bngu+2 if @bngu==@bnsu then @mrbtLbl3.setText(tr("pekepon")) #何故表示しないかわからない end end if @zzz==0 then @bngu=@bngu+2 if @bnsu==@bngu then @bngu=0 @ggg=1 end @hjmt=1 end @zzz=0 end def ymkm @ggg=0 @bngu=0 mrbtfile=File::open($iii,"r") mrbtcunt= 0 @hnbn=Array.new(){|i| i} @yorn=Array.new(){|i| i} while (!mrbtfile.eof?) buf=mrbtfile.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @hnbn[mrbtcunt]=buf @yorn[mrbtcunt]=bufkte mrbtcunt=mrbtcunt+1 end mrbtfile.close() @bnsu=@hnbn.length-1 end end class MrbtDialog < QDialog def initialize(parent, caption) super(parent, "MrbtDialog", true) ymkm() setCaption(tr(caption)) if (@yorn[0]=="Y"||@yorn[0]=="N") then @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @mrbtLbl1 = QLabel.new(tr(""), self) @mrbtLbl2 = QLabel.new(tr("丸罰問題"), self) @mrbtLbl3 = QLabel.new(tr("問題文"), self) @mrbtbtn1=QPushButton.new(@saveIcon,tr("終了する"),self) @mrbtbtn2=QPushButton.new(tr("次の問題へ"),self) @mrbtbtn3=QPushButton.new(tr("○ (o)"),self) @mrbtbtn4=QPushButton.new(tr("× (k)"),self) connect(@mrbtbtn1,QSIGNAL("clicked()"),self,'mrbtowari') connect(@mrbtbtn2,QSIGNAL("clicked()"),self,'mrtrnm') connect(@mrbtbtn3,QSIGNAL("clicked()"),self,'mrbtmaru') connect(@mrbtbtn4,QSIGNAL("clicked()"),self,'mrbtbatu') @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_O), self, 'mrbtmaru') @key.connectItem(@key.insertItem(Qt::Key_K), self, 'mrbtbatu') @mrbtLbl1.setGeometry(5, 2, 640, 480) @mrbtLbl2.setGeometry(5, 2, 300, 30) @mrbtLbl3.setGeometry(5, 132, 500, 100) @mrbtbtn1.setGeometry(5, 32, 150, 40) @mrbtbtn2.setGeometry(205, 32, 150, 40) @mrbtbtn3.setGeometry(5, 232, 150, 40) @mrbtbtn4.setGeometry(205, 232, 150, 40) mrtrnm() elsif (@yorn[0]!="Y") then if (@yorn[0]!="N") then @mrbtLbl1 = QLabel.new(tr("○×問題の書式が違います!"), self) @mrbtLbl2 = QLabel.new(tr("確認をしてください"), self) @mrbtLbl1.setGeometry(5, 2, 300, 40) @mrbtLbl2.setGeometry(5, 42, 300, 30) end elsif (@yorn[0]!="N") then if (@yorn[0]!="Y") then @mrbtLbl1 = QLabel.new(tr("○×問題の書式が違います!"), self) @mrbtLbl2 = QLabel.new(tr("確認をしてください"), self) @mrbtLbl1.setGeometry(5, 2, 300, 40) @mrbtLbl2.setGeometry(5, 42, 300, 30) end end end def mrbtowari close() end def mrtrnm QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") @mrbtLbl3.setText(tr(NKF.nkf("-ef40",@hnbn[@bngu].gsub(/@/," ")))) @mrbtLbl2.setText(tr("問題"+@bngu.to_s)) @bngu=@bngu+1 if @bnsu==@bngu then @bngu=0 end end def mrbtmis @mrbtLbl2.setText(tr("間違ってます")) QSound::playFile("/home/QtPalmtop/sounds/shtr.wav") end def mrbtmaru if @yorn[@bngu-1]=="Y" then mrtrnm() else mrbtmis() end end def mrbtbatu if @yorn[@bngu-1]=="N" then mrtrnm() else mrbtmis() end end def ymkm @bngu=0 mrbtfile=File::open($mmm,"r") mrbtcunt= 0 @hnbn=Array.new(){|i| i} @yorn=Array.new(){|i| i} while (!mrbtfile.eof?) buf=mrbtfile.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @hnbn[mrbtcunt]=buf @yorn[mrbtcunt]=bufkte mrbtcunt=mrbtcunt+1 end mrbtfile.close() @bnsu=@hnbn.length-1 end end class MrtkDialog < QDialog def initialize(parent, caption) super(parent, "MrtkDialog", true) setCaption(tr(caption)) fs=File::open($ddd,"r") tex= 0 @faa=Array.new(){|i| i} @faa2=Array.new(){|i| i} while (!fs.eof?) buf=fs.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @faa[tex]=buf @faa2[tex]=bufkte tex=tex+1 end fs.close() if(@faa2[0]=="Q") @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @dirLabel = QLabel.new(tr(""), self) @dirLabel2 = QLabel.new(tr("選択問題  終了(o or Cancel) 次の問題(n)"), self) @dirLabel2w = QLabel.new(tr("選択問題un"), self) @mbtn01=QPushButton.new(@saveIcon,tr("終了する"),self) @mbtn02=QPushButton.new(tr("次の問題へ"),self) connect(@mbtn01,QSIGNAL("clicked()"),self,'owari') connect(@mbtn02,QSIGNAL("clicked()"),self,'aaaaa') @dirLabel.setGeometry(5, 2, 640, 480) @dirLabel2.setGeometry(5, 2, 500, 30) @mbtn01.setGeometry(5, 32, 150, 40) @mbtn02.setGeometry(205, 32, 150, 40) @dirLabel2w.setGeometry(5, 82, 500, 100) @sntk=Array.new(){|i| i} @sntk[0] = QLabel.new(tr(""), self) @sntk[1] = QLabel.new(tr(""), self) @sntk[2] = QLabel.new(tr(""), self) @sntk[3] = QLabel.new(tr(""), self) @sntk[4] = QLabel.new(tr(""), self) @sntk[5] = QLabel.new(tr(""), self) @sbtn=Array.new(){|i| i} @sbtn[0]=QPushButton.new(tr("q"),self) @sbtn[1]=QPushButton.new(tr("w"),self) @sbtn[2]=QPushButton.new(tr("e"),self) @sbtn[3]=QPushButton.new(tr("r"),self) @sbtn[4]=QPushButton.new(tr("t"),self) @sbtn[5]=QPushButton.new(tr("y"),self) @sbtn[0].setGeometry(5, 165, 50, 40) @sbtn[1].setGeometry(5, 208, 50, 40) @sbtn[2].setGeometry(5, 251, 50, 40) @sbtn[3].setGeometry(5, 294, 50, 40) @sbtn[4].setGeometry(5, 337, 50, 40) @sbtn[5].setGeometry(5, 380, 50, 40) @sntk[0].setGeometry(60, 165, 500, 40) @sntk[1].setGeometry(60, 208, 500, 40) @sntk[2].setGeometry(60, 251, 500, 40) @sntk[3].setGeometry(60, 294, 500, 40) @sntk[4].setGeometry(60, 337, 500, 40) @sntk[5].setGeometry(60, 380, 500, 40) connect(@sbtn[0],QSIGNAL("clicked()"), self,'kkkk0') connect(@sbtn[1],QSIGNAL("clicked()"), self,'kkkk1') connect(@sbtn[2],QSIGNAL("clicked()"), self,'kkkk2') connect(@sbtn[3],QSIGNAL("clicked()"), self,'kkkk3') connect(@sbtn[4],QSIGNAL("clicked()"), self,'kkkk4') connect(@sbtn[5],QSIGNAL("clicked()"), self,'kkkk5') @uuu=6 aaaaa() else @mrbtLbl1 = QLabel.new(tr("選択問題の書式が違います!"), self) @mrbtLbl2 = QLabel.new(tr("確認をしてください"), self) @mrbtLbl1.setGeometry(5, 2, 300, 40) @mrbtLbl2.setGeometry(5, 42, 300, 30) end end def aaaaa if $www==@faa.length-1 $www=0 end @dirLabel2w.setText(tr(NKF.nkf("-ef50",@faa[$www].gsub(/@/," ")))) @sntk[2].setText(tr("")) @sntk[3].setText(tr("")) @sntk[4].setText(tr("")) @sntk[5].setText(tr("")) @sbtn[2].setEnabled(false) @sbtn[3].setEnabled(false) @sbtn[4].setEnabled(false) @sbtn[5].setEnabled(false) @nm=Array.new(){|i| i} $www=$www+1 ss=0 while (@faa2[$www]!="Q") kumk=@faa[$www].gsub(/@/," ") @nm[ss]=kumk.gsub(/\n/," ") $www=$www+1 ss=ss+1 end @ml=@nm[0] for hh in 0..10 n1=rand(ss) n2=rand(ss) nn=@nm[n1] @nm[n1]=@nm[n2] @nm[n2]=nn end for kk in 0..ss-1 @sntk[kk].setText(tr(NKF.nkf("-e",@nm[kk]))) @sbtn[kk].setEnabled(true) end if @nm[0]==@ml then @uuu=0 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[1]==@ml then @uuu=1 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[2]==@ml then @uuu=2 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[3]==@ml then @uuu=3 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[4]==@ml then @uuu=4 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[5]==@ml then @uuu=5 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'kteaws') end @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_O), self, 'owari') @key.connectItem(@key.insertItem(Qt::Key_N), self, 'aaaaa') end def kkkk0 if @uuu==0 then;kteaws() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk1 if @uuu==0 then;miss() elsif @uuu==1 then;kteaws() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk2 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;kteaws() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk3 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;kteaws() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk4 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;kteaws() elsif @uuu==5 then;miss() else;miss();end end def kkkk5 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;kteaws() else;miss();end end def miss QSound::playFile("/home/QtPalmtop/sounds/shtr.wav") end def kteaws QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") aaaaa() end def owari close() end end class MrtkaDialog < QDialog def initialize(parent, caption) super(parent, "MrtkaDialog", true) setCaption(tr(caption)) @faa3=Array.new(){|i| i} ttt=0 fs=File::open($ddd,"r") tex= 0 @faa=Array.new(){|i| i} @faa2=Array.new(){|i| i} while (!fs.eof?) buf=fs.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @faa[tex]=buf @faa2[tex]=bufkte if @faa2[tex]=="Q" @faa3[ttt]=tex ttt=ttt+1 end tex=tex+1 end fs.close() if(@faa2[0]=="Q") @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @dirLabel = QLabel.new(tr(""), self) @dirLabel2 = QLabel.new(tr("選択問題  終了(o or Cancel) 次の問題(n)"), self) @dirLabel2w = QLabel.new(tr("選択問題un"), self) @mbtn01=QPushButton.new(@saveIcon,tr("終了する"),self) @mbtn02=QPushButton.new(tr("次の問題へ"),self) connect(@mbtn01,QSIGNAL("clicked()"),self,'owari') connect(@mbtn02,QSIGNAL("clicked()"),self,'aaaaa') @dirLabel.setGeometry(5, 2, 640, 480) @dirLabel2.setGeometry(5, 2, 500, 30) @mbtn01.setGeometry(5, 32, 150, 40) @mbtn02.setGeometry(205, 32, 150, 40) @dirLabel2w.setGeometry(5, 82, 500, 100) @sntk=Array.new(){|i| i} @sntk[0] = QLabel.new(tr(""), self) @sntk[1] = QLabel.new(tr(""), self) @sntk[2] = QLabel.new(tr(""), self) @sntk[3] = QLabel.new(tr(""), self) @sntk[4] = QLabel.new(tr(""), self) @sntk[5] = QLabel.new(tr(""), self) @sbtn=Array.new(){|i| i} @sbtn[0]=QPushButton.new(tr("q"),self) @sbtn[1]=QPushButton.new(tr("w"),self) @sbtn[2]=QPushButton.new(tr("e"),self) @sbtn[3]=QPushButton.new(tr("r"),self) @sbtn[4]=QPushButton.new(tr("t"),self) @sbtn[5]=QPushButton.new(tr("y"),self) @sbtn[0].setGeometry(5, 165, 50, 40) @sbtn[1].setGeometry(5, 208, 50, 40) @sbtn[2].setGeometry(5, 251, 50, 40) @sbtn[3].setGeometry(5, 294, 50, 40) @sbtn[4].setGeometry(5, 337, 50, 40) @sbtn[5].setGeometry(5, 380, 50, 40) @sntk[0].setGeometry(60, 165, 500, 40) @sntk[1].setGeometry(60, 208, 500, 40) @sntk[2].setGeometry(60, 251, 500, 40) @sntk[3].setGeometry(60, 294, 500, 40) @sntk[4].setGeometry(60, 337, 500, 40) @sntk[5].setGeometry(60, 380, 500, 40) connect(@sbtn[0],QSIGNAL("clicked()"), self,'kkkk0') connect(@sbtn[1],QSIGNAL("clicked()"), self,'kkkk1') connect(@sbtn[2],QSIGNAL("clicked()"), self,'kkkk2') connect(@sbtn[3],QSIGNAL("clicked()"), self,'kkkk3') connect(@sbtn[4],QSIGNAL("clicked()"), self,'kkkk4') connect(@sbtn[5],QSIGNAL("clicked()"), self,'kkkk5') @uuu=6 aaaaa() else @mrbtLbl1 = QLabel.new(tr("選択問題の書式が違います!"), self) @mrbtLbl2 = QLabel.new(tr("確認をしてください"), self) @mrbtLbl1.setGeometry(5, 2, 300, 40) @mrbtLbl2.setGeometry(5, 42, 300, 30) end end def aaaaa vvv=rand(@faa3.length-1) @dirLabel2w.setText(tr(NKF.nkf("-ef50",@faa[@faa3[vvv]].gsub(/@/," ")))) @sntk[2].setText(tr("")) @sntk[3].setText(tr("")) @sntk[4].setText(tr("")) @sntk[5].setText(tr("")) @sbtn[2].setEnabled(false) @sbtn[3].setEnabled(false) @sbtn[4].setEnabled(false) @sbtn[5].setEnabled(false) jjj=@faa3[vvv+1]-@faa3[vvv]-2 @btn=Array.new(){|i| i} @nm=Array.new(){|i| i} zzz=@faa3[vvv] ss=0 for ff in 0..jjj kumk=@faa[zzz+1].gsub(/@/," ") @nm[ss]=kumk.gsub(/\n/," ") zzz=zzz+1 ss=ss+1 end @ml=@nm[0] for hh in 0..10 n1=rand(jjj+1) n2=rand(jjj+1) nn=@nm[n1] @nm[n1]=@nm[n2] @nm[n2]=nn end for kk in 0..jjj @sntk[kk].setText(tr(NKF.nkf("-e",@nm[kk]))) @sbtn[kk].setEnabled(true) end if @nm[0]==@ml then @uuu=0 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[1]==@ml then @uuu=1 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[2]==@ml then @uuu=2 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[3]==@ml then @uuu=3 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[4]==@ml then @uuu=4 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[5]==@ml then @uuu=5 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'kteaws') end @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_O), self, 'owari') @key.connectItem(@key.insertItem(Qt::Key_N), self, 'aaaaa') end def kkkk0 if @uuu==0 then;kteaws() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk1 if @uuu==0 then;miss() elsif @uuu==1 then;kteaws() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk2 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;kteaws() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk3 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;kteaws() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk4 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;kteaws() elsif @uuu==5 then;miss() else;miss();end end def kkkk5 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;kteaws() else;miss();end end def miss QSound::playFile("/home/QtPalmtop/sounds/shtr.wav") end def kteaws QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") aaaaa() end def owari close() end end class MrbtrndmDialog < QDialog def initialize(parent, caption) super(parent, "MrbtrndmDialog", true) ymkm() setCaption(tr(caption)) if (@yorn[0]=="Y"||@yorn[0]=="N") then @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @mrbtLbl1 = QLabel.new(tr(""), self) @mrbtLbl2 = QLabel.new(tr("丸罰問題"), self) @mrbtLbl3 = QLabel.new(tr("問題文"), self) @mrbtbtn1=QPushButton.new(@saveIcon,tr("終了する"),self) @mrbtbtn2=QPushButton.new(tr("次の問題へ"),self) @mrbtbtn3=QPushButton.new(tr("○ (o)"),self) @mrbtbtn4=QPushButton.new(tr("× (k)"),self) connect(@mrbtbtn1,QSIGNAL("clicked()"),self,'mrbtowari') connect(@mrbtbtn2,QSIGNAL("clicked()"),self,'mrtrnm') connect(@mrbtbtn3,QSIGNAL("clicked()"),self,'mrbtmaru') connect(@mrbtbtn4,QSIGNAL("clicked()"),self,'mrbtbatu') @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_O), self, 'mrbtmaru') @key.connectItem(@key.insertItem(Qt::Key_K), self, 'mrbtbatu') @mrbtLbl1.setGeometry(5, 2, 640, 480) @mrbtLbl2.setGeometry(5, 2, 300, 30) @mrbtLbl3.setGeometry(5, 132, 500, 100) @mrbtbtn1.setGeometry(5, 32, 150, 40) @mrbtbtn2.setGeometry(205, 32, 150, 40) @mrbtbtn3.setGeometry(5, 232, 150, 40) @mrbtbtn4.setGeometry(205, 232, 150, 40) mrtrnm() elsif (@yorn[0]!="Y") then if (@yorn[0]!="N") then @mrbl1 = QLabel.new(tr("○×問題の書式が違います!"), self) @mrbl2 = QLabel.new(tr("確認をしてください"), self) @mrbl1.setGeometry(5, 2, 300, 40) @mrbl2.setGeometry(5, 42, 300, 30) end elsif (@yorn[0]!="N") then if (@yorn[0]!="Y") then @mrbl1 = QLabel.new(tr("○×問題の書式が違います!"), self) @mrbl2 = QLabel.new(tr("確認をしてください"), self) @mrbl1.setGeometry(5, 2, 300, 40) @mrbl2.setGeometry(5, 42, 300, 30) end end end def mrbtowari close() end def mrtrnm QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") @bngu=rand(@bnsu) @mrbtLbl3.setText(tr(NKF.nkf("-ef40",@hnbn[@bngu].gsub(/@/," ")))) @mrbtLbl2.setText(tr("問題"+@bngu.to_s)) end def mrbtmis @mrbtLbl2.setText(tr("間違ってます")) QSound::playFile("/home/QtPalmtop/sounds/shtr.wav") end def mrbtmaru if @yorn[@bngu]=="Y" then mrtrnm() else mrbtmis() end end def mrbtbatu if @yorn[@bngu]=="N" then mrtrnm() else mrbtmis() end end def ymkm @bngu=0 mrbtfile=File::open($mmm,"r") mrbtcunt= 0 @hnbn=Array.new(){|i| i} @yorn=Array.new(){|i| i} while (!mrbtfile.eof?) buf=mrbtfile.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @hnbn[mrbtcunt]=buf @yorn[mrbtcunt]=bufkte mrbtcunt=mrbtcunt+1 end mrbtfile.close() @bnsu=@hnbn.length-1 end end class Mrbtrndm2Dialog < QDialog def initialize(parent, caption) super(parent, "Mrbtrndm2Dialog", true) ymkm() setCaption(tr(caption)) @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @mrbtLbl1 = QLabel.new(tr(""), self) @mrbtLbl2 = QLabel.new(tr("丸罰問題"), self) @mrbtLbl3 = QLabel.new(tr("問題文"), self) @mrbtbtn1=QPushButton.new(@saveIcon,tr("終了する"),self) @mrbtbtn2=QPushButton.new(tr("次の問題へ"),self) @mrbtbtn3=QPushButton.new(tr("○ (o)"),self) @mrbtbtn4=QPushButton.new(tr("× (k)"),self) connect(@mrbtbtn1,QSIGNAL("clicked()"),self,'mrbtowari') connect(@mrbtbtn2,QSIGNAL("clicked()"),self,'mrtrnm') connect(@mrbtbtn3,QSIGNAL("clicked()"),self,'mrbtmaru') connect(@mrbtbtn4,QSIGNAL("clicked()"),self,'mrbtbatu') @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_O), self, 'mrbtmaru') @key.connectItem(@key.insertItem(Qt::Key_K), self, 'mrbtbatu') @mrbtLbl1.setGeometry(5, 2, 640, 480) @mrbtLbl2.setGeometry(5, 2, 300, 30) @mrbtLbl3.setGeometry(5, 132, 500, 100) @mrbtbtn1.setGeometry(5, 32, 150, 40) @mrbtbtn2.setGeometry(205, 32, 150, 40) @mrbtbtn3.setGeometry(5, 232, 150, 40) @mrbtbtn4.setGeometry(205, 232, 150, 40) mrtrnme() end def mrtrnme @bngu=rand(@bnsu) @mrbtLbl3.setText(tr(NKF.nkf("-ef40",@hnbn[@bngu].gsub(/@/," ")))) @mrbtLbl2.setText(tr("問題"+@bngu.to_s)) end def mrbtowari close() end def mrtrnm QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") b=rand($hh.length) $tt=$dirLabel6.text().utf8().to_str() $tt=$tt+"/"+$hh[b] if $hh[b][0,1]=="m" then dlg = Mrbtrndm2Dialog.new(self,"○×選択ランダム") res = dlg.exec() close() else dlg = Mrtka2Dialog.new(self,"○×選択ランダム") res = dlg.exec() close() end close() end def mrbtmis @mrbtLbl2.setText(tr("間違ってます")) QSound::playFile("/home/QtPalmtop/sounds/shtr.wav") end def mrbtmaru if @yorn[@bngu]=="Y" then mrtrnm() else mrbtmis() end end def mrbtbatu if @yorn[@bngu]=="N" then mrtrnm() else mrbtmis() end end def ymkm @bngu=0 mrbtfile=File::open($tt,"r") mrbtcunt= 0 @hnbn=Array.new(){|i| i} @yorn=Array.new(){|i| i} while (!mrbtfile.eof?) buf=mrbtfile.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @hnbn[mrbtcunt]=buf @yorn[mrbtcunt]=bufkte mrbtcunt=mrbtcunt+1 end mrbtfile.close() @bnsu=@hnbn.length-1 end end class Mrtka2Dialog < QDialog def initialize(parent, caption) super(parent, "Mrtka2Dialog", true) setCaption(tr(caption)) @faa3=Array.new(){|i| i} ttt=0 fs=File::open($tt,"r") tex= 0 @faa=Array.new(){|i| i} @faa2=Array.new(){|i| i} while (!fs.eof?) buf=fs.gets bufkte=buf[0,1] buf=buf[2,buf.length-1] @faa[tex]=buf @faa2[tex]=bufkte if @faa2[tex]=="Q" @faa3[ttt]=tex ttt=ttt+1 end tex=tex+1 end fs.close() @saveIcon = QPixmap.new( "/home/QtPalmtop/pics/tux-logo.png" ) @dirLabel = QLabel.new(tr(""), self) @dirLabel2 = QLabel.new(tr("選択問題  終了(o or Cancel) 次の問題(n)"), self) @dirLabel2w = QLabel.new(tr("選択問題un"), self) @mbtn01=QPushButton.new(@saveIcon,tr("終了する"),self) @mbtn02=QPushButton.new(tr("次の問題へ"),self) connect(@mbtn01,QSIGNAL("clicked()"),self,'owari') connect(@mbtn02,QSIGNAL("clicked()"),self,'mrtk') @dirLabel.setGeometry(5, 2, 640, 480) @dirLabel2.setGeometry(5, 2, 500, 30) @mbtn01.setGeometry(5, 32, 150, 40) @mbtn02.setGeometry(205, 32, 150, 40) @dirLabel2w.setGeometry(5, 82, 500, 100) @sntk=Array.new(){|i| i} @sntk[0] = QLabel.new(tr(""), self) @sntk[1] = QLabel.new(tr(""), self) @sntk[2] = QLabel.new(tr(""), self) @sntk[3] = QLabel.new(tr(""), self) @sntk[4] = QLabel.new(tr(""), self) @sntk[5] = QLabel.new(tr(""), self) @sbtn=Array.new(){|i| i} @sbtn[0]=QPushButton.new(tr("q"),self) @sbtn[1]=QPushButton.new(tr("w"),self) @sbtn[2]=QPushButton.new(tr("e"),self) @sbtn[3]=QPushButton.new(tr("r"),self) @sbtn[4]=QPushButton.new(tr("t"),self) @sbtn[5]=QPushButton.new(tr("y"),self) @sbtn[0].setGeometry(5, 165, 50, 40) @sbtn[1].setGeometry(5, 208, 50, 40) @sbtn[2].setGeometry(5, 251, 50, 40) @sbtn[3].setGeometry(5, 294, 50, 40) @sbtn[4].setGeometry(5, 337, 50, 40) @sbtn[5].setGeometry(5, 380, 50, 40) @sntk[0].setGeometry(60, 165, 500, 40) @sntk[1].setGeometry(60, 208, 500, 40) @sntk[2].setGeometry(60, 251, 500, 40) @sntk[3].setGeometry(60, 294, 500, 40) @sntk[4].setGeometry(60, 337, 500, 40) @sntk[5].setGeometry(60, 380, 500, 40) connect(@sbtn[0],QSIGNAL("clicked()"), self,'kkkk0') connect(@sbtn[1],QSIGNAL("clicked()"), self,'kkkk1') connect(@sbtn[2],QSIGNAL("clicked()"), self,'kkkk2') connect(@sbtn[3],QSIGNAL("clicked()"), self,'kkkk3') connect(@sbtn[4],QSIGNAL("clicked()"), self,'kkkk4') connect(@sbtn[5],QSIGNAL("clicked()"), self,'kkkk5') vvv=rand(@faa3.length-1) @dirLabel2w.setText(tr(NKF.nkf("-ef50",@faa[@faa3[vvv]].gsub(/@/," ")))) @sntk[2].setText(tr("")) @sntk[3].setText(tr("")) @sntk[4].setText(tr("")) @sntk[5].setText(tr("")) @sbtn[2].setEnabled(false) @sbtn[3].setEnabled(false) @sbtn[4].setEnabled(false) @sbtn[5].setEnabled(false) jjj=@faa3[vvv+1]-@faa3[vvv]-2 @btn=Array.new(){|i| i} @nm=Array.new(){|i| i} zzz=@faa3[vvv] ss=0 for ff in 0..jjj kumk=@faa[zzz+1].gsub(/@/," ") @nm[ss]=kumk.gsub(/\n/," ") zzz=zzz+1 ss=ss+1 end @ml=@nm[0] for hh in 0..10 n1=rand(jjj+1) n2=rand(jjj+1) nn=@nm[n1] @nm[n1]=@nm[n2] @nm[n2]=nn end for kk in 0..jjj @sntk[kk].setText(tr(NKF.nkf("-e",@nm[kk]))) @sbtn[kk].setEnabled(true) end if @nm[0]==@ml then @uuu=0 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[1]==@ml then @uuu=1 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[2]==@ml then @uuu=2 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[3]==@ml then @uuu=3 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[4]==@ml then @uuu=4 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'kteaws') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'miss') elsif @nm[5]==@ml then @uuu=5 @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_Q), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_W), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_E), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_R), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_T), self, 'miss') @key.connectItem(@key.insertItem(Qt::Key_Y), self, 'kteaws') end @key = QAccel.new(self) @key.connectItem(@key.insertItem(Qt::Key_O), self, 'owari') @key.connectItem(@key.insertItem(Qt::Key_N), self, 'mrtk') end def kkkk0 if @uuu==0 then;kteaws() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk1 if @uuu==0 then;miss() elsif @uuu==1 then;kteaws() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk2 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;kteaws() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk3 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;kteaws() elsif @uuu==4 then;miss() elsif @uuu==5 then;miss() else;miss();end end def kkkk4 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;kteaws() elsif @uuu==5 then;miss() else;miss();end end def kkkk5 if @uuu==0 then;miss() elsif @uuu==1 then;miss() elsif @uuu==2 then;miss() elsif @uuu==3 then;miss() elsif @uuu==4 then;miss() elsif @uuu==5 then;kteaws() else;miss();end end def miss QSound::playFile("/home/QtPalmtop/sounds/shtr.wav") end def kteaws QSound::playFile("/home/QtPalmtop/sounds/xylophone.wav") mrtk() end def owari close() end def mrtk b=rand($hh.length) $tt=$dirLabel6.text().utf8().to_str() $tt=$tt+"/"+$hh[b] if $hh[b][0,1]=="m" then dlg = Mrbtrndm2Dialog.new(self,"○×選択ランダム") res = dlg.exec() close() else dlg = Mrtka2Dialog.new(self,"○×選択ランダム") res = dlg.exec() close() end close() end end class MyApplication < QPEApplication def initialize super([$0]+ARGV) self.setDefaultCodec(QTextCodec::codecForName("eucJP")) end end app=MyApplication.new app.showMainWidget(MainWindow.new()) app.exec