Commit 84a63fd7 authored by Yann Boucher's avatar Yann Boucher
Browse files

Ajout d'un mode plein écran

parent a1042598
Pipeline #79738 passed with stages
in 17 seconds
...@@ -644,8 +644,15 @@ pattern recorded :</string> ...@@ -644,8 +644,15 @@ pattern recorded :</string>
<addaction name="action_bad_apple"/> <addaction name="action_bad_apple"/>
<addaction name="action_snake"/> <addaction name="action_snake"/>
</widget> </widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
<addaction name="action_fullscreen"/>
</widget>
<addaction name="menuFichier"/> <addaction name="menuFichier"/>
<addaction name="menuEditer"/> <addaction name="menuEditer"/>
<addaction name="menuView"/>
<addaction name="menuBonus"/> <addaction name="menuBonus"/>
<addaction name="menuA_propos"/> <addaction name="menuA_propos"/>
</widget> </widget>
...@@ -698,6 +705,14 @@ pattern recorded :</string> ...@@ -698,6 +705,14 @@ pattern recorded :</string>
<string>Save as an animated GIF...</string> <string>Save as an animated GIF...</string>
</property> </property>
</action> </action>
<action name="action_fullscreen">
<property name="text">
<string>Enter fullscreen</string>
</property>
<property name="shortcut">
<string>F11</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
......
...@@ -142,11 +142,17 @@ public: ...@@ -142,11 +142,17 @@ public:
//! \brief Retourne une QImage représentant la grille actuelle. //! \brief Retourne une QImage représentant la grille actuelle.
const QImage &grid_image() const; const QImage &grid_image() const;
//! \brief Place le GridView en plein écran
void enter_fullscreen();
signals: signals:
//! \brief Signal émis quand le zoom change. //! \brief Signal émis quand le zoom change.
//! \param cell_size la nouvelle taille à l'écran en pixels d'une cellule //! \param cell_size la nouvelle taille à l'écran en pixels d'une cellule
void zoom_changed(unsigned cell_size); void zoom_changed(unsigned cell_size);
//! \brief Signal émis lorsque l'utilisateur désire quitter le mode plein écran.
void exit_fullscreen();
private: private:
void load_grid(const Grid& grid); void load_grid(const Grid& grid);
...@@ -176,6 +182,7 @@ private: ...@@ -176,6 +182,7 @@ private:
History m_undo_history; History m_undo_history;
std::vector<uint32_t> m_image_data; std::vector<uint32_t> m_image_data;
QImage m_grid_image; QImage m_grid_image;
QWidget* m_info_section;
QLabel* m_mouse_pos_label; QLabel* m_mouse_pos_label;
Grid m_grid; Grid m_grid;
Coord m_last_mouse_pos; Coord m_last_mouse_pos;
......
...@@ -95,7 +95,11 @@ private slots: ...@@ -95,7 +95,11 @@ private slots:
//! \brief Change la profondeur de l'historique de simulation //! \brief Change la profondeur de l'historique de simulation
void on_recordSpinBox_valueChanged(int arg1); void on_recordSpinBox_valueChanged(int arg1);
//! \brief Place le GridView en plein écran
void enter_fullscreen();
//! \brief Quitte le mode plein écran
void exit_fullscreen();
//! \brief Bouton permettant de réintialiser la grille à zéro //! \brief Bouton permettant de réintialiser la grille à zéro
void on_pushButton_clicked(); void on_pushButton_clicked();
......
...@@ -293,10 +293,17 @@ GridView::GridView(QWidget *parent) ...@@ -293,10 +293,17 @@ GridView::GridView(QWidget *parent)
QGridLayout *layout = new QGridLayout; QGridLayout *layout = new QGridLayout;
layout->addWidget(m_view); layout->addWidget(m_view);
m_info_section = new QWidget(this);
QVBoxLayout* info_layout = new QVBoxLayout;
m_mouse_pos_label = new QLabel(""); m_mouse_pos_label = new QLabel("");
layout->addWidget(m_mouse_pos_label); info_layout->addWidget(m_mouse_pos_label);
layout->addWidget(new QLabel("Left click : edit; Right click : select", this)); info_layout->addWidget(new QLabel("Left click : edit; Right click : select; F11 for fullscreen mode", this));
layout->addWidget(new QLabel("Hold SHIFT to move across the grid; Scroll wheel or CTRL+/CTRL- to zoom", this)); info_layout->addWidget(new QLabel("Hold SHIFT to move across the grid; Scroll wheel or CTRL+/CTRL- to zoom", this));
info_layout->setMargin(0);
m_info_section->setLayout(info_layout);
layout->addWidget(m_info_section);
setLayout(layout); setLayout(layout);
m_drag_drop_handler = new DragDropHandlerItem(*this); m_drag_drop_handler = new DragDropHandlerItem(*this);
...@@ -597,6 +604,15 @@ const QImage &GridView::grid_image() const ...@@ -597,6 +604,15 @@ const QImage &GridView::grid_image() const
return m_grid_image; return m_grid_image;
} }
void GridView::enter_fullscreen()
{
m_info_section->hide();
layout()->removeWidget(this);
setParent(nullptr);
raise();
showFullScreen();
}
void GridView::handle_rubberband(QRect rubberBandRect, QPointF fromScenePoint, QPointF toScenePoint) void GridView::handle_rubberband(QRect rubberBandRect, QPointF fromScenePoint, QPointF toScenePoint)
{ {
QGraphicsRectItem* item; QGraphicsRectItem* item;
...@@ -672,7 +688,20 @@ void GridView::keyPressEvent(QKeyEvent *event) ...@@ -672,7 +688,20 @@ void GridView::keyPressEvent(QKeyEvent *event)
delete_selection(); delete_selection();
} }
return QFrame::keyPressEvent(event); // Exit fullscreen ?
if (parent() == nullptr)
{
if (event->key() == Qt::Key_F11 || event->key() == Qt::Key_Escape)
{
event->accept();
m_info_section->show();
emit exit_fullscreen();
}
}
else
{
return QFrame::keyPressEvent(event);
}
} }
void GridView::keyReleaseEvent(QKeyEvent *event) void GridView::keyReleaseEvent(QKeyEvent *event)
......
...@@ -83,6 +83,8 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -83,6 +83,8 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->action_save_image, &QAction::triggered, this, &MainWindow::save_as_image); connect(ui->action_save_image, &QAction::triggered, this, &MainWindow::save_as_image);
connect(ui->action_save_gif, &QAction::triggered, this, &MainWindow::save_as_gif); connect(ui->action_save_gif, &QAction::triggered, this, &MainWindow::save_as_gif);
connect(ui->border_combo, QOverload<int>::of(&QComboBox::activated), this, &MainWindow::load_boundary_policy); connect(ui->border_combo, QOverload<int>::of(&QComboBox::activated), this, &MainWindow::load_boundary_policy);
connect(ui->action_fullscreen, &QAction::triggered, this, &MainWindow::enter_fullscreen);
connect(ui->grid_view, &GridView::exit_fullscreen, this, &MainWindow::exit_fullscreen);
ui->struct_library->update_cell_pixel_size(ui->grid_view->cell_screen_size()); ui->struct_library->update_cell_pixel_size(ui->grid_view->cell_screen_size());
...@@ -961,6 +963,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) ...@@ -961,6 +963,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
m_arrow_key_state[2] = true; m_arrow_key_state[2] = true;
if (event->key() == Qt::Key_Z || event->key() == Qt::Key_Up) if (event->key() == Qt::Key_Z || event->key() == Qt::Key_Up)
m_arrow_key_state[3] = true; m_arrow_key_state[3] = true;
QMainWindow::keyPressEvent(event); QMainWindow::keyPressEvent(event);
} }
...@@ -1060,6 +1063,18 @@ void MainWindow::on_recordSpinBox_valueChanged(int newSize) { ...@@ -1060,6 +1063,18 @@ void MainWindow::on_recordSpinBox_valueChanged(int newSize) {
simulation.setHistorySize(newSize); simulation.setHistorySize(newSize);
} }
void MainWindow::enter_fullscreen()
{
ui->grid_view->enter_fullscreen();
}
void MainWindow::exit_fullscreen()
{
ui->grid_view->setParent(ui->grid);
ui->gridLayout_2->addWidget(ui->grid_view, 0, 0, 1, 1);
this->activateWindow();
}
void MainWindow::on_pushButton_clicked() void MainWindow::on_pushButton_clicked()
{ {
Grid oldGrid = ui->grid_view->get_grid(); Grid oldGrid = ui->grid_view->get_grid();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment