Skip to content

Commit

Permalink
Added insert caption action for sound effects
Browse files Browse the repository at this point in the history
  • Loading branch information
TrickyLeifa committed Aug 5, 2022
1 parent 64f8c53 commit 3c6bc01
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ class Courtroom : public QWidget
QColor m_sfx_color_missing;
QMenu *ui_sfx_menu = nullptr;
QAction *ui_sfx_menu_preview = nullptr;
QAction *ui_sfx_menu_insert_ooc = nullptr;
QAction *ui_sfx_menu_insert_file_name = nullptr;
QAction *ui_sfx_menu_insert_caption = nullptr;

QLineEdit *ui_ic_chat_showname = nullptr;
QWidget *ui_ic_chat_message = nullptr;
Expand Down Expand Up @@ -766,7 +767,8 @@ private slots:
void on_sfx_list_current_item_changed(QListWidgetItem *current_item, QListWidgetItem *previous_item);
void on_sfx_list_context_menu_requested(QPoint point);
void on_sfx_menu_preview_triggered();
void on_sfx_menu_insert_ooc_triggered();
void on_sfx_menu_insert_file_name_triggered();
void on_sfx_menu_insert_caption_triggered();

/*!
* =============================================================================
Expand Down
19 changes: 18 additions & 1 deletion src/courtroom_sfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <QLineEdit>
#include <QListWidget>
#include <QMenu>
#include <QRegularExpression>
#include <QRegularExpressionMatch>

#include <optional>

Expand Down Expand Up @@ -143,8 +145,23 @@ void Courtroom::on_sfx_menu_preview_triggered()
m_effects_player->play_effect(current_sfx_file());
}

void Courtroom::on_sfx_menu_insert_ooc_triggered()
void Courtroom::on_sfx_menu_insert_file_name_triggered()
{
ui_ooc_chat_message->insert(current_sfx_file());
ui_ooc_chat_message->setFocus();
}

void Courtroom::on_sfx_menu_insert_caption_triggered()
{
const std::optional<DRSfx> l_sfx = current_sfx();
if (l_sfx.has_value())
{
QString l_caption = l_sfx->name;
static const QRegularExpression l_regex("\"(.+)\"");
if (const auto l_match = l_regex.match(l_caption); l_match.hasMatch())
{
l_caption = l_match.captured(1);
}
ui_ic_chat_message_field->insert(l_caption);
}
}
6 changes: 4 additions & 2 deletions src/courtroom_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ void Courtroom::create_widgets()
ui_sfx_search->setFrame(false);
ui_sfx_menu = new QMenu(this);
ui_sfx_menu_preview = ui_sfx_menu->addAction(tr("Preview"));
ui_sfx_menu_insert_ooc = ui_sfx_menu->addAction(tr("Insert to OOC"));
ui_sfx_menu_insert_file_name = ui_sfx_menu->addAction(tr("Insert filename"));
ui_sfx_menu_insert_caption = ui_sfx_menu->addAction("Insert caption");

ui_ic_chat_message = new QWidget(this);

Expand Down Expand Up @@ -389,7 +390,8 @@ void Courtroom::connect_widgets()
connect(ui_sfx_list, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_sfx_list_context_menu_requested(QPoint)));

connect(ui_sfx_menu_preview, SIGNAL(triggered()), this, SLOT(on_sfx_menu_preview_triggered()));
connect(ui_sfx_menu_insert_ooc, SIGNAL(triggered()), this, SLOT(on_sfx_menu_insert_ooc_triggered()));
connect(ui_sfx_menu_insert_file_name, SIGNAL(triggered()), this, SLOT(on_sfx_menu_insert_file_name_triggered()));
connect(ui_sfx_menu_insert_caption, SIGNAL(triggered()), this, SLOT(on_sfx_menu_insert_caption_triggered()));

connect(ui_note_area->add_button, SIGNAL(clicked(bool)), this, SLOT(on_add_button_clicked()));
connect(ui_set_notes, SIGNAL(clicked(bool)), this, SLOT(on_set_notes_clicked()));
Expand Down

0 comments on commit 3c6bc01

Please sign in to comment.