From e8f5b7ec366f1cf7660e870335b4e503e4527990 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Aug 2021 19:44:11 +0200 Subject: video/ps3eye: add missing translation strings --- video-ps3eye/lang/nl_NL.ts | 15 +++++++++++++++ video-ps3eye/lang/ru_RU.ts | 15 +++++++++++++++ video-ps3eye/lang/stub.ts | 15 +++++++++++++++ video-ps3eye/lang/zh_CN.ts | 15 +++++++++++++++ video-ps3eye/module.cpp | 14 +++++++++++--- video-ps3eye/module.hpp | 1 + 6 files changed, 72 insertions(+), 3 deletions(-) diff --git a/video-ps3eye/lang/nl_NL.ts b/video-ps3eye/lang/nl_NL.ts index c98370ec..81ffc826 100644 --- a/video-ps3eye/lang/nl_NL.ts +++ b/video-ps3eye/lang/nl_NL.ts @@ -20,4 +20,19 @@ + + dialog + + Can't open camera + + + + PS3 Eye driver error: %1 + + + + Unknown error + + + diff --git a/video-ps3eye/lang/ru_RU.ts b/video-ps3eye/lang/ru_RU.ts index c98370ec..81ffc826 100644 --- a/video-ps3eye/lang/ru_RU.ts +++ b/video-ps3eye/lang/ru_RU.ts @@ -20,4 +20,19 @@ + + dialog + + Can't open camera + + + + PS3 Eye driver error: %1 + + + + Unknown error + + + diff --git a/video-ps3eye/lang/stub.ts b/video-ps3eye/lang/stub.ts index c98370ec..81ffc826 100644 --- a/video-ps3eye/lang/stub.ts +++ b/video-ps3eye/lang/stub.ts @@ -20,4 +20,19 @@ + + dialog + + Can't open camera + + + + PS3 Eye driver error: %1 + + + + Unknown error + + + diff --git a/video-ps3eye/lang/zh_CN.ts b/video-ps3eye/lang/zh_CN.ts index c98370ec..81ffc826 100644 --- a/video-ps3eye/lang/zh_CN.ts +++ b/video-ps3eye/lang/zh_CN.ts @@ -20,4 +20,19 @@ + + dialog + + Can't open camera + + + + PS3 Eye driver error: %1 + + + + Unknown error + + + diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp index 34987241..25d82170 100644 --- a/video-ps3eye/module.cpp +++ b/video-ps3eye/module.cpp @@ -190,13 +190,13 @@ bool ps3eye_camera::start(info& args) } if (ptr.out.error_string[0] == '\0') - error = "Unknown error"; + error = QString{}; else error = QString::fromLatin1((const char*)ptr.out.error_string, strnlen((const char*)ptr.out.error_string, sizeof(ptr.out.error_string))); - run_in_thread_async(qApp, [=]() { - QMessageBox::critical(nullptr, "Can't open camera", "PS3 Eye driver error: " + error, QMessageBox::Close); + run_in_thread_async(qApp, [error = std::move(error)] { + dialog::show_open_failure_msgbox(error); }); return false; @@ -267,6 +267,14 @@ dialog::dialog(QWidget* parent) : QWidget(parent) connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &dialog::do_cancel); connect(&t, &QTimer::timeout, this, [this] { s.set_exposure(); s.set_gain(); }); } +void dialog::show_open_failure_msgbox(const QString& error) +{ + const QString& error_ = error.isNull() ? tr("Unknown error") : error; + QMessageBox::critical(nullptr, + tr("Can't open camera"), + tr("PS3 Eye driver error: %1").arg(error_), + QMessageBox::Close); +} // XXX copypasta -sh 20200329 void settings::set_gain() diff --git a/video-ps3eye/module.hpp b/video-ps3eye/module.hpp index 6dcec66a..595d446a 100644 --- a/video-ps3eye/module.hpp +++ b/video-ps3eye/module.hpp @@ -47,6 +47,7 @@ protected: public: explicit dialog(QWidget* parent = nullptr); + static void show_open_failure_msgbox(const QString& error); }; struct ps3eye_camera final : video::impl::camera -- cgit v1.2.3