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
bd9afa91
Commit
bd9afa91
authored
Jun 09, 2021
by
Yann Boucher
Browse files
Restored Bad Apple for Qt 5 users
parent
3a09da61
Pipeline
#79528
passed with stages
in 16 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/interface.hpp
View file @
bd9afa91
...
...
@@ -94,6 +94,8 @@ private slots:
//! \brief Bouton permettant de réintialiser la grille à zéro
void
on_pushButton_clicked
();
void
on_simSpeedSlider_sliderMoved
(
int
position
);
private:
//! \brief Initialiser la liste des transitions et voisinages disponibles
void
init_transition_neighborhood_list
();
...
...
src/interface.cpp
View file @
bd9afa91
...
...
@@ -13,6 +13,7 @@
#include "neighborhoodDialog.hpp"
#include "colorlabel.h"
#include <QtGlobal>
#include <QJsonArray>
#include <QDate>
#include <QTextStream>
...
...
@@ -20,6 +21,15 @@
#include <QTimer>
#include <QElapsedTimer>
#if QT_VERSION >= 0x050000 && QT_VERSION < 0x060000
#define BAD_APPLE_AUDIO
#endif
#ifdef BAD_APPLE_AUDIO
#include <QMediaPlayer>
#endif
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
)
,
ui
(
new
Ui
::
MainWindow
)
...
...
@@ -644,7 +654,11 @@ void MainWindow::play_bad_apple()
static
QJsonArray
bad_apple_frame_list
;
static
QTimer
bad_apple_timer
;
static
bool
bad_apple_connected
;
#ifdef BAD_APPLE_AUDIO
static
QMediaPlayer
bad_apple_player
;
#else
static
QElapsedTimer
bad_apple_elapsed
;
#endif
QFile
f
(
"extras/bad_apple.json"
);
if
(
!
f
.
open
(
QFile
::
ReadOnly
|
QFile
::
Text
))
...
...
@@ -665,8 +679,11 @@ void MainWindow::play_bad_apple()
{
bad_apple_timer
.
callOnTimeout
([
this
]
{
#ifdef BAD_APPLE_AUDIO
unsigned
frame_idx
=
bad_apple_player
.
position
()
/
(
1000.
f
/
30
);
#else
unsigned
frame_idx
=
bad_apple_elapsed
.
elapsed
()
/
(
1000.
f
/
30
);
#endif
if
((
int
)
frame_idx
>=
bad_apple_frame_list
.
size
())
{
bad_apple_timer
.
stop
();
...
...
@@ -693,19 +710,17 @@ void MainWindow::play_bad_apple()
ui
->
grid_view
->
copy_grid
(
grid
);
});
}
//bad_apple_player.setMedia(QUrl::fromLocalFile("bad-apple.mp3"));
//bad_apple_player.play();
;
#ifdef BAD_APPLE_WIN
PlaySound
(
TEXT
(
"extras/bad-apple.wav"
),
GetModuleHandle
(
NULL
),
SND_FILENAME
|
SND_ASYNC
);
Sleep
(
1300
);
// delay for the sound to load
#ifdef BAD_APPLE_AUDIO
bad_apple_player
.
setMedia
(
QUrl
::
fromLocalFile
(
"extras/bad-apple.wav"
));
bad_apple_player
.
play
();
#else
QMessageBox
::
information
(
this
,
""
,
"Music functionnality is only available on Windows"
);
QMessageBox
::
information
(
this
,
""
,
"Music functionnality is only available with Qt 5"
);
bad_apple_elapsed
.
start
();
#endif
bad_apple_elapsed
.
start
();
bad_apple_timer
.
start
(
24
);
statusBar
()
->
showMessage
(
"Original :
\"
Bad Apple!!
\"
feat. Nomico by Alstroemeria Records"
,
60000
);
}
...
...
@@ -860,6 +875,5 @@ void MainWindow::on_simSpeedSlider_sliderMoved(int position)
return
;
timer
->
setInterval
(
1000
/
frequence
);
timer
->
start
();
}
src/src.pro
View file @
bd9afa91
QT
+=
core
gui
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
equals
(
QT_MAJOR_VERSION
,
5
)
:
QT
+=
multimedia
CONFIG
+=
c
++
14
TEMPLATE
=
app
...
...
@@ -96,10 +97,6 @@ qnx: target.path = /tmp/$${TARGET}/bin
else
:
unix
:
!
android
:
target
.
path
=
/
opt
/
$$
{
TARGET
}
/
bin
!
isEmpty
(
target
.
path
)
:
INSTALLS
+=
target
win32
{
LIBS
+=
-
lwinmm
}
CONFIG
(
debug
,
debug
|
release
)
{
DEBUG_OR_RELEASE
=
debug
}
else
{
...
...
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