From f7def0d883fa5cab62ef61b40b9f857245be8e6c Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 26 Nov 2023 21:29:16 -0500 Subject: Initial Qt 6 port. Many bug fixes. --- visualization/renderer/CMakeLists.txt | 4 +++- visualization/renderer/qmppluginapistub.cpp | 30 +++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'visualization') diff --git a/visualization/renderer/CMakeLists.txt b/visualization/renderer/CMakeLists.txt index 106d453..cbe918a 100644 --- a/visualization/renderer/CMakeLists.txt +++ b/visualization/renderer/CMakeLists.txt @@ -18,8 +18,10 @@ add_executable(qmpvisrender ) target_link_libraries(qmpvisrender - Qt5::Core + Qt${QT_VERSION_MAJOR}::Core qmpcore + ICU::uc + ICU::i18n ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ) diff --git a/visualization/renderer/qmppluginapistub.cpp b/visualization/renderer/qmppluginapistub.cpp index 7804cc6..c594f02 100644 --- a/visualization/renderer/qmppluginapistub.cpp +++ b/visualization/renderer/qmppluginapistub.cpp @@ -1,10 +1,11 @@ +#include +#include +#include #include "qmpmidiplay.hpp" #include "qmpvisrendercore.hpp" #include "qmpsettingsro.hpp" #include "qmppluginapistub.hpp" -#include - qmpPluginAPIStub::qmpPluginAPIStub(qmpVisRenderCore *_core): core(_core) { @@ -84,19 +85,24 @@ bool qmpPluginAPIStub::getChannelMask(int ch) } std::string qmpPluginAPIStub::getTitle() { - if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode") - return std::string(core->player->getTitle()); - return QTextCodec::codecForName( - core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())-> - toUnicode(core->player->getTitle()).toStdString(); + std::string enc(core->settings()->getOptionEnumIntOptName("Midi/TextEncoding")); + icu::UnicodeString us(core->player->getTitle(), enc.c_str()); + std::string r; + us.toUTF8String(r); + return r; } std::wstring qmpPluginAPIStub::getWTitle() { - if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode") - return QString(core->player->getTitle()).toStdWString(); - return QTextCodec::codecForName( - core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())-> - toUnicode(core->player->getTitle()).toStdWString(); + std::string enc(core->settings()->getOptionEnumIntOptName("Midi/TextEncoding")); + icu::UnicodeString us(core->player->getTitle(), enc.c_str()); + std::wstring r; + int32_t sz; + UErrorCode e = U_ZERO_ERROR; + u_strToWCS(nullptr, 0, &sz, us.getBuffer(), us.length(), &e); + r.resize(sz + 1); + e = U_ZERO_ERROR; + u_strToWCS(r.data(), r.size(), nullptr, us.getBuffer(), us.length(), &e); + return r; } std::string qmpPluginAPIStub::getFilePath() -- cgit v1.2.3