Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LO21_Pin_Noir_Boucher_Bouri_Detree
CellulutLO21
Commits
84a63fd7
Commit
84a63fd7
authored
Jun 12, 2021
by
Yann Boucher
Browse files
Ajout d'un mode plein écran
parent
a1042598
Pipeline
#79738
passed with stages
in 17 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
forms/interface.ui
View file @
84a63fd7
...
...
@@ -644,8 +644,15 @@ pattern recorded :</string>
<addaction
name=
"action_bad_apple"
/>
<addaction
name=
"action_snake"
/>
</widget>
<widget
class=
"QMenu"
name=
"menuView"
>
<property
name=
"title"
>
<string>
View
</string>
</property>
<addaction
name=
"action_fullscreen"
/>
</widget>
<addaction
name=
"menuFichier"
/>
<addaction
name=
"menuEditer"
/>
<addaction
name=
"menuView"
/>
<addaction
name=
"menuBonus"
/>
<addaction
name=
"menuA_propos"
/>
</widget>
...
...
@@ -698,6 +705,14 @@ pattern recorded :</string>
<string>
Save as an animated GIF...
</string>
</property>
</action>
<action
name=
"action_fullscreen"
>
<property
name=
"text"
>
<string>
Enter fullscreen
</string>
</property>
<property
name=
"shortcut"
>
<string>
F11
</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
...
...
include/gridview.hpp
View file @
84a63fd7
...
...
@@ -142,11 +142,17 @@ public:
//! \brief Retourne une QImage représentant la grille actuelle.
const
QImage
&
grid_image
()
const
;
//! \brief Place le GridView en plein écran
void
enter_fullscreen
();
signals:
//! \brief Signal émis quand le zoom change.
//! \param cell_size la nouvelle taille à l'écran en pixels d'une cellule
void
zoom_changed
(
unsigned
cell_size
);
//! \brief Signal émis lorsque l'utilisateur désire quitter le mode plein écran.
void
exit_fullscreen
();
private:
void
load_grid
(
const
Grid
&
grid
);
...
...
@@ -176,6 +182,7 @@ private:
History
m_undo_history
;
std
::
vector
<
uint32_t
>
m_image_data
;
QImage
m_grid_image
;
QWidget
*
m_info_section
;
QLabel
*
m_mouse_pos_label
;
Grid
m_grid
;
Coord
m_last_mouse_pos
;
...
...
include/interface.hpp
View file @
84a63fd7
...
...
@@ -95,7 +95,11 @@ private slots:
//! \brief Change la profondeur de l'historique de simulation
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
void
on_pushButton_clicked
();
...
...
src/gridview.cpp
View file @
84a63fd7
...
...
@@ -293,10 +293,17 @@ GridView::GridView(QWidget *parent)
QGridLayout
*
layout
=
new
QGridLayout
;
layout
->
addWidget
(
m_view
);
m_info_section
=
new
QWidget
(
this
);
QVBoxLayout
*
info_layout
=
new
QVBoxLayout
;
m_mouse_pos_label
=
new
QLabel
(
""
);
layout
->
addWidget
(
m_mouse_pos_label
);
layout
->
addWidget
(
new
QLabel
(
"Left click : edit; Right click : select"
,
this
));
layout
->
addWidget
(
new
QLabel
(
"Hold SHIFT to move across the grid; Scroll wheel or CTRL+/CTRL- to zoom"
,
this
));
info_layout
->
addWidget
(
m_mouse_pos_label
);
info_layout
->
addWidget
(
new
QLabel
(
"Left click : edit; Right click : select; F11 for fullscreen mode"
,
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
);
m_drag_drop_handler
=
new
DragDropHandlerItem
(
*
this
);
...
...
@@ -597,6 +604,15 @@ const QImage &GridView::grid_image() const
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
)
{
QGraphicsRectItem
*
item
;
...
...
@@ -672,7 +688,20 @@ void GridView::keyPressEvent(QKeyEvent *event)
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
)
...
...
src/interface.cpp
View file @
84a63fd7
...
...
@@ -83,6 +83,8 @@ MainWindow::MainWindow(QWidget *parent)
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
->
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
());
...
...
@@ -961,6 +963,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
m_arrow_key_state
[
2
]
=
true
;
if
(
event
->
key
()
==
Qt
::
Key_Z
||
event
->
key
()
==
Qt
::
Key_Up
)
m_arrow_key_state
[
3
]
=
true
;
QMainWindow
::
keyPressEvent
(
event
);
}
...
...
@@ -1060,6 +1063,18 @@ void MainWindow::on_recordSpinBox_valueChanged(int 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
()
{
Grid
oldGrid
=
ui
->
grid_view
->
get_grid
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment