Nav apraksta

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3. #include "grid.cpp"
  4. #include <QtGui>
  5. #include <QtCore>
  6. #include <QWidget>
  7. #include <QGridLayout>
  8. /// \fn Dialog::Dialog(QWidget *parent)
  9. /// \~English
  10. /// \brief The constructor sets the undo and redo to disable so it cant be pressed
  11. /// also sets the connections between the buttons and their respective signals.
  12. /// \~Spanish
  13. /// \brief El constructor ajusta el boton de deshacer (undo) y rehacer (redo) para que no
  14. /// puedan ser apretados, tambien ajusta las conecciones entre los botones y sus senales.
  15. Dialog::Dialog(QWidget *parent) :
  16. QDialog(parent),
  17. ui(new Ui::Dialog)
  18. {
  19. ui->setupUi(this);
  20. ui->undoButton->setDisabled(true);
  21. ui->redoButton->setDisabled(true);
  22. connect(ui->mainGrid, SIGNAL(canUndo(bool)), this, SLOT(setUndo(bool)));
  23. connect(ui->mainGrid, SIGNAL(canRedo(bool)), this, SLOT(setRedo(bool)));
  24. }
  25. /// \fn void Dialog::setUndo(bool can)
  26. /// \~English
  27. /// \brief Enables the undo button
  28. /// \~Spanish
  29. /// \brief Permite utilizar el boton de deshacer (undo)
  30. void Dialog::setUndo(bool can){
  31. if (can == true) ui->undoButton->setDisabled(false);
  32. else ui->undoButton->setDisabled(true);
  33. }
  34. /// \fn void Dialog::setRedo(bool can)
  35. /// \~English
  36. /// \brief Enables the redo button
  37. /// \~Spanish
  38. /// \brief Permite utilizar el boton de (rehacer)
  39. void Dialog::setRedo(bool can){
  40. if (can == true) ui->redoButton->setDisabled(false);
  41. else ui->redoButton->setDisabled(true);
  42. }
  43. /// \fn Dialog::~Dialog()
  44. /// \~English
  45. /// \brief Destructor
  46. /// \~Spanish
  47. /// \brief Destructor
  48. Dialog::~Dialog()
  49. {
  50. delete ui;
  51. }
  52. /// \fn void Dialog::on_frontcolorComboBox_activated(const QString &color)
  53. /// \~English
  54. /// \brief Sets the color of the brush
  55. /// \param color color of the brush
  56. /// \~Spanish
  57. /// \brief Ajusta el color de la brocha
  58. /// \param color color de la brocha
  59. void Dialog::on_frontcolorComboBox_activated(const QString &color)
  60. {
  61. ui->mainGrid->setFront(color);
  62. }
  63. /// \fn void Dialog::on_backgroundComboBox_activated(const QString &color)
  64. /// \~English
  65. /// \brief Sets the color of the background
  66. /// \param color color del background
  67. /// \~Spanish
  68. /// \brief Ajusta el color del fondo
  69. /// \param color color del fondo
  70. void Dialog::on_backgroundComboBox_activated(const QString &color)
  71. {
  72. ui->mainGrid->setBack(color);
  73. ui->mainGrid->repaint();
  74. }
  75. /// \fn void Dialog::on_lapizButton_clicked()
  76. /// \~English
  77. /// \brief Sets the tool to dot
  78. /// \~Spanish
  79. /// \brief Ajusta la herramienta a usar la punta
  80. void Dialog::on_lapizButton_clicked()
  81. {
  82. ui->mainGrid->setTool("dot");
  83. }
  84. /// \fn void Dialog::on_cleargridButton_clicked()
  85. /// \~English
  86. /// \brief Clears the grid. Erase the grid
  87. /// \~Spanish
  88. /// \brief Limpia la cuadricula Borra la cuadricula.
  89. void Dialog::on_cleargridButton_clicked()
  90. {
  91. ui->mainGrid->clear();
  92. ui->mainGrid->repaint();
  93. }
  94. /// \fn void Dialog::on_rowmajorfillButton_clicked()
  95. /// \~English
  96. /// \brief Sets the tool to Row fill
  97. /// \~Spanish
  98. /// \brief Ajusta la herramienta a llenar fila
  99. void Dialog::on_rowmajorfillButton_clicked()
  100. {
  101. ui->mainGrid->setTool("row");
  102. }
  103. /// \fn void Dialog::on_colmajorfillButton_clicked()
  104. /// \~English
  105. /// \brief Sets the tool to Column fill
  106. /// \~Spanish
  107. /// \brief Ajusta la herramienta a llenar columna
  108. void Dialog::on_colmajorfillButton_clicked()
  109. {
  110. ui->mainGrid->setTool("column");
  111. }
  112. /// \fn void Dialog::on_diagonalleftButton_clicked()
  113. /// \~English
  114. /// \brief Sets the tool to Diagonal Left fill
  115. /// \~Spanish
  116. /// \brief Ajusta la herrramienta a llenar en diagonal a la izquierda
  117. void Dialog::on_diagonalleftButton_clicked()
  118. {
  119. ui->mainGrid->setTool("diagonal left");
  120. }
  121. /// \fn void Dialog::on_diagonalrightButton_clicked()
  122. /// \~English
  123. /// \brief Sets the tool to Diagonal Right fill
  124. /// \~Spanish
  125. /// \brief Ajusta la herrramienta a llenar en diagonal a la derecha
  126. void Dialog::on_diagonalrightButton_clicked()
  127. {
  128. ui->mainGrid->setTool("diagonal right");
  129. }
  130. /// \fn void Dialog::on_drawsquareButton_clicked()
  131. /// \~English
  132. /// \brief Sets the tool to paint Squares
  133. /// \~Spanish
  134. /// \brief Ajusta la herramiento a pintar cuadrados
  135. void Dialog::on_drawsquareButton_clicked()
  136. {
  137. ui->mainGrid->setTool("square");
  138. }
  139. /// \fn void Dialog::on_drawtriangleButton_clicked()
  140. /// \~English
  141. /// \brief Sets the tool to paint Triangles
  142. /// \~Spanish
  143. /// \brief Ajusta la herramiento a pintar triangulos
  144. void Dialog::on_drawtriangleButton_clicked()
  145. {
  146. ui->mainGrid->setTool("triangle");
  147. }
  148. /// \fn void Dialog::on_drawcircleButton_clicked()
  149. /// \~English
  150. /// \brief Sets the tool to paint Circles
  151. /// \~Spanish
  152. /// \brief Ajusta la herramiento a pintar circulos
  153. void Dialog::on_drawcircleButton_clicked()
  154. {
  155. ui->mainGrid->setTool("circle");
  156. }
  157. /// \fn void Dialog::on_speedHorizontalSlider_valueChanged(int value)
  158. /// \~English
  159. /// \brief Sets the tool point size
  160. /// \param value point size
  161. /// \~Spanish
  162. /// \brief Ajusta el tamano de la punta de la herramienta
  163. /// \param value tamano de la punta
  164. void Dialog::on_speedHorizontalSlider_valueChanged(int value)
  165. {
  166. ui->mainGrid->setToolSize(value);
  167. ui->lblSize->setText(QString::number(value));
  168. }
  169. /// \fn void Dialog::on_undoButton_clicked()
  170. /// \~English
  171. /// \brief Undo the previous grid modification
  172. /// \~Spanish
  173. /// \brief Deshace la modificacion previa de la cuadricula
  174. void Dialog::on_undoButton_clicked()
  175. {
  176. ui->mainGrid->undo();
  177. }
  178. /// \fn void Dialog::on_redoButton_clicked()
  179. /// \~English
  180. /// \brief Redo the previous grid modification
  181. /// \~Spanish
  182. /// \brief Rehace la modificacion previa de la cuadricula
  183. void Dialog::on_redoButton_clicked()
  184. {
  185. ui->mainGrid->redo();
  186. }
  187. void Dialog::on_floodButton_clicked()
  188. {
  189. ui->mainGrid->setTool("flood");
  190. }