diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b90ba619e018d0102484656f92623c26c04e6ac..472ec5debc78272fe08faae94a9a7c3a7a9aef43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,7 @@ target_link_libraries(Vivy PRIVATE -fopenmp) target_compile_definitions(Vivy PRIVATE QT_DISABLE_DEPRECATED_BEFORE=0x050F00 QT_NO_CAST_TO_ASCII - # QT_RESTRICTED_CAST_FROM_ASCII + QT_RESTRICTED_CAST_FROM_ASCII QTCREATOR_UTILS_STATIC_LIB ) diff --git a/src/Lib/Audio.cc b/src/Lib/Audio.cc index 8c492175f4849f7381af719a860cca4d73f1e706..23ad3e86e0fe014206f8e41bb7f0c044c7a12aa6 100644 --- a/src/Lib/Audio.cc +++ b/src/Lib/Audio.cc @@ -281,7 +281,7 @@ AudioContext::Stream::getDataSampleRate() const noexcept QString AudioContext::Stream::getName() const noexcept { - return QString(codec->name); + return QString::fromUtf8(codec->name); } // Get the codec's ID used to decode the stream diff --git a/src/Lib/Document/VivyDocument.cc b/src/Lib/Document/VivyDocument.cc index e5e4302e0f68c8507803ce6b37ed885eeb64d2d0..eb39bd2d7fbcc125796c03de5719d8210bb3e12c 100644 --- a/src/Lib/Document/VivyDocument.cc +++ b/src/Lib/Document/VivyDocument.cc @@ -92,7 +92,7 @@ VivyDocument::loadSaveJsonDocumentFile(const QJsonDocument &json) const QString savedVersion = savedVersionJson.toString(); for (const auto &[version, callback] : loadFunctions) { - if (savedVersion == version) + if (savedVersion == QString::fromUtf8(version)) return callback(this, json); } @@ -264,14 +264,11 @@ VivyDocument::getDocumentCapabilitiesString() const noexcept { QStringList ret; if (documentType & AudioAble) - ret.push_back("AudioAble" + - QString(audioDocument ? QStringLiteral("") : QStringLiteral("(ack)"))); + ret.push_back("AudioAble" + QString::fromUtf8(audioDocument ? "" : "(ack)")); if (documentType & VideoAble) - ret.push_back("VideoAble" + - QString(videoDocument ? QStringLiteral("") : QStringLiteral("(ack)"))); + ret.push_back("VideoAble" + QString::fromUtf8(videoDocument ? "" : "(ack)")); if (documentType & AssAble) - ret.push_back("AssAble" + - QString(assDocument ? QStringLiteral("") : QStringLiteral("(ack)"))); + ret.push_back("AssAble" + QString::fromUtf8(assDocument ? "" : "(ack)")); return ret.join(", "); } diff --git a/src/Lib/Script/LuaContext.cc b/src/Lib/Script/LuaContext.cc index a7c26e659ec30d9e216967d501df263b5c84c285..f5b4d341dbcd1e32686904ea1b27b5c05bb405d6 100644 --- a/src/Lib/Script/LuaContext.cc +++ b/src/Lib/Script/LuaContext.cc @@ -129,8 +129,7 @@ LuaContext::getLastLuaError() noexcept return QStringLiteral("No lua error detected..."); } - const char *error = lua_tostring(L, -1); - QString ret = QStringLiteral("%1").arg(error); + QString ret = QString::fromUtf8(lua_tostring(L, -1)); lua_pop(L, 1); return ret; } diff --git a/src/Lib/Script/ScriptStore.cc b/src/Lib/Script/ScriptStore.cc index 61a970d59026592d3b7d10c4e8222f56ba7185f0..689dfc7898593ed82e3e0e936ce7484082310dfb 100644 --- a/src/Lib/Script/ScriptStore.cc +++ b/src/Lib/Script/ScriptStore.cc @@ -63,7 +63,7 @@ ScriptStore::executeScript(Uuid id) noexcept QRegExp errorDetect(QStringLiteral("^([^\\:]*)\\:(\\d+)\\:(.*)\\n?$")); while (std::getline(streamErr, buffer, '\n')) { std::cout << '\t' << buffer << '\n'; - if (errorDetect.indexIn(buffer.c_str()) != -1) { + if (errorDetect.indexIn(QString::fromUtf8(buffer.c_str())) != -1) { std::string errorDesc = errorDetect.cap(3).toStdString(); return std::tuple{ QString(errorDetect.cap(2)).toInt(), Utils::trim(errorDesc) }; } diff --git a/src/UI/AboutWindow.cc b/src/UI/AboutWindow.cc index 4bb7e87b24f480d6f45cb70eb4e6c33ac08cd0a9..85cb2e01da8f31408f9b938b93569c6bca65e511 100644 --- a/src/UI/AboutWindow.cc +++ b/src/UI/AboutWindow.cc @@ -52,7 +52,7 @@ AboutWindow::SimpleLabel::SimpleLabel(QWidget *parent, const char *text) setTextFormat(Qt::RichText); setTextInteractionFlags(Qt::NoTextInteraction | Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard); - setText(QString(text)); + setText(QString::fromUtf8(text)); setAlignment(Qt::AlignJustify | Qt::AlignTop); setWordWrap(true); } @@ -78,8 +78,8 @@ AboutWindow::LicenceLabel::LicenceLabel(QWidget *parent, const QString &url, switch (format) { case Qt::PlainText: - case Qt::RichText: setText(QString(content.readAll())); break; - case Qt::MarkdownText: setMarkdown(content.readAll()); break; + case Qt::RichText: setText(QString::fromUtf8(content.readAll())); break; + case Qt::MarkdownText: setMarkdown(QString::fromUtf8(content.readAll())); break; case Qt::AutoText: qCritical() << "Invalid text format for LicenceLabel" << format; } } diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc index ef64b08f76860e1aed2df00318ea67590e7ebdea..e7457ed853dbdfa173b1947ad354c77ce110ec5c 100644 --- a/src/UI/DocumentViews/MpvContainer.cc +++ b/src/UI/DocumentViews/MpvContainer.cc @@ -106,7 +106,7 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept case MPV_EVENT_LOG_MESSAGE: msg = reinterpret_cast<mpv_event_log_message *>(event->data); - msgText = QString(msg->text); + msgText = QString::fromUtf8(msg->text); msgText.replace('\n', ""); qDebug().nospace().noquote() << "MPV - MSG [" << msg->prefix << "] " << msg->level << ": " << msgText; @@ -179,7 +179,7 @@ MpvContainer::getAssSid() const noexcept { bool conversionOk = false; const char *result = mpv_get_property_string(mpv, "sid"); - const int ret = QString(result).toInt(&conversionOk); + const int ret = QString::fromUtf8(result).toInt(&conversionOk); return (result == nullptr || !conversionOk) ? -1 : ret; } diff --git a/src/UI/MainWindow.cc b/src/UI/MainWindow.cc index ddf90b9edee5ef6b113ee6fe83762f0010f9444c..b320ac79e2ceeb2f43b8e5660261a35b2c374ee6 100644 --- a/src/UI/MainWindow.cc +++ b/src/UI/MainWindow.cc @@ -333,7 +333,7 @@ MainWindow::openDocument() noexcept if (errorTuple.has_value()) { const auto &[line, desc] = errorTuple.value(); - emit newView->luaErrorFound(line, QString{ desc.c_str() }); + emit newView->luaErrorFound(line, QString::fromUtf8(desc.c_str())); } addTab(newView); diff --git a/src/UI/ScriptDocumentView.cc b/src/UI/ScriptDocumentView.cc index b91e3830cc759f1ca3df43d7ab3e572a159ede0a..a7ab4938c8d2e3275589286d17ad07692415950a 100644 --- a/src/UI/ScriptDocumentView.cc +++ b/src/UI/ScriptDocumentView.cc @@ -19,7 +19,7 @@ ScriptDocumentView::ScriptDocumentView(std::shared_ptr<ScriptDocument> ptr, QWid throw std::runtime_error("Failed to open script file"); } - editor->setPlainText(textFile.readAll()); + editor->setPlainText(QString::fromUtf8(textFile.readAll())); setCentralWidget(editor); editor->setFocus(Qt::OtherFocusReason); diff --git a/src/UI/VivyDocumentView.cc b/src/UI/VivyDocumentView.cc index a82725074114229ae36477d7aa9ef5a4a5f84f35..984ffbd4b2523485fffcc327448047167e964bd8 100644 --- a/src/UI/VivyDocumentView.cc +++ b/src/UI/VivyDocumentView.cc @@ -61,7 +61,8 @@ VivyDocumentView::getDocument() const noexcept QString VivyDocumentView::getDocumentTabName() const noexcept { - return (document->checkDocumentOption(VivyDocument::UntouchedByDefault) ? "(*) " : "") + + return QString::fromUtf8( + document->checkDocumentOption(VivyDocument::UntouchedByDefault) ? "(*) " : "") + document->getName(); } diff --git a/src/VivyCli.cc b/src/VivyCli.cc index 1305babcbb026ba9c5984a00aae8529bfcdb2202..87e54139c37d6324cca7fcb9945a5bf54d7d664f 100644 --- a/src/VivyCli.cc +++ b/src/VivyCli.cc @@ -6,7 +6,7 @@ using namespace Vivy; VivyCli::VivyCli(int &argc, char **argv) noexcept { if (argc >= 2) { - selectedDoc = scriptStore.loadDocument(QString(argv[1])); + selectedDoc = scriptStore.loadDocument(QString::fromUtf8(argv[1])); } }