aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2023-11-26 21:29:16 -0500
committerGravatar Chris Xiong <chirs241097@gmail.com> 2023-11-26 21:29:16 -0500
commitf7def0d883fa5cab62ef61b40b9f857245be8e6c (patch)
treed29322dd4be6e98c0740ae6df4dc70eb41614a76
parent60989e52b3f3bc0a95d3e61bd8e59fa4d9b7ab83 (diff)
downloadQMidiPlayer-f7def0d883fa5cab62ef61b40b9f857245be8e6c.tar.xz
Initial Qt 6 port. Many bug fixes.
-rw-r--r--CMakeLists.txt32
-rw-r--r--mpris-plugin/CMakeLists.txt8
-rw-r--r--mpris-plugin/qmpmprisimpl.cpp1
-rw-r--r--qmidiplayer-desktop/CMakeLists.txt7
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.cpp14
-rw-r--r--qmidiplayer-desktop/qmpefxwindow.cpp56
-rw-r--r--qmidiplayer-desktop/qmpefxwindow.hpp10
-rw-r--r--qmidiplayer-desktop/qmpinfowindow.cpp13
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp65
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp3
-rw-r--r--qmidiplayer-desktop/qmpsettings.cpp2
-rw-r--r--simple-visualization/CMakeLists.txt2
-rw-r--r--visualization/renderer/CMakeLists.txt4
-rw-r--r--visualization/renderer/qmppluginapistub.cpp30
-rw-r--r--windows-extra/CMakeLists.txt4
15 files changed, 125 insertions, 126 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c84653..3e64f6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,24 +4,36 @@ project(QMidiPlayer VERSION 0.8.7 LANGUAGES C CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
-include(FindPkgConfig)
-find_package(Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
-find_package(Threads REQUIRED)
-pkg_search_module(fluidsynth REQUIRED fluidsynth>=2.0.0)
-pkg_search_module(rtmidi REQUIRED rtmidi)
+set(OPTIONAL_QT_DEPS "")
option(BUILD_VISUALIZATION "Build visualization plugin" ON)
if(WIN32)
+ set(OPTIONAL_QT_DEPS "WinExtras")
option(BUILD_WINEXTRA "Build Windows extra library" ON)
option(BUILD_BACKTRACE "Build backtrace library" OFF)
endif()
if(UNIX)
- option(BUILD_PORTABLE "Instruct the built binary not to search system directories" OFF)
+ option(BUILD_PORTABLE "Instruct the built binary not to search system directories" OFF)
+endif()
+
+option(USE_QT6 "Build with Qt 6" OFF)
+
+include(FindPkgConfig)
+if (USE_QT6)
+ find_package(QT NAMES Qt6 REQUIRED)
+ find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools OPTIONAL_COMPONENTS DBus ${OPTIONAL_QT_DEPS})
+else()
+ find_package(QT NAMES Qt5 REQUIRED)
+ find_package(Qt5 5.15 REQUIRED COMPONENTS Widgets LinguistTools OPTIONAL_COMPONENTS DBus ${OPTIONAL_QT_DEPS})
endif()
+find_package(Threads REQUIRED)
+find_package(ICU COMPONENTS uc i18n REQUIRED)
+pkg_search_module(fluidsynth REQUIRED fluidsynth>=2.0.0)
+pkg_search_module(rtmidi REQUIRED rtmidi)
add_definitions(-DAPP_VERSION=\"${PROJECT_VERSION}\")
add_definitions(-DPLUGIN_VERSION=\"${PROJECT_VERSION}\")
@@ -32,14 +44,16 @@ add_definitions(-DRC_VER_PATCH=${PROJECT_VERSION_PATCH})
add_subdirectory(core)
add_subdirectory(qmidiplayer-desktop)
add_subdirectory(sample-plugin)
-add_subdirectory(mpris-plugin)
+if (Qt${QT_VERSION_MAJOR}DBus_FOUND)
+ add_subdirectory(mpris-plugin)
+endif()
add_subdirectory(midifmt-plugin)
add_subdirectory(simple-visualization)
if(BUILD_VISUALIZATION)
add_subdirectory(visualization)
endif()
if(WIN32)
- if(BUILD_WINEXTRA)
+ if(BUILD_WINEXTRA AND Qt${QT_VERSION_MAJOR}WinExtras_FOUND)
add_subdirectory(windows-extra)
endif()
if(BUILD_BACKTRACE)
diff --git a/mpris-plugin/CMakeLists.txt b/mpris-plugin/CMakeLists.txt
index c0395c0..1366f39 100644
--- a/mpris-plugin/CMakeLists.txt
+++ b/mpris-plugin/CMakeLists.txt
@@ -13,8 +13,6 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
-find_package(Qt5 REQUIRED COMPONENTS DBus)
-
include_directories(${PROJECT_SOURCE_DIR}/include/)
add_library(qmpmpris MODULE
@@ -22,9 +20,9 @@ add_library(qmpmpris MODULE
)
target_link_libraries(qmpmpris
- Qt5::Core
- Qt5::Widgets
- Qt5::DBus
+ Qt${QT_VERSION_MAJOR}::Core
+ Qt${QT_VERSION_MAJOR}::Widgets
+ Qt${QT_VERSION_MAJOR}::DBus
)
install(TARGETS qmpmpris LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/qmidiplayer/)
diff --git a/mpris-plugin/qmpmprisimpl.cpp b/mpris-plugin/qmpmprisimpl.cpp
index 335a638..583cc70 100644
--- a/mpris-plugin/qmpmprisimpl.cpp
+++ b/mpris-plugin/qmpmprisimpl.cpp
@@ -56,7 +56,6 @@ QVariantMap QMPPlayer::getMetadata()
qlonglong QMPPlayer::getPosition()
{
::PlaybackStatus ps = api->getPlaybackStatus();
- fprintf(stderr, "%lu\n", ps.curtime_ms);
return ps.curtime_ms * 1000;
}
diff --git a/qmidiplayer-desktop/CMakeLists.txt b/qmidiplayer-desktop/CMakeLists.txt
index d3ee116..5def90f 100644
--- a/qmidiplayer-desktop/CMakeLists.txt
+++ b/qmidiplayer-desktop/CMakeLists.txt
@@ -57,6 +57,7 @@ set(CMAKE_AUTOUIC ON)
include_directories(${fluidsynth_INCLUDE_DIRS})
include_directories(${rtmidi_INCLUDE_DIRS})
+include_directories(${ICU_INCLUDE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/include/)
include_directories(${PROJECT_SOURCE_DIR}/core/)
@@ -71,8 +72,10 @@ add_executable(qmidiplayer
)
target_link_libraries(qmidiplayer
- Qt5::Widgets
+ Qt${QT_VERSION_MAJOR}::Widgets
qmpcore
+ ICU::uc
+ ICU::i18n
${fluidsynth_LIBRARIES}
${rtmidi_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
@@ -90,7 +93,7 @@ PRIVATE
)
file(GLOB qmpdesktop_TS_FILES translations/*.ts)
-qt5_create_translation(qmpdesktop_QM_FILES ${qmpdesktop_SOURCES} ${qmpdesktop_TS_FILES})
+qt_create_translation(qmpdesktop_QM_FILES ${qmpdesktop_SOURCES} ${qmpdesktop_TS_FILES})
add_custom_target(translations ALL DEPENDS ${qmpdesktop_QM_FILES})
install(TARGETS qmidiplayer)
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp
index 8957254..7743084 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.cpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.cpp
@@ -1,5 +1,4 @@
#include <cstdio>
-#include <functional>
#include <set>
#include <QCheckBox>
#include <QPushButton>
@@ -14,23 +13,16 @@ qmpChannelsModel::qmpChannelsModel(QObject *parent): QAbstractTableModel(parent)
evh = qmpMainWindow::getInstance()->getPlayer()->registerEventHandler(
[this](const void *_e, void *)
{
+ const SEvent *e = (const SEvent *)(_e);
+ if ((e->type & 0xF0) == 0xC0)
+ emit dataChanged(index(e->type & 0x0F, 4), index(e->type & 0x0F, 4), {Qt::ItemDataRole::DisplayRole});
if (!updatequeued)
{
updatequeued = true;
- const SEvent *e = (const SEvent *)(_e);
- if ((e->p1 & 0xF0) == 0xC0)
- emit dataChanged(index(e->p1 & 0xF0, 4), index(e->p1 & 0xF0, 4), {Qt::ItemDataRole::DisplayRole});
QMetaObject::invokeMethod(this, &qmpChannelsModel::updateChannelActivity, Qt::ConnectionType::QueuedConnection);
}
}
, nullptr, false);
- QTimer *t = new QTimer(this);
- t->setInterval(500);
- t->setSingleShot(false);
- connect(t, &QTimer::timeout, [this]()
- {
- emit this->dataChanged(this->index(0, 4), this->index(15, 4), {Qt::ItemDataRole::DisplayRole});
- });
memset(mute, 0, sizeof(mute));
memset(solo, 0, sizeof(solo));
}
diff --git a/qmidiplayer-desktop/qmpefxwindow.cpp b/qmidiplayer-desktop/qmpefxwindow.cpp
index 0a281cd..2cea976 100644
--- a/qmidiplayer-desktop/qmpefxwindow.cpp
+++ b/qmidiplayer-desktop/qmpefxwindow.cpp
@@ -35,6 +35,14 @@ qmpEfxWindow::qmpEfxWindow(QWidget *parent) :
0,
true
);
+ connect(ui->sbRoom, qOverload<int>(&QSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
+ connect(ui->sbDamp, qOverload<int>(&QSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
+ connect(ui->sbWidth, qOverload<int>(&QSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
+ connect(ui->sbLevelR, qOverload<int>(&QSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
+ connect(ui->sbFeedBack, qOverload<int>(&QSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
+ connect(ui->sbRate, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
+ connect(ui->sbDepth, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
+ connect(ui->sbLevelC, qOverload<int>(&QSpinBox::valueChanged), this, &qmpEfxWindow::spinValueChange);
if (!settings->getOptionRaw("DialogStatus/EfxW", QRect()).toRect().isNull())
setGeometry(settings->getOptionRaw("DialogStatus/EfxW", QRect()).toRect());
if (settings->getOptionRaw("DialogStatus/EfxWShown", 0).toInt())
@@ -218,54 +226,6 @@ void qmpEfxWindow::on_dLevelC_valueChanged()
dailValueChange();
}
-void qmpEfxWindow::on_sbRoom_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
-void qmpEfxWindow::on_sbDamp_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
-void qmpEfxWindow::on_sbWidth_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
-void qmpEfxWindow::on_sbLevelR_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
-void qmpEfxWindow::on_sbFeedBack_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
-void qmpEfxWindow::on_sbRate_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
-void qmpEfxWindow::on_sbDepth_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
-void qmpEfxWindow::on_sbLevelC_valueChanged(QString s)
-{
- s = QString();
- spinValueChange();
-}
-
void qmpEfxWindow::on_cbEnabledC_stateChanged()
{
sendEfxChange();
diff --git a/qmidiplayer-desktop/qmpefxwindow.hpp b/qmidiplayer-desktop/qmpefxwindow.hpp
index 9e5e8bf..3b74df3 100644
--- a/qmidiplayer-desktop/qmpefxwindow.hpp
+++ b/qmidiplayer-desktop/qmpefxwindow.hpp
@@ -46,22 +46,14 @@ private slots:
void on_dRate_valueChanged();
void on_dDepth_valueChanged();
void on_dLevelC_valueChanged();
- void on_sbRoom_valueChanged(QString s);
- void on_sbDamp_valueChanged(QString s);
- void on_sbWidth_valueChanged(QString s);
- void on_sbLevelR_valueChanged(QString s);
- void on_sbFeedBack_valueChanged(QString s);
- void on_sbRate_valueChanged(QString s);
- void on_sbDepth_valueChanged(QString s);
- void on_sbLevelC_valueChanged(QString s);
void on_cbEnabledC_stateChanged();
void on_cbEnabledR_stateChanged();
void on_rbSine_toggled();
void on_rbTriangle_toggled();
+ void spinValueChange();
private:
void dailValueChange();
- void spinValueChange();
Ui::qmpEfxWindow *ui;
double rr, rd, rw, rl;
int cfb, ct, initialized;
diff --git a/qmidiplayer-desktop/qmpinfowindow.cpp b/qmidiplayer-desktop/qmpinfowindow.cpp
index 654c8f4..fe46c18 100644
--- a/qmidiplayer-desktop/qmpinfowindow.cpp
+++ b/qmidiplayer-desktop/qmpinfowindow.cpp
@@ -1,4 +1,3 @@
-#include <QTextCodec>
#include "qmpinfowindow.hpp"
#include "ui_qmpinfowindow.h"
#include "qmpmainwindow.hpp"
@@ -51,20 +50,12 @@ void qmpInfoWindow::updateInfo()
ui->lbFileName->setText(QString("File name: ") + qmpMainWindow::getInstance()->getFileName());
if (player->getTitle())
{
- if (textencoding != "Unicode")
- ui->lbTitle->setText(QString("Title: ") +
- QTextCodec::codecForName(textencoding.c_str())->toUnicode(player->getTitle()));
- else
- ui->lbTitle->setText(QString("Title: ") + player->getTitle());
+ ui->lbTitle->setText(QString("Title: %1").arg(qmpMainWindow::decodeString(player->getTitle())));
}
else ui->lbTitle->setText(QString("Title: "));
if (player->getCopyright())
{
- if (textencoding != "Unicode")
- ui->lbCopyright->setText(QString("Copyright: ") +
- QTextCodec::codecForName(textencoding.c_str())->toUnicode(player->getCopyright()));
- else
- ui->lbCopyright->setText(QString("Copyright: ") + player->getCopyright());
+ ui->lbCopyright->setText(QString("Copyright: %1").arg(qmpMainWindow::decodeString(player->getCopyright())));
}
else ui->lbCopyright->setText(QString("Copyright: "));
ui->lbTempo->setText(QString("Tempo: ") + QString::number(player->getTempo(), 'g', 5));
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index c02a206..9b18e0d 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -1,11 +1,12 @@
#include <cstdio>
#include <cmath>
-#include <functional>
+#include <unicode/ustring.h>
+#include <unicode/unistr.h>
+#include <unicode/ucnv.h>
#include <QUrl>
#include <QFileInfo>
#include <QMimeData>
#include <QFont>
-#include <QTextCodec>
#include <QDirIterator>
#include <QMessageBox>
#include <QCheckBox>
@@ -406,19 +407,11 @@ void qmpMainWindow::switchTrack(QString s, bool interrupt)
}
std::string qmpMainWindow::getTitle()
{
- if (settings->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
- return std::string(player->getTitle());
- return QTextCodec::codecForName(
- settings->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
- toUnicode(player->getTitle()).toStdString();
+ return decodeStdString(player->getTitle());
}
std::wstring qmpMainWindow::getWTitle()
{
- if (settings->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
- return QString(player->getTitle()).toStdWString();
- return QTextCodec::codecForName(
- settings->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
- toUnicode(player->getTitle()).toStdWString();
+ return decodeStdWString(player->getTitle());
}
void qmpMainWindow::playerSetup(IFluidSettings *fs)
@@ -505,7 +498,16 @@ void qmpMainWindow::registerMidiOptions()
settings->registerOptionBool("MIDI", "Send system exclusive messages", "Midi/SendSysEx", true);
settings->registerOptionBool("MIDI", "Wait for remaining voice before stopping", "Midi/WaitVoice", true);
settings->registerOptionInt("MIDI", "Fluidsynth Device ID", "FluidSynth/DeviceID", 0x00, 0x7E, 0x10);
- settings->registerOptionEnumInt("MIDI", "Text encoding", "Midi/TextEncoding", {"Unicode", "Big5", "Big5-HKSCS", "CP949", "EUC-JP", "EUC-KR", "GB18030", "KOI8-R", "KOI8-U", "Macintosh", "Shift-JIS"}, 0);
+ UErrorCode e = U_ZERO_ERROR;
+ auto ucnvc = ucnv_countAvailable();
+ std::vector<std::string> converters;
+ for (auto i = 0; i < ucnvc; ++i)
+ {
+ auto n = ucnv_getAvailableName(i);
+ auto sn = ucnv_getStandardName(n, "MIME", &e);
+ if (sn) converters.push_back(std::string(sn));
+ }
+ settings->registerOptionEnumInt("MIDI", "Text encoding", "Midi/TextEncoding", converters, 0);
}
void qmpMainWindow::registerBehaviorOptions()
@@ -517,6 +519,43 @@ void qmpMainWindow::registerBehaviorOptions()
settings->registerOptionEnumInt("Behavior", "Icon Theme", "Behavior/IconTheme", {"Auto", "Dark", "Light"}, 0);
}
+QString qmpMainWindow::decodeString(const char *str)
+{
+ std::string enc("utf-8");
+ if (ref && ref->settings)
+ enc = ref->settings->getOptionEnumIntOptName("Midi/TextEncoding");
+ icu::UnicodeString us(str, enc.c_str());
+ std::string r;
+ return QString::fromUtf8(us.toUTF8String(r).c_str());
+}
+
+std::string qmpMainWindow::decodeStdString(const char *str)
+{
+ std::string enc("utf-8");
+ if (ref && ref->settings)
+ enc = ref->settings->getOptionEnumIntOptName("Midi/TextEncoding");
+ icu::UnicodeString us(str, enc.c_str());
+ std::string r;
+ us.toUTF8String(r);
+ return r;
+}
+
+std::wstring qmpMainWindow::decodeStdWString(const char *str)
+{
+ std::string enc("utf-8");
+ if (ref && ref->settings)
+ enc = ref->settings->getOptionEnumIntOptName("Midi/TextEncoding");
+ icu::UnicodeString us(str, enc.c_str());
+ std::wstring r;
+ int32_t sz = 0;
+ 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;
+}
+
void qmpMainWindow::on_pbPlayPause_clicked()
{
if (stopped)
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index 7a34cb6..757ec14 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -312,6 +312,9 @@ public:
{
return ref;
}
+ static QString decodeString(const char* str);
+ static std::string decodeStdString(const char* str);
+ static std::wstring decodeStdWString(const char* str);
};
class qmpRenderFunc: public qmpFuncBaseIntf
diff --git a/qmidiplayer-desktop/qmpsettings.cpp b/qmidiplayer-desktop/qmpsettings.cpp
index 6ce542a..70cd720 100644
--- a/qmidiplayer-desktop/qmpsettings.cpp
+++ b/qmidiplayer-desktop/qmpsettings.cpp
@@ -7,7 +7,9 @@
QSettings *qmpSettings::settings = nullptr;
qmpSettings::qmpSettings()
{
+#if QT_VERSION_MAJOR < 6
qRegisterMetaTypeStreamOperators<QPair<QString, QString>>();
+#endif
QString confpath = QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qmprc");
settings = new QSettings(confpath, QSettings::IniFormat);
if (settings->value("ConfigurationFileRevision").toInt() != QMP_CONFIGURATION_FILE_REV &&
diff --git a/simple-visualization/CMakeLists.txt b/simple-visualization/CMakeLists.txt
index 9966c31..6cd408f 100644
--- a/simple-visualization/CMakeLists.txt
+++ b/simple-visualization/CMakeLists.txt
@@ -24,7 +24,7 @@ add_library(simple-visualization MODULE
)
target_link_libraries(simple-visualization
- Qt5::Widgets
+ Qt${QT_VERSION_MAJOR}::Widgets
)
install(TARGETS simple-visualization LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/qmidiplayer/)
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 <unicode/ustring.h>
+#include <unicode/unistr.h>
+#include <unicode/ucnv.h>
#include "qmpmidiplay.hpp"
#include "qmpvisrendercore.hpp"
#include "qmpsettingsro.hpp"
#include "qmppluginapistub.hpp"
-#include <QTextCodec>
-
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()
diff --git a/windows-extra/CMakeLists.txt b/windows-extra/CMakeLists.txt
index 6754e46..c9b58ab 100644
--- a/windows-extra/CMakeLists.txt
+++ b/windows-extra/CMakeLists.txt
@@ -5,12 +5,10 @@ set(windowsextra_SOURCES
include_directories(${PROJECT_SOURCE_DIR}/include/)
-find_package(Qt5 REQUIRED COMPONENTS Widgets WinExtras)
-
add_library(windowsextra MODULE
${windowsextra_SOURCES}
)
-target_link_libraries(windowsextra Qt5::Widgets Qt5::WinExtras)
+target_link_libraries(windowsextra Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WinExtras)
install(TARGETS windowsextra LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/qmidiplayer/)