diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/aoapplication.cpp | 4 | ||||
| -rw-r--r-- | src/aocaseannouncerdialog.cpp | 8 | ||||
| -rw-r--r-- | src/aoemotebutton.cpp | 4 | ||||
| -rw-r--r-- | src/aoevidencebutton.cpp | 10 | ||||
| -rw-r--r-- | src/aoevidencedisplay.cpp | 2 | ||||
| -rw-r--r-- | src/aolayer.cpp | 135 | ||||
| -rw-r--r-- | src/aolineedit.cpp | 22 | ||||
| -rw-r--r-- | src/aooptionsdialog.cpp | 52 | ||||
| -rw-r--r-- | src/aotextedit.cpp | 17 | ||||
| -rw-r--r-- | src/charselect.cpp | 38 | ||||
| -rw-r--r-- | src/chatlogpiece.cpp | 4 | ||||
| -rw-r--r-- | src/courtroom.cpp | 545 | ||||
| -rw-r--r-- | src/demoserver.cpp | 4 | ||||
| -rw-r--r-- | src/emotes.cpp | 18 | ||||
| -rw-r--r-- | src/evidence.cpp | 157 | ||||
| -rw-r--r-- | src/file_functions.cpp | 3 | ||||
| -rw-r--r-- | src/lobby.cpp | 54 | ||||
| -rw-r--r-- | src/networkmanager.cpp | 65 | ||||
| -rw-r--r-- | src/path_functions.cpp | 6 | ||||
| -rw-r--r-- | src/scrolltext.cpp | 2 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 8 |
22 files changed, 534 insertions, 626 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b04db8b..32e924a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,13 +10,11 @@ aoevidencebutton.cpp aoevidencedisplay.cpp aoimage.cpp aolayer.cpp -aolineedit.cpp aomusicplayer.cpp aooptionsdialog.cpp aopacket.cpp aosfxplayer.cpp aotextarea.cpp -aotextedit.cpp charselect.cpp chatlogpiece.cpp courtroom.cpp diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index 74dc6ed..4a5ed52 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -16,8 +16,8 @@ AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv) net_manager = new NetworkManager(this); discord = new AttorneyOnline::Discord(); - QObject::connect(net_manager, SIGNAL(ms_connect_finished(bool, bool)), - SLOT(ms_connect_finished(bool, bool))); + connect(net_manager, &NetworkManager::ms_connect_finished, + this, &AOApplication::ms_connect_finished); asset_lookup_cache.reserve(2048); } diff --git a/src/aocaseannouncerdialog.cpp b/src/aocaseannouncerdialog.cpp index aea6405..0c9ee0f 100644 --- a/src/aocaseannouncerdialog.cpp +++ b/src/aocaseannouncerdialog.cpp @@ -23,10 +23,10 @@ AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, ui_announcer_buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - QObject::connect(ui_announcer_buttons, SIGNAL(accepted()), this, - SLOT(ok_pressed())); - QObject::connect(ui_announcer_buttons, SIGNAL(rejected()), this, - SLOT(cancel_pressed())); + connect(ui_announcer_buttons, &QDialogButtonBox::accepted, this, + &AOCaseAnnouncerDialog::ok_pressed); + connect(ui_announcer_buttons, &QDialogButtonBox::rejected, this, + &AOCaseAnnouncerDialog::cancel_pressed); setUpdatesEnabled(false); diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp index 3260a94..638d49d 100644 --- a/src/aoemotebutton.cpp +++ b/src/aoemotebutton.cpp @@ -11,7 +11,7 @@ AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, this->move(p_x, p_y); this->resize(p_w, p_h); - connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); + connect(this, &AOEmoteButton::clicked, this, &AOEmoteButton::on_clicked); } void AOEmoteButton::set_image(QString p_image, QString p_emote_comment) @@ -67,4 +67,4 @@ void AOEmoteButton::set_char_image(QString p_char, int p_emote, QString suffix) this->set_image(image_path, ao_app->get_emote_comment(p_char, p_emote)); } -void AOEmoteButton::on_clicked() { emote_clicked(m_id); } +void AOEmoteButton::on_clicked() { emit emote_clicked(m_id); } diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index ae67b82..800c8b4 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -27,7 +27,7 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, this->resize(p_w, p_h); // this->setAcceptDrops(true); - connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); + connect(this, &AOEvidenceButton::clicked, this, &AOEvidenceButton::on_clicked); } void AOEvidenceButton::set_image(QString p_image) @@ -80,12 +80,12 @@ void AOEvidenceButton::set_selected(bool p_selected) ui_selected->hide(); } -void AOEvidenceButton::on_clicked() { evidence_clicked(m_id); } +void AOEvidenceButton::on_clicked() { emit evidence_clicked(m_id); } void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) { QPushButton::mouseDoubleClickEvent(e); - evidence_double_clicked(m_id); + emit evidence_double_clicked(m_id); } /* @@ -108,7 +108,7 @@ void AOEvidenceButton::enterEvent(QEvent *e) { ui_selector->show(); - on_hover(m_id, true); + emit on_hover(m_id, true); setFlat(false); QPushButton::enterEvent(e); @@ -118,6 +118,6 @@ void AOEvidenceButton::leaveEvent(QEvent *e) { ui_selector->hide(); - on_hover(m_id, false); + emit on_hover(m_id, false); QPushButton::leaveEvent(e); } diff --git a/src/aoevidencedisplay.cpp b/src/aoevidencedisplay.cpp index c635a02..0d3eae7 100644 --- a/src/aoevidencedisplay.cpp +++ b/src/aoevidencedisplay.cpp @@ -13,7 +13,7 @@ AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) evidence_movie = new InterfaceLayer(this, ao_app); - connect(evidence_movie, SIGNAL(done()), this, SLOT(show_done())); + connect(evidence_movie, &InterfaceLayer::done, this, &AOEvidenceDisplay::show_done); } void AOEvidenceDisplay::show_evidence(QString p_evidence_image, diff --git a/src/aolayer.cpp b/src/aolayer.cpp index 3791d66..dd1fe76 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -12,16 +12,16 @@ AOLayer::AOLayer(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) shfx_timer = new QTimer(this); shfx_timer->setTimerType(Qt::PreciseTimer); shfx_timer->setSingleShot(true); - connect(shfx_timer, SIGNAL(timeout()), this, SLOT(shfx_timer_done())); + connect(shfx_timer, &QTimer::timeout, this, &AOLayer::shfx_timer_done); ticker = new QTimer(this); ticker->setTimerType(Qt::PreciseTimer); ticker->setSingleShot(false); - connect(ticker, SIGNAL(timeout()), this, SLOT(movie_ticker())); + connect(ticker, &QTimer::timeout, this, &AOLayer::movie_ticker); preanim_timer = new QTimer(this); preanim_timer->setSingleShot(true); - connect(preanim_timer, SIGNAL(timeout()), this, SLOT(preanim_done())); + connect(preanim_timer, &QTimer::timeout, this, &AOLayer::preanim_done); } BackgroundLayer::BackgroundLayer(QWidget *p_parent, AOApplication *p_ao_app) @@ -52,7 +52,7 @@ StickerLayer::StickerLayer(QWidget *p_parent, AOApplication *p_ao_app) QString AOLayer::find_image(QStringList p_list) { QString image_path; - for (QString path : p_list) { + for (const QString &path : p_list) { #ifdef DEBUG_MOVIE qDebug() << "checking path " << path; #endif @@ -145,7 +145,8 @@ void BackgroundLayer::load_image(QString p_filename) #ifdef DEBUG_MOVIE qDebug() << "[BackgroundLayer] BG loaded: " << p_filename; #endif - start_playback(ao_app->get_image_suffix(ao_app->get_background_path(p_filename))); + QString final_path = ao_app->get_image_suffix(ao_app->get_background_path(p_filename)); + start_playback(final_path); play(); } @@ -179,15 +180,16 @@ void CharLayer::load_image(QString p_filename, QString p_charname, last_emote = current_emote; last_prefix = prefix; is_preanim = p_is_preanim; - if ((p_filename.left(3) == "(a)") || (p_filename.left(3) == "(b)")) { - prefix = p_filename.left(3); + if ((p_filename.left(3) == "(a)") || (p_filename.left(3) == "(b)")) { // if we are playing an idle or talking animation + prefix = p_filename.left(3); // separate the prefix from the emote name current_emote = p_filename.mid(3, -1); } - else if ((duration > 0) || (p_filename.left(3) == "(c)")) { - if (p_filename.left(3) == "(c)") { - prefix = "(c)"; + else if ((duration > 0) || (p_filename.left(3) == "(c)")) { // else if we are playing a preanim or postanim + if (p_filename.left(3) == "(c)") { // if we are playing a postanim + prefix = "(c)"; // separate the prefix from the emote name current_emote = p_filename.mid(3, -1); } + // pre/postanim specific flags is_preanim = true; play_once = true; preanim_timer->start(duration); @@ -197,7 +199,7 @@ void CharLayer::load_image(QString p_filename, QString p_charname, << current_emote << " from character: " << p_charname << " continuous: " << continuous; #endif - QVector<VPath> pathlist { + QVector<VPath> pathlist { // cursed character path resolution vector ao_app->get_character_path( p_charname, prefix + current_emote), // Default path ao_app->get_character_path( @@ -232,7 +234,7 @@ void EffectLayer::load_image(QString p_filename, bool p_looping) play_once = true; continuous = false; force_continuous = true; - start_playback(p_filename); // handled in its own file before we see it + start_playback(p_filename); // path resolution is handled by the caller for EffectLayer objects play(); } @@ -269,6 +271,13 @@ void CharLayer::start_playback(QString p_image) void AOLayer::start_playback(QString p_image) { + if (p_image == "") {// image wasn't found by the path resolution function + this->kill(); + return; + } + QMutexLocker locker(&mutex); + if (frame_loader.isRunning()) + exit_loop = true; // tell the loader to stop, we have a new image to load this->show(); if (!ao_app->is_continuous_enabled()) { @@ -276,7 +285,7 @@ void AOLayer::start_playback(QString p_image) force_continuous = true; } - if ((last_path == p_image) && (!force_continuous)) + if (((last_path == p_image) && (!force_continuous)) || p_image == "") return; #ifdef DEBUG_MOVIE @@ -296,55 +305,36 @@ void AOLayer::start_playback(QString p_image) stretch = stretch_override.startsWith("true"); #ifdef DEBUG_MOVIE - qDebug() << "stretch:" << stretch << "filename:" << p_image; + qDebug() << "[AOLayer::start_playback] Stretch:" << stretch << "Filename:" << p_image; #endif m_reader.setFileName(p_image); if (m_reader.loopCount() == 0) play_once = true; - if (!continuous) - frame = 0; last_max_frames = max_frames; max_frames = m_reader.imageCount(); - if (((continuous) && (max_frames != last_max_frames)) || max_frames == 0) { + if (!continuous + || ((continuous) && (max_frames != last_max_frames)) + || max_frames == 0 + || frame >= max_frames) { frame = 0; continuous = false; } - // CANTFIX: this causes a hitch - // The correct way of doing this would be to use QImageReader::jumpToImage() - // and populate missing data in the movie ticker when it's needed. This is - // unfortunately completely impossible, because QImageReader::jumpToImage() is - // not implemented in any image format AO2 is equipped to use. Instead, the - // default behavior is used - that is, absolutely nothing. - // This is why continuous playback can be toggled off. - if (continuous) { - for (int i = frame; i--;) { - if (i <= -1) - break; - QPixmap l_pixmap = this->get_pixmap(m_reader.read()); - int l_delay = m_reader.nextImageDelay(); - movie_frames.append(l_pixmap); - movie_delays.append(l_delay); - } - } + frame_loader = QtConcurrent::run(this, &AOLayer::populate_vectors); last_path = p_image; - QPixmap f_pixmap = this->get_pixmap(m_reader.read()); - int f_delay = m_reader.nextImageDelay(); + while (movie_frames.size() <= frame) // if we haven't loaded the frame we need yet + frameAdded.wait(&mutex); // wait for the frame loader to add another frame, then check again + this->set_frame(movie_frames[frame]); - this->set_frame(f_pixmap); - if (max_frames > 1) { - movie_frames.append(f_pixmap); - movie_delays.append(f_delay); - } - else if (max_frames <= 1) { + if (max_frames <= 1) { duration = static_duration; #ifdef DEBUG_MOVIE - qDebug() << "max_frames is <= 1, using static duration"; + qDebug() << "[AOLayer::start_playback] max_frames is <= 1, using static duration"; #endif } if (duration > 0 && cull_image == true) shfx_timer->start(duration); #ifdef DEBUG_MOVIE - qDebug() << max_frames << "Setting image to " << image_path + qDebug() << "[AOLayer::start_playback] Max frames:" << max_frames << "Setting image to " << p_image << "Time taken to process image:" << actual_time.elapsed(); actual_time.restart(); @@ -375,8 +365,12 @@ void AOLayer::play() else this->freeze(); } - else + else { + while (movie_delays.size() <= frame) { + frameAdded.wait(&mutex); + } ticker->start(this->get_frame_delay(movie_delays[frame])); + } } void AOLayer::set_play_once(bool p_play_once) { play_once = p_play_once; } @@ -454,7 +448,7 @@ void CharLayer::load_network_effects() // data, let's yank it in. effect += f_data; #ifdef DEBUG_MOVIE - qDebug() << effect << f_data << "frame" << f_frame << "for" + qDebug() << "[CharLayer::load_network_effects]" << effect << f_data << "frame" << f_frame << "for" << m_emote; #endif movie_effects[f_frame].append(effect); @@ -473,24 +467,24 @@ void CharLayer::play_frame_effect(int p_frame) if (p_frame < max_frames) { foreach (QString effect, movie_effects[p_frame]) { if (effect == "shake") { - shake(); + emit shake(); #ifdef DEBUG_MOVIE - qDebug() << "Attempting to play shake on frame" << frame; + qDebug() << "[CharLayer::play_frame_effect] Attempting to play shake on frame" << frame; #endif } if (effect == "flash") { - flash(); + emit flash(); #ifdef DEBUG_MOVIE - qDebug() << "Attempting to play flash on frame" << frame; + qDebug() << "[CharLayer::play_frame_effect] Attempting to play flash on frame" << frame; #endif } if (effect.startsWith("sfx^")) { QString sfx = effect.section("^", 1); - play_sfx(sfx); + emit play_sfx(sfx); #ifdef DEBUG_MOVIE - qDebug() << "Attempting to play sfx" << sfx << "on frame" << frame; + qDebug() << "[CharLayer::play_frame_effect] Attempting to play sfx" << sfx << "on frame" << frame; #endif } } @@ -544,21 +538,38 @@ void AOLayer::movie_ticker() else frame = 0; } - // qint64 difference = elapsed - movie_delays[frame]; - if (frame >= movie_frames.size()) { - movie_frames.append(this->get_pixmap(m_reader.read())); - movie_delays.append(m_reader.nextImageDelay()); + mutex.lock(); + while (frame >= movie_frames.size() && frame < max_frames) { // oops! our frame isn't ready yet + frameAdded.wait(&mutex); // wait for a new frame to be added, then check again } - + mutex.unlock(); #ifdef DEBUG_MOVIE - qDebug() << frame << movie_delays[frame] - << "actual time taken from last frame:" << actual_time.restart(); + qDebug() << "[AOLayer::movie_ticker] Frame:" << frame << "Delay:" << movie_delays[frame] + << "Actual time taken from last frame:" << actual_time.restart(); #endif - this->set_frame(movie_frames[frame]); ticker->setInterval(this->get_frame_delay(movie_delays[frame])); } +void AOLayer::populate_vectors() { + while (movie_frames.size() < max_frames && !exit_loop) { + load_next_frame(); +#ifdef DEBUG_MOVIE + qDebug() << "[AOLayer::populate_vectors] Loaded frame" << movie_frames.size(); +#endif + } + exit_loop = false; +} + +void AOLayer::load_next_frame() { + //QMutexLocker locker(&mutex); + mutex.lock(); + movie_frames.append(this->get_pixmap(m_reader.read())); + movie_delays.append(m_reader.nextImageDelay()); + mutex.unlock(); + frameAdded.wakeAll(); +} + void CharLayer::preanim_done() { if (is_preanim) @@ -571,7 +582,7 @@ void AOLayer::preanim_done() { ticker->stop(); preanim_timer->stop(); - done(); + emit done(); } void AOLayer::shfx_timer_done() @@ -581,5 +592,5 @@ void AOLayer::shfx_timer_done() qDebug() << "shfx timer signaled done"; #endif // signal connected to courtroom object, let it figure out what to do - done(); + emit done(); } diff --git a/src/aolineedit.cpp b/src/aolineedit.cpp deleted file mode 100644 index d80fa01..0000000 --- a/src/aolineedit.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "aolineedit.h" - -AOLineEdit::AOLineEdit(QWidget *parent) : QLineEdit(parent) {} - -void AOLineEdit::mouseDoubleClickEvent(QMouseEvent *e) -{ - QLineEdit::mouseDoubleClickEvent(e); - - double_clicked(); -} -void AOLineEdit::focusOutEvent(QFocusEvent *ev) -{ - int start = selectionStart(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - int len = selectionLength(); -#else - int len = selectedText().length(); -#endif - QLineEdit::focusOutEvent(ev); - if (p_selection && start != -1 && len != -1) - this->setSelection(start, len); -} diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 5f3dbf0..1b9342c 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -29,12 +29,12 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) QDialogButtonBox::Save | QDialogButtonBox::RestoreDefaults); - QObject::connect(ui_settings_buttons, SIGNAL(accepted()), this, - SLOT(save_pressed())); - QObject::connect(ui_settings_buttons, SIGNAL(rejected()), this, - SLOT(discard_pressed())); - QObject::connect(ui_settings_buttons, SIGNAL(clicked(QAbstractButton*)), this, - SLOT(button_clicked(QAbstractButton*))); + connect(ui_settings_buttons, &QDialogButtonBox::accepted, this, + &AOOptionsDialog::save_pressed); + connect(ui_settings_buttons, &QDialogButtonBox::rejected, this, + &AOOptionsDialog::discard_pressed); + connect(ui_settings_buttons, &QDialogButtonBox::clicked, this, + &AOOptionsDialog::button_clicked); // We'll stop updates so that the window won't flicker while it's being made. setUpdatesEnabled(false); @@ -90,8 +90,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) } } - QObject::connect(ui_theme_combobox, SIGNAL(currentIndexChanged(int)), this, - SLOT(theme_changed(int))); + connect(ui_theme_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &AOOptionsDialog::theme_changed); ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_combobox); row += 1; @@ -124,8 +124,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_theme_reload_button->setToolTip( tr("Refresh the theme and update all of the ui elements to match.")); ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_reload_button); - QObject::connect(ui_theme_reload_button, SIGNAL(clicked()), this, - SLOT(on_reload_theme_clicked())); + connect(ui_theme_reload_button, &QPushButton::clicked, this, + &AOOptionsDialog::on_reload_theme_clicked); row += 1; ui_animated_theme_lbl = new QLabel(ui_form_layout_widget); @@ -216,9 +216,34 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_log_timestamp_cb = new QCheckBox(ui_form_layout_widget); + connect(ui_log_timestamp_cb, &QCheckBox::stateChanged, this, &AOOptionsDialog::timestamp_cb_changed); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_timestamp_cb); row += 1; + ui_log_timestamp_format_lbl = new QLabel(ui_form_layout_widget); + ui_log_timestamp_format_lbl->setText(tr("Log timestamp format:\n") + QDateTime::currentDateTime().toString(ao_app->get_log_timestamp_format())); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_timestamp_format_lbl); + + ui_log_timestamp_format_combobox = new QComboBox(ui_form_layout_widget); + ui_log_timestamp_format_combobox->setEditable(true); + + QString l_current_format = ao_app->get_log_timestamp_format(); + + ui_log_timestamp_format_combobox->setCurrentText(l_current_format); + ui_log_timestamp_format_combobox->addItem("h:mm:ss AP"); // 2:13:09 PM + ui_log_timestamp_format_combobox->addItem("hh:mm:ss"); // 14:13:09 + ui_log_timestamp_format_combobox->addItem("h:mm AP"); // 2:13 PM + ui_log_timestamp_format_combobox->addItem("hh:mm"); // 14:13 + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_timestamp_format_combobox); + + connect(ui_log_timestamp_format_combobox, &QComboBox::currentTextChanged, this, &AOOptionsDialog::on_timestamp_format_edited); + + if(!ao_app->get_log_timestamp()) + ui_log_timestamp_format_combobox->setDisabled(true); + + row += 1; ui_log_ic_actions_lbl = new QLabel(ui_form_layout_widget); ui_log_ic_actions_lbl->setText(tr("Log IC actions:")); ui_log_ic_actions_lbl->setToolTip( @@ -230,7 +255,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_ic_actions_cb); - row += 1; ui_stay_time_lbl = new QLabel(ui_form_layout_widget); ui_stay_time_lbl->setText(tr("Text Stay Time:")); @@ -1072,6 +1096,7 @@ void AOOptionsDialog::update_values() { ui_downwards_cb->setChecked(ao_app->get_log_goes_downwards()); ui_log_newline_cb->setChecked(ao_app->get_log_newline()); ui_log_timestamp_cb->setChecked(ao_app->get_log_timestamp()); + ui_log_timestamp_format_combobox->setCurrentText(ao_app->get_log_timestamp_format()); ui_log_ic_actions_cb->setChecked(ao_app->get_log_ic_actions()); ui_desync_logs_cb->setChecked(ao_app->is_desyncrhonized_logs_enabled()); ui_instant_objection_cb->setChecked(ao_app->is_instant_objection_enabled()); @@ -1133,6 +1158,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("log_newline", ui_log_newline_cb->isChecked()); configini->setValue("log_margin", ui_log_margin_spinbox->value()); configini->setValue("log_timestamp", ui_log_timestamp_cb->isChecked()); + configini->setValue("log_timestamp_format", ui_log_timestamp_format_combobox->currentText()); configini->setValue("log_ic_actions", ui_log_ic_actions_cb->isChecked()); configini->setValue("desync_logs", ui_desync_logs_cb->isChecked()); configini->setValue("stay_time", ui_stay_time_spinbox->value()); @@ -1260,6 +1286,10 @@ void AOOptionsDialog::theme_changed(int i) { } +void AOOptionsDialog::on_timestamp_format_edited() { ui_log_timestamp_format_lbl->setText(tr("Log timestamp format:\n") + QDateTime::currentDateTime().toString(ui_log_timestamp_format_combobox->currentText())); } + +void AOOptionsDialog::timestamp_cb_changed(int state) { ui_log_timestamp_format_combobox->setDisabled(state == 0); } + #if (defined(_WIN32) || defined(_WIN64)) bool AOOptionsDialog::needs_default_audiodev() { return true; } #elif (defined(LINUX) || defined(__linux__)) diff --git a/src/aotextedit.cpp b/src/aotextedit.cpp deleted file mode 100644 index 22d9a62..0000000 --- a/src/aotextedit.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "aotextedit.h" - -AOTextEdit::AOTextEdit(QWidget *parent) : QPlainTextEdit(parent) -{ - this->setReadOnly(true); - - // connect(this, SIGNAL(returnPressed()), this, SLOT(on_enter_pressed())); -} - -void AOTextEdit::mouseDoubleClickEvent(QMouseEvent *e) -{ - QPlainTextEdit::mouseDoubleClickEvent(e); - - this->setReadOnly(false); -} - -void AOTextEdit::on_enter_pressed() { this->setReadOnly(true); } diff --git a/src/charselect.cpp b/src/charselect.cpp index 4d5edbc..8928f44 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -52,25 +52,25 @@ void Courtroom::construct_char_select() ui_char_taken->setText(tr("Taken")); ui_char_taken->setObjectName("ui_char_taken"); - connect(ui_char_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), - this, SLOT(on_char_list_double_clicked(QTreeWidgetItem *, int))); + connect(ui_char_list, &QTreeWidget::itemDoubleClicked, + this, &Courtroom::on_char_list_double_clicked); - connect(ui_back_to_lobby, SIGNAL(clicked()), this, - SLOT(on_back_to_lobby_clicked())); + connect(ui_back_to_lobby, &AOButton::clicked, this, + &Courtroom::on_back_to_lobby_clicked); - connect(ui_char_select_left, SIGNAL(clicked()), this, - SLOT(on_char_select_left_clicked())); - connect(ui_char_select_right, SIGNAL(clicked()), this, - SLOT(on_char_select_right_clicked())); + connect(ui_char_select_left, &AOButton::clicked, this, + &Courtroom::on_char_select_left_clicked); + connect(ui_char_select_right, &AOButton::clicked, this, + &Courtroom::on_char_select_right_clicked); - connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); + connect(ui_spectator, &AOButton::clicked, this, &Courtroom::on_spectator_clicked); - connect(ui_char_search, SIGNAL(textEdited(const QString &)), this, - SLOT(on_char_search_changed())); - connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, - SLOT(on_char_passworded_clicked())); - connect(ui_char_taken, SIGNAL(stateChanged(int)), this, - SLOT(on_char_taken_clicked())); + connect(ui_char_search, &QLineEdit::textEdited,this, + &Courtroom::on_char_search_changed); + connect(ui_char_passworded, &QCheckBox::stateChanged, this, + &Courtroom::on_char_passworded_clicked); + connect(ui_char_taken, &QCheckBox::stateChanged, this, + &Courtroom::on_char_taken_clicked); } @@ -116,7 +116,7 @@ void Courtroom::set_char_select_page() ui_char_select_left->hide(); ui_char_select_right->hide(); - for (AOCharButton *i_button : ui_char_button_list) { + for (AOCharButton *i_button : qAsConst(ui_char_button_list)) { i_button->reset(); i_button->hide(); i_button->move(0, 0); @@ -298,9 +298,9 @@ void Courtroom::character_loading_finished() 100); ao_app->w_lobby->set_loading_value(loading_value); ao_app->w_lobby->set_loading_text( - tr("Generating chars:\n%1/%2") - .arg(QString::number(ao_app->generated_chars)) - .arg(QString::number(ao_app->char_list_size))); + tr("Generating chars:\n%1/%2").arg( + QString::number(ao_app->generated_chars), + QString::number(ao_app->char_list_size))); } } ui_char_list->expandAll(); diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp index 05a924c..f4cb225 100644 --- a/src/chatlogpiece.cpp +++ b/src/chatlogpiece.cpp @@ -7,7 +7,7 @@ chatlogpiece::chatlogpiece() message = tr("UNKNOWN"); color = 0; action = ""; - datetime = QDateTime::currentDateTime().toUTC(); + datetime = QDateTime::currentDateTimeUtc(); } chatlogpiece::chatlogpiece(QString p_name, QString p_showname, @@ -18,7 +18,7 @@ chatlogpiece::chatlogpiece(QString p_name, QString p_showname, message = p_message; action = p_action; color = p_color; - datetime = QDateTime::currentDateTime().toUTC(); + datetime = QDateTime::currentDateTimeUtc(); } chatlogpiece::chatlogpiece(QString p_name, QString p_showname, diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 1fb8ce0..8c59f1d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -109,6 +109,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() log_newline = ao_app->get_log_newline(); log_margin = ao_app->get_log_margin(); log_timestamp = ao_app->get_log_timestamp(); + log_timestamp_format = ao_app->get_log_timestamp_format(); ui_ms_chatlog = new AOTextArea(this); ui_ms_chatlog->setReadOnly(true); @@ -150,7 +151,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_music_name->setText(tr("None")); ui_music_name->setAttribute(Qt::WA_TransparentForMouseEvents); ui_music_name->setObjectName("ui_music_name"); - + for (int i = 0; i < max_clocks; i++) { ui_clock[i] = new AOClockLabel(this); ui_clock[i]->setAttribute(Qt::WA_TransparentForMouseEvents); @@ -164,10 +165,12 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_ic_chat_name->setText(p_ao_app->get_default_showname()); ui_ic_chat_name->setObjectName("ui_ic_chat_name"); - ui_ic_chat_message = new AOLineEdit(this); + ui_ic_chat_message = new QLineEdit(this); ui_ic_chat_message->setFrame(false); ui_ic_chat_message->setPlaceholderText(tr("Message")); - ui_ic_chat_message->preserve_selection(true); + ui_ic_chat_message_filter = new AOLineEditFilter(); + ui_ic_chat_message_filter->preserve_selection = true; + ui_ic_chat_message->installEventFilter(ui_ic_chat_message_filter); ui_ic_chat_message->setObjectName("ui_ic_chat_message"); ui_vp_sticker = new StickerLayer(ui_viewport, ao_app); @@ -396,154 +399,154 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() construct_char_select(); - connect(keepalive_timer, SIGNAL(timeout()), this, SLOT(ping_server())); - - connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done())); - connect(ui_vp_effect, SIGNAL(done()), this, SLOT(effect_done())); - connect(ui_vp_wtce, SIGNAL(done()), this, SLOT(effect_done())); - connect(ui_vp_player_char, SIGNAL(done()), this, SLOT(preanim_done())); - connect(ui_vp_player_char, SIGNAL(shake()), this, SLOT(do_screenshake())); - connect(ui_vp_player_char, SIGNAL(flash()), this, SLOT(do_flash())); - connect(ui_vp_player_char, SIGNAL(play_sfx(QString)), this, - SLOT(play_char_sfx(QString))); - - connect(text_delay_timer, SIGNAL(timeout()), this, - SLOT(start_chat_ticking())); - - connect(text_queue_timer, SIGNAL(timeout()), this, - SLOT(chatmessage_dequeue())); - - connect(sfx_delay_timer, SIGNAL(timeout()), this, SLOT(play_sfx())); - - connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick())); - - connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, - SLOT(on_pos_dropdown_changed(int))); - connect(ui_pos_dropdown, SIGNAL(editTextChanged(QString)), this, - SLOT(on_pos_dropdown_changed(QString))); - connect(ui_pos_remove, SIGNAL(clicked()), this, SLOT(on_pos_remove_clicked())); - - connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this, - SLOT(on_iniswap_dropdown_changed(int))); - connect(ui_iniswap_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(on_iniswap_context_menu_requested(QPoint))); - connect(ui_iniswap_remove, SIGNAL(clicked()), this, - SLOT(on_iniswap_remove_clicked())); - - connect(ui_sfx_dropdown, SIGNAL(currentIndexChanged(int)), this, - SLOT(on_sfx_dropdown_changed(int))); - connect(ui_sfx_dropdown, SIGNAL(editTextChanged(QString)), this, - SLOT(on_sfx_dropdown_custom(QString))); - connect(ui_sfx_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(on_sfx_context_menu_requested(QPoint))); - connect(ui_sfx_remove, SIGNAL(clicked()), this, - SLOT(on_sfx_remove_clicked())); - - connect(ui_effects_dropdown, SIGNAL(currentIndexChanged(int)), this, - SLOT(on_effects_dropdown_changed(int))); - connect(ui_effects_dropdown, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(on_effects_context_menu_requested(QPoint))); - - connect(ui_music_search, SIGNAL(returnPressed()), this, - SLOT(on_music_search_return_pressed())); - connect(ui_mute_list, SIGNAL(clicked(QModelIndex)), this, - SLOT(on_mute_list_clicked(QModelIndex))); - - connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, - SLOT(on_chat_return_pressed())); - - connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, - SLOT(on_ooc_return_pressed())); - - connect(ui_music_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), - this, SLOT(on_music_list_double_clicked(QTreeWidgetItem *, int))); - connect(ui_music_list, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(on_music_list_context_menu_requested(QPoint))); - - connect(ui_area_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, - SLOT(on_area_list_double_clicked(QTreeWidgetItem *, int))); - - connect(ui_hold_it, SIGNAL(clicked()), this, SLOT(on_hold_it_clicked())); - connect(ui_objection, SIGNAL(clicked()), this, SLOT(on_objection_clicked())); - connect(ui_take_that, SIGNAL(clicked()), this, SLOT(on_take_that_clicked())); - connect(ui_custom_objection, SIGNAL(clicked()), this, - SLOT(on_custom_objection_clicked())); + connect(keepalive_timer, &QTimer::timeout, this, &Courtroom::ping_server); + + connect(ui_vp_objection, &SplashLayer::done, this, &Courtroom::objection_done); + connect(ui_vp_effect, &EffectLayer::done, this, &Courtroom::effect_done); + connect(ui_vp_wtce, &SplashLayer::done, this, &Courtroom::effect_done); + connect(ui_vp_player_char, &CharLayer::done, this, &Courtroom::preanim_done); + connect(ui_vp_player_char, &CharLayer::shake, this, &Courtroom::do_screenshake); + connect(ui_vp_player_char, &CharLayer::flash, this, &Courtroom::do_flash); + connect(ui_vp_player_char, &CharLayer::play_sfx, this, + &Courtroom::play_char_sfx); + + connect(text_delay_timer, &QTimer::timeout, this, + &Courtroom::start_chat_ticking); + + connect(text_queue_timer, &QTimer::timeout, this, + &Courtroom::chatmessage_dequeue); + + connect(sfx_delay_timer, &QTimer::timeout, this, &Courtroom::play_sfx); + + connect(chat_tick_timer, &QTimer::timeout, this, &Courtroom::chat_tick); + + connect(ui_pos_dropdown, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + QOverload<int>::of(&Courtroom::on_pos_dropdown_changed)); + connect(ui_pos_dropdown, &QComboBox::editTextChanged, this, + QOverload<QString>::of(&Courtroom::on_pos_dropdown_changed)); + connect(ui_pos_remove, &AOButton::clicked, this, &Courtroom::on_pos_remove_clicked); + + connect(ui_iniswap_dropdown, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &Courtroom::on_iniswap_dropdown_changed); + connect(ui_iniswap_dropdown, &QComboBox::customContextMenuRequested, this, + &Courtroom::on_iniswap_context_menu_requested); + connect(ui_iniswap_remove, &AOButton::clicked, this, + &Courtroom::on_iniswap_remove_clicked); + + connect(ui_sfx_dropdown, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &Courtroom::on_sfx_dropdown_changed); + connect(ui_sfx_dropdown, &QComboBox::editTextChanged, this, + &Courtroom::on_sfx_dropdown_custom); + connect(ui_sfx_dropdown, &QComboBox::customContextMenuRequested, this, + &Courtroom::on_sfx_context_menu_requested); + connect(ui_sfx_remove, &AOButton::clicked, this, + &Courtroom::on_sfx_remove_clicked); + + connect(ui_effects_dropdown, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &Courtroom::on_effects_dropdown_changed); + connect(ui_effects_dropdown, &QComboBox::customContextMenuRequested, this, + &Courtroom::on_effects_context_menu_requested); + + connect(ui_music_search, &QLineEdit::returnPressed, this, + &Courtroom::on_music_search_return_pressed); + connect(ui_mute_list, &QListWidget::clicked, this, + &Courtroom::on_mute_list_clicked); + + connect(ui_ic_chat_message, &QLineEdit::returnPressed, this, + &Courtroom::on_chat_return_pressed); + + connect(ui_ooc_chat_message, &QLineEdit::returnPressed, this, + &Courtroom::on_ooc_return_pressed); + + connect(ui_music_list, &QTreeWidget::itemDoubleClicked, + this, &Courtroom::on_music_list_double_clicked); + connect(ui_music_list, &QTreeWidget::customContextMenuRequested, this, + &Courtroom::on_music_list_context_menu_requested); + + connect(ui_area_list, &QTreeWidget::itemDoubleClicked, this, + &Courtroom::on_area_list_double_clicked); + + connect(ui_hold_it, &AOButton::clicked, this, &Courtroom::on_hold_it_clicked); + connect(ui_objection, &AOButton::clicked, this, &Courtroom::on_objection_clicked); + connect(ui_take_that, &AOButton::clicked, this, &Courtroom::on_take_that_clicked); + connect(ui_custom_objection, &AOButton::clicked, this, + &Courtroom::on_custom_objection_clicked); connect(ui_custom_objection, - SIGNAL(customContextMenuRequested(const QPoint &)), this, - SLOT(show_custom_objection_menu(const QPoint &))); - - connect(ui_realization, SIGNAL(clicked()), this, - SLOT(on_realization_clicked())); - connect(ui_screenshake, SIGNAL(clicked()), this, - SLOT(on_screenshake_clicked())); - - connect(ui_mute, SIGNAL(clicked()), this, SLOT(on_mute_clicked())); - - connect(ui_defense_minus, SIGNAL(clicked()), this, - SLOT(on_defense_minus_clicked())); - connect(ui_defense_plus, SIGNAL(clicked()), this, - SLOT(on_defense_plus_clicked())); - connect(ui_prosecution_minus, SIGNAL(clicked()), this, - SLOT(on_prosecution_minus_clicked())); - connect(ui_prosecution_plus, SIGNAL(clicked()), this, - SLOT(on_prosecution_plus_clicked())); - - connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this, - SLOT(on_text_color_changed(int))); - - connect(ui_music_slider, SIGNAL(valueChanged(int)), this, - SLOT(on_music_slider_moved(int))); - connect(ui_sfx_slider, SIGNAL(valueChanged(int)), this, - SLOT(on_sfx_slider_moved(int))); - connect(ui_blip_slider, SIGNAL(valueChanged(int)), this, - SLOT(on_blip_slider_moved(int))); - - connect(ui_ooc_toggle, SIGNAL(clicked()), this, - SLOT(on_ooc_toggle_clicked())); - - connect(ui_music_search, SIGNAL(textChanged(QString)), this, - SLOT(on_music_search_edited(QString))); - - connect(ui_witness_testimony, SIGNAL(clicked()), this, - SLOT(on_witness_testimony_clicked())); - connect(ui_cross_examination, SIGNAL(clicked()), this, - SLOT(on_cross_examination_clicked())); - connect(ui_guilty, SIGNAL(clicked()), this, SLOT(on_guilty_clicked())); - connect(ui_not_guilty, SIGNAL(clicked()), this, - SLOT(on_not_guilty_clicked())); - - connect(ui_change_character, SIGNAL(clicked()), this, - SLOT(on_change_character_clicked())); - connect(ui_reload_theme, SIGNAL(clicked()), this, - SLOT(on_reload_theme_clicked())); - connect(ui_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked())); - connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked())); - connect(ui_announce_casing, SIGNAL(clicked()), this, - SLOT(on_announce_casing_clicked())); - connect(ui_switch_area_music, SIGNAL(clicked()), this, - SLOT(on_switch_area_music_clicked())); - - connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked())); - connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked())); - connect(ui_additive, SIGNAL(clicked()), this, SLOT(on_additive_clicked())); - connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked())); - connect(ui_casing, SIGNAL(clicked()), this, SLOT(on_casing_clicked())); - - connect(ui_showname_enable, SIGNAL(clicked()), this, - SLOT(on_showname_enable_clicked())); - - connect(ui_pair_button, SIGNAL(clicked()), this, SLOT(on_pair_clicked())); - connect(ui_pair_list, SIGNAL(clicked(QModelIndex)), this, - SLOT(on_pair_list_clicked(QModelIndex))); - connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this, - SLOT(on_pair_offset_changed(int))); - connect(ui_pair_vert_offset_spinbox, SIGNAL(valueChanged(int)), this, - SLOT(on_pair_vert_offset_changed(int))); - connect(ui_pair_order_dropdown, SIGNAL(currentIndexChanged(int)), this, - SLOT(on_pair_order_dropdown_changed(int))); - - connect(ui_evidence_button, SIGNAL(clicked()), this, - SLOT(on_evidence_button_clicked())); + &AOButton::customContextMenuRequested, this, + &Courtroom::show_custom_objection_menu); + + connect(ui_realization, &AOButton::clicked, this, + &Courtroom::on_realization_clicked); + connect(ui_screenshake, &AOButton::clicked, this, + &Courtroom::on_screenshake_clicked); + + connect(ui_mute, &AOButton::clicked, this, &Courtroom::on_mute_clicked); + + connect(ui_defense_minus, &AOButton::clicked, this, + &Courtroom::on_defense_minus_clicked); + connect(ui_defense_plus, &AOButton::clicked, this, + &Courtroom::on_defense_plus_clicked); + connect(ui_prosecution_minus, &AOButton::clicked, this, + &Courtroom::on_prosecution_minus_clicked); + connect(ui_prosecution_plus, &AOButton::clicked, this, + &Courtroom::on_prosecution_plus_clicked); + + connect(ui_text_color, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &Courtroom::on_text_color_changed); + + connect(ui_music_slider, &QSlider::valueChanged, this, + &Courtroom::on_music_slider_moved); + connect(ui_sfx_slider, &QSlider::valueChanged, this, + &Courtroom::on_sfx_slider_moved); + connect(ui_blip_slider, &QSlider::valueChanged, this, + &Courtroom::on_blip_slider_moved); + + connect(ui_ooc_toggle, &AOButton::clicked, this, + &Courtroom::on_ooc_toggle_clicked); + + connect(ui_music_search, &QLineEdit::textChanged, this, + &Courtroom::on_music_search_edited); + + connect(ui_witness_testimony, &AOButton::clicked, this, + &Courtroom::on_witness_testimony_clicked); + connect(ui_cross_examination, &AOButton::clicked, this, + &Courtroom::on_cross_examination_clicked); + connect(ui_guilty, &AOButton::clicked, this, &Courtroom::on_guilty_clicked); + connect(ui_not_guilty, &AOButton::clicked, this, + &Courtroom::on_not_guilty_clicked); + + connect(ui_change_character, &AOButton::clicked, this, + &Courtroom::on_change_character_clicked); + connect(ui_reload_theme, &AOButton::clicked, this, + &Courtroom::on_reload_theme_clicked); + connect(ui_call_mod, &AOButton::clicked, this, &Courtroom::on_call_mod_clicked); + connect(ui_settings, &AOButton::clicked, this, &Courtroom::on_settings_clicked); + connect(ui_announce_casing, &AOButton::clicked, this, + &Courtroom::on_announce_casing_clicked); + connect(ui_switch_area_music, &AOButton::clicked, this, + &Courtroom::on_switch_area_music_clicked); + + connect(ui_pre, &AOButton::clicked, this, &Courtroom::on_pre_clicked); + connect(ui_flip, &AOButton::clicked, this, &Courtroom::on_flip_clicked); + connect(ui_additive, &AOButton::clicked, this, &Courtroom::on_additive_clicked); + connect(ui_guard, &AOButton::clicked, this, &Courtroom::on_guard_clicked); + connect(ui_casing, &AOButton::clicked, this, &Courtroom::on_casing_clicked); + + connect(ui_showname_enable, &AOButton::clicked, this, + &Courtroom::on_showname_enable_clicked); + + connect(ui_pair_button, &AOButton::clicked, this, &Courtroom::on_pair_clicked); + connect(ui_pair_list, &QListWidget::clicked, this, + &Courtroom::on_pair_list_clicked); + connect(ui_pair_offset_spinbox, QOverload<int>::of(&QSpinBox::valueChanged), this, + &Courtroom::on_pair_offset_changed); + connect(ui_pair_vert_offset_spinbox, QOverload<int>::of(&QSpinBox::valueChanged), this, + &Courtroom::on_pair_vert_offset_changed); + connect(ui_pair_order_dropdown, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &Courtroom::on_pair_order_dropdown_changed); + + connect(ui_evidence_button, &AOButton::clicked, this, + &Courtroom::on_evidence_button_clicked); set_widgets(); @@ -583,12 +586,12 @@ void Courtroom::set_mute_list() QStringList sorted_mute_list; - for (char_type i_char : char_list) + for (const char_type &i_char : qAsConst(char_list)) sorted_mute_list.append(i_char.name); sorted_mute_list.sort(); - for (QString i_name : sorted_mute_list) { + for (const QString &i_name : sorted_mute_list) { // mute_map.insert(i_name, false); ui_mute_list->addItem(i_name); } @@ -598,12 +601,12 @@ void Courtroom::set_pair_list() { QStringList sorted_pair_list; - for (char_type i_char : char_list) + for (const char_type &i_char : qAsConst(char_list)) sorted_pair_list.append(i_char.name); sorted_pair_list.sort(); - for (QString i_name : sorted_pair_list) { + for (const QString &i_name : sorted_pair_list) { ui_pair_list->addItem(i_name); } } @@ -706,12 +709,14 @@ void Courtroom::set_widgets() log_colors != ao_app->is_colorlog_enabled() || log_newline != ao_app->get_log_newline() || log_margin != ao_app->get_log_margin() || - log_timestamp != ao_app->get_log_timestamp(); + log_timestamp != ao_app->get_log_timestamp() || + log_timestamp_format != ao_app->get_log_timestamp_format(); log_goes_downwards = ao_app->get_log_goes_downwards(); log_colors = ao_app->is_colorlog_enabled(); log_newline = ao_app->get_log_newline(); log_margin = ao_app->get_log_margin(); log_timestamp = ao_app->get_log_timestamp(); + log_timestamp_format = ao_app->get_log_timestamp_format(); if (regenerate) regenerate_ic_chatlog(); @@ -767,7 +772,7 @@ void Courtroom::set_widgets() ui_music_list->resetIndentation(); else ui_music_list->setIndentation(music_list_indentation.toInt()); - + QString music_list_animated = ao_app->get_design_element("music_list_animated", "courtroom_design.ini"); if (music_list_animated == "1") ui_music_list->setAnimated(true); @@ -1332,7 +1337,7 @@ void Courtroom::set_background(QString p_background, bool display) // Populate the dropdown list with all pos that exist on this bg QStringList pos_list = {}; - for (QString key : default_pos.keys()) { + for (const QString &key : default_pos) { if (file_exists(ao_app->get_image_suffix( ao_app->get_background_path(default_pos[key]))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng file_exists( @@ -1340,7 +1345,7 @@ void Courtroom::set_background(QString p_background, bool display) pos_list.append(default_pos[key]); } } - for (QString pos : ao_app->read_design_ini("positions", ao_app->get_background_path("design.ini")).split(",")) { + for (const QString &pos : ao_app->read_design_ini("positions", ao_app->get_background_path("design.ini")).split(",")) { if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos)))) { pos_list.append(pos); } @@ -1667,7 +1672,7 @@ void Courtroom::list_areas() int n_listed_areas = 0; for (int n_area = 0; n_area < area_list.size(); ++n_area) { - QString i_area = ""; + QString i_area = ""; i_area.append(area_list.at(n_area)); if (ao_app->arup_enabled) { @@ -1757,7 +1762,7 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message, ui_server_chatlog->append_chatmessage(p_name, p_message, color); if (ao_app->get_auto_logging_enabled() && !ao_app->log_filename.isEmpty()) { - QString full = "[OOC][" + QDateTime::currentDateTime().toUTC().toString() + "] " + p_name + ": " + p_message; + QString full = "[OOC][" + QDateTime::currentDateTimeUtc().toString() + "] " + p_name + ": " + p_message; ao_app->append_to_file(full, ao_app->log_filename, true); } } @@ -2196,7 +2201,7 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show objection_mod = f_objection_mod.toInt(); } - QString f_custom_theme = ao_app->get_chat(f_char); + //QString f_custom_theme = ao_app->get_chat(f_char); if (objection_mod <= 4 && objection_mod >= 1) { QString shout_message; switch (objection_mod) { @@ -2263,7 +2268,7 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show if ((f_log_mode != IO_ONLY) && // if we're not in I/O only mode, f_message.isEmpty() && // our current message is a blankpost, !ic_chatlog_history.isEmpty() && // the chat log isn't empty, - last_ic_message == f_displayname + ":" && // the chat log's last message is a blank post, and + last_ic_message == f_displayname + ":" && // the chat log's last message is a blank post, and last_ic_message.mid(0, last_ic_message.lastIndexOf(":")) == f_displayname) // the blankpost's showname is the same as ours return; // Skip adding message switch (f_log_mode) { @@ -2331,7 +2336,7 @@ bool Courtroom::handle_objection() "custom", m_chatmessage[CHAR_NAME], ao_app->get_chat(m_chatmessage[CHAR_NAME])); } - break; + break; m_chatmessage[EMOTE_MOD] = 1; } ui_vp_objection->load_image( @@ -2446,6 +2451,7 @@ void Courtroom::display_pair_character(QString other_charid, QString other_offse // Play the other pair character's idle animation QString filename = "(a)" + m_chatmessage[OTHER_EMOTE]; + ui_vp_sideplayer_char->set_play_once(false); ui_vp_sideplayer_char->load_image(filename, m_chatmessage[OTHER_NAME], 0, false); } @@ -2757,7 +2763,7 @@ void Courtroom::handle_callwords() // Obtain the current call words (Really? It does File I/O on every single message???) QStringList call_words = ao_app->get_call_words(); // Loop through each word in the call words list - for (QString word : call_words) { + for (const QString &word : qAsConst(call_words)) { // If our message contains that specific call word if (f_message.contains(word, Qt::CaseInsensitive)) { // Play the call word sfx on the modcall_player sound container @@ -2777,7 +2783,7 @@ void Courtroom::display_evidence_image() if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size()) { // shifted by 1 because 0 is no evidence per legacy standards QString f_image = local_evidence_list.at(f_evi_id - 1).image; - QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name; + //QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name; // def jud and hlp should display the evidence icon on the RIGHT side bool is_left_side = !(side == "def" || side == "hlp" || side == "jud" || side == "jur"); @@ -3125,7 +3131,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, if (log_timestamp) { if (timestamp.isValid()) { ui_ic_chatlog->textCursor().insertText( - "[" + timestamp.toString("h:mm:ss AP") + "] ", normal); + "[" + timestamp.toString(log_timestamp_format) + "] ", normal); } else { qDebug() << "could not insert invalid timestamp"; } @@ -3281,7 +3287,7 @@ void Courtroom::play_preanim(bool immediate) void Courtroom::preanim_done() { // Currently, someone's talking over us mid-preanim... - if (anim_state != 1 && anim_state != 4) + if (anim_state != 1 && anim_state != 4 && anim_state != 5) return; anim_state = 1; @@ -3444,7 +3450,7 @@ void Courtroom::chat_tick() } ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme); ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme); // Chat stopped being processed, indicate that. - QString f_message_filtered = filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); + QString f_message_filtered = filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); for (int c = 0; c < max_colors; ++c) { additive_previous = additive_previous.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); @@ -3749,7 +3755,7 @@ void Courtroom::set_self_offset(QString p_list) { int self_offset_v; if (self_offsets.length() <= 1) self_offset_v = 0; - else + else self_offset_v = self_offsets[1].toInt(); ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100); } @@ -3884,7 +3890,7 @@ void Courtroom::handle_song(QStringList *p_contents) void Courtroom::handle_wtce(QString p_wtce, int variant) { - QString sfx_file = "courtroom_sounds.ini"; + //QString sfx_file = "courtroom_sounds.ini"; QString bg_misc = ao_app->read_design_ini("misc", ao_app->get_background_path("design.ini")); QString sfx_name; QString filename; @@ -3996,7 +4002,9 @@ void Courtroom::on_ooc_return_pressed() { QString ooc_message = ui_ooc_chat_message->text(); - if (ooc_message.startsWith("/pos")) { + //We ignore it when the server is compatible with 2.8 + //Using an arbitrary 2.8 feature flag certainly won't cause issues someday. + if (ooc_message.startsWith("/pos") & !ao_app->effects_enabled) { if (ooc_message == "/pos jud") { toggle_judge_buttons(true); } @@ -4004,167 +4012,13 @@ void Courtroom::on_ooc_return_pressed() toggle_judge_buttons(false); } } - else if (ooc_message.startsWith("/settings")) { - ui_ooc_chat_message->clear(); - ao_app->call_settings_menu(); - append_server_chatmessage("CLIENT", tr("You opened the settings menu."), - "1"); - return; - } - else if (ooc_message.startsWith("/pair")) { - ui_ooc_chat_message->clear(); - ooc_message.remove(0, 6); - - bool ok; - int whom = ooc_message.toInt(&ok); - if (ok) { - if (whom > -1) { - other_charid = whom; - QString msg = tr("You will now pair up with %1 if they also choose " - "your character in return.") - .arg(char_list.at(whom).name); - append_server_chatmessage("CLIENT", msg, "1"); - } - else { - other_charid = -1; - append_server_chatmessage( - "CLIENT", tr("You are no longer paired with anyone."), "1"); - } - } - else { - int whom = 0; - bool matched = false; - for (char_type chara : char_list) { - if (chara.name.toLower() == ooc_message.toLower()) { - matched = true; - break; - } - whom++; - } - if (matched) { - other_charid = whom; - QString msg = tr("You will now pair up with %1 if they also choose " - "your character in return.") - .arg(char_list.at(whom).name); - append_server_chatmessage("CLIENT", msg, "1"); - } - else { - append_server_chatmessage("CLIENT", - tr("Are you sure you typed that well? The char " - "ID/name could not be recognised."), - "1"); - } - } - return; - } - else if (ooc_message.startsWith("/offset")) { - ui_ooc_chat_message->clear(); - ooc_message.remove(0, 8); - - bool ok; - int off = ooc_message.toInt(&ok); - if (ok) { - if (off >= -100 && off <= 100) { - char_offset = off; - QString msg = - tr("You have set your offset to %1%%.").arg(QString::number(off)); - append_server_chatmessage("CLIENT", msg, "1"); - } - else { - append_server_chatmessage( - "CLIENT", tr("Your offset must be between -100% and 100%!"), "1"); - } - } - else { - append_server_chatmessage("CLIENT", - tr("That offset does not look like one."), "1"); - } - return; - } - else if (ooc_message.startsWith("/voffset")) { - ui_ooc_chat_message->clear(); - ooc_message.remove(0, 8); - - bool ok; - int off = ooc_message.toInt(&ok); - if (ok) { - if (off >= -100 && off <= 100) { - char_vert_offset = off; - QString msg = tr("You have set your vertical offset to %1%%.") - .arg(QString::number(off)); - append_server_chatmessage("CLIENT", msg, "1"); - } - else { - append_server_chatmessage( - "CLIENT", - tr("Your vertical offset must be between -100% and 100%!"), "1"); - } - } - else { - append_server_chatmessage( - "CLIENT", tr("That vertical offset does not look like one."), "1"); - } - return; - } - else if (ooc_message.startsWith("/switch_am")) { - append_server_chatmessage( - "CLIENT", tr("You switched your music and area list."), "1"); - on_switch_area_music_clicked(); - ui_ooc_chat_message->clear(); - return; - } - else if (ooc_message.startsWith("/enable_blocks")) { - append_server_chatmessage("CLIENT", - tr("You have forcefully enabled features that " - "the server may not support. You may not be " - "able to talk IC, or worse, because of this."), - "1"); - ao_app->cccc_ic_support_enabled = true; - ao_app->arup_enabled = true; - ao_app->modcall_reason_enabled = true; - on_reload_theme_clicked(); - ui_ooc_chat_message->clear(); - return; - } - else if (ooc_message.startsWith("/non_int_pre")) { - if (ui_immediate->isChecked()) - append_server_chatmessage( - "CLIENT", tr("Your pre-animations interrupt again."), "1"); - else - append_server_chatmessage( - "CLIENT", tr("Your pre-animations will not interrupt text."), "1"); - ui_immediate->setChecked(!ui_immediate->isChecked()); - ui_ooc_chat_message->clear(); - return; - } - else if (ooc_message.startsWith("/save_chatlog")) { - QFile file("chatlog.txt"); - - if (!file.open(QIODevice::WriteOnly | QIODevice::Text | - QIODevice::Truncate)) { - append_server_chatmessage( - "CLIENT", tr("Couldn't open chatlog.txt to write into."), "1"); - ui_ooc_chat_message->clear(); - return; - } - - QTextStream out(&file); - out.setCodec("UTF-8"); - - foreach (chatlogpiece item, ic_chatlog_history) { - out << item.get_full() << '\n'; - } - - file.close(); - append_server_chatmessage("CLIENT", tr("The IC chatlog has been saved."), - "1"); - ui_ooc_chat_message->clear(); - return; - } - else if (ooc_message.startsWith("/load_case")) { + if (ooc_message.startsWith("/load_case")) { +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); - +#else + QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts); +#endif QDir casefolder("base/cases"); if (!casefolder.exists()) { QDir::current().mkdir("base/" + casefolder.dirName()); @@ -4261,8 +4115,11 @@ void Courtroom::on_ooc_return_pressed() return; } else if (ooc_message.startsWith("/save_case")) { +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); - +#else + QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts); +#endif QDir casefolder("base/cases"); if (!casefolder.exists()) { QDir::current().mkdir("base/" + casefolder.dirName()); @@ -4567,7 +4424,7 @@ void Courtroom::set_sfx_dropdown() ao_app->get_base_path() + "soundlist.ini"); QStringList display_sounds; - for (QString sound : sound_list) { + for (const QString &sound : qAsConst(sound_list)) { QStringList unpacked = sound.split("="); QString display = unpacked[0].trimmed(); if (unpacked.size() > 1) @@ -4812,7 +4669,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) // Redo the character list. QStringList sorted_pair_list; - for (char_type i_char : char_list) + for (const char_type &i_char : qAsConst(char_list)) sorted_pair_list.append(i_char.name); sorted_pair_list.sort(); @@ -4849,32 +4706,32 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos) { QMenu *menu = new QMenu(this); menu->setAttribute(Qt::WA_DeleteOnClose); - menu->addAction(QString(tr("Stop Current Song")), this, SLOT(music_stop())); - menu->addAction(QString(tr("Play Random Song")), this, SLOT(music_random())); + menu->addAction(QString(tr("Stop Current Song")), this, &Courtroom::music_stop); + menu->addAction(QString(tr("Play Random Song")), this, &Courtroom::music_random); menu->addSeparator(); menu->addAction(QString(tr("Expand All Categories")), this, - SLOT(music_list_expand_all())); + &Courtroom::music_list_expand_all); menu->addAction(QString(tr("Collapse All Categories")), this, - SLOT(music_list_collapse_all())); + &Courtroom::music_list_collapse_all); menu->addSeparator(); menu->addAction(new QAction(tr("Fade Out Previous"), this)); menu->actions().back()->setCheckable(true); menu->actions().back()->setChecked(music_flags & FADE_OUT); - connect(menu->actions().back(), SIGNAL(toggled(bool)), this, - SLOT(music_fade_out(bool))); + connect(menu->actions().back(), &QAction::toggled, this, + &Courtroom::music_fade_out); menu->addAction(new QAction(tr("Fade In"), this)); menu->actions().back()->setCheckable(true); menu->actions().back()->setChecked(music_flags & FADE_IN); - connect(menu->actions().back(), SIGNAL(toggled(bool)), this, - SLOT(music_fade_in(bool))); + connect(menu->actions().back(), &QAction::toggled, this, + &Courtroom::music_fade_in); menu->addAction(new QAction(tr("Synchronize"), this)); menu->actions().back()->setCheckable(true); menu->actions().back()->setChecked(music_flags & SYNC_POS); - connect(menu->actions().back(), SIGNAL(toggled(bool)), this, - SLOT(music_synchronize(bool))); + connect(menu->actions().back(), &QAction::toggled, this, + &Courtroom::music_synchronize); menu->popup(ui_music_list->mapToGlobal(pos)); } @@ -4939,7 +4796,7 @@ void Courtroom::music_stop(bool no_effects) // If the fake song is not present in the music list if (!music_list.contains(fake_song)) { // Loop through our music list - for (QString song : music_list) { + for (const QString &song : qAsConst(music_list)) { // Pick first song that does not contain a file extension if (!song.contains('.')) { // Use it as a fake song as the server we're working with must recognize song categories diff --git a/src/demoserver.cpp b/src/demoserver.cpp index ee0fcf2..db5e1bc 100644 --- a/src/demoserver.cpp +++ b/src/demoserver.cpp @@ -97,7 +97,7 @@ void DemoServer::recv_data() QStringList packet_list = in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts)); - for (QString packet : packet_list) { + for (const QString &packet : packet_list) { AOPacket ao_packet(packet); handle_packet(ao_packet); } @@ -297,7 +297,7 @@ void DemoServer::load_demo(QString filename) QTextStream out(&demo_file); out.setCodec("UTF-8"); out << p_demo_data.dequeue(); - for (QString line : p_demo_data) { + for (const QString &line : qAsConst(p_demo_data)) { out << "\n" << line; } demo_file.flush(); diff --git a/src/emotes.cpp b/src/emotes.cpp index 8272007..541a6e2 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -15,13 +15,13 @@ void Courtroom::initialize_emotes() ui_emote_dropdown = new QComboBox(this); ui_emote_dropdown->setObjectName("ui_emote_dropdown"); - connect(ui_emote_left, SIGNAL(clicked()), this, - SLOT(on_emote_left_clicked())); - connect(ui_emote_right, SIGNAL(clicked()), this, - SLOT(on_emote_right_clicked())); + connect(ui_emote_left, &AOButton::clicked, this, + &Courtroom::on_emote_left_clicked); + connect(ui_emote_right, &AOButton::clicked, this, + &Courtroom::on_emote_right_clicked); - connect(ui_emote_dropdown, SIGNAL(activated(int)), this, - SLOT(on_emote_dropdown_changed(int))); + connect(ui_emote_dropdown, QOverload<int>::of(&QComboBox::activated), this, + &Courtroom::on_emote_dropdown_changed); } void Courtroom::refresh_emotes() @@ -74,8 +74,8 @@ void Courtroom::refresh_emotes() f_emote->set_id(n); - connect(f_emote, SIGNAL(emote_clicked(int)), this, - SLOT(on_emote_clicked(int))); + connect(f_emote, &AOEmoteButton::emote_clicked, this, + &Courtroom::on_emote_clicked); ++x_mod_count; @@ -96,7 +96,7 @@ void Courtroom::set_emote_page() ui_emote_left->hide(); ui_emote_right->hide(); - for (AOEmoteButton *i_button : ui_emote_list) { + for (AOEmoteButton *i_button : qAsConst(ui_emote_list)) { i_button->hide(); } diff --git a/src/evidence.cpp b/src/evidence.cpp index 2cc1d75..fc305d2 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -6,7 +6,9 @@ void Courtroom::initialize_evidence() ui_evidence->setObjectName("ui_evidence"); // ui_evidence_name = new QLabel(ui_evidence); - ui_evidence_name = new AOLineEdit(ui_evidence); + ui_evidence_name = new QLineEdit(ui_evidence); + ui_evidence_name_filter = new AOLineEditFilter(); + ui_evidence_name->installEventFilter(ui_evidence_name_filter); ui_evidence_name->setAlignment(Qt::AlignCenter); ui_evidence_name->setFrame(false); ui_evidence_name->setObjectName("ui_evidence_name"); @@ -41,11 +43,14 @@ void Courtroom::initialize_evidence() ui_evidence_delete = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_delete->setToolTip(tr("Destroy this piece of evidence")); ui_evidence_delete->setObjectName("ui_evidence_delete"); - ui_evidence_image_name = new AOLineEdit(ui_evidence_overlay); + ui_evidence_image_name = new QLineEdit(ui_evidence_overlay); + ui_evidence_image_name_filter = new AOLineEditFilter(); + ui_evidence_image_name->installEventFilter(ui_evidence_image_name_filter); ui_evidence_image_name->setObjectName("ui_evidence_image_name"); ui_evidence_image_button = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_image_button->setText(tr("Choose..")); ui_evidence_image_button->setObjectName("ui_evidence_image_button"); + ui_evidence_image_button->setDisabled(true); ui_evidence_x = new AOButton(ui_evidence_overlay, ao_app); ui_evidence_x->setToolTip( tr("Close the evidence display/editing overlay.\n" @@ -56,50 +61,51 @@ void Courtroom::initialize_evidence() "evidence and send them to server.")); ui_evidence_ok->setObjectName("ui_evidence_ok"); - ui_evidence_description = new AOTextEdit(ui_evidence_overlay); + ui_evidence_description = new QPlainTextEdit(ui_evidence_overlay); ui_evidence_description->setFrameStyle(QFrame::NoFrame); ui_evidence_description->setToolTip( - tr("Double-click to edit. Press [X] to update your changes.")); + tr("Click the pencil icon to edit. Press [X] to update your changes.")); ui_evidence_description->setObjectName("ui_evidence_description"); - connect(ui_evidence_name, SIGNAL(returnPressed()), this, - SLOT(on_evidence_name_edited())); - connect(ui_evidence_name, SIGNAL(double_clicked()), this, - SLOT(on_evidence_name_double_clicked())); - connect(ui_evidence_left, SIGNAL(clicked()), this, - SLOT(on_evidence_left_clicked())); - connect(ui_evidence_right, SIGNAL(clicked()), this, - SLOT(on_evidence_right_clicked())); - connect(ui_evidence_present, SIGNAL(clicked()), this, - SLOT(on_evidence_present_clicked())); - connect(ui_evidence_switch, SIGNAL(clicked()), this, - SLOT(on_evidence_switch_clicked())); - connect(ui_evidence_transfer, SIGNAL(clicked()), this, - SLOT(on_evidence_transfer_clicked())); - connect(ui_evidence_save, SIGNAL(clicked()), this, - SLOT(on_evidence_save_clicked())); - connect(ui_evidence_load, SIGNAL(clicked()), this, - SLOT(on_evidence_load_clicked())); - - connect(ui_evidence_delete, SIGNAL(clicked()), this, - SLOT(on_evidence_delete_clicked())); - connect(ui_evidence_image_name, SIGNAL(returnPressed()), this, - SLOT(on_evidence_image_name_edited())); - connect(ui_evidence_image_name, SIGNAL(double_clicked()), this, - SLOT(on_evidence_image_name_double_clicked())); - connect(ui_evidence_image_button, SIGNAL(clicked()), this, - SLOT(on_evidence_image_button_clicked())); - connect(ui_evidence_x, SIGNAL(clicked()), this, - SLOT(on_evidence_x_clicked())); - connect(ui_evidence_ok, SIGNAL(clicked()), this, - SLOT(on_evidence_ok_clicked())); - - connect(ui_evidence_name, SIGNAL(textChanged(QString)), this, - SLOT(on_evidence_edited())); - connect(ui_evidence_image_name, SIGNAL(textChanged(QString)), this, - SLOT(on_evidence_edited())); - connect(ui_evidence_description, SIGNAL(textChanged()), this, - SLOT(on_evidence_edited())); + ui_evidence_edit = new AOButton(ui_evidence_overlay, ao_app); + ui_evidence_edit->setToolTip(tr("Edit this piece of evidence.")); + ui_evidence_edit->setObjectName("ui_evidence_edit"); + + connect(ui_evidence_name, &QLineEdit::returnPressed, this, + &Courtroom::on_evidence_name_edited); + connect(ui_evidence_left, &AOButton::clicked, this, + &Courtroom::on_evidence_left_clicked); + connect(ui_evidence_right, &AOButton::clicked, this, + &Courtroom::on_evidence_right_clicked); + connect(ui_evidence_present, &AOButton::clicked, this, + &Courtroom::on_evidence_present_clicked); + connect(ui_evidence_switch, &AOButton::clicked, this, + &Courtroom::on_evidence_switch_clicked); + connect(ui_evidence_transfer, &AOButton::clicked, this, + &Courtroom::on_evidence_transfer_clicked); + connect(ui_evidence_save, &AOButton::clicked, this, + &Courtroom::on_evidence_save_clicked); + connect(ui_evidence_load, &AOButton::clicked, this, + &Courtroom::on_evidence_load_clicked); + + connect(ui_evidence_delete, &AOButton::clicked, this, + &Courtroom::on_evidence_delete_clicked); + connect(ui_evidence_image_name, &QLineEdit::returnPressed, this, + &Courtroom::on_evidence_image_name_edited); + connect(ui_evidence_image_button, &AOButton::clicked, this, + &Courtroom::on_evidence_image_button_clicked); + connect(ui_evidence_x, &AOButton::clicked, this, + &Courtroom::on_evidence_x_clicked); + connect(ui_evidence_ok, &AOButton::clicked, this, + &Courtroom::on_evidence_ok_clicked); + + connect(ui_evidence_name, &QLineEdit::textChanged, this, + &Courtroom::on_evidence_edited); + connect(ui_evidence_image_name, &QLineEdit::textChanged, this, + &Courtroom::on_evidence_image_name_edited); + connect(ui_evidence_description, &QPlainTextEdit::textChanged, this, + &Courtroom::on_evidence_edited); + connect(ui_evidence_edit, &AOButton::clicked, this, &Courtroom::on_evidence_edit_clicked); ui_evidence->hide(); } @@ -156,6 +162,9 @@ void Courtroom::refresh_evidence() set_size_and_pos(ui_evidence_ok, "evidence_ok"); ui_evidence_ok->set_image("evidence_ok"); + set_size_and_pos(ui_evidence_edit, "evidence_edit"); + ui_evidence_edit->set_image("evidence_edit"); + set_size_and_pos(ui_evidence_switch, "evidence_switch"); if (current_evidence_global) { ui_evidence_switch->set_image("evidence_global"); @@ -227,12 +236,12 @@ void Courtroom::refresh_evidence() f_evidence->set_id(n); - connect(f_evidence, SIGNAL(evidence_clicked(int)), this, - SLOT(on_evidence_clicked(int))); - connect(f_evidence, SIGNAL(evidence_double_clicked(int)), this, - SLOT(on_evidence_double_clicked(int))); - connect(f_evidence, SIGNAL(on_hover(int, bool)), this, - SLOT(on_evidence_hover(int, bool))); + connect(f_evidence, &AOEvidenceButton::evidence_clicked, this, + &Courtroom::on_evidence_clicked); + connect(f_evidence, &AOEvidenceButton::evidence_double_clicked, this, + &Courtroom::on_evidence_double_clicked); + connect(f_evidence, &AOEvidenceButton::on_hover, this, + &Courtroom::on_evidence_hover); ++x_mod_count; @@ -281,7 +290,11 @@ void Courtroom::set_evidence_list(QVector<evi_type> &p_evi_list) msgBox->setDetailedText(tr( "Name: %1\n" "Image: %2\n" - "Description:\n%3").arg(local_evidence_list.at(current_evidence).name).arg(local_evidence_list.at(current_evidence).image).arg(local_evidence_list.at(current_evidence).description)); + "Description:\n%3").arg( + local_evidence_list.at(current_evidence).name, + local_evidence_list.at(current_evidence).image, + local_evidence_list.at(current_evidence).description) + ); msgBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox->setDefaultButton(QMessageBox::LastButton); // msgBox->setWindowModality(Qt::NonModal); @@ -309,7 +322,7 @@ void Courtroom::set_evidence_page() ui_evidence_left->hide(); ui_evidence_right->hide(); - for (AOEvidenceButton *i_button : ui_evidence_list) { + for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list)) { i_button->hide(); } @@ -368,26 +381,10 @@ void Courtroom::set_evidence_page() void Courtroom::on_evidence_name_edited() { - ui_evidence_name->setReadOnly(true); if (current_evidence >= local_evidence_list.size()) return; } -void Courtroom::on_evidence_name_double_clicked() -{ - if (ui_evidence_overlay->isVisible()) { - ui_evidence_name->setReadOnly(false); - } - else { - ui_evidence_name->setReadOnly(true); - } -} - -void Courtroom::on_evidence_image_name_double_clicked() -{ - ui_evidence_image_name->setReadOnly(false); -} - void Courtroom::on_evidence_image_name_edited() { ui_evidence_image_name->setReadOnly(true); @@ -445,7 +442,7 @@ void Courtroom::on_evidence_clicked(int p_id) ui_evidence_name->setText(local_evidence_list.at(f_real_id).name); - for (AOEvidenceButton *i_button : ui_evidence_list) + for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list)) i_button->set_selected(false); ui_evidence_list.at(p_id)->set_selected(true); @@ -469,14 +466,14 @@ void Courtroom::on_evidence_double_clicked(int p_id) ui_evidence_description->clear(); ui_evidence_description->appendPlainText(f_evi.description); ui_evidence_description->setReadOnly(true); - ui_evidence_description->setToolTip(tr("Double-click to edit...")); + ui_evidence_description->setToolTip(tr("Click the pencil to edit...")); ui_evidence_name->setText(f_evi.name); ui_evidence_name->setReadOnly(true); - ui_evidence_name->setToolTip(tr("Double-click to edit...")); + ui_evidence_name->setToolTip(tr("Click the pencil to edit...")); ui_evidence_image_name->setText(f_evi.image); ui_evidence_image_name->setReadOnly(true); - ui_evidence_image_name->setToolTip(tr("Double-click to edit...")); + ui_evidence_image_name->setToolTip(tr("Click the pencil to edit...")); ui_evidence_overlay->show(); ui_evidence_ok->hide(); @@ -598,6 +595,8 @@ void Courtroom::on_evidence_ok_clicked() ui_evidence_name->setReadOnly(true); ui_evidence_description->setReadOnly(true); ui_evidence_image_name->setReadOnly(true); + ui_evidence_edit->show(); + ui_evidence_image_button->setDisabled(true); if (current_evidence < local_evidence_list.size()) { evi_type f_evi = local_evidence_list.at(current_evidence); if (current_evidence_global) { @@ -680,6 +679,22 @@ void Courtroom::on_evidence_transfer_clicked() msgBox->exec(); } +void Courtroom::on_evidence_edit_clicked() +{ + if (!ui_evidence_overlay->isVisible()) + return; + if (!ui_evidence_edit->isHidden()) { + ui_evidence_name->setReadOnly(false); + ui_evidence_image_name->setReadOnly(false); + ui_evidence_description->setReadOnly(false); + ui_evidence_image_button->setDisabled(false); + ui_evidence_edit->hide(); + } + else { + return; + } +} + void Courtroom::on_evidence_edited() { if (current_evidence >= @@ -704,6 +719,8 @@ void Courtroom::evidence_close() ui_evidence_name->setToolTip(""); ui_evidence_image_name->setReadOnly(true); ui_evidence_image_name->setToolTip(""); + ui_evidence_edit->show(); + ui_evidence_image_button->setDisabled(true); ui_evidence_overlay->hide(); ui_ic_chat_message->setFocus(); } diff --git a/src/file_functions.cpp b/src/file_functions.cpp index 37cdc32..95e9b5f 100644 --- a/src/file_functions.cpp +++ b/src/file_functions.cpp @@ -12,6 +12,9 @@ bool file_exists(QString file_path) bool dir_exists(QString dir_path) { + if (dir_path == "") + return false; + QDir check_dir(dir_path); return check_dir.exists(); diff --git a/src/lobby.cpp b/src/lobby.cpp index 31895d1..08fcaae 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -75,28 +75,28 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_cancel = new AOButton(ui_loading_background, ao_app); ui_cancel->setObjectName("ui_cancel"); - connect(ui_public_servers, SIGNAL(clicked()), this, - SLOT(on_public_servers_clicked())); - connect(ui_favorites, SIGNAL(clicked()), this, SLOT(on_favorites_clicked())); - connect(ui_refresh, SIGNAL(pressed()), this, SLOT(on_refresh_pressed())); - connect(ui_refresh, SIGNAL(released()), this, SLOT(on_refresh_released())); - connect(ui_add_to_fav, SIGNAL(pressed()), this, - SLOT(on_add_to_fav_pressed())); - connect(ui_add_to_fav, SIGNAL(released()), this, - SLOT(on_add_to_fav_released())); - connect(ui_connect, SIGNAL(pressed()), this, SLOT(on_connect_pressed())); - connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released())); - connect(ui_about, SIGNAL(clicked()), this, SLOT(on_about_clicked())); - connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked())); - connect(ui_server_list, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, - SLOT(on_server_list_clicked(QTreeWidgetItem *, int))); - connect(ui_server_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), - this, SLOT(on_server_list_doubleclicked(QTreeWidgetItem *, int))); - connect(ui_server_search, SIGNAL(textChanged(QString)), this, - SLOT(on_server_search_edited(QString))); - connect(ui_chatmessage, SIGNAL(returnPressed()), this, - SLOT(on_chatfield_return_pressed())); - connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled())); + connect(ui_public_servers, &AOButton::clicked, this, + &Lobby::on_public_servers_clicked); + connect(ui_favorites, &AOButton::clicked, this, &Lobby::on_favorites_clicked); + connect(ui_refresh, &AOButton::pressed, this, &Lobby::on_refresh_pressed); + connect(ui_refresh, &AOButton::released, this, &Lobby::on_refresh_released); + connect(ui_add_to_fav, &AOButton::pressed, this, + &Lobby::on_add_to_fav_pressed); + connect(ui_add_to_fav, &AOButton::released, this, + &Lobby::on_add_to_fav_released); + connect(ui_connect, &AOButton::pressed, this, &Lobby::on_connect_pressed); + connect(ui_connect, &AOButton::released, this, &Lobby::on_connect_released); + connect(ui_about, &AOButton::clicked, this, &Lobby::on_about_clicked); + connect(ui_settings, &AOButton::clicked, this, &Lobby::on_settings_clicked); + connect(ui_server_list, &QTreeWidget::itemClicked, this, + &Lobby::on_server_list_clicked); + connect(ui_server_list, &QTreeWidget::itemDoubleClicked, + this, &Lobby::on_server_list_doubleclicked); + connect(ui_server_search, &QLineEdit::textChanged, this, + &Lobby::on_server_search_edited); + connect(ui_chatmessage, &QLineEdit::returnPressed, this, + &Lobby::on_chatfield_return_pressed); + connect(ui_cancel, &AOButton::clicked, ao_app, &AOApplication::loading_cancelled); ui_connect->setEnabled(false); @@ -517,7 +517,7 @@ void Lobby::list_servers() ui_server_search->setText(""); int i = 0; - for (server_type i_server : ao_app->get_server_list()) { + for (const server_type &i_server : qAsConst(ao_app->get_server_list())) { QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_server_list); treeItem->setData(0, Qt::DisplayRole, i); treeItem->setText(1, i_server.name); @@ -533,7 +533,7 @@ void Lobby::list_favorites() ui_server_list->clear(); int i = 0; - for (server_type i_server : ao_app->get_favorite_list()) { + for (const server_type &i_server : qAsConst(ao_app->get_favorite_list())) { QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_server_list); treeItem->setData(0, Qt::DisplayRole, i); treeItem->setText(1, i_server.name); @@ -557,9 +557,9 @@ void Lobby::append_error(QString f_message) void Lobby::set_player_count(int players_online, int max_players) { - QString f_string = tr("Online: %1/%2") - .arg(QString::number(players_online)) - .arg(QString::number(max_players)); + QString f_string = tr("Online: %1/%2").arg( + QString::number(players_online), + QString::number(max_players)); ui_player_count->setText(f_string); } diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 5e29e21..08d0124 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -13,15 +13,15 @@ NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent) ms_reconnect_timer = new QTimer(this); ms_reconnect_timer->setSingleShot(true); - QObject::connect(ms_reconnect_timer, SIGNAL(timeout()), this, - SLOT(retry_ms_connect())); + connect(ms_reconnect_timer, &QTimer::timeout, this, + &NetworkManager::retry_ms_connect); - QObject::connect(ms_socket, SIGNAL(readyRead()), this, - SLOT(handle_ms_packet())); - QObject::connect(server_socket, SIGNAL(readyRead()), this, - SLOT(handle_server_packet())); - QObject::connect(server_socket, SIGNAL(disconnected()), ao_app, - SLOT(server_disconnected())); + connect(ms_socket, &QTcpSocket::readyRead, this, + &NetworkManager::handle_ms_packet); + connect(server_socket, &QTcpSocket::readyRead, this, + &NetworkManager::handle_server_packet); + connect(server_socket, &QTcpSocket::disconnected, ao_app, + &AOApplication::server_disconnected); QString master_config = ao_app->configini->value("master", "").value<QString>(); @@ -45,11 +45,17 @@ void NetworkManager::connect_to_master() void NetworkManager::connect_to_master_nosrv() { - QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, - SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + connect(ms_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), + this, &NetworkManager::on_ms_socket_error); +#else + connect(ms_socket, &QTcpSocket::errorOccurred, + this, &NetworkManager::on_ms_socket_error); +#endif + + connect(ms_socket, &QTcpSocket::connected, + this, &NetworkManager::on_ms_nosrv_connect_success); - QObject::connect(ms_socket, SIGNAL(connected()), this, - SLOT(on_ms_nosrv_connect_success())); ms_socket->connectToHost(ms_nosrv_hostname, ms_port); } @@ -110,7 +116,7 @@ void NetworkManager::perform_srv_lookup() #ifdef MS_FAILOVER_SUPPORTED ms_dns = new QDnsLookup(QDnsLookup::SRV, ms_srv_hostname, this); - connect(ms_dns, SIGNAL(finished()), this, SLOT(on_srv_lookup())); + connect(ms_dns, &QDnsLookup::finished, this, &NetworkManager::on_srv_lookup); ms_dns->lookup(); #endif } @@ -155,9 +161,13 @@ void NetworkManager::on_srv_lookup() if (connected) { // Connect a one-shot signal in case the master server disconnects // randomly - QObject::connect( - ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, - SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + connect(ms_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), + this, &NetworkManager::on_ms_socket_error); +#else + connect(ms_socket, &QTcpSocket::errorOccurred, + this, &NetworkManager::on_ms_socket_error); +#endif break; } else { @@ -179,11 +189,16 @@ void NetworkManager::on_ms_nosrv_connect_success() { emit ms_connect_finished(true, false); - QObject::disconnect(ms_socket, SIGNAL(connected()), this, - SLOT(on_ms_nosrv_connect_success())); + disconnect(ms_socket, &QTcpSocket::connected, this, + &NetworkManager::on_ms_nosrv_connect_success); - QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, - SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + connect(ms_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), + this, &NetworkManager::on_ms_socket_error); +#else + connect(ms_socket, &QTcpSocket::errorOccurred, + this, &NetworkManager::on_ms_socket_error); +#endif } void NetworkManager::on_ms_socket_error(QAbstractSocket::SocketError error) @@ -193,9 +208,13 @@ void NetworkManager::on_ms_socket_error(QAbstractSocket::SocketError error) // Disconnect the one-shot signal - this way, failover connect attempts // don't trigger a full retry - QObject::disconnect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, - SLOT(on_ms_socket_error(QAbstractSocket::SocketError))); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + disconnect(ms_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), + this, &NetworkManager::on_ms_socket_error); +#else + disconnect(ms_socket, &QTcpSocket::errorOccurred, + this, &NetworkManager::on_ms_socket_error); +#endif emit ms_connect_finished(false, true); diff --git a/src/path_functions.cpp b/src/path_functions.cpp index 61df1c6..6fd06e7 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -253,6 +253,12 @@ QString AOApplication::get_real_path(const VPath &vpath) { } } + // Not found in mount paths; check if the file is remote + QString remotePath = vpath.toQString(); + if (remotePath.startsWith("http:") || remotePath.startsWith("https:")) { + return remotePath; + } + // File or directory not found return QString(); } diff --git a/src/scrolltext.cpp b/src/scrolltext.cpp index d5da6ce..b526a8a 100644 --- a/src/scrolltext.cpp +++ b/src/scrolltext.cpp @@ -9,7 +9,7 @@ ScrollText::ScrollText(QWidget *parent) : QWidget(parent), scrollPos(0) setSeparator(" --- "); - connect(&timer, SIGNAL(timeout()), this, SLOT(timer_timeout())); + connect(&timer, &QTimer::timeout, this, &ScrollText::timer_timeout); timer.setInterval(50); } diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index d9b341b..d873b3c 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -89,6 +89,12 @@ bool AOApplication::get_log_timestamp() return result.startsWith("true"); } +QString AOApplication::get_log_timestamp_format() +{ + QString result = configini->value("log_timestamp_format", "h:mm:ss AP").value<QString>(); + return result; +} + bool AOApplication::get_log_ic_actions() { QString result = @@ -511,7 +517,7 @@ QString AOApplication::get_sfx_suffix(VPath sound_to_check) QString AOApplication::get_image_suffix(VPath path_to_check, bool static_image) { - QStringList suffixes { "" }; + QStringList suffixes {}; if (!static_image) { suffixes.append({ ".webp", ".apng", ".gif" }); } |
