Added Play SFX context menu action (#791)

* Added Play SFX context menu action

Resolve #746

* The SFX context menu now allows the user to preview the sound selected by playing it.

* Changed declarations for methods.
This commit is contained in:
Leifa♥ 2022-07-07 12:55:44 +02:00 committed by GitHub
parent 7b4b297a22
commit 7805e80e83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -256,7 +256,7 @@ public:
// Handle the stuff that comes when the character appears on screen and starts animating (preanims etc.)
void handle_ic_message();
// Display the character.
void display_character();
@ -442,7 +442,7 @@ private:
// delay before chat messages starts ticking
QTimer *text_delay_timer;
// delay before the next queue entry is going to be processed
QTimer *text_queue_timer;
@ -884,6 +884,7 @@ private slots:
void on_sfx_dropdown_custom(QString p_sfx);
void set_sfx_dropdown();
void on_sfx_context_menu_requested(const QPoint &pos);
void on_sfx_play_clicked();
void on_sfx_edit_requested();
void on_sfx_remove_clicked();

View File

@ -4553,18 +4553,24 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos)
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->addSeparator();
menu->addAction(QString("Play"), this, &Courtroom::on_sfx_play_clicked);
if (file_exists(ao_app->get_real_path(
ao_app->get_character_path(current_char, "soundlist.ini"))))
ao_app->get_character_path(current_char, "soundlist.ini"))))
menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this,
SLOT(on_sfx_edit_requested()));
&Courtroom::on_sfx_edit_requested);
else
menu->addAction(QString("Edit global soundlist.ini"), this,
SLOT(on_sfx_edit_requested()));
&Courtroom::on_sfx_edit_requested);
if (!custom_sfx.isEmpty())
menu->addAction(QString("Clear Edit Text"), this, SLOT(on_sfx_remove_clicked()));
menu->addAction(QString("Clear Edit Text"), this, &Courtroom::on_sfx_remove_clicked);
menu->popup(ui_sfx_dropdown->mapToGlobal(pos));
}
void Courtroom::on_sfx_play_clicked()
{
sfx_player->play(get_char_sfx(), get_current_char());
}
void Courtroom::on_sfx_edit_requested()
{
QString p_path = ao_app->get_real_path(ao_app->get_character_path(current_char, "soundlist.ini"));