
百人一首かるた 流しの練習用
| Revision | ae0ab68818cadeb3bd2a07be98bc210e4ecf98cc (tree) |
|---|---|
| Time | 2012-10-15 22:58:45 |
| Author | arakaki <alucky4416@user...> |
| Commiter | arakaki |
CHG: Add FudaImgView Class (QGraphicsView SubClass, MousePressEvent Override) for FudaImage Change. and Delete FudaClick Bottun.
| @@ -10,10 +10,12 @@ TARGET = QtKarutaNagashi | ||
| 10 | 10 | TEMPLATE = app |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -SOURCES += main.cpp\ | |
| 14 | - mainwindow.cpp | |
| 13 | +SOURCES += main.cpp \ | |
| 14 | + mainwindow.cpp \ | |
| 15 | + fudaimgview.cpp | |
| 15 | 16 | |
| 16 | 17 | HEADERS += mainwindow.h \ |
| 18 | + fudaimgview.h \ | |
| 17 | 19 | textrsc.h |
| 18 | 20 | |
| 19 | 21 | FORMS += mainwindow.ui |
| @@ -22,4 +24,3 @@ RESOURCES += \ | ||
| 22 | 24 | QtKarutaNagashi.qrc |
| 23 | 25 | |
| 24 | 26 | RC_FILE = Icon.rc |
| 25 | - |
| @@ -0,0 +1,15 @@ | ||
| 1 | +#include "fudaimgview.h" | |
| 2 | + | |
| 3 | +#include <QDebug> | |
| 4 | + | |
| 5 | +FudaImgView::FudaImgView(QWidget *parent) : | |
| 6 | + QGraphicsView(parent) | |
| 7 | +{ | |
| 8 | + ; | |
| 9 | +} | |
| 10 | + | |
| 11 | +void FudaImgView::mousePressEvent(QMouseEvent * event) | |
| 12 | +{ | |
| 13 | +// qDebug() << __FUNCTION__; | |
| 14 | + emit mousePress(); | |
| 15 | +} |
| @@ -0,0 +1,23 @@ | ||
| 1 | +#ifndef FUDAIMGVIEW_H | |
| 2 | +#define FUDAIMGVIEW_H | |
| 3 | + | |
| 4 | +#include <QtGui> | |
| 5 | + | |
| 6 | +class FudaImgView : public QGraphicsView | |
| 7 | +{ | |
| 8 | + Q_OBJECT | |
| 9 | + | |
| 10 | +public: | |
| 11 | + explicit FudaImgView(QWidget *parent = 0); | |
| 12 | + | |
| 13 | +protected: | |
| 14 | + void mousePressEvent(QMouseEvent * event); | |
| 15 | + | |
| 16 | +signals: | |
| 17 | + void mousePress(); | |
| 18 | + | |
| 19 | +public slots: | |
| 20 | + | |
| 21 | +}; | |
| 22 | + | |
| 23 | +#endif // FUDAIMGVIEW_H |
| @@ -46,6 +46,7 @@ MainWindow::MainWindow(QWidget *parent) : | ||
| 46 | 46 | ui->Slct_FudaMuki->addItem(tr("ランダム")); |
| 47 | 47 | ui->label_5->setEnabled(false); |
| 48 | 48 | |
| 49 | + connect(ui->gView_Fuda, SIGNAL(mousePress()), this, SLOT(Fuda_clicked())); | |
| 49 | 50 | // qDebug() << QCoreApplication::applicationDirPath(); |
| 50 | 51 | // qDebug() << QCoreApplication::applicationFilePath(); |
| 51 | 52 | AppPath = QCoreApplication::applicationDirPath(); |
| @@ -126,6 +127,21 @@ void MainWindow::TimeoutDone() | ||
| 126 | 127 | } |
| 127 | 128 | } |
| 128 | 129 | |
| 130 | +void MainWindow::Fuda_clicked() | |
| 131 | +{ | |
| 132 | + // Update FudaImage | |
| 133 | + if (execflag && mode == 1) { | |
| 134 | + fudaindex++; | |
| 135 | + if (fudaindex >= maisu) { | |
| 136 | +// if (mode == 0) timer->stop(); | |
| 137 | + execflag = false; | |
| 138 | + EndingFuda(); | |
| 139 | + } else { | |
| 140 | + UpdateFuda(); | |
| 141 | + } | |
| 142 | + } | |
| 143 | +} | |
| 144 | + | |
| 129 | 145 | void MainWindow::on_Btn_Start_clicked() |
| 130 | 146 | { |
| 131 | 147 | // int mode; // モード自動(0)/手動(1) |
| @@ -149,8 +165,9 @@ void MainWindow::on_Btn_Start_clicked() | ||
| 149 | 165 | maisu = ui->Num_Count->value(); |
| 150 | 166 | waittime = (int)(ui->Num_WaitTime->value() * 1000); |
| 151 | 167 | muki = ui->Slct_FudaMuki->currentIndex(); |
| 152 | - QString msg = QString("mode is %1, maisu is %2, waittime is %3, muki is %4").arg(mode).arg(maisu).arg(waittime).arg(muki); | |
| 153 | - qDebug() << msg; | |
| 168 | + | |
| 169 | +// QString msg = QString("mode is %1, maisu is %2, waittime is %3, muki is %4").arg(mode).arg(maisu).arg(waittime).arg(muki); | |
| 170 | +// qDebug() << msg; | |
| 154 | 171 | |
| 155 | 172 | // Generate Random Datas |
| 156 | 173 | for (int i = 0; i < 100; i++) { |
| @@ -193,8 +210,8 @@ void MainWindow::on_Btn_Restart_clicked() | ||
| 193 | 210 | maisu = ui->Num_Count->value(); |
| 194 | 211 | waittime = (int)(ui->Num_WaitTime->value() * 1000 + 1); |
| 195 | 212 | muki = ui->Slct_FudaMuki->currentIndex(); |
| 196 | - QString msg = QString("mode is %1, maisu is %2, waittime is %3, muki is %4").arg(mode).arg(maisu).arg(waittime).arg(muki); | |
| 197 | - qDebug() << msg; | |
| 213 | +// QString msg = QString("mode is %1, maisu is %2, waittime is %3, muki is %4").arg(mode).arg(maisu).arg(waittime).arg(muki); | |
| 214 | +// qDebug() << msg; | |
| 198 | 215 | |
| 199 | 216 | execflag = true; |
| 200 | 217 | fudaindex = 0; |
| @@ -225,10 +242,8 @@ void MainWindow::on_Slct_Mode_currentIndexChanged(int index) | ||
| 225 | 242 | // qDebug() << msg; |
| 226 | 243 | |
| 227 | 244 | if (index) { |
| 228 | - ui->Btn_Fuda->setEnabled(true); | |
| 229 | 245 | ui->label_5->setEnabled(true); |
| 230 | 246 | } else { |
| 231 | - ui->Btn_Fuda->setEnabled(false); | |
| 232 | 247 | ui->label_5->setEnabled(false); |
| 233 | 248 | } |
| 234 | 249 | } |
| @@ -247,7 +262,7 @@ void MainWindow::on_actionExit_triggered() | ||
| 247 | 262 | |
| 248 | 263 | void MainWindow::on_actionAbout_triggered() |
| 249 | 264 | { |
| 250 | - QMessageBox::about(this, "About", tr("流しの練習 v0.2")); | |
| 265 | + QMessageBox::about(this, "About", tr("流しの練習 v0.3")); | |
| 251 | 266 | } |
| 252 | 267 | |
| 253 | 268 | void MainWindow::on_actionAbout_Qt_triggered() |
| @@ -255,21 +270,6 @@ void MainWindow::on_actionAbout_Qt_triggered() | ||
| 255 | 270 | QApplication::aboutQt(); |
| 256 | 271 | } |
| 257 | 272 | |
| 258 | -void MainWindow::on_Btn_Fuda_clicked() | |
| 259 | -{ | |
| 260 | - // Update FudaImage | |
| 261 | - if (execflag && mode == 1) { | |
| 262 | - fudaindex++; | |
| 263 | - if (fudaindex >= maisu) { | |
| 264 | -// if (mode == 0) timer->stop(); | |
| 265 | - execflag = false; | |
| 266 | - EndingFuda(); | |
| 267 | - } else { | |
| 268 | - UpdateFuda(); | |
| 269 | - } | |
| 270 | - } | |
| 271 | -} | |
| 272 | - | |
| 273 | 273 | void MainWindow::on_checkBox_DispKaminoku_stateChanged(int chk) |
| 274 | 274 | { |
| 275 | 275 | if (chk) { |
| @@ -35,14 +35,14 @@ private slots: | ||
| 35 | 35 | |
| 36 | 36 | void TimeoutDone(); |
| 37 | 37 | |
| 38 | + void Fuda_clicked(); | |
| 39 | + | |
| 38 | 40 | void on_actionExit_triggered(); |
| 39 | 41 | |
| 40 | 42 | void on_actionAbout_triggered(); |
| 41 | 43 | |
| 42 | 44 | void on_actionAbout_Qt_triggered(); |
| 43 | 45 | |
| 44 | - void on_Btn_Fuda_clicked(); | |
| 45 | - | |
| 46 | 46 | void on_checkBox_DispKaminoku_stateChanged(int ); |
| 47 | 47 | |
| 48 | 48 | private: |
| @@ -32,7 +32,7 @@ | ||
| 32 | 32 | <string>競技かるた - 流しの練習</string> |
| 33 | 33 | </property> |
| 34 | 34 | <property name="windowIcon"> |
| 35 | - <iconset resource="KarutaNagashi.qrc"> | |
| 35 | + <iconset resource="QtKarutaNagashi.qrc"> | |
| 36 | 36 | <normaloff>:/images/KarutaNagashiIcon.png</normaloff>:/images/KarutaNagashiIcon.png</iconset> |
| 37 | 37 | </property> |
| 38 | 38 | <widget class="QWidget" name="centralWidget"> |
| @@ -157,7 +157,7 @@ p, li { white-space: pre-wrap; } | ||
| 157 | 157 | <number>-1</number> |
| 158 | 158 | </property> |
| 159 | 159 | </widget> |
| 160 | - <widget class="QGraphicsView" name="gView_Fuda"> | |
| 160 | + <widget class="FudaImgView" name="gView_Fuda"> | |
| 161 | 161 | <property name="enabled"> |
| 162 | 162 | <bool>true</bool> |
| 163 | 163 | </property> |
| @@ -270,15 +270,18 @@ p, li { white-space: pre-wrap; } | ||
| 270 | 270 | <widget class="QLabel" name="label_5"> |
| 271 | 271 | <property name="geometry"> |
| 272 | 272 | <rect> |
| 273 | - <x>390</x> | |
| 273 | + <x>360</x> | |
| 274 | 274 | <y>330</y> |
| 275 | - <width>161</width> | |
| 275 | + <width>221</width> | |
| 276 | 276 | <height>16</height> |
| 277 | 277 | </rect> |
| 278 | 278 | </property> |
| 279 | 279 | <property name="text"> |
| 280 | 280 | <string>手動の時は札をクリックしてください。</string> |
| 281 | 281 | </property> |
| 282 | + <property name="alignment"> | |
| 283 | + <set>Qt::AlignCenter</set> | |
| 284 | + </property> | |
| 282 | 285 | </widget> |
| 283 | 286 | <widget class="QLabel" name="label_6"> |
| 284 | 287 | <property name="geometry"> |
| @@ -304,37 +307,12 @@ p, li { white-space: pre-wrap; } | ||
| 304 | 307 | <string/> |
| 305 | 308 | </property> |
| 306 | 309 | <property name="pixmap"> |
| 307 | - <pixmap resource="KarutaNagashi.qrc">:/images/NagashiTitle.png</pixmap> | |
| 310 | + <pixmap resource="QtKarutaNagashi.qrc">:/images/NagashiTitle.png</pixmap> | |
| 308 | 311 | </property> |
| 309 | 312 | <property name="alignment"> |
| 310 | 313 | <set>Qt::AlignCenter</set> |
| 311 | 314 | </property> |
| 312 | 315 | </widget> |
| 313 | - <widget class="QPushButton" name="Btn_Fuda"> | |
| 314 | - <property name="enabled"> | |
| 315 | - <bool>false</bool> | |
| 316 | - </property> | |
| 317 | - <property name="geometry"> | |
| 318 | - <rect> | |
| 319 | - <x>360</x> | |
| 320 | - <y>40</y> | |
| 321 | - <width>221</width> | |
| 322 | - <height>291</height> | |
| 323 | - </rect> | |
| 324 | - </property> | |
| 325 | - <property name="focusPolicy"> | |
| 326 | - <enum>Qt::NoFocus</enum> | |
| 327 | - </property> | |
| 328 | - <property name="autoFillBackground"> | |
| 329 | - <bool>false</bool> | |
| 330 | - </property> | |
| 331 | - <property name="text"> | |
| 332 | - <string/> | |
| 333 | - </property> | |
| 334 | - <property name="flat"> | |
| 335 | - <bool>true</bool> | |
| 336 | - </property> | |
| 337 | - </widget> | |
| 338 | 316 | <widget class="QPlainTextEdit" name="TextEdit_Kaminoku"> |
| 339 | 317 | <property name="enabled"> |
| 340 | 318 | <bool>true</bool> |
| @@ -399,7 +377,7 @@ p, li { white-space: pre-wrap; } | ||
| 399 | 377 | <string>開始</string> |
| 400 | 378 | </property> |
| 401 | 379 | <property name="icon"> |
| 402 | - <iconset resource="KarutaNagashi.qrc"> | |
| 380 | + <iconset resource="QtKarutaNagashi.qrc"> | |
| 403 | 381 | <normaloff>:/images/Play.png</normaloff>:/images/Play.png</iconset> |
| 404 | 382 | </property> |
| 405 | 383 | </widget> |
| @@ -424,7 +402,7 @@ p, li { white-space: pre-wrap; } | ||
| 424 | 402 | <string>もう一度</string> |
| 425 | 403 | </property> |
| 426 | 404 | <property name="icon"> |
| 427 | - <iconset resource="KarutaNagashi.qrc"> | |
| 405 | + <iconset resource="QtKarutaNagashi.qrc"> | |
| 428 | 406 | <normaloff>:/images/RePlay.png</normaloff>:/images/RePlay.png</iconset> |
| 429 | 407 | </property> |
| 430 | 408 | </widget> |
| @@ -449,7 +427,7 @@ p, li { white-space: pre-wrap; } | ||
| 449 | 427 | <string>中止</string> |
| 450 | 428 | </property> |
| 451 | 429 | <property name="icon"> |
| 452 | - <iconset resource="KarutaNagashi.qrc"> | |
| 430 | + <iconset resource="QtKarutaNagashi.qrc"> | |
| 453 | 431 | <normaloff>:/images/Stop.png</normaloff>:/images/Stop.png</iconset> |
| 454 | 432 | </property> |
| 455 | 433 | </widget> |
| @@ -460,7 +438,7 @@ p, li { white-space: pre-wrap; } | ||
| 460 | 438 | <x>0</x> |
| 461 | 439 | <y>0</y> |
| 462 | 440 | <width>600</width> |
| 463 | - <height>19</height> | |
| 441 | + <height>22</height> | |
| 464 | 442 | </rect> |
| 465 | 443 | </property> |
| 466 | 444 | <widget class="QMenu" name="menuFile"> |
| @@ -508,8 +486,15 @@ p, li { white-space: pre-wrap; } | ||
| 508 | 486 | </action> |
| 509 | 487 | </widget> |
| 510 | 488 | <layoutdefault spacing="6" margin="11"/> |
| 489 | + <customwidgets> | |
| 490 | + <customwidget> | |
| 491 | + <class>FudaImgView</class> | |
| 492 | + <extends>QGraphicsView</extends> | |
| 493 | + <header>fudaimgview.h</header> | |
| 494 | + </customwidget> | |
| 495 | + </customwidgets> | |
| 511 | 496 | <resources> |
| 512 | - <include location="KarutaNagashi.qrc"/> | |
| 497 | + <include location="QtKarutaNagashi.qrc"/> | |
| 513 | 498 | </resources> |
| 514 | 499 | <connections/> |
| 515 | 500 | </ui> |